Showing results for 
Search instead for 
Did you mean: 

NX7 Offset Curve Builder


Hello, I am attempting to update some older NX Open dll's originally written and built for NX 7. As a part of this, I'm trying to create an OffsetCurve() function. I've done a manually recording multiple times to try and manipulate it into a useable function but I still recieve "Internal error: memory access violation" errors anytime I try to run it. Below you will find my current version of the function. Does anyone have any tips on how to fix this or coding in NX 7 in general? I'm also fighting an issue with the BridgeCurveBuilder as well regarding which direction the curves are supposed to be bridged on. Thanks for any help.


Function offsetCurve(ByVal crv As CurveByVal reverse As BooleanByVal name As StringByVal dist As DoubleAs Curve
        Dim offsetCurveBuilder1 As Features.OffsetCurveBuilder = wrkPrt.Features.CreateOffsetCurveBuilder(Nothing)
        offsetCurveBuilder1.Tolerance = 0.0002
        offsetCurveBuilder1.Type = Features.OffsetCurveBuilder.Types.Distance
        offsetCurveBuilder1.OffsetDistance.RightHandSide = dist
        offsetCurveBuilder1.InputCurvesOptions.InputCurveOption = GeometricUtilities.CurveOptions.InputCurve.Retain
        offsetCurveBuilder1.CurvesToOffset.DistanceTolerance = 0.0002
        offsetCurveBuilder1.CurvesToOffset.ChainingTolerance = 0.00019
        offsetCurveBuilder1.LawControl.AlongSpineData.Spine.DistanceTolerance = 0.0002
        offsetCurveBuilder1.LawControl.AlongSpineData.Spine.ChainingTolerance = 0.00019
        offsetCurveBuilder1.LawControl.LawCurve.DistanceTolerance = 0.0002
        offsetCurveBuilder1.LawControl.LawCurve.ChainingTolerance = 0.00019
        Dim curves1(0) As Curve
        Dim spline1 As Spline = crv
        curves1(0) = spline1
        Dim curveDumbRule1 As CurveDumbRule
        curveDumbRule1 = wrkPrt.ScRuleFactory.CreateRuleCurveDumb(curves1)
        Dim rules1(0) As SelectionIntentRule
        rules1(0) = curveDumbRule1
        Dim helpPoint1 As Point3d = New Point3d(0, 0, 0)
        offsetCurveBuilder1.CurvesToOffset.AddToSection(rules1, spline1, NothingNothing, helpPoint1, Section.Mode.Create, False)
        offsetCurveBuilder1.ReverseDirection = reverse
        Dim nXObject1 As NXObject = offsetCurveBuilder1.Commit()
        Dim objects1() As NXObject = offsetCurveBuilder1.GetCommittedObjects()
        Dim offsetFeature As Feature = offsetCurveBuilder1.CommitFeature
        Dim section1 As Section = wrkPrt.Sections.CreateSection(0.000095, 0.0001, 0.125)
        Return offsetFeature.GetEntities(0)
    End Function
DHuskic Nx 9

Re: NX7 Offset Curve Builder


Your offset curve function as is will only work in the very special case when the curve to be offset is a spline.

If you change the following lines to not use a spline to


Dim curves1(0) As Curve

' Dim spline1 As Spline = crv

curves1(0) = crv




Dim helpPoint1 As Point3d = New Point3d(0, 0, 0)

offsetCurveBuilder1.CurvesToOffset.AddToSection(rules1, crv, Nothing, Nothing, helpPoint1, Section.Mode.Create, False)


should work.


Just another point using 0,0,0 as your help point does not always give the expected results.  When using a help point it should be located on or near the start end of the curve.  This is probably why you may be having a problem with the bridging curve.


Frank Swinkels