Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IFRs on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

more journal help please

Status
Not open for further replies.

UGMENTALCASE

Aerospace
Oct 10, 2011
123
Hi all,

Just getting into these journals and there's a standard one that seems to come with NX. It's file to points. Now i've been playing with it but not sure if it's possible.

To use the file the text needs to be:

0,0,0
1,0,0
1,1,0
0,1,0

this creates the corners of a box, however you can't use decimal places. Is there a way to edit the attached code to do this? I have text files that read:

-273.811432 3097.611816 -268.873260
-273.508575 3096.599121 -268.920746
-273.245361 3095.709717 -268.902283
-272.955902 3094.736816 -268.915466
-272.670044 3093.780273 -268.955780

etc. Can this could be edited to suit this type of thing?

Thanks in advance.
 
Replies continue below

Recommended for you

The success of that particular journal will depend on the regional settings your computer uses. You should be able to check the regional settings somewhere in the control panel. Is your computer set to use something other than the decimal point (.) for the decimal symbol (a comma, perhaps)?

Try temporarily changing your regional settings to English(US) and run the journal again. If it works this time, we can modify the journal to accommodate your computer settings.

www.nxjournaling.com
 
Hi COWSKI, thanks for the advice. Just tried it on my laptop at home and it works fine. So it must be something to do with the settings on my PC at work.

Thanks for the advice
 
Try this version, it should run correctly regardless of your computer's regional settings.

Code:
Imports System
Imports System.IO
Imports System.Windows.Forms
Imports NXOpen

Module Test

    Sub Main
	
	Dim USculture As system.globalization.CultureInfo = New System.Globalization.CultureInfo("en-US")
        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 session 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), USculture)
                        pt.y = Double.Parse(strings(1), USculture)
                        pt.z = Double.Parse(strings(2), USculture)
                        Dim p As Point
                        p = session.Parts.Work.Points.CreatePoint(pt)
                        p.SetVisibility(SmartObject.VisibilityOption.Visible)
                        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

www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor