<?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: Pipe (sweep) and workpoints in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/pipe-sweep-and-workpoints/m-p/8496806#M92812</link>
    <description>&lt;P&gt;This is the simplest thing I could come up with... you may need to change "Center Point" to "&lt;SPAN&gt;Mittelpunkt" (based on the comments in your code I'm assuming the German word for center point)&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;Sub ExportArbeitspunkte()
    Dim app As Application
    Set app = ThisApplication
    
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
   
    Dim oDef As PartComponentDefinition
    Set oDef = oDoc.ComponentDefinition
   
    Dim oWorkpoints As WorkPoints
    Dim oWP As WorkPoint
    Dim oP As Point
       
    'get all workpoints in this part
    Set oWorkpoints = oDef.WorkPoints
    
    'Create a new Excel instance
    Dim oExcelApplication As Excel.Application
    Set oExcelApplication = New Excel.Application

    'create a new excel workbook
    Dim oBook As Excel.Workbook
    Set oBook = oExcelApplication.Workbooks.Add()
    Dim oSheet As Excel.WorkSheet
    Set oSheet = oBook.ActiveSheet
   
    Dim nRow As Integer
    nRow = 1
    
    'Ask for Origin point
    Dim MyOrg As WorkPoint
    Set MyOrg = app.CommandManager.Pick(kAllPointEntities, "Choose sweep origin")
    
    'find difference to center point&lt;BR /&gt;    Dim DeltaX As Double
    Dim DeltaY As Double
    Dim DeltaZ As Double
    DeltaX = oDef.WorkPoints.Item("Center Point").Point.x - MyOrg.Point.x
    DeltaY = oDef.WorkPoints.Item("Center Point").Point.Y - MyOrg.Point.Y
    DeltaZ = oDef.WorkPoints.Item("Center Point").Point.Z - MyOrg.Point.Z
    
    'write the coordinates into separate columns, one workpoint each row
    For Each oWP In oWorkpoints
        If Not oWP.Name = "Center Point" Then
            Set oP = oWP.Point
            oSheet.Cells(nRow, 1) = (oP.x + DeltaX) * 10
            oSheet.Cells(nRow, 2) = (oP.Y + DeltaY) * 10
            oSheet.Cells(nRow, 3) = (oP.Z + DeltaZ) * 10
            nRow = nRow + 1
        End If
    Next
    
    Dim OutputFile As String
    OutputFile = Left(ThisApplication.ActiveDocument.FullFileName, _
    Len(ThisApplication.ActiveDocument.FullFileName) - 4) + "_Arbeitspunkte.xls"
                
    On Error Resume Next
    oBook.SaveAs (OutputFile)
    oBook.Close
    
    Set oBook = Nothing
    Set oSheet = Nothing
    Set oExcelApplication = Nothing
    
    MsgBox "Es wurde eine Excel Tabelle im aktuellen Verzeichnis erstellt und eine neue IPT für den Import geöffnet!"
            
    'Make a new part file
    Dim oPartDoc As PartDocument
    'Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
    Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, , True)
    
End Sub&lt;/PRE&gt;
&lt;P&gt;Edit: Don't forget to put your template path back in on the last line&lt;/P&gt;</description>
    <pubDate>Wed, 02 Jan 2019 21:09:59 GMT</pubDate>
    <dc:creator>clutsa</dc:creator>
    <dc:date>2019-01-02T21:09:59Z</dc:date>
    <item>
      <title>Pipe (sweep) and workpoints</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/pipe-sweep-and-workpoints/m-p/8495478#M92802</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;i have a code which exports workpoints to an excel file. I need the coordinates of the workpoints to create a sweeping of a pipe. the code exports the workpoints and the zeropoint (0,0,0).&amp;nbsp;This zeropoint is not a point of the pipe. - only the 4 workpoints.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="workpoints.JPG" style="width: 595px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/586339iC11C3D15CF60EFE4/image-size/large?v=v2&amp;amp;px=999" role="button" title="workpoints.JPG" alt="workpoints.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="excel.JPG" style="width: 356px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/586340i229C3AB6782D7C96/image-size/large?v=v2&amp;amp;px=999" role="button" title="excel.JPG" alt="excel.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to change the code that i can choose a workpoint? This workpoint shouldt be the new startpoint (0,0,0) for the sweeping. The code shouldt be take the coordinates of this choosen workpoint and calculate the new coordinates for all the other 4 points (not for the original zeropint).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, if i choose the Point -100,-300,100 the Excel file shouldt Looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="excel1.JPG" style="width: 313px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/586346iAC847C85331B8AB9/image-size/large?v=v2&amp;amp;px=999" role="button" title="excel1.JPG" alt="excel1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is my code:&lt;/P&gt;
