×
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

Datums On Curve Through Point Sets
2

Datums On Curve Through Point Sets

Datums On Curve Through Point Sets

(OP)
Is there a way to create a point set on a curve and in one step create datums normal to the curve on all of the points in the set?

Thanks

RE: Datums On Curve Through Point Sets

No, but you should be able to do what you need with a macro or journal.

RE: Datums On Curve Through Point Sets

(OP)
Thanks, I'm not so hip on macroing or journaling, but I am sure if it is a necessity someone else at my work can do that.
 

RE: Datums On Curve Through Point Sets

2
Here is a journal which allows you to select a spline and then define the number of datum planes required to be placed on the spline.  The points for the datum origin are associative so that you can move the points along the spline to change the datum plane location/orientation.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.UF

Module datumPlanesonSpline
    Dim s As Session = Session.GetSession()
    Dim ui As UI = ui.GetUI()
    Dim ufs As UFSession = UFSession.GetUFSession()

    Sub Main()
        Dim mask(0) As Selection.MaskTriple
        mask(0).Type = UFConstants.UF_spline_type
        mask(0).Subtype = 0
        mask(0).SolidBodySubtype = 0

        Dim spline1 As Spline = Nothing
        Dim cursor As Point3d = Nothing

        Dim markId1 As Session.UndoMarkId
        markId1 = s.SetUndoMark(Session.MarkVisibility.Visible, "Start")

        ' Select a spline

        Dim resp As Selection.Response = _
     ui.SelectionManager.SelectObject("Datum Planes on Spline", "Select a Spline", _
         Selection.SelectionScope.AnyInAssembly, _
         Selection.SelectionAction.ClearAndEnableSpecific, _
         False, False, mask, spline1, cursor)

        ' Get the number of datum planes
        Dim no1 As Integer = NXInputBox.GetInputNumber("Enter Number of Datum Planes")

        ' Spline points and parameters
        Dim parm As Double = 0.0
        Dim delparm As Double = 1.0 / (no1 - 1)
        Dim pnt1(2) As Double
        Dim junk3(2) As Double
        Dim junk1 As Double
        ' Create Datum Planes
        For i As Integer = 0 To no1 - 1
            ufs.Modl.AskCurveProps(spline1.Tag, parm, pnt1, junk3, junk3, junk3, junk1, junk1)
            CreateDatumPlane(spline1, pnt1, parm)
            parm += delparm
        Next
    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function

    Public Sub CreateDatumPlane(ByVal spline1 As Spline, ByVal pnt1() As Double, ByVal parm1 As Double)
        Dim workPart As Part = s.Parts.Work
        Dim nullFeatures_Feature As Features.Feature = Nothing
        Dim pointFeatureBuilder1 As Features.PointFeatureBuilder
        pointFeatureBuilder1 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullFeatures_Feature)
        Dim datumPlaneBuilder1 As Features.DatumPlaneBuilder
        datumPlaneBuilder1 = workPart.Features.CreateDatumPlaneBuilder(nullFeatures_Feature)
        Dim plane1 As Plane
        plane1 = datumPlaneBuilder1.GetPlane()
        Dim scalar1 As Scalar
        scalar1 = workPart.Scalars.CreateScalar(parm1, Scalar.DimensionalityType.None, SmartObject.UpdateOption.WithinModeling)
        Dim point1 As Point
        point1 = workPart.Points.CreatePoint(spline1, scalar1, SmartObject.UpdateOption.WithinModeling)
        pointFeatureBuilder1.Point = point1
        Dim nXObject1 As NXObject
        nXObject1 = pointFeatureBuilder1.Commit()

        Dim direction1 As Direction
        direction1 = workPart.Directions.CreateDirection(spline1, scalar1, Direction.OnCurveOption.Tangent, Sense.Forward, SmartObject.UpdateOption.WithinModeling)
        plane1.SetMethod(PlaneTypes.MethodType.PointDir)

        Dim geom1(1) As NXObject
        geom1(0) = point1
        geom1(1) = direction1
        plane1.SetGeometry(geom1)

        Dim feature1 As Features.Feature
        feature1 = datumPlaneBuilder1.CommitFeature()

        Dim datumPlaneFeature1 As Features.DatumPlaneFeature = CType(feature1, Features.DatumPlaneFeature)

        Dim datumPlane1 As DatumPlane
        datumPlane1 = datumPlaneFeature1.DatumPlane

        datumPlaneBuilder1.Destroy()
        pointFeatureBuilder1.Destroy()

    End Sub

