PLM之家精品课程培训,联系电话:18301858168 QQ: 939801026

  • NX二次开培训

    NX二次开培训

    适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术对于老鸟也值得借鉴!.

    NX CAM二次开发培训报名 NX二次开发基础培训报名
  • PLM之家Catia CAA二次开发培训

    Catia二次开发培训

    Catia二次开发的市场大,这方面开发人才少,难度大。所以只要你掌握了开发,那么潜力巨大,随着时间的积累,你必将有所用武之地!

  • PLM之Teamcenter最佳学习方案

    Teamcenter培训

    用户应用基础培训,管理员基础培训,管理员高级培训,二次开发培训应有尽有,只要你感兴趣肯学习,专业多年经验大师级打造!

  • PLM之Tecnomatix制造领域培训

    Tecnomatix培训

    想了解制造领域数字化吗?想了解工厂,生产线设计吗?数字化双胞胎,工业4.0吗?我们的课程虚位以待!

PLM之家PLMHome-国产软件践行者

[二次开发源码] NX二次开发源码分享: 加载所有的装配组件----全部加载

[复制链接]

2019-4-12 09:06:31 2131 0

admin 发表于 2019-4-12 09:06:31 |阅读模式

admin 楼主

2019-4-12 09:06:31

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

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

x
[mw_shl_code=csharp,true]Imports System
) x' @& V- Z! [% H; p! c6 p# ^) hImports NXOpen1 g" h% n* m4 \: J
Imports NXOpen.UF9 F# l: r- p7 ?
Imports NXOpen.Utilities1 a; |, H% n$ z* y1 T  I# ?
'- I/ T& T7 A3 K+ d" q9 {& ?( r
' The OpenComponents() parameter
6 ^4 z: k3 N8 W' NXOpen.Assemblies.ComponentAssembly.OpenOption.WholeAssembly
2 a( N4 s8 R" ?- p# _' only opens unloaded components fully (see also PR-8406345)
& A+ B8 s* z. w" c# a' ]/ o' Workaround: collect and open all components individually, |7 |. M  E9 T+ J: o4 s+ j
'2 I, G7 O# K" t( i
Module NXJournal9 S, E$ v# @, m+ b3 T1 k
    Dim theSession As Session = Session.GetSession()4 E. Z4 S% J0 R5 T7 t+ i
    Dim theUFSession As UFSession = UFSession.GetUFSession()* J- w5 Z& f; U( N$ R) b
    Dim dispPart As Part = theSession.Parts.Display
$ H: u; x$ z6 K$ d& R0 D
6 Z: b. A3 Z1 s5 A( [    Sub DoIt()5 m( d- c8 V' ^, K+ S" X
        Dim allComps() As Assemblies.Component = getAllChildren(dispPart)+ }8 t' U8 K" G8 p: r- e
        Echo("Number of Components: " & allComps.Length.ToString)
# q- Z$ m  \' ^8 j; N7 N6 }( w        For ii As Integer = 0 To allComps.Length - 1
8 f' ]+ v: s1 ?$ F, a2 D5 g! S; s3 X            Echo(allComps(ii).DisplayName)
1 c' V; U7 ]+ i% u1 O9 m5 q        Next
5 s2 k- F+ q  o: m/ ]) `* z$ s8 S0 u" j$ {4 x: u7 e! D3 G
        Dim option1 As Boolean = theSession.Parts.LoadOptions.UsePartialLoading1 F/ O9 W# T! P5 Q& ~
        theSession.Parts.LoadOptions.UsePartialLoading = False
% y1 W1 P+ W" B' V7 _9 q4 y1 s3 j1 Y0 |. F& ^1 ~; D0 {
        Dim openStatus1() As NXOpen.Assemblies.ComponentAssembly.OpenComponentStatus
# s  t  N1 B0 h+ E& ^, \        Dim partLoadStatus1 As NXOpen.PartLoadStatus = Nothing- A8 }+ q( E, c
        partLoadStatus1 = dispPart.ComponentAssembly.OpenComponents(/ R' J+ a" g0 h6 B- P
            NXOpen.Assemblies.ComponentAssembly.OpenOption.ComponentOnly, allComps, openStatus1)9 E5 ^7 \, G7 G/ x2 c7 m6 _

; f) j* \; E9 n0 p        reportPartLoadStatus(partLoadStatus1)
& Q) J, b" L5 ~6 ]7 L        partLoadStatus1.Dispose()
: c3 {0 w- k& }9 R; N; n0 j( P
' V* L4 p% S- O8 S        theSession.Parts.LoadOptions.UsePartialLoading = option1# t/ n# p. k5 l/ W  I! N

( J) P4 y' a2 A1 ~4 L+ e5 C    End Sub" S2 X9 b4 h* [% H5 D" T
$ \8 I2 p' m' T0 o
    Function getAllChildren(ByVal assy As BasePart) As Assemblies.Component()6 p6 [) T0 c5 s- L, P( @
        Dim theChildren As Collections.ArrayList = New Collections.ArrayList
* s4 M" ?( _# c  p$ A6 y        Dim aChildTag As Tag = Tag.Null
, B9 e/ W) \) Q. [+ U- S! V2 E% q
! J9 ?; i) j3 T$ q9 D8 o        Do# F1 B' D9 i! o: [7 b. Y! a' R& [
            theUFSession.Obj.CycleObjsInPart(assy.Tag, UFConstants.UF_component_type, aChildTag)
: |1 x7 ]) l* j, N  R" d( r/ C: Q            If (aChildTag = Tag.Null) Then Exit Do
8 X9 Q% O6 Y! `+ V8 z3 ^: G+ o6 s
            Dim aChild As Assemblies.Component = NXObjectManager.Get(aChildTag)
% E. h; Z1 i4 L: V) t            theChildren.Add(aChild)  e# `8 W( i0 h! Z: v
        Loop+ x+ ?# \: ]% m
        Return theChildren.ToArray(GetType(Assemblies.Component))
