Moving MeshBody in Global space

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
First some terminology:
Global space = Root component coordinate system
Local space = Mesh body coordinate system
The meshBody is a child of the rootComponent, there are no other components in between.
I am trying to align a meshBody to the Z-axis of the global space. I have computed the transform matrix to correctly transform the meshBody in Global space.
However the moveFeature apparently applies transforms in local space, so it doesn't line up anymore if the meshBody has been moved before.
I can't figure out where to find the transformation matrix to convert from global space to local space.
I know with components the transform can be found in the occurrence but there are no occurrences for bodies.
There is also no transform in the Body itself.
Where can I find the required transformation matrix? Or can I tell the moveFeature to move in global space?
app = adsk.core.Application.get() des = app.activeProduct root = des.rootComponent
des.designType = 0 bodies = adsk.core.ObjectCollection.create() bodies.add(meshBody) vector = adsk.core.Vector3D.create(0.0, 10.0, 0.0) transform = adsk.core.Matrix3D.create() # Example Transform rotating by about 45 around Z axis transform.setToRotation(3.14/4, adsk.core.Vector3D.create(0,0,1), adsk.core.Point3D.create(0,0,0)) # Actual Transform that is to complex to be included but is known to work #transform.setToRotateTo(adsk.core.Vector3D.create(res.x[3], res.x[4], res.x[5]), adsk.core.Vector3D.create(0,0,1)) # Create a move feature moveFeats = root.features.moveFeatures moveFeatureInput = moveFeats.createInput(bodies, transform) moveFeats.add(moveFeatureInput)