Is it possible to save a mesh to a filepath?

Hi all,

I would like to save my mesh to a path (C:\dummy\test). Of course, I could just manually save the Rhino file, but I am wondering there is a more “Script-wise” way so that one can generate a mesh in Grasshopper and save it using a component/GhPython script.

Thank you in advance.

Sure, check this out:

It exports meshes as OBJ straight from Grasshopper. :wink:

1 Like

This is so great!! However, I am getting this small error. Do you have any advise for this?

It’s kind of hard to tell, but you might have forgotten to copy the last part of my code?
Anyways, here’s an example file I just tried and it seems to work.

By the way, once you specify an output directory with the Path component, it instantly runs and exports the example mesh as an OBJ!

mesh_obj_export_example.gh (781.2 KB)

1 Like

Yes, this code perfectly works. But, in your other post “How to optimise GHPython OBJ export?” Terry reported an exporting speed of 3.249 GB/sec. Now with this code, my scripts takes around 1 sec for the given mesh. Is it because of my Computer spec or are they different scripts?

If you don’t need to use it elsewhere, it’s faster to use Data Input/Output

Haha, yes! So Terry wrote a super optimized C++ script/library. Python is by nature slower. :wink:

Sure, the specs of your computer, mainly hard-drive and CPU speed play into this a little, but one second to export the example mesh, which has 16900 vertices and 15360 faces doesn’t seem that bad really. For me it takes about 6 seconds 0.6144 seconds.
Fun fact, Terry’s approach is by far quicker than even the native Rhino export, which I use in this script.

@haraaald45, what do you want to use this for? I exported entire OBJ sequences (for animations) without a problem really.

@gankeyu, could you explain a little what you mean? Data input/output that’s basically what I do - I use the Rhino OBJ export -, unless you mean something else?
OP asked specifically for a “component/GhPython script”, if you’re referring to some C# shenanigans. :wink:

I want to save meshes directly in my Azure cloud. I got the other C script running (Just commented out some parts which are getting textures for). You really helped a lot, thanks.

There’re two components. One is called Data Input and another is called Data Output.

If the fastest output is really needed and a universal format isn’t required, BinarySerializer on Mesh will be the optimal.