% B; _6 i# O' L" h
% c7 W) x. u; I  V/ K    End Function& e1 W# u, G" ]5 `2 ^+ y$ L
# o/ ?7 G2 ?1 v) u+ ^
    Public Sub Main(ByVal args As String())
$ |4 @; }9 U1 y" n+ {: E1 c0 e; ~        If dispPart IsNot Nothing Then
. n  K& F7 d3 w7 }* B* r. d# C# i            DoIt()
/ }0 D. Z9 L! w! H% O            Return2 }* F9 O$ m5 s7 T6 h, h
        End If
# C! Q  A; T+ L3 e8 z- C7 o" c& S+ o2 z+ u: e* O7 j
    End Sub* M, i  g6 j$ v) V( L
- p- j9 b1 H# m: y1 |
    Sub Echo(ByVal output As String)
: Z, Z6 _- R/ e        theSession.ListingWindow.Open()
9 ~9 ?8 f; A8 t        theSession.ListingWindow.WriteLine(output)9 v4 Z- @" e/ g# P; O
        theSession.LogFile.WriteLine(output)
4 k& P( F: {' |: J    End Sub
/ V4 Q9 W6 J9 l, W* }4 _, i* E" R* a+ N
    Sub reportPartLoadStatus(ByVal load_status As PartLoadStatus)
8 j+ \! A. R$ K/ E% i) u( }" F        If load_status.NumberUnloadedParts = 0 Then; Q, u6 a' y! ^0 O
            Return" v& L3 X' @& P) {7 G
        End If
, `2 {1 ?8 ?  t' ?* r9 `: I% e1 M
        Echo("  Load notes:")
- d8 J4 D+ G- s6 A0 R# ?
4 d" H4 l0 z9 e4 v+ u7 R- f        For ii As Integer = 0 To load_status.NumberUnloadedParts - 12 P( V+ k1 W( a5 E5 q* R) q$ e
            Echo("  " & load_status.GetPartName(ii) & " - " & load_status.GetStatusDescription(ii))
$ d3 O5 |7 e3 i" L" c" L# D/ W        Next
! ^, e" a2 P) m, A    End Sub
. O8 B  t1 w4 ]1 N) D$ ]4 l. p5 ?
  K/ L& y8 _0 |$ Y6 S$ [- A+ R    Public Function GetUnloadOption(ByVal arg As String) As Integer8 `8 w6 a0 ?  }9 k- Z
        Return Session.LibraryUnloadOption.Immediately
3 u4 D( E. n& U1 \    End Function$ C, ?$ Y' V7 }( {* o/ i

/ o' }7 E4 k  h3 c, OEnd Module[/mw_shl_code]
5 m7 a" q( i' C
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了