Bakiki Posted January 20, 2018 Share Posted January 20, 2018 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) obj.createNode("geo") Quote Link to comment Share on other sites More sharing options...
Atom Posted January 21, 2018 Share Posted January 21, 2018 (edited) 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 January 21, 2018 by Atom Quote Link to comment Share on other sites More sharing options...
fathom Posted January 21, 2018 Share Posted January 21, 2018 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. http://www.sidefx.com/docs/houdini/hom/hou/PackedPrim.html 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. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted January 21, 2018 Share Posted January 21, 2018 node = hou.pwd() geo = node.geometry() geo1 = hou.Geometry() geo1.loadFromFile('$HIP/geo/geo1.obj') geo2 = hou.Geometry() geo2.loadFromFile('$HIP/geo/geo2.obj') geo.merge(geo1) geo.merge(geo2) 1 Quote Link to comment Share on other sites More sharing options...
Bakiki Posted January 22, 2018 Author Share Posted January 22, 2018 Thank you all or your great responses. I knew there was a simple solution out there..... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.