找回密码 注册 QQ登录
开思网工业级高精度在线3D打印服务

iCAx开思网

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

请教vb.net下UG二次开发:拉伸特征方位变换(有源码)

[复制链接]
跳转到指定楼层
1
发表于 2007-3-27 14:09:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多同行朋友,交流,分享,学习。

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

x
总是变换不成功,弹出错误对话框,

请高人指点,多谢!!!



' NX 4.0.0.25
' Journal created by nmgf on Tue Mar 27 11:12:31 2007 中国标准时间
'
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module UGTransformTest
    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work

        Dim displayPart As Part = theSession.Parts.Display

        ' ----------------------------------------------
        '  菜单: 插入->曲线->Basic Curves...
        ' ----------------------------------------------
        
        Dim startPoint1 As Point3d = New Point3d(-30, 30, 0.0)
        Dim endPoint1 As Point3d = New Point3d(60, 30, 0.0)
        Dim line1 As Line
        line1 = workPart.Curves.CreateLine(startPoint1, endPoint1)

        
        Dim startPoint2 As Point3d = New Point3d(60, 30, 0.0)
        Dim endPoint2 As Point3d = New Point3d(60, -30, 0.0)
        Dim line2 As Line
        line2 = workPart.Curves.CreateLine(startPoint2, endPoint2)

        
        Dim startPoint3 As Point3d = New Point3d(60, -30, 0.0)
        Dim endPoint3 As Point3d = New Point3d(-30, -30, 0.0)
        Dim line3 As Line
        line3 = workPart.Curves.CreateLine(startPoint3, endPoint3)

     

        Dim startPoint4 As Point3d = New Point3d(-30, -30, 0.0)
        Dim endPoint4 As Point3d = New Point3d(-30, 30, 0.0)
        Dim line4 As Line
        line4 = workPart.Curves.CreateLine(startPoint4, endPoint4)

        

        ' ----------------------------------------------
        '  菜单: 插入->Design Feature->拉伸...
        ' ----------------------------------------------
        

        Dim section1 As Section
        section1 = workPart.Sections.CreateSection(0.02413, 0.0254, 0.5)

        Dim nullFeatures_Feature As Features.Feature = Nothing

        Dim extrudeBuilder1 As Features.ExtrudeBuilder
        extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(nullFeatures_Feature)

        extrudeBuilder1.Section = section1

        Dim limits1 As GeometricUtilities.Limits
        limits1 = extrudeBuilder1.Limits

        Dim featureOptions1 As GeometricUtilities.FeatureOptions
        featureOptions1 = extrudeBuilder1.FeatureOptions

        Dim linearLimits1 As GeometricUtilities.LinearLimits = CType(limits1, GeometricUtilities.LinearLimits)

        Dim extend1 As GeometricUtilities.Extend
        extend1 = linearLimits1.StartExtend

        Dim extend2 As GeometricUtilities.Extend
        extend2 = linearLimits1.EndExtend

        Dim booleanOperation1 As GeometricUtilities.BooleanOperation
        booleanOperation1 = extrudeBuilder1.BooleanOperation

        Dim direction1 As Direction
        direction1 = extrudeBuilder1.Direction

        Dim featureOffset1 As GeometricUtilities.FeatureOffset
        featureOffset1 = extrudeBuilder1.Offset

        Dim simpleDraft1 As GeometricUtilities.SimpleDraft
        simpleDraft1 = extrudeBuilder1.Draft

        Dim featureOptions2 As GeometricUtilities.FeatureOptions
        featureOptions2 = extrudeBuilder1.FeatureOptions

        extend1.SetValue("0")

        extend2.SetValue("25")

        featureOffset1.SetStartOffset("0")

        featureOffset1.SetEndOffset("5")

        featureOffset1.OffsetType = GeometricUtilities.Type.NonsymmetricOffset

        simpleDraft1.SetDraftAngle("2")

        simpleDraft1.DraftType = GeometricUtilities.SimpleDraft.SimpleDraftType.SimpleFromStart


        Dim curves1(3) As Curve
        curves1(0) = line3
        curves1(1) = line2
        curves1(2) = line1
        curves1(3) = line4
        Dim curveDumbRule1 As CurveDumbRule
        curveDumbRule1 = workPart.ScRuleFactory.CreateRuleCurveDumb(curves1)

        section1.AllowSelfIntersection(False)

        Dim rules1(0) As SelectionIntentRule
        rules1(0) = curveDumbRule1
        Dim nullNXObject As NXObject = Nothing

        Dim helpPoint1 As Point3d = New Point3d(33.1834217214209, -32.8259757986841, 0.0)
        section1.AddToSection(rules1, line3, nullNXObject, nullNXObject, helpPoint1, Section.Mode.Create)


        Dim origin1 As Point3d = New Point3d(11.40625, -7.96875000000001, 0.0)
        Dim vector1 As Vector3d = New Vector3d(0.0, 0.0, 1.0)
        Dim direction2 As Direction
        direction2 = workPart.Directions.CreateDirection(origin1, vector1, SmartObject.UpdateOption.WithinModeling)

        extrudeBuilder1.Direction = direction2

      
        Dim feature1 As Features.Feature
        feature1 = extrudeBuilder1.CommitFeature()

        extrudeBuilder1.Destroy()

        ' ----------------------------------------------
        '  菜单: 工具->日记->停止
        ' ----------------------------------------------

        Dim fs() As Features.Feature = workPart.Features.ToArray

        Dim count As Integer = fs.GetLength(0)
        Dim i As Integer = 0

        Dim featureTag(count - 1) As Tag

        For Each f As Features.Feature In fs
            featureTag(i) = f.Tag
            i += 1

        Next
        
        Dim transMode As Integer = 2

        Dim csysTrans(1, 11) As Double

        csysTrans(0, 0) = 0
        csysTrans(0, 1) = 0
        csysTrans(0, 2) = 0

        csysTrans(0, 3) = 1
        csysTrans(0, 4) = 0
        csysTrans(0, 5) = 0
        csysTrans(0, 6) = 0
        csysTrans(0, 7) = 1
        csysTrans(0, 8) = 0
        csysTrans(0, 9) = 0
        csysTrans(0, 10) = 0
        csysTrans(0, 11) = 1



        csysTrans(1, 0) = 120
        csysTrans(1, 1) = 0
        csysTrans(1, 2) = 0


        csysTrans(1, 3) = 0
        csysTrans(1, 4) = 0
        csysTrans(1, 5) = 1
        csysTrans(1, 6) = 1
        csysTrans(1, 7) = 0
        csysTrans(1, 8) = 0
        csysTrans(1, 9) = 0
        csysTrans(1, 10) = 1
        csysTrans(1, 11) = 0

        Dim theUFSession As UFSession = UFSession.GetUFSession
        theUFSession.Modl.MoveFeature(featureTag, transMode, csysTrans)

        theUFSession.Modl.Update()
    End Sub
