Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get Point in UserCoordinateSystem

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
556 Views, 2 Replies

Get Point in UserCoordinateSystem

I have a Problem and need help.

 

I want to get the coordinates of an workpoint in a UserCoordinateSystem (UCS).

 

GetPointInUCS.png

 

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

 

2 REPLIES 2
Message 2 of 3
johnster100
in reply to: Anonymous

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

Message 3 of 3
Anonymous
in reply to: johnster100

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report