End Module

Hope this helps you.

Frank Swinkels  

RE: Datums On Curve Through Point Sets

(OP)
Sweet! Thanks!

RE: Datums On Curve Through Point Sets

FrankSwinks,

I am trying to adapt your code to my needs.  I have a program, placing a spline, putting points on the spline, then datums on the points normal to the spline.  I am up to the datum part, the program is selecting the existing point, preferably I'd like it to use the point "NAME" rather than the designation Point (1), but haven't figured that out yet, but right now I'm just trying to get the datum to place.

CODE

Sub PlaceDatum( ByRef counter as Integer )

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

        Dim displayPart As Part = theSession.Parts.Display

        Dim nullFeatures_Feature As Features.Feature = Nothing
        Dim pointFeatureBuilder1 As Features.PointFeatureBuilder
        pointFeatureBuilder1 = workPart.BaseFeatures.
         _CreatePointFeatureBuilder(nullFeatures_Feature)
        Dim datumPlaneBuilder1 As Features.DatumPlaneBuilder
        datumPlaneBuilder1 = workPart.Features.
         _CreateDatumPlaneBuilder(nullFeatures_Feature)
        Dim plane1 As Plane
        plane1 = datumPlaneBuilder1.GetPlane()

        Dim scalar1 As Scalar
        'dim counter as integer = 4


        Dim unit1 As Unit = CType(workPart.UnitCollection.
         _FindObject("MilliMeter"), Unit)


        Dim expression1 As Expression
        expression1 = workPart.Expressions.
         _CreateSystemExpressionWithUnits("0", unit1)
        scalar1 = workPart.Scalars.
         _CreateScalarExpression(expression1, Scalar.
         _DimensionalityType.None, SmartObject.UpdateOption.
         _WithinModeling)

        Dim curves1(0) As Curve
        Dim spline1 As Spline = CType(workPart.Splines.
         _FindObject("ENTITY 9 1 1"), Spline)

        curves1(0) = spline1


        Dim pointFeature1 As Features.PointFeature =
         _CType(workPart.Features.FindObject("POINT (2)" ),
         _Features.PointFeature)

        Dim point1 As Point = CType(pointFeature1.
         _FindObject("POINT 2" ), Point)

        Dim direction1 As Direction
        direction1 = workPart.Directions.
         _CreateDirection(spline1, scalar1, Direction.
         _OnCurveOption.Tangent, Sense.Forward,
         _SmartObject.UpdateOption.WithinModeling)
        plane1.SetMethod(PlaneTypes.MethodType.PointDir)


        Dim geom1(1) As NXObject
        geom1(0) = point1
        geom1(1) = direction1
        plane1.SetGeometry(geom1)

        Dim feature1 As Features.Feature
        feature1 = datumPlaneBuilder1.CommitFeature()

        Dim datumPlaneFeature1 As Features.DatumPlaneFeature =
         _CType(feature1, Features.DatumPlaneFeature)

        Dim datumPlane1 As DatumPlane
        datumPlane1 = datumPlaneFeature1.DatumPlane

        datumPlaneBuilder1.Destroy()
        pointFeatureBuilder1.Destroy()



End Sub

I get an error, for a No object found with this name on the following line:

datumPlane1 = datumPlaneFeature1.DatumPlane

  Any idea what I've done wrong?

RE: Datums On Curve Through Point Sets

