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!

Do/While statements not working in Modeling

Status
Not open for further replies.

Twullf

Mechanical
Jan 24, 2012
196
X-posted to GTAC Support Forums.

I have an automation I use very frequently. I have made no changes to it and have not updated NX, currently version 7.5. However now suddenly the program just cycles away and never achieves anything. I have managed to narrow down where the code is failing. This is a while statement I haven't changed since the first iteration of the program.

Code:
   While Not line is Nothing
         If Len( Trim( line )) > 0 then
            Try
               strings = line.Split( vbTab )
               pt1.x = Double.Parse( strings(0) )
               pt1.y = Double.Parse( strings(1) )
               pt1.z = Double.Parse( strings(2) )
            Catch
               MessageBox.Show( "Spline data file " & strFile & " must be tab deliminted," & _
                  " and located in " & strDir, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error )
               Exit Sub
            End Try

            '------------------------------------------------------------------------------------------
            '   Create an array of points, each array value containing a single point
            '------------------------------------------------------------------------------------------

            ReDim Preserve ArrayofPoints( count )
            ArrayOfPoints( count ) = workPart.Points.createPoint(pt1)

            '------------------------------------------------------------------------------------------
            '   Increase count value by 1, Read the next line of the file and continue While statement
            '------------------------------------------------------------------------------------------

            count = count + 1
            line = sr.ReadLine()
         End If
      End While
I have no idea why this is suddenly a problem, any help would be greatly appreciated.

UPDATE: I have tried multiple different Do / While Loops all of them just continue to run without ever accomplishing anything. While in Modeling this is a problem.

However things seem to work just fine if run in Drafting.
 
Replies continue below

Recommended for you

And what was the solution?

"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli
 
The readline is inside the If check. So when it ran across a blank line it never read the next line of the file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor