Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Been working on a problem all morning that I cannot solve so I thought I'd reach out to the experts. The code, I have pasted in below, used in conjunction with the file I have uploaded (Linked File Test v6.f3z) works with standard components but not with linked components. The file I have attached has a linked component and an internal component. You will see two copyPasteBodies features created, one having a body within it and one not. Code does not crash, it just does not work for the linked component. Can someone tell me how this can be repaired or give me a work around. Thanks in advance!!!
Eric
import adsk.core, adsk.fusion, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
# Get active design
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
# Get root component in this design
rootComp = design.rootComponent
# Get the first sub component
occs = rootComp.occurrences
subComp1 = occs.itemByName('Test v3:1').component
# Get the second sub component
subComp2 = occs.itemByName('SubComp2:1').component
# Get the third sub component
subComp3 = occs.itemByName('Test v3 Unlinked:1').component
# Get the first body in sub component 1
bodyInSubComp1 = subComp1.bRepBodies.item(0)
# Get the first body in sub component 1
bodyInSubComp3 = subComp3.bRepBodies.item(0)
copyPasteBody = subComp2.features.copyPasteBodies.add(bodyInSubComp1)
copyPasteBody1 = subComp2.features.copyPasteBodies.add(bodyInSubComp3)
print('')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.