Submitted by quicova@gmail.com on Wed, 01/31/2018 - 02:55
Forums:
Hello everyone.
Got a challenge that maybe someone can help me.
I need to create a Datum plane on a Curve at al specified point on the curve.
The datum has to be normal to the curve and Orientation on Curve Parallel to X-axis.
I recorded a journal but OMG is massive for just one feature.
I'm working on it today, if I manage I will post here.
Thanks Kico
Well got it working, there
Well got it working, there are some parts that are straight from the journal and I don't know what they do, but if I take them out it crashes.
hate when this happens.
here is the code I used as a function, so I can use it in a loop.
'''' add point where datum has to go '''''
Dim pointCoord As New Point3d
pointCoord.X = FileDic(key)(0) * 1000
pointCoord.Y = FileDic(key)(1) * 1000
pointCoord.Z = FileDic(key)(2) * 1000
'''' now create the real point and display it in nx
Dim realPoint As Point
realPoint = workPart.Points.CreatePoint(pointCoord)
realPoint.SetVisibility(SmartObject.VisibilityOption.Visible)
''''' create the datum builder '''''
Dim nullNXOpen_Features_Feature As NXOpen.Features.Feature = Nothing
Dim datumPlaneBuilder As NXOpen.Features.DatumPlaneBuilder
datumPlaneBuilder = workPart.Features.CreateDatumPlaneBuilder(nullNXOpen_Features_Feature)
Dim plane As NXOpen.Plane
plane = datumPlaneBuilder.GetPlane()
plane.SetUpdateOption(NXOpen.SmartObject.UpdateOption.WithinModeling)
'''' plane vectore orientation in X ''''
Dim origin As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
Dim vector As NXOpen.Vector3d = New NXOpen.Vector3d(1.0, 0.0, 0.0)
Dim direction As NXOpen.Direction
direction = workPart.Directions.CreateDirection(origin, vector, NXOpen.SmartObject.UpdateOption.WithinModeling)
''''' coordinates where plane is to start ''''
Dim coordinates As NXOpen.Point3d = New NXOpen.Point3d(pointCoord.X, pointCoord.Y, pointCoord.Z)
Dim point As NXOpen.Point
point = workPart.Points.CreatePoint(coordinates)
plane.SetMethod(NXOpen.PlaneTypes.MethodType.Frenet)
'''' tell which is the curve to use ''''
Dim section As NXOpen.Section
section = workPart.Sections.CreateSection(0.0095, 0.01, 0.5) '''' dont know what this is, from recorded journal
'''' uses the fitcurve returned from CreateLEcurve function ''''
Dim curves(0) As NXOpen.IBaseCurve
Dim fitCurve As NXOpen.Features.FitCurve = curve
Dim spline As NXOpen.Spline = CType(fitCurve.FindObject("CURVE 1"), NXOpen.Spline)
curves(0) = spline
'''' rules, DON'T KNOW WHY THIS WORKS, FROM JOURNAL '''''
Dim curveDumbRule As NXOpen.CurveDumbRule
curveDumbRule = workPart.ScRuleFactory.CreateRuleBaseCurveDumb(curves)
Dim rules(0) As NXOpen.SelectionIntentRule
rules(0) = curveDumbRule
''''' add the Leading edge curve to the section '''''
Dim nullNXOpen_NXObject As NXOpen.NXObject = Nothing
Dim helpPoint As NXOpen.Point3d = New NXOpen.Point3d(pointCoord.X, pointCoord.Y, pointCoord.Z)
section.AddToSection(rules, spline, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint, NXOpen.Section.Mode.Create, False)
'''' add curve, point and direction to datum feacture'''''
Dim geometry(2) As NXOpen.NXObject
geometry(0) = section
geometry(1) = point
geometry(2) = direction
plane.SetGeometry(geometry)
plane.SetFrenetSubtype(NXOpen.PlaneTypes.FrenetSubtype.ThruPointParallelToVector)
plane.SetPercent(False)
plane.SetAlternate(NXOpen.PlaneTypes.AlternateType.One)
plane.Evaluate()
Dim datumfeature As NXOpen.Features.Feature
datumfeature = datumPlaneBuilder.CommitFeature()
datumPlaneBuilder.Destroy()