Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Create a point with a name

Status
Not open for further replies.

Twullf

Mechanical
Jan 24, 2012
196
I have code which successfully creates a point. I want to give that point a name so I can reference it later. At least that is the hope.

Code:
strExp1 = "p" & counter & "=0"

       expression1 = workPart.Expressions.CreateSystemExpressionWithUnits( strExp1, unit1 )
       scalar2 = workPart.Scalars.CreateScalarExpression(expression1, Scalar.DimensionalityType.None, SmartObject.UpdateOption.WithinModeling)
       point1 = workPart.Points.CreatePoint(spline1, scalar2, SmartObject.UpdateOption.WithinModeling)
       strExp2 = "E" & counter & "_arclen=S" & counter
       expression2 = workPart.Expressions.CreateSystemExpressionWithUnits( strExp2, unit1 )
       scalar1 = workPart.Scalars.CreateScalarExpression(expression2, Scalar.DimensionalityType.None, SmartObject.UpdateOption.WithinModeling)
       point2 = workPart.Points.CreatePoint(spline1, point1, scalar1, PointCollection.AlongCurveOption.Distance, Sense.Forward, SmartObject.UpdateOption.WithinModeling)


'-------------------------------------------------------------------
'   Naming beginning here.  requires feature.point feature which calls for previously "named" point, 
'-------------------------------------------------------------------
       Dim pointFeature1 As Features.PointFeature = CType(workPart.Features.FindObject("POINT(17)"), Features.PointFeature)
       pName = "Point S" & counter
       point2.SetName(pName)

I want to name it without telling the program to look for a previously named point. Reason is basically if a user puts a point or anything in the modeler before the program is run, it will increment the feature number and then the selection will no longer work. I want to ensure that the point and later features are named at the time of creation in order to ensure the program selects the correct feature when building from it.

I'm open to being told there is a better way to do the selection process for each subsequent feature.
 
Replies continue below

Recommended for you

Found a solution after destroying the builder put in the following code. This selects the last feature number, it does run into a problem if a feature has been destroyed, ultimately I'll need to find one that resets the count, by reordering features or something so that the last feature is the number of features, but this is at least a first step:

Code:
Dim featArray() As Feature = myFeats.ToArray()
      Dim lastFeatNum As Integer = featArray.GetUpperBound(0)
      Dim lastFeat As Feature = featArray(lastFeatNum)
      ufs.Modl.SetCurrentFeature(lastFeat.Tag())
      Dim oldPName As String
      'lastFeatNum = lastFeatNum + 1
      oldPname = "POINT(" & lastFeatNum &")"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor