Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In try to copy a body 6 times and move it to different positions in a loop. I tried different things but can't get it work.
Here is the code and the error:
app = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
# Get the root component of the active design.
rootComp = design.rootComponent
# Get the first sub component
occs = rootComp.occurrences
subComp1 = occs.item(0).component
# Get the first body in sub component 1
baseBody = subComp1.bRepBodies.item(0)
for i in range(6):
# Copy/paste body
subComp1.features.copyPasteBodies.add(baseBody)
baseBodyCopy = subComp1.bRepBodies.item(i+1)
# Create a collection of entities for move
bodies = adsk.core.ObjectCollection.create()
bodies.add(baseBodyCopy)
# Create a transform to do move
vector = adsk.core.Vector3D.create(5 * i, 0, 0)
transform = adsk.core.Matrix3D.create()
transform.translation = vector
moveFeats = subComp1.features.moveFeatures
moveFeatureInput = moveFeats.createInput(bodies, transform)
moveFeats.add(moveFeatureInput)
Error:
Failed:
Traceback (most recent call last):
File "...py", line 83, in run
moveFeats.add(moveFeatureInput)
File "/Library/Application Support/Autodesk/webdeploy/production/3f1b40e356e6df065e6a8f3470590c17c5502c2a/Autodesk Fusion 360.app/Contents/Api/Python/packages/adsk/fusion.py", line 21839, in add
return _fusion.MoveFeatures_add(self, input)
RuntimeError: 3 : invalid transform
Solved! Go to Solution.