SetToRotation question

SetToRotation question

Anonymous
Not applicable
1,534 Views
2 Replies
Message 1 of 3

SetToRotation question

Anonymous
Not applicable
I have written a little app. that copies an assembly for a location on the network to a local folder. I am placing the assembly into another assembly at 0,0,0 location. I want to place it spinning it about the Y axis 180deg. I also want to spin it around the Z axis at a specified angle. I hacked the example file to make what is below. It works but it will rotate the assembly in the same degree for each axis.... I need two different axies... how would i go about accomplishing this? the "oMatrix.SetToRotation" holds one value...how do I clear it to have another degree set current or????

Thanks for any help....
Bill

Private Sub cmd_Apply_Click()

'Public Sub AddOccurrence()
' Set a reference to the assembly component definintion.
' This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

' Set a reference to the transient geometry object.
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry

' Create a matrix. A new matrix is initialized with an identity matrix.
Dim oMatrix As Matrix
Set oMatrix = oTG.CreateMatrix

'this calculates the overall width of the guard
RotAngle = 180 / Val(tb_Angle)

If opt_CW_Rotation.Value = True Then

' Set the rotation of the matrix for a 45 degree rotation about the Z axis.
Call oMatrix.SetToRotation(3.14159265358979 / RotAngle, oTG.CreateVector(0, 0, 1), oTG.CreatePoint(0, 0, 0))

' Set the translation portion of the matrix so the part will be positioned
' at (0,0,0).
Call oMatrix.SetTranslation(oTG.CreateVector(0, 0, 0))

ElseIf opt_CCW_Rotation.Value = True Then

' Set the rotation of the matrix for a 45 degree rotation about the Z axis.
Call oMatrix.SetToRotation(3.14159265358979 / RotAngle, oTG.CreateVector(0, 0, 1), oTG.CreatePoint(0, 0, 0))
Call oMatrix.SetToRotation(3.14159265358979, oTG.CreateVector(0, 180, 0), oTG.CreatePoint(0, 0, 0))

' Set the translation portion of the matrix so the part will be positioned
' at (0,180,0).
Call oMatrix.SetTranslation(oTG.CreateVector(0, 0, 0))

End If

' Add the occurrence.
Dim oOcc As ComponentOccurrence
Set oOcc = oAsmCompDef.Occurrences.Add("C:locaton on hard drive", oMatrix)

Unload Me

End Sub
0 Likes
1,535 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Help-me-to-Mate-a-tube-outside-of-a-dr...

 

Boss, No Solution or no Support from AutoDesk Forum.  Waste, better switch to another 3D Apps.

0 Likes
Message 3 of 3

Vladimir.Ananyev
Alumni
Alumni

To combine several transformations use Matrix.TransformBy() method. Look at the sample “UCS by transformation matrix API” in the Inventor API Help.

There is a very good presentation on Inventor math:

Author:  Brian Ekins

“How Deep is the Rabbit Hole? Examining the Matrix and Other Inventor Math and Geometry Objects.”

http://modthemachine.typepad.com/files/mathgeometry.pdf

http://modthemachine.typepad.com/files/demos.zip

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes