Have you ever wanted to export all work points in a part file out to CSV or TXT file? Well look no further!

This is some pretty old code that I have had kicking about for some years, the reason I had not released it until now, is that it contained a small bug, which I finally got around to fixing.

The iLogic code works as follows:

Find Existing CSV file, if it exists, delete it

Iterate through the model and find all work points and their coordinates

Write work point names and coordinates to CSV file (of same name as part file)

Here is a quick GIF showing the code in action:

Here is the iLogic code to export to CSV:

'Original Code by @ClintBrown3D 'Posted at https://clintbrown.co.uk/export-points-To-csv-With-ilogic On Error GoTo ClintBrown3D ' Check if old csv exists and delete it if it does oNaam = ThisDoc.PathAndFileName(False)'Get file Names If System.IO.File.Exists(oNaam + ".csv") Then oDeleteFile = ThisDoc.PathAndFileName(False) & ".csv" My.Computer.FileSystem.DeleteFile(oDeleteFile) End If 'Iterate through Model and gather Work Point co-ordinates Dim oDoc As PartDocument oDoc = ThisDoc.Document Dim oWP As WorkPoint oWP = oDoc.ComponentDefinition.WorkPoints(1) i = ClintBrown + 1 oWP.Name = i For Each oWP In ThisDoc.Document.ComponentDefinition.WorkPoints oPart = ThisApplication.ActiveDocument ClintBrown3D = oWP 'Write work point info to CSV file Dim oAppend As System.IO.StreamWriter oFile = ThisDoc.PathAndFileName(False) & ".csv" oAppend = IO.File.AppendText(oFile) oAppend.WriteLine((oWP.Name & "," & (ClintBrown3D.Point.X*10))& "," & (ClintBrown3D.Point.Y*10)& "," &(ClintBrown3D.Point.Z*10)) oAppend.Flush() oAppend.Close() Next 'Open the CSV file i = MessageBox.Show("Open the CSV?", "@ClintBrown3D",MessageBoxButtons.YesNo) If i = vbYes Then : ThisDoc.Launch(ThisDoc.PathAndFileName(False) & ".csv") : Else : Return : End If Return ClintBrown3D : MessageBox.Show("This rule must be run from a part file", "@ClintBrown3D")

This is what the TXT code looks like, it is practically identical to the CSV code, but with the file extensions changed from CSV to TXT

Here is the iLogic code to export to TXT :

'Original Code by @ClintBrown3D 'Posted at https://clintbrown.co.uk/export-points-To-csv-With-ilogic On Error GoTo ClintBrown3D ' Check if old csv exists and delete it if it does oNaam = ThisDoc.PathAndFileName(False)'Get file Names If System.IO.File.Exists(oNaam + ".txt") Then oDeleteFile = ThisDoc.PathAndFileName(False) & ".txt" My.Computer.FileSystem.DeleteFile(oDeleteFile) End If 'Iterate through Model and gather Work Point co-ordinates Dim oDoc As PartDocument oDoc = ThisDoc.Document Dim oWP As WorkPoint oWP = oDoc.ComponentDefinition.WorkPoints(1) i = ClintBrown + 1 oWP.Name = i For Each oWP In ThisDoc.Document.ComponentDefinition.WorkPoints oPart = ThisApplication.ActiveDocument ClintBrown3D = oWP 'Write work point info to TXT file Dim oAppend As System.IO.StreamWriter oFile = ThisDoc.PathAndFileName(False) & ".txt" oAppend = IO.File.AppendText(oFile) oAppend.WriteLine((oWP.Name & "," & (ClintBrown3D.Point.X*10))& "," & (ClintBrown3D.Point.Y*10)& "," &(ClintBrown3D.Point.Z*10)) oAppend.Flush() oAppend.Close() Next 'Open the TXT file i = MessageBox.Show("Open the TXT?", "@ClintBrown3D",MessageBoxButtons.YesNo) If i = vbYes Then : ThisDoc.Launch(ThisDoc.PathAndFileName(False) & ".txt") : Else : Return : End If Return ClintBrown3D : MessageBox.Show("This rule must be run from a part file", "@ClintBrown3D")

Notes:

This version of the code was briefly tested with Inventor 2020.1.

Please note that I cannot offer any additional support, this blog post is offered as-is, and is aimed at the more advanced user.

As always, please test all iLogic code extensively on non-production files. Do not use any code in a production environment until YOU have thoroughly tested it and have verified that it works as expected. Always back up any data before running any experimental code. You are ultimately responsible for any iLogic code that you run, so make sure you test it thoroughly!