<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Export coordinates in relation to UCS in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/export-coordinates-in-relation-to-ucs/m-p/10078386#M120974</link>
    <description>&lt;P&gt;I tried adding a line with&amp;nbsp; &amp;nbsp; &amp;nbsp;points(i).TransformBy(yourUCSmat)&amp;nbsp; &amp;nbsp; &amp;nbsp;but I would get errors. I looked at other examples of people using transforms and they use Call. So I tried that, I now have a line of&amp;nbsp; &amp;nbsp;Call points(i).Point.TransformBy(yourUCSmat)&amp;nbsp; &amp;nbsp; &amp;nbsp; and I no longer get an error. But it doesn't seem to be applying any changes to my points. What am I doing wrong?&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Public Sub ExportWorkPoints()
    Dim partDoc As PartDocument
    Dim partCompDef As PartComponentDefinition
    
    If ThisApplication.ActiveDocumentType = kPartDocumentObject Then
        Set partDoc = ThisApplication.ActiveDocument
        Dim partDef As PartComponentDefinition
        Set partDef = partDoc.ComponentDefinition
                
        
    Else
        MsgBox "A part must be active."
        Exit Sub
    End If
    
    Dim points() As WorkPoint
    
        
    
    Dim pointCount As Long
    pointCount = 0
    If partDoc.SelectSet.Count &amp;gt; 0 Then
        ReDim points(partDoc.SelectSet.Count - 1)
        
        Dim selectedObj As Object
        For Each selectedObj In partDoc.SelectSet
            If TypeOf selectedObj Is WorkPoint Then
                Set points(pointCount) = selectedObj
                pointCount = pointCount + 1
                
            End If
        Next
    
        ReDim Preserve points(pointCount - 1)
    End If
    
    Dim getAllPoints As Boolean
    getAllPoints = True
    If pointCount &amp;gt; 0 Then
        Dim result As VbMsgBoxResult
        result = MsgBox("Some work points are selected. Do you want to export only the selected work points? (Answering No will export all work points)", vbYesNoCancel)
        If result = vbCancel Then
            Exit Sub
        End If
        
        If result = vbYes Then
            getAllPoints = False
        End If
    Else
        If MsgBox("No work points are selected. All work points" &amp;amp; _
        "will be exported. Do you want to continue?", _
        vbQuestion + vbYesNo) = vbNo Then
        Exit Sub
        End If
    End If
    
    
    If getAllPoints Then
        ReDim points(partDef.WorkPoints.Count - 2)
        
        Dim i As Integer
        For i = 2 To partDef.WorkPoints.Count
            Set points(i - 2) = partDef.WorkPoints.Item(i)
        Next
    End If
    
    Dim yourUCS As UserCoordinateSystem
    Set yourUCS = partDef.UserCoordinateSystems.Item(1)
    Dim yourUCSmat As Matrix
    Set yourUCSmat = yourUCS.Transformation
    
    
    Dim dialog As FileDialog
    Dim filename As String
    Call ThisApplication.CreateFileDialog(dialog)
    With dialog
        .DialogTitle = "Specify Output .CSV File"
        .Filter = "Comma delimited file (*.csv)|*.csv"
        .FilterIndex = 0
        .OptionsEnabled = False
        .MultiSelectEnabled = False
        .ShowSave
        filename = .filename
    End With
    
    
    If filename &amp;lt;&amp;gt; "" Then
        On Error Resume Next
        Open filename For Output As #1
        If Err.Number &amp;lt;&amp;gt; 0 Then
                MsgBox "unable to open the specified file. " &amp;amp; _
                "It may be open by another process."
            Exit Sub
        End If
        
        Dim uom As UnitsOfMeasure
        Set uom = partDoc.UnitsOfMeasure
        
        
        Print #1, "Point" &amp;amp; "," &amp;amp; _
        "X:" &amp;amp; "," &amp;amp; _
        "Y:" &amp;amp; "," &amp;amp; _
        "Z:" &amp;amp; "," &amp;amp; _
        "Radius:" &amp;amp; "," &amp;amp; _
        "Work point name"
        For i = 0 To UBound(points)
            
            Call points(i).Point.TransformBy(yourUCSmat)
            
            Dim xCoord As Double
            xCoord = uom.ConvertUnits(points(i).Point.X, _
                kCentimeterLengthUnits, kDefaultDisplayLengthUnits)
            Dim yCoord As Double
            yCoord = uom.ConvertUnits(points(i).Point.Y, _
                kCentimeterLengthUnits, kDefaultDisplayLengthUnits)
            Dim zCoord As Double
            zCoord = uom.ConvertUnits(points(i).Point.Z, _
                kCentimeterLengthUnits, kDefaultDisplayLengthUnits)
            
            Print #1, i + 1 &amp;amp; "," &amp;amp; _
                Format(xCoord, "0.000") &amp;amp; "," &amp;amp; _
                Format(yCoord, "0.000") &amp;amp; "," &amp;amp; _
                Format(zCoord, "0.000") &amp;amp; "," &amp;amp; _
                "," &amp;amp; _
                points(i).Name
        Next
        
        Close #1
        MsgBox "Finished writing data to """ &amp;amp; filename &amp;amp; """"
    End If
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Feb 2021 13:17:57 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-02-12T13:17:57Z</dc:date>
    <item>
      <title>Export coordinates in relation to UCS</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/export-coordinates-in-relation-to-ucs/m-p/10076482#M120950</link>
      <description>&lt;P&gt;I am trying to write a macro that will automatically export my selected work points to an excel sheet. So far I've been able to get it to do everything I need it to except I need the coordinates based off my UCS, not the origin. Its just like how when you use the Measure Tool you can select either your part origin or one of your UCS's. Does anyone know how to help with this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have alot of experience with programming, most of my attached code is a Frankenstein of various other codes I've seen online. Like I said, all I need to do is get it to export point coordinates based off my UCS. For the ease of programming, lets assume that the UCS I want to use will always be the newest UCS. I appreciate any help I can get!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 18:06:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/export-coordinates-in-relation-to-ucs/m-p/10076482#M120950</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-02-11T18:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Export coordinates in relation to UCS</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/export-coordinates-in-relation-to-ucs/m-p/10076850#M120953</link>
      <description>&lt;P&gt;you can get workpoint coordinates acc. to UCS like this.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;doc&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;PartDocument&lt;/SPAN&gt; = &lt;SPAN style="color: #800080;"&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN style="color: #800080;"&gt;Document&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;partDef&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;PartComponentDefinition&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;doc&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;ComponentDefinition&lt;/SPAN&gt;

&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;workpoint&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;WorkPoint&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;partDef&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;WorkPoints&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Item&lt;/SPAN&gt;(1)
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;point&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;Point&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;workpoint&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Point&lt;/SPAN&gt;
&lt;SPAN style="color: #800000;"&gt;MsgBox&lt;/SPAN&gt;(&lt;SPAN style="color: #ff0000;"&gt;String&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Format&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"WorkPoint: {0}x{1}x{2}"&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;point&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;X&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;point&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Y&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;point&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Z&lt;/SPAN&gt;))

&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;yourUCS&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;UserCoordinateSystem&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;partDef&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;UserCoordinateSystems&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Item&lt;/SPAN&gt;(1)
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;yourUCSmat&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;Matrix&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;yourUCS&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Transformation&lt;/SPAN&gt;

&lt;SPAN style="color: #800000;"&gt;point&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;TransformBy&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;yourUCSmat&lt;/SPAN&gt;)

&lt;SPAN style="color: #800000;"&gt;MsgBox&lt;/SPAN&gt;(&lt;SPAN style="color: #ff0000;"&gt;String&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Format&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"WorkPoint acc. to UCS: {0}x{1}x{2} (Dimensions in cm)"&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;point&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;X&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;point&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Y&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;point&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Z&lt;/SPAN&gt;))&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Feb 2021 20:40:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/export-coordinates-in-relation-to-ucs/m-p/10076850#M120953</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2021-02-11T20:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Export coordinates in relation to UCS</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/export-coordinates-in-relation-to-ucs/m-p/10078386#M120974</link>
      <description>&lt;P&gt;I tried adding a line with&amp;nbsp; &amp;nbsp; &amp;nbsp;points(i).TransformBy(yourUCSmat)&amp;nbsp; &amp;nbsp; &amp;nbsp;but I would get errors. I looked at other examples of people using transforms and they use Call. So I tried that, I now have a line of&amp;nbsp; &amp;nbsp;Call points(i).Point.TransformBy(yourUCSmat)&amp;nbsp; &amp;nbsp; &amp;nbsp; and I no longer get an error. But it doesn't seem to be applying any changes to my points. What am I doing wrong?&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Public Sub ExportWorkPoints()
    Dim partDoc As PartDocument
    Dim partCompDef As PartComponentDefinition
    
    If ThisApplication.ActiveDocumentType = kPartDocumentObject Then
        Set partDoc = ThisApplication.ActiveDocument
        Dim partDef As PartComponentDefinition
        Set partDef = partDoc.ComponentDefinition
                
        
    Else
        MsgBox "A part must be active."
        Exit Sub
    End If
    
    Dim points() As WorkPoint
    
        
    
    Dim pointCount As Long
    pointCount = 0
    If partDoc.SelectSet.Count &amp;gt; 0 Then
        ReDim points(partDoc.SelectSet.Count - 1)
        
        Dim selectedObj As Object
        For Each selectedObj In partDoc.SelectSet
            If TypeOf selectedObj Is WorkPoint Then
                Set points(pointCount) = selectedObj
                pointCount = pointCount + 1
                
            End If
        Next
    
        ReDim Preserve points(pointCount - 1)
    End If
    
    Dim getAllPoints As Boolean
    getAllPoints = True
    If pointCount &amp;gt; 0 Then
        Dim result As VbMsgBoxResult
        result = MsgBox("Some work points are selected. Do you want to export only the selected work points? (Answering No will export all work points)", vbYesNoCancel)
        If result = vbCancel Then
            Exit Sub
        End If
        
        If result = vbYes Then
            getAllPoints = False
        End If
    Else
        If MsgBox("No work points are selected. All work points" &amp;amp; _
        "will be exported. Do you want to continue?", _
        vbQuestion + vbYesNo) = vbNo Then
        Exit Sub
        End If
    End If
    
    
    If getAllPoints Then
        ReDim points(partDef.WorkPoints.Count - 2)
        
        Dim i As Integer
        For i = 2 To partDef.WorkPoints.Count
            Set points(i - 2) = partDef.WorkPoints.Item(i)
        Next
    End If
    
    Dim yourUCS As UserCoordinateSystem
    Set yourUCS = partDef.UserCoordinateSystems.Item(1)
    Dim yourUCSmat As Matrix
    Set yourUCSmat = yourUCS.Transformation
    
    
    Dim dialog As FileDialog
    Dim filename As String
    Call ThisApplication.CreateFileDialog(dialog)
    With dialog
        .DialogTitle = "Specify Output .CSV File"
        .Filter = "Comma delimited file (*.csv)|*.csv"
        .FilterIndex = 0
        .OptionsEnabled = False
        .MultiSelectEnabled = False
        .ShowSave
        filename = .filename
    End With
    
    
    If filename &amp;lt;&amp;gt; "" Then
        On Error Resume Next
        Open filename For Output As #1
        If Err.Number &amp;lt;&amp;gt; 0 Then
                MsgBox "unable to open the specified file. " &amp;amp; _
                "It may be open by another process."
            Exit Sub
        End If
        
        Dim uom As UnitsOfMeasure
        Set uom = partDoc.UnitsOfMeasure
        
        
        Print #1, "Point" &amp;amp; "," &amp;amp; _
        "X:" &amp;amp; "," &amp;amp; _
        "Y:" &amp;amp; "," &amp;amp; _
        "Z:" &amp;amp; "," &amp;amp; _
        "Radius:" &amp;amp; "," &amp;amp; _
        "Work point name"
        For i = 0 To UBound(points)
            
            Call points(i).Point.TransformBy(yourUCSmat)
            
            Dim xCoord As Double
            xCoord = uom.ConvertUnits(points(i).Point.X, _
                kCentimeterLengthUnits, kDefaultDisplayLengthUnits)
            Dim yCoord As Double
            yCoord = uom.ConvertUnits(points(i).Point.Y, _
                kCentimeterLengthUnits, kDefaultDisplayLengthUnits)
            Dim zCoord As Double
            zCoord = uom.ConvertUnits(points(i).Point.Z, _
                kCentimeterLengthUnits, kDefaultDisplayLengthUnits)
            
            Print #1, i + 1 &amp;amp; "," &amp;amp; _
                Format(xCoord, "0.000") &amp;amp; "," &amp;amp; _
                Format(yCoord, "0.000") &amp;amp; "," &amp;amp; _
                Format(zCoord, "0.000") &amp;amp; "," &amp;amp; _
                "," &amp;amp; _
                points(i).Name
        Next
        
        Close #1
        MsgBox "Finished writing data to """ &amp;amp; filename &amp;amp; """"
    End If
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 13:17:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/export-coordinates-in-relation-to-ucs/m-p/10078386#M120974</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-02-12T13:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Export coordinates in relation to UCS</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/export-coordinates-in-relation-to-ucs/m-p/10078430#M120977</link>
      <description>&lt;P&gt;points(i).Point is read only there for it cant be transformed. try to create a new point and transform that point. something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;For i = 0 To UBound(points)
            
            dim newPoint as Point
	    newPoint = points(i).Point
	    newPoint.TransformBy(yourUCSmat)

            Dim xCoord As Double
            xCoord = uom.ConvertUnits(newPoint.X, _
                kCentimeterLengthUnits, kDefaultDisplayLengthUnits)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 13:36:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/export-coordinates-in-relation-to-ucs/m-p/10078430#M120977</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2021-02-12T13:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Export coordinates in relation to UCS</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/export-coordinates-in-relation-to-ucs/m-p/10078535#M120978</link>
      <description>&lt;P&gt;That kind of worked. It offset my coordinates in the wrong direction though. After I defined my matrix I inverted it and that solved my issue. Thanks for helping!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 14:13:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/export-coordinates-in-relation-to-ucs/m-p/10078535#M120978</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-02-12T14:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Export coordinates in relation to UCS</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/export-coordinates-in-relation-to-ucs/m-p/11207362#M138788</link>
      <description>&lt;P&gt;Hi, I'm actually in the same position here. According to my tests, Point.TransformBy(UCS) will only do the translation part of the matrix. If your UCS is rotated, that seems a problem.&lt;/P&gt;&lt;P&gt;I found no convient way so far, seems I have to go the full matrix calculation way.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2022 11:13:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/export-coordinates-in-relation-to-ucs/m-p/11207362#M138788</guid>
      <dc:creator>gilsdorf_e</dc:creator>
      <dc:date>2022-06-01T11:13:59Z</dc:date>
    </item>
  </channel>
</rss>

