coordinate system

coordinate system

Anonymous
Not applicable
330 Views
2 Replies
Message 1 of 3

coordinate system

Anonymous
Not applicable
hi
how do i get an occurrence's coordinate system?

i'm writing a VBA application and at one moment the application asks the user to click on an occurrence in an assembly, and after the click the code should suit the occurrence's inertial system to a variable. A coordinate system is compound from an origin and three unitvectors suited to the direction X,Y and Z
so i suppose i need a variable like this:

Public Type GROUND
Origin as Point
Xaxis as UnitVector
Yaxis as UnitVector
Zaxis as UnitVector
End Type

so i just need to get the inertial system's unitvectors, if it is possible
regards
0 Likes
331 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
A ComponentOccurrence object supports a property called Transformation.
This is a read-write property that returns and takes a Matrix object. A
matrix is a common way of defining position and orientation of objects
within a 3D graphics system. The easy way to get the information you're
looking for is to use the GetCoordinateSystem method of the Matrix object.
Here's an example assuming an occurrence has been selected in the active
assembly.

Public Sub GetCoordSystem()
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument

Dim oOcc As ComponentOccurrence
Set oOcc = oAsmDoc.SelectSet.Item(1)

Dim oTransform As Matrix
Set oTransform = oOcc.Transformation

Dim oOrigin As Point
Dim oXAxis As Vector
Dim oYAxis As Vector
Dim oZAxis As Vector
Call oTransform.GetCoordinateSystem(oOrigin, oXAxis, oYAxis, oZAxis)

Debug.Print "The coordinate system of part " & oOcc.Name
Debug.Print " Origin: " & oOrigin.X & ", " & oOrigin.Y & ", " &
oOrigin.Z
Debug.Print " X-Axis: " & oXAxis.X & ", " & oXAxis.Y & ", " & oXAxis.Z
Debug.Print " Y-Axis: " & oYAxis.X & ", " & oYAxis.Y & ", " & oYAxis.Z
Debug.Print " Z-Axis: " & oZAxis.X & ", " & oZAxis.Y & ", " & oZAxis.Z
End Sub
--
Brian Ekins
Autodesk Inventor API
0 Likes
Message 3 of 3

Anonymous
Not applicable
thanks a lot
it works nice
0 Likes