End Module
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 赞一下!赞一下!
2
发表于 2007-3-28 15:15:13 | 只看该作者

re:

(附源码)
我用block特征测试了一下,完全能够变换,没有出现任何错误
所以我认为可能是拉伸特征是从曲线拉伸的原因,因为拉伸体是曲线的子特征,所以应该变换那些曲线特征!
可是,如何得到那些曲线特征呢?我只能用CreateLine得到Line对象,有没有办法得到拉伸体的曲线特征呢 ?
多谢

请高人指点~~~~~~

对了,我用的是UG NX4, VB.NET




Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF



Module Transform

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim theUFSession As UFSession = UFSession.GetUFSession

        Dim workPart As Part = theSession.Parts.Work
        Dim displayPart As Part = theSession.Parts.Display


        Dim nullFeatures_Feature As Features.Feature = Nothing

        Dim blockFeatureBuilder1 As Features.BlockFeatureBuilder
        blockFeatureBuilder1 = workPart.Features.CreateBlockFeatureBuilder(nullFeatures_Feature)

        Dim basePoint1 As Point3d = New Point3d(0.0, 0.0, 0.0)

        blockFeatureBuilder1.SetOriginAndLengths(basePoint1, "100", "80", "10")

        Dim nullBody As Body = Nothing

        blockFeatureBuilder1.SetBooleanOperationAndTarget(Features.Feature.BooleanType.Create, nullBody)

        Dim feature1 As Features.Feature
        feature1 = blockFeatureBuilder1.CommitFeature()

        blockFeatureBuilder1.Destroy()



        Dim theBodies() As Body = workPart.Bodies.ToArray
        Dim theFeatures() As Features.Feature = theBodies(0).GetFeatures


        Dim bodyTag(0) As Tag
        bodyTag(0) = theFeatures(0).Tag



        Dim transMode As Integer = 2

        Dim csysTrans(1, 11) As Double

        csysTrans(0, 0) = 0
        csysTrans(0, 1) = 0
        csysTrans(0, 2) = 0

        csysTrans(0, 3) = 1
        csysTrans(0, 4) = 0
        csysTrans(0, 5) = 0
        csysTrans(0, 6) = 0
        csysTrans(0, 7) = 1
        csysTrans(0, 8) = 0
        csysTrans(0, 9) = 0
        csysTrans(0, 10) = 0
        csysTrans(0, 11) = 1



        csysTrans(1, 0) = 120
        csysTrans(1, 1) = 0
        csysTrans(1, 2) = 0


        csysTrans(1, 3) = 0
        csysTrans(1, 4) = 0
        csysTrans(1, 5) = 1
        csysTrans(1, 6) = 1
        csysTrans(1, 7) = 0
        csysTrans(1, 8) = 0
        csysTrans(1, 9) = 0
        csysTrans(1, 10) = 1
        csysTrans(1, 11) = 0

        theUFSession.Modl.MoveFeature(bodyTag, transMode, csysTrans)

        theUFSession.Modl.Update()
    End Sub

End Module
3
发表于 2007-3-31 13:07:04 | 只看该作者
提前~~,让高人看到~~
4
发表于 2007-4-13 10:48:55 | 只看该作者
高手都不来了吗?遗憾~~
5
发表于 2007-6-20 02:31:43 | 只看该作者
vb也可以做吗
可不可以告诉我要什么插件
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

GMT+8, 2024-12-31 06:19 , Processed in 0.029054 second(s), 11 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

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