Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Been wheel spinning for hours on this. I have inserted some code below that is supposed to rotate an occurrence, followed by moving it a specific distance. The rotation works but the move does not work. Its supposed to rotate it 90 degrees and then move it 1 inch in the X direction. It ends up being moved in both x and y by unknown distances. Can anyone help with this. I'm sure I am doing something fundamentally wrong.
Eric
def rotateMoveComp(comp,angleDeg,x,y,z):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
if not design:
ui.messageBox('No active Fusion design', 'No Design')
return
# Get the root component
rootComp = design.rootComponent
#get bounding box min
bbMin = comp.boundingBox.minPoint
# get Occurrence transform
mat: adsk.core.Matrix3D = comp.transform
import math
mat.setToRotation(math.radians(angleDeg), adsk.core.Vector3D.create(0,0,1), bbMin)
# set transform
comp.transform = mat
vector = adsk.core.Vector3D.create(x, y, z)
# Matrix translation
mat.translation = vector
# set transform
comp.transform = mat
print('')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
app = adsk.core.Application.get()
ui = app.userInterface
sel = ui.selectEntity('Choose Cushion Component', 'Occurrences')
cushion = adsk.fusion.Occurrence.cast(sel.entity)
rotateMoveComp(cushion,90,1*2.54,0,0)
Solved! Go to Solution.