Remove - or not display - some import / export options

Is there anyway to remove or not to display by default all of the import / export files options in that related menu? Some of us - at least me :slight_smile: have to scroll every time to export / import the type of file we choose. Such as always scrolling down to export as an STL. I REALIZE this may not be a big deal, I guess it is not, but it would - for me again - eliminate the daily scroll, scroll, … so thought I would ask. In the options / plugin menu it would be nice to select what to display in the dialog box - then we could all have handy right away what we use on a daily basis. I rarely import /export anything but STLs or DWGs.

Again, not a big deal breaker - but just a question.

You can add a toolbar button with the following script

-_RunPythonScript (
import rhinoscriptsyntax as rs

fn = rs.OpenFileName("Open STL file", "STL|*.stl||")
rs.Command("_Import \""+fn+"\"")
)

You can do something similar for _Export.

Thanks much - very helpful. I have used a few posted scripts - but I am not as advanced as most I see on the forum. I do appreciate the help.

No problem. You should be able to create a similar button for importing DWG files.

Probably need dash Import

rs.Command("_-Import \""+fn+"\"")

-Pascal

OK, so it did not work - errored on first try so editied with the new comment in edit button box I have:

-_RunPythonScript (
import rhinoscriptsyntax as rs

fn = rs.OpenFileName(“Open STL file”, “STL|*.stl||”)
rs.Command("_-IMPORT""+fn+""")
)

Which yields the following error if I just close the dialog:

Message: unsupported operand type(s) for +:‘str’ and ‘NoneType’

Followed with:
line 4, in , “”

So is there a catch? Seriously, ready to shelve this for the day, need to get busy and a few clicks is better than an error. But I DO appreciate the help and will play/investigate later.

that second line for some reason must interfere with the editor:

line 4, in , “< string >”

without the space before and after string

I did not account for the case where you cancel the dialog. You can copy/paste the following verbatim to your button:

-_RunPythonScript (
import rhinoscriptsyntax as rs

fn = rs.OpenFileName("Open STL file", "STL|*.stl||")
if fn:
  rs.Command("_-Import \""+fn+"\"")
else:
  print("STL import cancelled.")
)

You made a few typoes when you transferred the script to your toolbar button, a space after the _-Import command was missing, and the backslashes as you see in my code are important, without those you’ll get more errors.

Sorry for the delay - thanks much. APpreciaTE the help as always :slight_smile: