Message 1 of 9
Unable to delete multiple sub assembly (occurences) under the top node (root component)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
The code below is supposed to delete every single occurrence (sub assembly) under the top node (root Component) that contain 'MALE' or 'FEMALE' in their name. When I run the script, I get an error message (see error message below). Can you please let me know what is the best way to do it.
ERROR MESSAGE :
Design:
Code:
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
rootComp = design.rootComponent
occs = rootComp.occurrences
for occ in occs:
occName = occ.name
occName = occName.upper()
if occName.find('MALE') != -1 or occName.find('FEMALE') != -1:
occ.deleteMe()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))