Okay, the prgram works so long as the point being searched for is Point 1, even though I have 14 points in the current model, it will not find the other points.

Any one have any idea why?  To my mind the findObject command should find the object of the specified name and I am only changing the number.  I haven't started looking into how to get the program to find the named property of a point or datum or what have you.

RE: Datums On Curve Through Point Sets

I have changed the code so that we get all points and then check for the points that lie on the spline.  The datum creation sub needs to be a little different.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.UF

Module datumPlanesonSpline
    Dim s As Session = Session.GetSession()
    Dim ui As UI = ui.GetUI()
    Dim ufs As UFSession = UFSession.GetUFSession()

    Sub Main()
        Dim mask(0) As Selection.MaskTriple
        mask(0).Type = UFConstants.UF_spline_type
        mask(0).Subtype = 0
        mask(0).SolidBodySubtype = 0
        Dim dispPart As Part = s.Parts.Display
        Dim spline1 As Spline = Nothing
        Dim cursor As Point3d = Nothing

        Dim markId1 As Session.UndoMarkId
        markId1 = s.SetUndoMark(Session.MarkVisibility.Visible, "Start")

        ' Select a spline

        Dim resp As Selection.Response = _
     ui.SelectionManager.SelectObject("Datum Planes on Spline", "Select a Spline", _
         Selection.SelectionScope.AnyInAssembly, _
         Selection.SelectionAction.ClearAndEnableSpecific, _
         False, False, mask, spline1, cursor)

        Dim parm As Double = Nothing
        Dim pntdouble(2) As Double
        Dim pnt3d As Point3d
        Dim pnts1 As PointCollection = dispPart.Points
        Dim crvpnt(2) As Double
        Dim distance1 As Double = Nothing
        For Each pnt As Point In pnts1
            pnt3d = pnt.Coordinates
            pntdouble(0) = pnt3d.X
            pntdouble(1) = pnt3d.Y
            pntdouble(2) = pnt3d.Z
            ufs.Modl.AskCurveParm(spline1.Tag, pntdouble, parm, crvpnt)
            ' must check that points lie on curve
            ufs.Vec3.Distance(pntdouble, crvpnt, distance1)
            If distance1 > 0.001 Then Continue For
            CreateDatumPlane(spline1, pnt, parm)
        Next
        
    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function

    Public Sub CreateDatumPlane(ByVal spline1 As Spline, ByVal pnt1 As Point, ByVal parm1 As Double)
        Dim workPart As Part = s.Parts.Work
        Dim nullFeatures_Feature As Features.Feature = Nothing
        Dim pointFeatureBuilder1 As Features.PointFeatureBuilder
        pointFeatureBuilder1 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullFeatures_Feature)
        Dim datumPlaneBuilder1 As Features.DatumPlaneBuilder
        datumPlaneBuilder1 = workPart.Features.CreateDatumPlaneBuilder(nullFeatures_Feature)
        Dim plane1 As Plane
        plane1 = datumPlaneBuilder1.GetPlane()
        Dim scalar1 As Scalar
        scalar1 = workPart.Scalars.CreateScalar(parm1, Scalar.DimensionalityType.None, SmartObject.UpdateOption.WithinModeling)

        Dim direction1 As Direction
        direction1 = workPart.Directions.CreateDirection(spline1, scalar1, Direction.OnCurveOption.Tangent, Sense.Forward, SmartObject.UpdateOption.WithinModeling)
        plane1.SetMethod(PlaneTypes.MethodType.PointDir)

        Dim geom1(1) As NXObject
        geom1(0) = pnt1
        geom1(1) = direction1
        plane1.SetGeometry(geom1)

        Dim feature1 As Features.Feature
        feature1 = datumPlaneBuilder1.CommitFeature()

        datumPlaneBuilder1.Destroy()
        pointFeatureBuilder1.Destroy()

    End Sub

End Module

Regards

Frank Swinkels

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