I have been using the assembly.remove feature and found it very useful. Would it be ok I make a small PR to make it even more useful for me.
Assembly.remove() only checks direct children. It would be useful if it searched recursively through the hierarchy, since users often don't know (or shouldn't need to know) which level of nesting a part lives at especially with imported STEP files.
# Build a nested assembly: outer -> inner -> [box_a, box_b]
outer = cq.Assembly(name='outer')
inner = cq.Assembly(name='inner')
inner.add(cq.Workplane('XY').box(1, 1, 1), name='box_a')
inner.add(cq.Workplane('XY').box(2, 2, 2), name='box_b')
outer.add(inner)
# This fails — remove() only searches direct children, not recursively
outer.remove('box_a')
# ValueError: No object with name 'box_a' found in the assembly
# Workaround: remove from the direct parent
inner.remove('box_a') # works
I have been using the assembly.remove feature and found it very useful. Would it be ok I make a small PR to make it even more useful for me.
Assembly.remove() only checks direct children. It would be useful if it searched recursively through the hierarchy, since users often don't know (or shouldn't need to know) which level of nesting a part lives at especially with imported STEP files.