efx Posted June 28, 2011 Share Posted June 28, 2011 Hi, I have simple question. Is it possible to convert or create point group from prim group in Python?? If not, I will use foreach sop though.... I just don't wanna use any other sop. I would appreciate any help!! Thanks Quote Link to comment Share on other sites More sharing options...
efx Posted June 28, 2011 Author Share Posted June 28, 2011 Sorry Topic title should be "possible convert/create point group from prim group in python??" Quote Link to comment Share on other sites More sharing options...
symek Posted June 28, 2011 Share Posted June 28, 2011 You mean in PythonSOP? (it's not possible outside this node, as groups belong to geometry). You can do this explicitly by iterating over prims, like (not tested): prims = hou.pwd().geometry().globPrims("mygroup") pgroup = hou.pwd().geometry().createPointGroup("mypointgroup") for prim in prims: for v in prim.vertices(): if not pgroup.contains(v.point()): pgroup.add(v.point()) cheers, skk. Quote Link to comment Share on other sites More sharing options...
graham Posted June 28, 2011 Share Posted June 28, 2011 (edited) I seem to have this kicking around: def primToPointGroup(geometry, prim_group, point_group_name=None, keep=False): """ Convert a primitive group to a point group. If point_group_name is None, the new point group will have the same name as the primitive group. If keep is False, the original primitive group will be destroyed. """ # Handle the name of the new group. if point_group_name is None: point_group = geometry.createPointGroup(prim_group.name()) else: point_group = geometry.createPointGroup(point_group_name) # Iterate over each primitive in the group. for prim in prim_group.prims(): # Iterate over each vertex in the primitive and add its referenced # point to the new group. for vert in prim.vertices(): point_group.add(vert.point()) # Destroy the source group. if not keep: prim_group.destroy() return point_group Edited June 28, 2011 by graham Quote Link to comment Share on other sites More sharing options...
efx Posted June 28, 2011 Author Share Posted June 28, 2011 Wow Thank you2 SO much !! I did not expect this fast reply!! I did not test it yet though, I'm pretty sure the way graham shows will fit my situation and should work. Again guys thanks a lot!! 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.