青华模具培训学校

 找回密码
 注册

QQ登录

只需一步,快速开始

青华模具培训学院
查看: 10239|回复: 1

[疑难] 遍历子部件(组件不是几何组件)

[复制链接]
发表于 2010-8-24 13:53 | 显示全部楼层 |阅读模式
aaa.jpg / O/ E: e/ \% J$ k( d1 @& d

! `4 I* B: v: r" V" t' f# X7 {' ~使用UF_ASSEM_ask_all_part_occ_children方法只能取到B,返回的数量为1,我尝试着用NXopen/vs.net2008 c++,代码如下,请高手指点一下,小弟不胜感激 5 }8 W- e, V5 \) q2 _
3 O: X: E" {& N" E

7 b" M/ k' v& a8 w  ?2 @//*.h文件
5 v0 }9 K; w% e2 G9 N+ j5 J#include <NXOpen/Session.hxx>
+ b+ t/ \; ~+ S  B0 ~3 h/ q#include <NXOpen/NXObjectManager.hxx>
  }/ b# _% `- Z7 T3 i+ K#include <NXOpen/NXException.hxx>- t* X' d+ R# @; V6 w# H
#include <NXOpen/Assemblies_Assembly.hxx>
5 b1 n; n7 v* e7 N* W# h#include <NXOpen/Assemblies_Component.hxx>
4 J* t' {: t- P1 h" \- I0 ?1 }: D#include <NXOpen/Assemblies_ComponentAssembly.hxx>
) y. b0 [& f! A7 I; I( P2 l#include <NXOpen/Part.hxx>' G9 t5 c! K; R. `- S( n
#include <NXOpen/PartCollection.hxx>
6 W9 R9 s0 C2 S% N& I# d' d4 m. F# X#pragma comment (lib, "libnxopencpp.lib")
( A) ^) i: b  E+ O
. t% D! R: n0 ]& x0 X" p, z
8 B. ]6 n+ i3 q1 G//*.cpp文件) n6 k/ P1 K9 F6 A' H. a( X
NXOpen::Session *theSession = NXOpen::Session::GetSession();+ V* V, V8 b1 {( I+ d( {/ z6 o
NXOpen:artCollection *partcol = theSession->arts();
. Y9 w( A; s+ r5 A5 W4 @ NXOpen:art *displayPart(partcol->Display()); 9 F5 e5 o" o% _/ |. T
NXOpen::Assemblies::ComponentAssembly *compa = (NXOpen::Assemblies::ComponentAssembly *)NXOpen::NXObjectManager().Get(displayPart->Tag());
. B& {1 g& G( `6 H# [6 z NXOpen::Assemblies::Component *comp = compa->RootComponent();$ V! L' x/ ^4 [7 x& Z
std::vector<NXOpen::Assemblies::Component*> vt;7 F  o( W" g( ?- r% C( z
vt = comp->GetChildren();  //到这里就崩溃了,郁闷中。。。& W6 a! n* f; X7 @2 \# z& B
int nn = (int)vt.size();
 楼主| 发表于 2010-8-25 13:11 | 显示全部楼层
自己解决:: J7 b: F5 B% h; Q. e) e- g0 t
UF_ASSEM_ask_all_part_occ_children方法遍历不到C# v. {7 W1 C; P. C& J  X  ]7 g, Y
使用UF_OBJ_cycle_objs_in_part0 S5 @" |" V* K2 z9 E; }
type的参数用UF_component_type 就可以了。
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|关于我们|sitemap|小黑屋|Archiver|手机版|UG网-UG技术论坛-青华数控模具培训学校 ( 粤ICP备15108561号 )

GMT+8, 2025-6-28 04:13 , Processed in 0.124225 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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