Rhino python script set FBX Export Options

Hi, I am using Rhino python script to convert .3dm files to .fbx files by using rs.Command("_-SaveAs _-Enter", True) .

But I found that if we do it manually, there is a dialog like thisFBXExportOptions

that I don’t know how to set these option from rhino python. These settings really affect my work. Could anyone help me how to set it up by using python?

Hello - the best way to see all of the fbx command line options is to run the command straight in Rhino and then you’ll see the options and how to set them. MacroEditor is very handy for this.
For example:

! -SaveAs "C:\test\testfbx.fbx

when you run this you’ll see the options:

Export FBX Options ( ExportNurbsObjectsAs=Mesh ExportMaterialsAs=Phong ExportFileAs=Version7Binary ):

Then set these as appropriate in your script.

-Pascal

Hello pascal, thank you for your advice. Would you mind be more clearer?

In my python code, it is like : cmd = “_-SaveAs " + “c:/1.fbx” + " _-Enter” + " _-Enter"
rs.Command(cmd, True)

Where should I set the Export FBX Options into my code?
.

Hello - I don’t know what options you need but if your image above has the settings that you need then

cmd = "_-SaveAs " + "C:\Users\pascal\Desktop\Junk\junk.fbx" + "ExportNurbsObjectsAs=NURBS ExportMaterialsAs=Phong ExportFileAs=Version7Binary Enter "

Does that work?
-Pascal

Hi Pascal, it doesn’t work. I tried this setting and failed. Actually I need setting for ExportNurbsObjectsAs is Mesh only.

When I run this command you provided, Rhino stuck when it is launching.
Capture

Any ideas? Thank you!

Hello - I guess I am not really sure how else to help - it is pretty straightforward- run the command

-SaveAs "Path"

Just run it, typed at the command line. You will then see the options that are available at the command line - set these the way you like, then use the exact same settings when running the command in your script.

-Pascal

Hello pascal, that was my mistake. Your advice is totally correct. Thank you for your help!!!

Hello! Can I ask here for help to not to create another one similar topic?
I’m trying to make macro for the first time (no Python or any other coding skills I have so far). My wish is to export selected items as a mesh to particular file without any options windows to save time on this routine task. Sure thing no luck at all so far, would you give a hand if it’s not to difficult?
Also it would be just awesome to have those items rotated around X-axis by -90 degrees before exporting.
Is it possible in case with macros or should I look for a Python code-master to get help?

Hi Mikey - since you posted this in a thread about saving to FBX, this would be the minimal version of a macro to do that:

-Export Pause “D:\Test\test-export.fbx” enter enter

… that is assuming that you have a D:\Test\ directory on your machine.

If you need to set any of the options that are relevant to the FBX format, you can edit that macro by removing the enter keywords. You will then be presented with the available options on the command line and need to proceed from there. When you find options that you will always want to set, you can include these in the macro.

The following options are available for FBX:

FBX Options: ExportNurbsObjectsAs=Mesh ExportMaterialsAs=Phong YUp=No ExportFileAs=Version7Binary
Meshing Options: DetailedOptions PolygonDensity=50

-wim

Thank you Wim, that’s pretty awesome except that I’m failing to add FBX Option Y-UpAxis (which is exactly the thing I was looking for). Also the file path ‘quotes’ confuses Rhino so I removed them and it worked, hmm. Otherwise I just get the message that my path is ‘Unknown command’. Don’t know, maybe I have some improper input language (United States-International (Default) is set). Let it be though, but please help to put the option into this macro correctly, I tried many variants but being def you won’t hear any music, right? : )

Hi Mikey - this one should do that:

-Export Pause D:\Test\test-export.fbx YUp=Yes Enter Enter

As for the quotes, yes, “curlification” of quotation marks is annoying. You have to replace those with "Straight Quotes" when you need them. FWIW, we have a feature request on our list to have those automatically converted when used in Rhino - RH-51712.
At any rate, as long as there are no spaces in your path name, you are fine without them.
-wim

I forgot to mention that we have here V5 only, can it spin the exported axis Z>Y?

Well anyway it doesn’t work here : ) for some reason I have UnknownCommand message whatever option I add. I thought that quotes do something wrong but nope. Though those ‘straight quotes’ finally started to work properly. I used your example line exactly the way you’ve wrote it symbol by symbol…
Anyways I just solved that axis issue in my polygonal software which macro do that job well so let’s skip this issue for awhile.

Hi Mikey - no, it doesn’t look like Rhino 5 supports that option:

One tip when creating new macros - always check the command history for feedback on the command line. In this case, when you ran the macro that I posted, this would be shown:

Command: _Paste
Command: -Export
Select objects to export: Pause
Select objects to export:
Select objects to export. Press Enter when done:
Save file name ( Version=5 SaveSmall=No GeometryOnly=No SaveTextures=No SavePlugInData=Yes Browse ): D:\Test\test-export-3.fbx
Export FBX Options ( ExportNurbsObjectsAs=Mesh ExportMaterialsAs=Phong ExportFileAs=Version7Binary ): YUp=Yes
Unknown command: YUp=Yes
Export FBX Options ( ExportNurbsObjectsAs=Mesh ExportMaterialsAs=Phong ExportFileAs=Version7Binary ): Enter
Export FBX Options ( ExportNurbsObjectsAs=Mesh ExportMaterialsAs=Phong ExportFileAs=Version7Binary ):
Choose meshing option ( DetailedOptions PolygonDensity=50 ): Enter
Choose meshing option ( DetailedOptions PolygonDensity=50 ):
Created a mesh with 24 points and 8 polygons.
Meshing… Press Esc to cancel
File successfully written as D:\Test\test-export.fbx

You can see all the options and can also see if any unknown commands are encountered.
-wim

Yep, V5 doesn’t support that. But thanks for the tip, gonna smoothly get into this things from now on, those are very handy. Thank you very much! : )