|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
代码如下: 这是从NX中录制的,我稍稍做了改动,其中InputCurve()为Curve类型的数组,是原始输入曲线。这段代码运行后,输入曲线可以偏置10毫米,但是原始曲线也消失了
Public Sub TheOffsetCurveSub(ByVal inputCurve() As NXOpen.Curve, ByRef TagIndex As Integer, ByVal LinkTolerance As Double)
Dim workPart As Part = Sess.Parts.Work
Dim markId1 As Session.UndoMarkId
markId1 = Sess.SetUndoMark(Session.MarkVisibility.Visible, "Start")
Dim nullFeatures_Feature As Features.Feature = Nothing
If Not workPart.Preferences.Modeling.GetHistoryMode Then
Throw (New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free
Mode."))
End If
Dim OffsetCurveBuilder1 As Features.OffsetCurveBuilder
OffsetCurveBuilder1 = workPart.Features.CreateOffsetCurveBuilder(nullFeatures_Feature)
OffsetCurveBuilder1.Tolerance = 0.0254
OffsetCurveBuilder1.OffsetDistance.RightHandSide = "10"
OffsetCurveBuilder1.DraftHeight.RightHandSide = "5"
OffsetCurveBuilder1.DraftAngle.RightHandSide = "0"
OffsetCurveBuilder1.LawControl.Value.RightHandSide = "5"
OffsetCurveBuilder1.LawControl.StartValue.RightHandSide = "5"
OffsetCurveBuilder1.LawControl.EndValue.RightHandSide = "5"
OffsetCurveBuilder1.Offset3dDistance.RightHandSide = "5"
OffsetCurveBuilder1.InputCurvesOptions.InputCurveOption = GeometricUtilities.CurveOptions.InputCurve.Retain
OffsetCurveBuilder1.TrimMethod = Features.OffsetCurveBuilder.TrimOption.ExtendTangents
OffsetCurveBuilder1.ExtendFactor = 12.0
OffsetCurveBuilder1.LawControl.AlongSpineData.SetFeatureSpine(OffsetCurveBuilder1.CurvesToOffset)
OffsetCurveBuilder1.CurvesToOffset.DistanceTolerance = 0.0254
OffsetCurveBuilder1.CurvesToOffset.ChainingTolerance = 0.02413
OffsetCurveBuilder1.LawControl.AlongSpineData.Spine.DistanceTolerance = 0.0254
OffsetCurveBuilder1.LawControl.AlongSpineData.Spine.ChainingTolerance = 0.02413
OffsetCurveBuilder1.LawControl.LawCurve.DistanceTolerance = 0.0254
OffsetCurveBuilder1.LawControl.LawCurve.ChainingTolerance = 0.02413
OffsetCurveBuilder1.InputCurvesOptions.InputCurveOption = GeometricUtilities.CurveOptions.InputCurve.Retain
OffsetCurveBuilder1.InputCurvesOptions.Associative = False
OffsetCurveBuilder1.NumberOfCopies = 1
Dim markId2 As Session.UndoMarkId
markId2 = Sess.SetUndoMark(Session.MarkVisibility.Visible, "section mark")
Dim markId3 As Session.UndoMarkId
markId3 = Sess.SetUndoMark(Session.MarkVisibility.Visible, Nothing)
Dim curveDumbRule1 As CurveDumbRule
curveDumbRule1 = workPart.ScRuleFactory.CreateRuleCurveDumb(InputCurve)
OffsetCurveBuilder1.CurvesToOffset.AllowSelfIntersection(False)
Dim rules1(0) As SelectionIntentRule
rules1(0) = curveDumbRule1
Dim nullNXObject As NXObject = Nothing
Dim helpPoint1 As Point3d = New Point3d(0.0, 0.0, 0.0)
OffsetCurveBuilder1.CurvesToOffset.AddToSection(rules1, nullNXObject, nullNXObject, nullNXObject, helpPoint1,
NXOpen.Section.Mode.Create, True)
Sess.DeleteUndoMark(markId3, Nothing)
Dim markId4 As Session.UndoMarkId
markId4 = Sess.SetUndoMark(Session.MarkVisibility.Invisible, "Update Law Data")
Sess.DeleteUndoMarksUpToMark(markId4, "Update Law Data", False)
Sess.DeleteUndoMark(markId2, Nothing)
Dim markId5 As Session.UndoMarkId
markId5 = Sess.SetUndoMark(Session.MarkVisibility.Invisible, "Offset Curve")
Dim nXObject1 As NXObject
nXObject1 = OffsetCurveBuilder1.Commit
Dim objects1() As NXObject
objects1 = OffsetCurveBuilder1.GetCommittedObjects()
Sess.DeleteUndoMark(markId5, Nothing)
Sess.SetUndoMarkName(markId1, "Offset Curve")
End Sub |
|