Import multiple .obj in one file

Hi,
I am new to this forum.
I am trying to import multiple .obj files into one Rhino file. I see that I should write a script for this perhaps but I do not know how to.
Maybe somebody knows how to put this in a script / knows the existance of an existing script within this or other forums?
Thank you! PIT

I have scripts for importing .obj files. Can you send me a link to an an example file? Then I will know if my scripting knowledge can be if help.

What happens when you try Rhino’s Import
Tool (File --> Import) and select .obj as the file type at the bottom of the import screen? You could do this for one .obj file after another. But it is a manual operation. Are you asking for a script because you need to do this automatically? Or do you have one file with multiple .obj files inside it?

Regards,
Terry

If there are not too many files, you can simply select them all in Windows file explorer then drag and drop them into the Rhino window- then choose Import from the radio button box that comes up. I say “not too many files” because IIRC you still have to hit Enter to accept the import settings for every file - no “yes to all” possibility…

Thank you Terry,

I’m trying to import them automatically. The file s are .obj files each one containing one model and they are all together in one folder with numeric based naming (frame01, frame02, etc). I want to drop them all in one single global rhino file, in the same coordinates they have in their native .obj environment.

Not sure if it’s clear.

If I use the import tool, I have to do one by one which is not ideal. It does not let me select all of them together.

P

P,

This sounds like a script would work. Do the .obj files have textures associated with them? If so, is the texture data (.MTL and .jpg files) in the same folder?

I would have time to work on this in the afternoon (6 hours from now) if you can give me more details on the .obj files. I am not familiar with any units information being in the .obj file so you will have to choose that during import of the batch. Also any other options you would normally choose from the Rhino Import form need to be specified. If the options are always the same, then we can put them in the script but I need a list. My script uses a DLL to make the import 3X faster. But the DLL only works in Windows. And my script has only been tested in Rhino 6/7. Are you using a Windows machine? Are you using Rhino 6 or 7 WIP?

Do the .obj files have the same number of vertices as textures? Do the mesh face lines that start with 'f ’ have indices that are the same for each of the 3 or four vertices? Here is an example line in a .obj file that contains both texture coordinates and vertex normals:
f 12345/12345/12345 456789/456789/456789 98765/98765/98765
If there are no textures or normals, the line is shorter:
f 12345 456789 98765
If there are more textures than vertices, then the line could look like:
f 12345/28/6783 456789/8295/1937 98765/37521/99435
Which type of face line is in you .obj files? You can look at the .obj file with Microsoft Notepad utility (right click on file, then select Open with --> and then select Notepad).

Regards,
Terry.

Hi Terry,

Thank you so much for getting back to me.

No texture associated. Just pure mesh solids.

Rhino 6 on windows.

I do not have info in face line yet but will get back to on this tomorrow.

The options to import will be always same. The idea is to drop the models according to spatial coordinates they carry within each of them.

Each model in each obj files is slightly moved compared to the model before (like frames in a video) and the position of each one should be retained when they all come together in the one final rhino file.

Best!

P

Does the mesh contain quads? Or is it all triangles?

Regards,
Terry.

Here is a quick batch importer using basic Rhino importer. Imports all .obj files in a given folder. There is no separation of geometry from different files to separate layers, everything goes to the current layer. (layering could be added) The command-line .obj import settings can be adjusted in the top section.

–Mitch
BatchImportObj.py (1.4 KB)

No, it’s all triangles

Helvetosaur, this works like a charm. I think I can keep it like this, without layer separation as it is not needed for what I am using this for.
Thank you so much this is so helpful!

Pietro


Virus-free. www.avg.com