Twullf
Mechanical
- Jan 24, 2012
- 196
I have written a program which uses a datum to place two intersection curves and measures the distance between these curves. Using an expression the datum is moved along a central spline and measurements taken each time. These numbers are put in a csv file to be perused later. As the program runs it get visibly slower and slower, mind you it moves 300+ times but I don't understand the slow down.
I have gone through the code and made sure the builders are destroyed when I am done with them. So I wonder if it is the update process or the fact that the csv file being created is at size 0 until the program completes and closes the file.
Ultimately the program never goes so slow that it is a detriment unless someone requires a massive number of checks, but I wish to improve my skills and am not sure if this a fault of sloppy programming or something inherent in UG.
Any help would be appreciated.
Here is the loop in the code I can post the subs if anyone thinks they may be necessary.
I have gone through the code and made sure the builders are destroyed when I am done with them. So I wonder if it is the update process or the fact that the csv file being created is at size 0 until the program completes and closes the file.
Ultimately the program never goes so slow that it is a detriment unless someone requires a massive number of checks, but I wish to improve my skills and am not sure if this a fault of sloppy programming or something inherent in UG.
Any help would be appreciated.
Here is the loop in the code I can post the subs if anyone thinks they may be necessary.
Code:
While( boolMoldSurface = True )
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Take Measurements")
strStation = Convert.ToString(intStation)
'Measure length of intersectionCurve on MoldSurface
MeasureLineLength( moldInterLine, strMoldLength, boolLength, unitMM )
'Measure minimum distance from moldInterLine to LoftInterLine
MeasureMinDistance( moldInterLine, loftInterLine, strMinDistance,unitMM )
'Measure minimum distance from moldInterLine startpoint to LoftInterLine
Dim moldCurves() As NXObject = moldInterLine.GetEntities()
scrMoldStart = workPart.Scalars.CreateScalar( 0.0, Scalar.DimensionalityType.None, _
SmartObject.UpdateOption.AfterModeling )
ptMoldStart = workPart.Points.CreatePoint( MoldCurves(0), scrMoldStart, _
SmartObject.UpdateOption.AFterModeling )
MeasureMinPtDistance( loftInterLine, ptMoldStart, strStrtpt )
'Measure minimum distance from moldInterLine endpoint to LoftInterLine
scrMoldEnd = workPart.Scalars.CreateScalar( 1.0, Scalar.DimensionalityType.None, _
SmartObject.UpdateOption.AfterModeling )
ptMoldEnd = workPart.Points.CreatePoint( MoldCurves(0), scrMoldEnd, _
SmartObject.UpdateOption.AFterModeling )
MeasureMinPtDistance( loftInterLine, ptMoldEnd, strEndpt )
'Write in file ("Station", "length", "Minimum", "startpoint", "endpoint\n")
wrtData.Write( strStation & "," & strMoldLength & "," & strMinDistance & "," & _
strStrtPt & "," & strEndPt & Environment.NewLine )
boolMoldSurface = True
Try
'Move Datum
intStation = intStation + intInterval
expDatum.RightHandSide = intStation
theSession.UpdateManager.DoUpdate(markId3)
Catch
boolMoldSurface = False
End Try
End While