If I understand correctly you want to get all work points relative to a UCS. And write the info to a csv file. In that case, try this iLogic rule. I changed the way the user needs to select the UCS. In my rule the user should select the UCS by clicking on it. In stead of selecting it from a list.
Sub Main()
Dim doc As PartDocument = ThisDoc.Document
Dim uom As UnitsOfMeasure = doc.UnitsOfMeasure
Dim workPoints = doc.ComponentDefinition.WorkPoints
Dim origin = workPoints.Item("Center Point")
Dim ucs As UserCoordinateSystem = ThisApplication.CommandManager.Pick(
SelectionFilterEnum.kUserCoordinateSystemFilter,
"Select an UserCoordinateSystem")
Dim translationVector = ucs.Origin.Point.VectorTo(origin.Point)
Dim csvFileInfo As New IO.FileInfo(ThisDoc.PathAndFileName(False) & ".csv")
If csvFileInfo.Exists Then
csvFileInfo.Delete()
End If
Using csvWriter As IO.StreamWriter = csvFileInfo.CreateText()
' This will make sure Excel will reconise the column seperator
csvWriter.WriteLine("sep=,")
csvWriter.WriteLine("Name,X,Y,Z")
For Each workPoint As WorkPoint In workPoints
If (WorkPoint.IsCoordinateSystemElement) Then Continue For
Dim p As Point = WorkPoint.Point
p.TranslateBy(translationVector)
Dim x As Double = ConvertToInch(uom, p.X)
Dim y As Double = ConvertToInch(uom, p.Y)
Dim z As Double = ConvertToInch(uom, p.Z)
csvWriter.WriteLine(string.Format("{0}, {1}, {2}, {3}",workPoint.Name,x,y,z))
Next
End Using
End Sub
Private Function ConvertToInch(uom As UnitsOfMeasure, value As Double) As Double
value = uom.ConvertUnits(value, UnitsTypeEnum.kDatabaseLengthUnits, UnitsTypeEnum.kInchLengthUnits)
Return Math.Round(value, 10)
End Function
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog: hjalte.nl - github.com