fsimerey Posted August 31, 2016 Share Posted August 31, 2016 Hi, how can i merge a PrimGroup (or a tuple of prims with hou.PrimGroup.prims() ) from another hou.Geomtry() into a new hou.Geometry() ? Thanks Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted September 19, 2016 Share Posted September 19, 2016 You can't merge group selectively nor you can't add primitives one by one. You need to have a hou.Geometry() which will contain only the primitives you need, and then hou.Geometry.merge them to main geo. source_geo = get_geo_from_somwhere() # source_geo will contain group_A for example tmp_geo = hou.Geometry() tmp_geo.merge(source_geo) # Build a list of prims which are not in group_A prim_grp = tmp_geo.findPrimGroup("group_A") prims_to_delete = [] for prim in tmp_geo.prims(): if not prim_grp.containts(prim): prims_to_delete.append(prim) # Now delete everything except group_A prims tmp_geo.deletePrims(prims_to_delete) # Now tmp_geo contains only prims from group_A geo.merge(tmp_geo) Quote Link to comment Share on other sites More sharing options...
fsimerey Posted September 19, 2016 Author Share Posted September 19, 2016 Thanks Alex, i used the same solution to solve this problem, but with large geometry, duplicate all the geo is not very effective. Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted September 19, 2016 Share Posted September 19, 2016 Is there a specific reason you need to use python? I would bet it's not the call to merge that's slowing you down, but iterating over the prims to build the list, plus the delete call as well. All in all that's 3 or more iterations per primitive(not including duplicating the geometry). The fastest way to handle this (outside of using nodes, or VEX) would probably be exposing GEO_Detail::merge to hou, using inlinecpp this way you can merge the prim groups directly. http://www.sidefx.com/docs/hdk/class_g_e_o___detail.html#ac18c35b3d974d251890af70fd3d5fe2b Also you could send an RFE to sidefx about it, they may be able to help you. Quote Link to comment Share on other sites More sharing options...
fsimerey Posted September 19, 2016 Author Share Posted September 19, 2016 Yes, i need python because it's an HDA to parse and recreate SVG files (some heavy files from DWG). But it's not so bad, a file of 175 Mo takes 30-60 sec depending the numbers of paths/groups/attributes/transforms. Thanks anyway, but i'm not a programmer, i know python and vex but not c++ Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted September 19, 2016 Share Posted September 19, 2016 It's definitely worth an RFE, that's a lot of work for something so simple. 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.