Loading file from local storage in 3dmloader

Hi @fraguda,

How do I load a 3dm file from the local storage into the Rhino 3dmloader without involving servers? Is there a boiler plate code that I can refer to for this?

Are you running your application locally as well?

Right now yes. But I’m planning to deploy the viewer if this works. Similar to rview by Steve. But I’m having a hard time understanding his code since it’s too complex tbh. I’m looking for a simple native js example if one exists.

Ok. I guess you are still running your app with a local server. If so, you need to use the File API. We have a few examples of this, but they are part of another project. I will create a rhino3dm example with an upload function. In the meantime, check out this example:

There is the input element defined in index.html: compute.rhino3d.appserver/index.html at main · mcneel/compute.rhino3d.appserver · GitHub

and the code to get the file from the local file system in app.js: compute.rhino3d.appserver/app.js at main · mcneel/compute.rhino3d.appserver · GitHub

You would then need to read the file with rhino3dm with something like:

const doc = rhino.File3dm.fromByteArray(arr)

Thanks for highlighting that we need a good example here!

1 Like

Thank you so much @fraguada. I’ll try this out. Please let me know when you have an example up. It will be of great help.

Got a sample going:

2 Likes

Thank you so much @fraguada

1 Like