NutAce
Mechanical
- Apr 22, 2010
- 1,192
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
Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2
Building new PLM environment from Scratch using NX11 / TC11
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:
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)
[b] theSession.ActiveSketch.AddGeometry(p, Sketch.InferConstraintsOption.InferNoConstraints)
theSession.ActiveSketch.Update()[/b]
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