找回密码 注册 QQ登录
一站式解决方案

iCAx开思网

CAD/CAM/CAE/设计/模具 高清视频【积分说明】如何快速获得积分?快速3D打印 手板模型CNC加工服务在线3D打印服务,上传模型,自动报价
查看: 19126|回复: 6
打印 上一主题 下一主题

[求助] 偏置操作后,如何保留原始曲线

[复制链接]
跳转到指定楼层
1
发表于 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空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 赞一下!赞一下!
2
发表于 2009-10-23 07:59:13 | 只看该作者
我来顶一下…………
3
发表于 2009-10-24 15:00:58 | 只看该作者
应该有个参数设置是否保留原有曲线的 找找
4
发表于 2009-10-29 13:59:57 | 只看该作者
NXOpen的朋友,不错

可不可以先拷贝曲线
5
发表于 2009-10-29 17:05:47 | 只看该作者
是啊,我就是这样做的,不过不应该这样啊。
6
发表于 2009-10-29 17:10:46 | 只看该作者
begtostudy 发表于 2009-10-29 13:59
NXOpen的朋友,不错

可不可以先拷贝曲线


高手啊,我关注你的博客已经很久了
7
发表于 2009-10-29 17:26:44 | 只看该作者
zhangcanwei 发表于 2009-10-29 17:10


高手啊,我关注你的博客已经很久了


真是惭愧,其实UG二次开发我也是外行,没发过几个帖子
而且还没有实际的工程经验,凭空瞎想的……
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3D打印手板模型快速制作服务,在线报价下单!

QQ 咨询|手机版|联系我们|iCAx开思网  

GMT+8, 2024-12-26 14:48 , Processed in 0.027209 second(s), 10 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

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