×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Create a point with a name

Create a point with a name

Create a point with a name

(OP)
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.

RE: Create a point with a name

(OP)
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 &")"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources