NGMatt
Aerospace
- Sep 11, 2013
- 21
I've searched high and low and maybe I skipped write over it but how can I create a vb journal to extract points (non-timestamp geometry) to a file with the point name? I'm talking about a point that has been renamed (i.e. Point "PNT1") in non-timestamp geometry. A couple of these come close but I haven't found one yet:
This code outputs points but no name.
Here is another thread but again no point name:
This code outputs points but no name.
Code:
'
' This journal should write the XYZ values of all points in the
' work part to a new .dat file.
'
' It will drop the ".prt" from the file name and append "_points.dat".
'
' As written, it separates the fields with a comma and a space,
' but you can easily change that.
'
' Also, note that the "F6" specifies that 6 digits will be shown to the
' right of the decimal, even if they are all zeroes.
' You can change that too, of course.
'
Option Strict Off
Imports System
Imports NXOpen
Module Points2File
Public s As Session = Session.GetSession()
Sub Main()
Dim workPart As Part = s.Parts.Work
Dim thePoints As PointCollection = workPart.Points
Dim wpName As String = workPart.FullPath.ToString()
Dim textFileName As String = Nothing
textFileName = wpName.Replace(".prt", "_points.dat")
Dim outFile As IO.StreamWriter
outFile = My.Computer.FileSystem.OpenTextFileWriter(textFileName, _
False)
outFile.AutoFlush = True
For Each thisPoint As Point In thePoints
outFile.WriteLine(thisPoint.Coordinates.X.ToString("F6") & ", " & _
thisPoint.Coordinates.Y.ToString("F6") & ", " & _
thisPoint.Coordinates.Z.ToString("F6"))
Next
outFile.Close()
MsgBox("Text File Name: " & textFileName, MsgBoxStyle.Information)
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
End Module
Here is another thread but again no point name: