Moving MeshBody in Global space

Moving MeshBody in Global space

Anonymous
Not applicable
486 Views
1 Reply
Message 1 of 2

Moving MeshBody in Global space

Anonymous
Not applicable

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)
0 Likes
487 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Update:

My assumption that it rotated about its local coordinate system was wrong. It seems to just pick an axis to rotate about at random. I have no idea what is happening.

 

This is an example of the code above, rotating 45 deg around Z. Ignore the vertex selection. It is necessary so the addin doesn't crash but does not affect the move. The first move seems to rotate it around the local Z axis. Moves after that seem to pick some axis that is neither local nor global.

 

Here is the entire code in case you want to try it yourself:

https://github.com/NicoSchlueter/Reverse

 

 

0 Likes