Message 1 of 3
SetToRotation question

Not applicable
05-14-2009
10:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
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