Importing and placing multiple .obj files


I’ve created a set of .obj files that I would like to import them into Rhino, placing each object in a different location and orientation. So far, I can’t seem to get it to import even one .obj file. The obj file is in the same directory as my script. Here’s the command I’m using:

rs.Command("-_Import File1.obj")

When I try to run this, I get the error “Directory (null) does not exist”, which would seem to suggest that perhaps it wants a path name. But if I change the command to try to import a file name that doesn’t exist in that directory (e.g. “-_Import FFile1.obj”) it says “file not found”. So this would suggest that it IS finding the file when I give it the correct name.

Any suggestions for how to make this work would be most welcome. And I’d also appreciate any advice on how to reposition that obj file once I’ve imported it.

(Alain Cormier) #2

Hi Edmark,

Can you try running the “_Import” command interactively from the command prompt once?

After that do you still get the “Directory (null) does not exist” error from the script?


(Dale Fugier) #3

Not knowing what Rhino’s current working folder is, you should always specify the full path to any file you are opening/importing.

Also, in case the path string contains spaces, we will want to surround the string with double-quote characters so the command line parser will deal with the string property.


Hi Alain,

Thanks, Yes, I’m afraid I still get the same message.



OK, I tried giving it the complete pathname:
rs.Command("-_Import “/Users/edmark/Library/Application Support/McNeel/Rhinoceros/Scripts/…/test.obj”")

It definitely finds the file (I know this because if I give it an incorrect file name with the same path, it complains that the file doesn’t exist). But now I get the following error message:

File name: /Users/bozo/Projects/Rhino5/src4/rhino4/RhinoPlugInManager.cpp
Line number: 4662
Code Type: X86-64
Version: 5.0 (5A772w)

It then gives me the option of reporting the error to Rhino.

I’m rather sure that it is also finding the file when I don’t give it the complete path (since, here too, it complains if I give it a non-existant file name). But in this case I get a different error message (as stated in my earlier post):

Directory (null) does not exist

The bottom line is that I just need to be able to import a .obj file into Rhino using Python. I’m not wed to using the “_Import” syntax. I’m happy to try a completely different approach if someone would be kind enough to suggest one. Surely there must be a way to perform such a straightforward operation, no?

(Wim Dekeyser) #6

As a very simple test, could you put a OBJ named temp.obj in the C:\Temp folder and run the following line

rhino.command("-_import C:\Temp\temp.obj")

in the RhinoScript editor? [not Python, I know]
That works on this end…

(Alain Cormier) #7

I didn’t realise you were on the Mac.
I logged the problem and it’ll be looked at.

Sorry I don’t know of a workaround in the meantime. Maybe @dale knows.

(Dale Fugier) #8

The /.../ syntax is not going to work…


the “…” is not actually part of the path, I put those there in order to shorten the very long pathname for the purposes of my post.


yeah, something is wrong with entering the path using the command -Import as opposed to browsing for it. (on mac)

as a possible workaround for now, you could maybe try using -Insert

give it the path, then insert as Objects , then OBJ options, then probably 0,0,0 as insertion point.


(Dale Fugier) #11

We are able to repeat the problem here, and the issue has been logged.

Thanks for reporting.



Thanks for the suggestion, but I’m not quite sure how to implement it. I’ve used insert to add a .3dm file, such as here, where the file is filename.3dm:
rs.Command("-_Insert filename _Block _Scale 1 _Rotate 90 0,0,0")

But I have no idea how to get it to do something like this for an .obj file, particularly since “insert” seems to assume the file is a .3dm file. Could you please suggest a syntax?


this seems to do the trick:

-_Insert /Users/jeff/Desktop/example.obj O M enter 0 1 0

run the -Insert command from rhino though… there are some other options available where i used M in the above… you may want/need some of those options.


Works for me too! Thanks a lot!

Where do I go to find the syntax for the various options?


if you’re using rs.Command() ,it’s basically the same thing as making a macro… it’s not really a rhinoscriptsyntax / python thing… i suppose it’s a way to ensure all commands are available via script even when a specialize rhinoscript function is not available?

so it works the same way as running the command from within rhino itself… in rhino, run the -Insert command then follow the prompts… those are the same things you’ll be able to enter in a macro or rs.Command()


hey @Edmark

-Import works properly now on mac version 5A794w

for instance, this works in python to bring in a .dwg

 rs.Command("-Import ~/Desktop/test.dwg enter")

(thanks @marlin )


[quote=“jeff_hammond, post:16, topic:18896, full:true”]
hey @Edmark

-Import works properly now on mac version 5A794w

for instance, this works in python to bring in a .dwg

 rs.Command("-Import ~/Desktop/test.dwg enter")

Thanks @jeff_hammond! That’s great news! And thanks for the previous reply re command syntax!