alican Posted June 5, 2015 Share Posted June 5, 2015 I am trying to create a primitive group with using a syntax something like this; n = hou.node('/obj/geo1/grid1') g = n.geometry() p = g.createPrimGroup("myGroup") I get an error when I do the last line. What is the way to create primitive or point groups with python, if I just want that group to have all the prims/points in that geometry? Thank you for the help, Alican Görgeç Quote Link to comment Share on other sites More sharing options...
anim Posted June 6, 2015 Share Posted June 6, 2015 (edited) I assume you are doing this within Python SOP if your grid is connected to first input of Python SOP then this should work: n = hou.pwd() g = n.geometry() p = g.createPrimGroup("myGroup") p.add(g.prims()) as Python SOP can only modify geometry that it owns, you can't modify geometry linked to an external sop in theory you could as well freeze (hou.Geometry.freeze()) the geometry coming from custom sop path and modify that and merge (hou.Geometry.merge()) with current (possibly empty) geo, I haven't tried it though Edited June 6, 2015 by anim 1 Quote Link to comment Share on other sites More sharing options...
alican Posted June 6, 2015 Author Share Posted June 6, 2015 Thank you for your response. What if I want to create a shelf tool and want it to work with in that tool. Is there no way to make it work externally? Currently I am practicing python and trying to create a tool that collects all the SOP nodes that comes with an alembic or FBX import and merges them into single object merge node. I have done this part, bu then I want to split them out again after the object merge node with a delete sop according to the groups that I will be creating before putting them into the object merge node. Thanks again! Quote Link to comment Share on other sites More sharing options...
anim Posted June 6, 2015 Share Posted June 6, 2015 - taking this as a python practice: the data have to be stored somewhere in the scene or disk so you'd have to insert Python SOP with (similar code to above) into every line coming to merge so that every merged geo has it's individual group but for that matter you would be rather creating/inserting Group SOPs if you want speed or attribwrangles if it as well entails more robust grouping - from less Python needy workflow (however you can still build the setup with Python) don't forget you can bring the whole alembic into sops with Alembic SOP and geo will have path attribute, that you can use to create your names and groups easily with a few SOP nodes for FBX (or imported Alembic as objects) you can import it into flat hierarchy, then create empty geo object and objectmerge the whole geo level at once using path like: /obj/importedfbx/* or multiple levels: /obj/importedfbx/*/*/* Object Merge has options to create individual groups for them or attribs so you can access corresponding geos later Quote Link to comment Share on other sites More sharing options...
alican Posted June 6, 2015 Author Share Posted June 6, 2015 Oh i didn't know about those options . I thought it would be a good practice as well as something useful in the end. But thanks for your help. I will try those methods and try to push it for the sake of practicing. 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.