Hello,
Having two sequences of .bgeo files with same named primitive groups in each.
E.g.
prim_group_001
prim_group_002
prim_group_003
…
prim_group_100
I want to merge this two sequences into one and delete each primitive group from first sequence if it exists in second one.
The number of groups in second sequence is changing from frame to frame and they may appear in some random order.
For example: prim_group_050 and prim_group_024 in first frame and prim_group_098, prim_group_045, prim_group_023 in second frame.
What is the best way to do that?
Thanks.
Deleting primitive groups
9756 3 0- sergey_sh
- Member
- 22 posts
- Joined: June 2008
- Offline
- asnowcappedromance
- Member
- 512 posts
- Joined: July 2009
- Offline
I wrote a python SOP that should do the deleting,
unfortunately as soon as I add the last line to the code, Houdini crashes with a runtime error message. Can you please try to create a python operator with two inputs and test the code for me? Maybe it's my built, haven't updated my apprentice in a while …
And to all the Python experts, is there anything wrong with my code?
geo.deletePrims(sequence) is the line that brings Houdini down …
Here's the code:
# This code is called when instances of this SOP cook.
node = hou.pwd()
geo = node.geometry()
# merge second inputs geometry
geo.merge(node.inputs().geometry())
input1 = node.inputs().geometry()
group1 = input1.primGroups()
input2 = node.inputs().geometry()
group2 = input2.primGroups()
template = set(p.name() for p in group2)
killprims =
for i in group1:
name = i.name()
if name in template:
killgroup = geo.findPrimGroup(name)
for q in killgroup.prims():
number = q.number()
killprims.append(number)
geo.deletePrims(killprims)
all the best,
Manu
unfortunately as soon as I add the last line to the code, Houdini crashes with a runtime error message. Can you please try to create a python operator with two inputs and test the code for me? Maybe it's my built, haven't updated my apprentice in a while …
And to all the Python experts, is there anything wrong with my code?
geo.deletePrims(sequence) is the line that brings Houdini down …
Here's the code:
# This code is called when instances of this SOP cook.
node = hou.pwd()
geo = node.geometry()
# merge second inputs geometry
geo.merge(node.inputs().geometry())
input1 = node.inputs().geometry()
group1 = input1.primGroups()
input2 = node.inputs().geometry()
group2 = input2.primGroups()
template = set(p.name() for p in group2)
killprims =
for i in group1:
name = i.name()
if name in template:
killgroup = geo.findPrimGroup(name)
for q in killgroup.prims():
number = q.number()
killprims.append(number)
geo.deletePrims(killprims)
all the best,
Manu
- graham
- Member
- 1914 posts
- Joined: Nov. 2006
- Offline
- asnowcappedromance
- Member
- 512 posts
- Joined: July 2009
- Offline
-
- Quick Links