petrbroz / svf-utils

Utilities for working with the SVF file format used by Autodesk Platform Services.
https://petrbroz.github.io/svf-utils/
MIT License
123 stars 53 forks source link

'RangeError: Invalid string length' when transferring #59

Closed zeusxx closed 1 year ago

zeusxx commented 2 years ago

Hi,

I am new to this code and it works great so far for my previous test. Today when I'm trying to convert a large model (the original file of this SVF is a ~250MB NWD), the program shows the error message as below:

xxxxxxxxxxx \AppData\Roaming\npm\node_modules\forge-convert-utils\lib\gltf\writer.js:108
        fse.writeFileSync(gltfPath, JSON.stringify(this.manifest, null, 4));
                                         ^

RangeError: Invalid string length
    at JSON.stringify (<anonymous>)
    at Writer.write (xxxxxxxxxxxxxxxx\AppData\Roaming\npm\node_modules\forge-convert-utils\lib\gltf\writer.js:108:42)
    at async convertLocal (xxxxxxxxxx\AppData\Roaming\npm\node_modules\forge-convert-utils\bin\forge-convert.js:31:5)`

Looking forward to your reply. Thanks a lot!

petrbroz commented 1 year ago

Unfortunately this means that the NWD model is so complex that the built-in JSON.stringify method is unable to convert the glTF manifest JSON into string.

We've experimented with serializing the glTF manifest into other formats such as msgpack but that doesn't really solve the issue. Another option would be to split your NWD design into multiple glTFs, for example, by filtering individual design elements by area: https://github.com/petrbroz/forge-convert-utils/blob/develop/samples/filter-by-area.js.