&lt;PRE&gt;Sub ExportArbeitspunkte()
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
   
    Dim oDef As PartComponentDefinition
    Set oDef = oDoc.ComponentDefinition
   
    Dim oWorkpoints As WorkPoints
    Dim oWP As WorkPoint
    Dim oP As Point
       
    'get all workpoints in this part
    Set oWorkpoints = oDef.WorkPoints
    
    'Create a new Excel instance
    Dim oExcelApplication As Excel.Application
    Set oExcelApplication = New Excel.Application

    'create a new excel workbook
    Dim oBook As Excel.Workbook
    Set oBook = oExcelApplication.Workbooks.Add()
    Dim oSheet As Excel.WorkSheet
    Set oSheet = oBook.ActiveSheet
   
    Dim nRow As Integer
    nRow = 1

    'write the coordinates into separate columns, one workpoint each row
    For Each oWP In oWorkpoints
        Set oP = oWP.Point
        oSheet.Cells(nRow, 1) = oP.X * 10
        oSheet.Cells(nRow, 2) = oP.Y * 10
        oSheet.Cells(nRow, 3) = oP.Z * 10
        nRow = nRow + 1
    Next
    
    Dim OutputFile As String
    OutputFile = Left(ThisApplication.ActiveDocument.FullFileName, _
    Len(ThisApplication.ActiveDocument.FullFileName) - 4) + "_Arbeitspunkte.xls"
                
    On Error Resume Next
    oBook.SaveAs (OutputFile)
    oBook.Close
    Set oBook = Nothing
    Set oSheet = Nothing
    Set oExcelApplication = Nothing
    
    MsgBox "Es wurde eine Excel Tabelle im aktuellen Verzeichnis erstellt und eine neue IPT für den Import geöffnet!"
            
    'Make a new part file
    Dim oPartDoc As PartDocument
    'Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
    Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, "V:\Inventor-2015\1-Inventor\TEMPLATES\_VORLAGE ROHR.ipt")

