Jump to content

How to import obj with python?

Recommended Posts

I'm trying to script a multiple obj importer, could someone tell me how to do a basic obj importer equivalent to the "File" SOP...

Here's what I have so far....


node = hou.pwd()
geo = node.geometry()

import os

import numpy as np

folder = r"PATH TO FOLDER WITH OBJ's "

models =  [f for f in os.listdir(folder) if f.endswith('.obj')]


rand = np.random.randint(0,len(models))

path =os.path.join(folder, models[rand])


print os.path.join(folder, models[rand])

obj = hou.node(path)










Share this post

Link to post
Share on other sites

I made a python script similar to what you are trying to do.

Feel free to check out the code here. It might have some tips on how to make nodes and populate their parameters. It basically uses the existing File node, created by default when a geometry type object is created, to read natively supported mesh/object types.


If you are looking to create and manage a non-native 3D object type. Take a look at my moon scanner script. It reads NASA data and constructs a geometry mesh from that data.

Edited by Atom

Share this post

Link to post
Share on other sites

the simplest approach is to use a packed disk primitive.  create a pakedPrim for each file you wish to read, then stuff in the path using a primintrinsic.




you can unpack later to turn into geo, or if you don't need to process anything, just leave them as-is for better performance for rendering and display.

if you need a format unsupported by houdini, then you've got a different problem on your hands.

Share this post

Link to post
Share on other sites
node = hou.pwd()
geo = node.geometry()

geo1 = hou.Geometry()

geo2 = hou.Geometry()



  • Like 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now