iCAx开思工具箱

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 26309|回复: 2
打印 上一主题 下一主题

vb.net 导出 *x_t(Parasolid文件)

[复制链接]
跳转到指定楼层
楼主
发表于 2011-6-21 15:28:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
Option Strict Off
Imports System.IO
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UF.UFPs
Imports NXOpen.UF.UFAssem
Imports NXOpen.UF.UFModl
Imports NXOpen.UF.UFObj
Imports NXOpen.UF.UFPart
Imports NXOpen.UF.UFConstants

Module Module1
    Public body_list() As Tag
    '  Explicit Activation
    '      This entry point is used to activate the application explicitly
    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim theUI As UI = UI.GetUI()
        Dim theUfSession As UFSession = UFSession.GetUFSession()
        ' TODO: Add your application code here
        Dim displayPart As Part = theSession.Parts.Display
        MsgBox("1")

        'Dim prtname As String = "D:\1111111.prt"                    '部件文件名
        'Dim prtname As String = "F:\lashen.prt"
        'Dim expname As String = "F:\lashen.txt"                                 '表达式文件名
        Dim x_tname As String = "D:\aasse_pb.x_t"                              'ParaSolid文件名
        Dim part_tag As NXOpen.Tag = displayPart.Tag
        'Dim load_status As NXOpen.UF.UFPart.LoadStatus
        'Try
        '    theUfSession.Part.Open(prtname, part_tag, load_status)
        'Catch ex As Exception
        '    MsgBox(ex.ToString)
        'End Try
        'Try
        '    theUfSession.Modl.ImportExp(expname, 0)
        'Catch ex As Exception
        '    MsgBox(ex.ToString)
        'End Try
        Try
            theUfSession.Modl.Update()
        Catch ex As Exception
            ex.ToString()
        End Try
        Try
            theUfSession.Part.Save()
        Catch ex As Exception
            ex.ToString()
        End Try
        Dim root_part_occ As NXOpen.Tag
        root_part_occ = theUfSession.Assem.AskRootPartOcc(part_tag)
        theUfSession.Modl.CreateList(body_list)
        Try
            If root_part_occ = Tag.Null Then
                make_body_list_part(part_tag)
            Else
                Dim obj As NXOpen.Tag = theUfSession.Assem.AskPrototypeOfOcc(root_part_occ)
                make_body_list_assem(obj)
            End If
            theUfSession.Ps.ExportData(body_list, x_tname)
            theUfSession.Modl.DeleteBodyParms(body_list)
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Sub make_body_list_part(ByVal body_tag As Tag)
        Dim obj As NXOpen.Tag = Tag.Null
        Dim UF_body_type As Int32
        Dim type As Int32
        Dim subtype As Int32
        Do
            UFSession.GetUFSession().Obj.CycleObjsInPart(body_tag, UF_solid_type, obj)
            If obj <> Tag.Null Then
                UFSession.GetUFSession().Obj.AskTypeAndSubtype(obj, type, subtype)
                UFSession.GetUFSession().Modl.AskBodyType(obj, UF_body_type)
                If subtype <> UF_solid_body_subtype Then
                    Continue Do
                End If
                If UF_body_type = UF_MODL_SOLID_BODY Then
                    UFSession.GetUFSession().Modl.PutListItem(body_list, obj)
                    Exit Do
                End If
            End If
        Loop
    End Sub

    Sub make_body_list_assem(ByVal body_tag As Tag)
        Dim obj As Tag = Tag.Null
        Dim UF_body_type As Int32
        Dim type As Int32
        Dim subtype As Int32
        Do
            Dim UF_OBJ As UFObj = UFSession.GetUFSession().Obj
            UF_OBJ.CycleObjsInPart(body_tag, UF_solid_type, obj)
            If obj <> Tag.Null Then
                UF_OBJ.AskTypeAndSubtype(obj, type, subtype)
                Dim UF_MODL As UFModl = UFSession.GetUFSession().Modl
                UF_MODL.AskBodyType(obj, UF_body_type)
                If subtype <> UF_solid_body_subtype Then
                    Continue Do
                End If
                If UF_body_type = UF_MODL_SOLID_BODY Then
                    UF_MODL.PutListItem(body_list, obj)
                    Exit Do
                End If
             End If
        Loop
    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
        '----Other unload options-------
        'Unloads the image when the NX session terminates
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
        '-------------------------------
    End Function

End Module



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 支持支持
沙发
发表于 2012-2-19 22:14:46 | 只看该作者

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

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

x
板凳
发表于 2012-9-14 15:54:04 | 只看该作者

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

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

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

本版积分规则

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

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

GMT+8, 2024-5-20 23:32 , Processed in 0.013165 second(s), 8 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

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