iCAx开思工具箱

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 25165|回复: 6
打印 上一主题 下一主题

偏置操作后,如何保留原始曲线

[复制链接]
跳转到指定楼层
楼主
发表于 2009-10-17 23:09:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

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
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 支持支持
沙发
发表于 2009-10-23 07:59:13 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
板凳
发表于 2009-10-24 15:00:58 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
地板
发表于 2009-10-29 13:59:57 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
5
 楼主| 发表于 2009-10-29 17:05:47 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
6
 楼主| 发表于 2009-10-29 17:10:46 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
7
发表于 2009-10-29 17:26:44 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手板模型制作,在线3D打印服务

QQ|小黑屋|手机版|开思工具箱 CAD工具箱_CAM工具箱  

GMT+8, 2024-12-1 03:25 , Processed in 0.021672 second(s), 8 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表