Message 1 of 14
Problem related to rotation of an occurence

Not applicable
09-17-2009
11:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi i tried rotate a particular occurence called cabin which is in a subassembly called my final crane assembly:1
when i tried to rotate the cabin , the whole crane is rotating. my code is given below. can any one try to help me out from this issue...Public Sub CreateProxies()
Dim oassDoc As AssemblyDocument
Set oassDoc = ThisApplication.ActiveDocument
Dim oasscompdef As AssemblyComponentDefinition
Set oasscompdef = oassDoc.ComponentDefinition
Dim oOcc As ComponentOccurrence
Dim cabin As ComponentOccurrence
Dim oPartProxy As ComponentOccurrenceProxy
Set oOcc = oasscompdef.Occurrences.ItemByName("my final crane assembly:1")
Set cabin = oOcc.Definition.Occurrences.ItemByName("cabin:1")
Call oOcc.CreateGeometryProxy(cabin, oPartProxy)
Dim oHS1 As HighlightSet
Set oHS1 = oassDoc.HighlightSets.Add
oHS1.SetColor 255, 0, 0
oHS1.Clear
oHS1.AddItem oPartProxy
MsgBox "proxy is highlighted"
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
' Get the current matrix from the occurrence.
Dim oRotMat As Matrix
Set oRotMat = oOcc.Transformation
'Create a point based on the current position of the occurrence.
Dim oCenter As Point
Set oCenter = oTG.CreatePoint(oRotMat.Translation.x, oRotMat.Translation.y, oRotMat.Translation.z)
' Define the matrix that specifies the rotation about the Z axis and the center point.
' The angle is pi/2 or 90 degrees.
Dim dpi As Double
dpi = 1.74532925199432E-02
Dim i As Integer
For i = 1 To 5
Call oRotMat.SetToRotation(dpi, oTG.CreateVector(0, 0, 1), oCenter)
' Get the current matrix from the occurrence.
Dim oMat As Matrix
Set oMat = oOcc.Transformation
'Multiply the occurrence matrix by the rotation matrix.
Call oMat.MultiplyBy(oRotMat)
'Apply the new matrix back to the occurrence.
oOcc.Transformation = oMat
dpi = dpi + 1.74532925199432E-02
Next
End Sub
when i tried to rotate the cabin , the whole crane is rotating. my code is given below. can any one try to help me out from this issue...Public Sub CreateProxies()
Dim oassDoc As AssemblyDocument
Set oassDoc = ThisApplication.ActiveDocument
Dim oasscompdef As AssemblyComponentDefinition
Set oasscompdef = oassDoc.ComponentDefinition
Dim oOcc As ComponentOccurrence
Dim cabin As ComponentOccurrence
Dim oPartProxy As ComponentOccurrenceProxy
Set oOcc = oasscompdef.Occurrences.ItemByName("my final crane assembly:1")
Set cabin = oOcc.Definition.Occurrences.ItemByName("cabin:1")
Call oOcc.CreateGeometryProxy(cabin, oPartProxy)
Dim oHS1 As HighlightSet
Set oHS1 = oassDoc.HighlightSets.Add
oHS1.SetColor 255, 0, 0
oHS1.Clear
oHS1.AddItem oPartProxy
MsgBox "proxy is highlighted"
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
' Get the current matrix from the occurrence.
Dim oRotMat As Matrix
Set oRotMat = oOcc.Transformation
'Create a point based on the current position of the occurrence.
Dim oCenter As Point
Set oCenter = oTG.CreatePoint(oRotMat.Translation.x, oRotMat.Translation.y, oRotMat.Translation.z)
' Define the matrix that specifies the rotation about the Z axis and the center point.
' The angle is pi/2 or 90 degrees.
Dim dpi As Double
dpi = 1.74532925199432E-02
Dim i As Integer
For i = 1 To 5
Call oRotMat.SetToRotation(dpi, oTG.CreateVector(0, 0, 1), oCenter)
' Get the current matrix from the occurrence.
Dim oMat As Matrix
Set oMat = oOcc.Transformation
'Multiply the occurrence matrix by the rotation matrix.
Call oMat.MultiplyBy(oRotMat)
'Apply the new matrix back to the occurrence.
oOcc.Transformation = oMat
dpi = dpi + 1.74532925199432E-02
Next
End Sub