Adding points from textfile in sketch: journal
Adding points from textfile in sketch: journal
(OP)
Hello guys...
I'm trying to addapt the file2points vb (from sample nxopen) to work inside a sketch.
I changed 2 lines (originals commented out) in below vb but I get an tag not allowed error
I'm trying to addapt the file2points vb (from sample nxopen) to work inside a sketch.
I changed 2 lines (originals commented out) in below vb but I get an tag not allowed error
CODE --> VB
Imports System
Imports System.IO
Imports System.Windows.Forms
Imports NXOpen
Module Test
Sub Main
Try
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 1
openFileDialog1.RestoreDirectory = True
If openFileDialog1.ShowDialog() = DialogResult.OK Then
Dim theSession As Session = Session.GetSession()
Dim sr As StreamReader = new StreamReader(openFileDialog1.FileName)
Dim line As String
Try
line = sr.ReadLine()
While Not line is Nothing
Dim pt As Point3d
Dim delim As Char () = { ","C }
Dim strings As String () = line.Split(delim)
pt.x = Double.Parse(strings(0))
pt.y = Double.Parse(strings(1))
pt.z = Double.Parse(strings(2))
Dim p As Point
'p = session.Parts.Work.Points.CreatePoint(pt)
'p.SetVisibility(SmartObject.VisibilityOption.Visible)
theSession.ActiveSketch.AddGeometry(p, Sketch.InferConstraintsOption.InferNoConstraints)
theSession.ActiveSketch.Update()
line = sr.ReadLine()
End While
Finally
sr.Close()
End Try
End If
Catch E As Exception
MessageBox.Show(E.Message)
End Try
End Sub
End Module Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2
Building new PLM environment from Scratch using NX11 / TC11





RE: Adding points from textfile in sketch: journal
CODE
Imports System Imports System.IO Imports System.Windows.Forms Imports NXOpen Module Test Sub Main Try Dim openFileDialog1 As New OpenFileDialog() openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" openFileDialog1.FilterIndex = 1 openFileDialog1.RestoreDirectory = True If openFileDialog1.ShowDialog() = DialogResult.OK Then Dim theSession As Session = Session.GetSession() Dim sr As StreamReader = new StreamReader(openFileDialog1.FileName) Dim line As String Try line = sr.ReadLine() While Not line is Nothing Dim pt As Point3d Dim delim As Char () = { ","c } Dim strings As String () = line.Split(delim) pt.x = Double.Parse(strings(0)) pt.y = Double.Parse(strings(1)) pt.z = Double.Parse(strings(2)) Dim p As Point p = theSession.Parts.Work.Points.CreatePoint(pt) theSession.ActiveSketch.AddGeometry(p, Sketch.InferConstraintsOption.InferNoConstraints) theSession.ActiveSketch.Update() line = sr.ReadLine() End While Finally sr.Close() End Try End If Catch E As Exception MessageBox.Show(E.Message) End Try End Sub End Modulewww.nxjournaling.com
RE: Adding points from textfile in sketch: journal
Thanks, that worked..
I see I shouldn't have removed the declaration of p
Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2
Building new PLM environment from Scratch using NX11 / TC11
RE: Adding points from textfile in sketch: journal
www.nxjournaling.com
RE: Adding points from textfile in sketch: journal
Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2
Building new PLM environment from Scratch using NX11 / TC11