End Sub
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;
&lt;P&gt;Regards from germany&lt;/P&gt;
&lt;P&gt;Martin&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 11:06:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/pipe-sweep-and-workpoints/m-p/8495478#M92802</guid>
      <dc:creator>martinhoos</dc:creator>
      <dc:date>2019-01-02T11:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Pipe (sweep) and workpoints</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/pipe-sweep-and-workpoints/m-p/8496806#M92812</link>
      <description>&lt;P&gt;This is the simplest thing I could come up with... you may need to change "Center Point" to "&lt;SPAN&gt;Mittelpunkt" (based on the comments in your code I'm assuming the German word for center point)&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;Sub ExportArbeitspunkte()
    Dim app As Application
    Set app = ThisApplication
    
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
   
    Dim oDef As PartComponentDefinition
    Set oDef = oDoc.ComponentDefinition
   
    Dim oWorkpoints As WorkPoints
    Dim oWP As WorkPoint
    Dim oP As Point
       
    'get all workpoints in this part
    Set oWorkpoints = oDef.WorkPoints
    
    'Create a new Excel instance
    Dim oExcelApplication As Excel.Application
    Set oExcelApplication = New Excel.Application

    'create a new excel workbook
    Dim oBook As Excel.Workbook
    Set oBook = oExcelApplication.Workbooks.Add()
    Dim oSheet As Excel.WorkSheet
    Set oSheet = oBook.ActiveSheet
   
    Dim nRow As Integer
    nRow = 1
    
    'Ask for Origin point
    Dim MyOrg As WorkPoint
    Set MyOrg = app.CommandManager.Pick(kAllPointEntities, "Choose sweep origin")
    
    'find difference to center point&lt;BR /&gt;    Dim DeltaX As Double
    Dim DeltaY As Double
    Dim DeltaZ As Double
    DeltaX = oDef.WorkPoints.Item("Center Point").Point.x - MyOrg.Point.x
    DeltaY = oDef.WorkPoints.Item("Center Point").Point.Y - MyOrg.Point.Y
    DeltaZ = oDef.WorkPoints.Item("Center Point").Point.Z - MyOrg.Point.Z
    
    'write the coordinates into separate columns, one workpoint each row
    For Each oWP In oWorkpoints
        If Not oWP.Name = "Center Point" Then
            Set oP = oWP.Point
            oSheet.Cells(nRow, 1) = (oP.x + DeltaX) * 10
            oSheet.Cells(nRow, 2) = (oP.Y + DeltaY) * 10
            oSheet.Cells(nRow, 3) = (oP.Z + DeltaZ) * 10
            nRow = nRow + 1
        End If
    Next
    
    Dim OutputFile As String
    OutputFile = Left(ThisApplication.ActiveDocument.FullFileName, _
    Len(ThisApplication.ActiveDocument.FullFileName) - 4) + "_Arbeitspunkte.xls"
                
    On Error Resume Next
    oBook.SaveAs (OutputFile)
    oBook.Close
    
    Set oBook = Nothing
    Set oSheet = Nothing
    Set oExcelApplication = Nothing
    
    MsgBox "Es wurde eine Excel Tabelle im aktuellen Verzeichnis erstellt und eine neue IPT für den Import geöffnet!"
            
    'Make a new part file
    Dim oPartDoc As PartDocument
    'Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
    Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, , True)
    
End Sub&lt;/PRE&gt;
&lt;P&gt;Edit: Don't forget to put your template path back in on the last line&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 21:09:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/pipe-sweep-and-workpoints/m-p/8496806#M92812</guid>
      <dc:creator>clutsa</dc:creator>
      <dc:date>2019-01-02T21:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Pipe (sweep) and workpoints</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/pipe-sweep-and-workpoints/m-p/8497033#M92830</link>
      <description>&lt;P&gt;Another method is to exclude the Center workpoint (which is always workpoints item 1) from your iteration.&lt;/P&gt;
&lt;P&gt;Instead of 'for each workpoint...', use:&lt;/P&gt;
&lt;P&gt;for ind as integer = 2 to oWorkpoints.count&lt;/P&gt;
&lt;P&gt;dim wp as workpoint = oWorkpoints(ind)&lt;/P&gt;
&lt;P&gt;'do work&lt;/P&gt;
&lt;P&gt;next&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 23:13:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/pipe-sweep-and-workpoints/m-p/8497033#M92830</guid>
      <dc:creator>JamieVJohnson2</dc:creator>
      <dc:date>2019-01-02T23:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Pipe (sweep) and workpoints</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/pipe-sweep-and-workpoints/m-p/8497468#M92839</link>
      <description>&lt;P&gt;Hello Clutsa,&lt;/P&gt;
&lt;P&gt;thanks for your solution, axactly&amp;nbsp;what i wanted!&lt;/P&gt;
&lt;P&gt;Regards from Germany...&lt;/P&gt;
&lt;P&gt;Martin&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jan 2019 07:13:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/pipe-sweep-and-workpoints/m-p/8497468#M92839</guid>
      <dc:creator>martinhoos</dc:creator>
      <dc:date>2019-01-03T07:13:12Z</dc:date>
    </item>
  </channel>
</rss>

