Toolbar Button to Save current file as OBJ (with settings)

Hello,

How should I go about creating a toolbar button script that would:

Take the location of the current file:
C:\Project\file.3dm

Then add a folder to the end of that path and append _mesh to the name of the new file:
C:\Project\OBJ_Exports\file_mesh.obj

I would like to be able to pass the settings within the script.
Any help greatly appreciated.

Thanks

Hello - you could use a script like the one attached here - you’ll want a bit more than this to set the exact options - I just made some up here. You may also want everything selected automatically, and exported, but this should get you started, it seems to work OK here.

ExportOBJ.py (843 Bytes)

use a macro like this on your button:

! _-RunPythonScript "Full path to py file inside double-quotes"

-Pascal

1 Like

Hello Pascal,

Perfect! Thank you
This is exactly what I needed. Somehow I am very slow to pick up the syntax and start writing on my own. Adds to the confusion the mixed styles of Python and the default Rhino Script.

Could I shoot another fast question?

I have this line for Rhino Script and for some reason I cannot figure how to pass on the settings again. I try to follow your logic with the script you shared but I can’t get the syntax right:

Rhino.Command "_-Import " & Chr(34) & strOpen & Chr(34), 0

Where strOpen is the full path to an .igs file.
The line does work but after it does its job I cannot pass _Enter _Enter to just confirm the default settings, or passing custom settings also doesn’t work.

Thanks

Hello - I think you want an Enter, like so-

`Rhino.Command “_-Import " Chr(34) & strOpen & Chr(34) & " _Enter”

-Pascal

1 Like

Okay… I was missing the space before the enter.
I must have tried all the non working versions in the last hour !

Thank a lot for your response : )