Showing results for 
Search instead for 
Did you mean: 

Re: Thousands of tiny lines to a spline

Hello Yamada,


Thanks for the Program.


Is it possible to create the Feature points through this program?

I have noticed the program creates basic points.



Mathi K


Thanks and Regards,
Mathi Krishnan.

Re: Thousands of tiny lines to a spline

Siemens Phenom Siemens Phenom
Siemens Phenom

I'm curious to know why you want "Feature Points". I don't see any benefit to having the points associated with the lines, and writing thousands of points into the Part Navigator is going to slow things down.


But, anyway, it's easy to do. Here is the code. It uses a mixture of SNAP and NX/Open functions:


Option Infer On
Imports Snap, Snap.Create, Snap.UI.Selection

Module NXJournal

   Sub Main()

      ' Create a selection dialog
      Dim dialog = SelectObject("Select lines")

      ' Allow selection of multiple lines
      dialog.AllowMultiple = True

      ' Display the dialog and get a result
      Dim result = dialog.Show()

      ' Cycle through the lines, creating points
      For Each obj In result.Objects
         Dim line = CType(obj, Snap.NX.Line)

   End Sub

   Public Function CreatePointFeature(pos As Position) As NXOpen.Features.PointFeature

      Dim workPart = NXOpen.Session.GetSession.Parts.Work
      Dim builder = workPart.BaseFeatures.CreatePointFeatureBuilder(Nothing)
      Dim pt As NXOpen.Point = Snap.Create.Point(pos)
      builder.Point = pt
      Dim pointFeature As NXOpen.Features.PointFeature = builder.Commit
      Return pointFeature

   End Function

End Module



Re: Thousands of tiny lines to a spline

Hello Yamada,

Thanks.It works well.

Is it possible to maintain the parent child relation between the Line and points?

Mathi K

Thanks and Regards,
Mathi Krishnan.

Re: Thousands of tiny lines to a spline

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Here is code that will create a point feature associative to the given line's start point.


Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Point")

'change code to reference your line
Dim line1 As Line = [reference to your line object]

Dim scalar1 As Scalar
scalar1 = workPart.Scalars.CreateScalar(0.0, Scalar.DimensionalityType.None, SmartObject.UpdateOption.WithinModeling)

Dim point1 As Point
point1 = workPart.Points.CreatePoint(line1, scalar1, SmartObject.UpdateOption.WithinModeling)


Dim nullFeatures_Feature As Features.Feature = Nothing

Dim pointFeatureBuilder1 As Features.PointFeatureBuilder
pointFeatureBuilder1 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullFeatures_Feature)

pointFeatureBuilder1.Point = point1

Dim nXObject2 As NXObject
nXObject2 = pointFeatureBuilder1.Commit()




Re: Thousands of tiny lines to a spline

Valued Contributor
Valued Contributor

Dont forget about Smooth Curve String. Many selection options. It fills gaps. It is cool.