Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The script below allows the selection of a BrepBody using UserInterface.selectEntity. It then duplicates the body to the root component. The new body is at the component definition's position and orientation. Shouldn't it instead be coincident with the proxy?
import adsk.core as ac
import adsk.fusion as af
import traceback
app: ac.Application = ac.Application.get()
ui: ac.UserInterface = app.userInterface
design: af.Design = app.activeProduct
rootComp = design.rootComponent
def addBody_toRoot(body: af.BRepBody):
bodies: af.BRepBodies = rootComp.bRepBodies
if design.designType == af.DesignTypes.ParametricDesignType:
baseFeat = rootComp.features.baseFeatures.add()
baseFeat.startEdit()
bodies.add(body, baseFeat)
baseFeat.finishEdit()
else:
# DirectDesignType.
bodies.add(body)
def run(context):
try:
while True:
try:
sel = ui.selectEntity('Select body', 'Bodies')
except:
break
body: af.BRepBody = sel.entity
if body.assemblyContext is None:
app.log("Native object picked. Try again.")
continue
addBody_toRoot(body)
except:
app.log('Failed:\n{}'.format(traceback.format_exc()))
app.log("End of script.")
Solved! Go to Solution.