How do I insert/import a 3DM file into Rhino


#1

Rhino has an “Insert” command to insert a 3DM file into a model. I’m trying to figure out how to write a script to do the same thing, but I can’t seem to find any rhinoscript method to do this. I would appreciate any suggestions on how to accomplish this. (Is there some other library I should be importing to provide me with this functionality?)


(Pascal Golay) #2

Hi Edmark- you can always script Rhino commands using

Rhino.Command “_-Insert (etc etc)”

See Help on using the Dash ("-") version of commands to supress dialog boxes and provide all inputs at the command line instead.

-Pascal


#3

Thanks, Pascal!

I had a little trouble figuring out how to use it due to some syntax issues. I believe the proper syntax is:

import rhinoscriptsyntax as Rhino
Rhino.Command("-_Insert etc etc")

-Edmark


#4

In Python I would not use this:

import rhinoscriptsyntax as Rhino

for Rhino also represents the module RhinoCommon and if you do that, you might not be able to use it correctly, at the least you will confuse people looking at your script.

The most common abbreviation to assign to rhinoscriptsyntax is “rs”, but use anything you want, just avoid common module names as well as Python native function or operator names.

and yes, you want to use rhinoscriptsyntax.Command("-_Insert…")

–Mitch


#5

Hi, can I use this code to import another 3dm file? I mean not the existing object in current 3dm file, but import from eg. the same folder, with a csv file containing the file names?
Thanks!!!


#6

Hi, can I use this code to import another 3dm file? I mean not the existing object in current 3dm file, but import from for example, the same folder, preferably whose names are read from a csv file?
Thanks!!!


#7

Not sure what you’re asking here… You can script the _-Import and _-Insert commands to import or insert any kind of file Rhino can import. In the case of a csv file however, as it’s not a 2D or 3D geometry file, you would probably need to script the importation by reading it in as a text file, and then do something with the data strings that would be the result of reading the file.

–Mitch


#8

Yes, that’s what I mean, but I’m not sure about the format. For example, the file I want to import is “A.3dm”. path:D:\10_PROJECTS\

I tried
import rhinoscriptsyntax as rs
rs.Command("-_Insert "&“D:\10_PROJECTS\A.3dm”)

Always returns file not found.


#9

Yes, that’s what I mean, but I’m not sure about the format. For example, the file I want to import is “A.3dm”. path:D:\10_PROJECTS\

I tried
import rhinoscriptsyntax as rs
rs.Command("-Insert "&“D:\10PROJECTS\A.3dm”)

Always returns file not found.


#10

Something like this, I think:

rs.Command('_-Insert "D:\10PROJECTS\A.3dm" Objects Enter 0,0,0 1 0')

–Mitch