I have a Problem and need help.
I want to get the coordinates of an workpoint in a UserCoordinateSystem (UCS).
I thought i can get it with the function „TransformBy“
point.TransformBy(UCS.Transformation)
But for the example in the screenshot i get the result: X: 0, Y: 2, Z: 0 … but it should be X: 0, Y: 0, Z: 0
Here a example-Code:
Public Sub test()
Dim p As PartDocument
Dim oTG As TransientGeometry
Dim u As UserCoordinateSystem
Dim wp As WorkPoint
Dim point As point
Dim v As Vector
Set p = ThisDocument
Set oTG = ThisApplication.TransientGeometry
Set u = p.ComponentDefinition.UserCoordinateSystems.Item(1)
For Each wp In p.ComponentDefinition.WorkPoints
Debug.Print wp.Name
If (InStr(1, wp.Name, "Point", vbTextCompare)) Then
Debug.Print "Orig x: " & wp.point.X & ", y: " & wp.point.Y & ", z: " & wp.point.Z
Set point = wp.point.Copy()
Call point.TransformBy(u.Transformation)
Debug.Print "Transform x: " & point.X & ", y: " & point.Y & ", z: " & point.Z
End If
Next
End Sub
Solved! Go to Solution.
Hi Guys,
Did you ever manage to get this to work?????????
If so the code would be useful to me. I'm trying to output work point coordinates to excel using ilogic.
thanks,
John
i solved my problem and because some people asked if i already have a solution i want to share it with you
the transformation-matrix has to be inverted before transformation
Private Function TransformByUserCoordinate(ByVal Point As ADSKInventor.Point) As ADSKInventor.Point
Dim UCS As ADSKInventor.UserCoordinateSystem = GetUserCoordinateSystem()
TransformByUserCoordinate = Nothing
If (UCS IsNot Nothing) Then
TransformByUserCoordinate = Point.Copy()
Dim TransformMatrix As ADSKInventor.Matrix = UCS.Transformation
TransformMatrix.Invert()
TransformByUserCoordinate.TransformBy(TransformMatrix)
End If
End Function