青华模具培训学校

 找回密码
 注册

QQ登录

只需一步,快速开始

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

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

[复制链接]
发表于 2010-8-24 13:53 | 显示全部楼层 |阅读模式
aaa.jpg
7 |8 G7 i9 m2 ^% I, n& W% J$ t9 O( z$ C& i" E2 v& p% ^1 V. i: ]. P2 w5 E
使用UF_ASSEM_ask_all_part_occ_children方法只能取到B,返回的数量为1,我尝试着用NXopen/vs.net2008 c++,代码如下,请高手指点一下,小弟不胜感激 ) C5 ^. n) d: e
7 \; c# [4 r- r9 R, q. ~: l( u; g
+ Y7 ~; w7 E: H. E& Q
//*.h文件) A9 @- a* \% @- k- w: `2 i: [
#include <NXOpen/Session.hxx>
+ r. f; o/ E- s" v' v+ ~1 s#include <NXOpen/NXObjectManager.hxx>
, x7 i9 M! ~# g2 E- }#include <NXOpen/NXException.hxx>! r1 E2 L. [. a$ Q6 C- S  i
#include <NXOpen/Assemblies_Assembly.hxx>
" E8 `1 O9 R. D2 O8 }#include <NXOpen/Assemblies_Component.hxx>
3 l2 |5 I: M8 O5 {" x! Q. L#include <NXOpen/Assemblies_ComponentAssembly.hxx>
* j* L& Y* N) q8 i  L+ h$ \#include <NXOpen/Part.hxx>
4 C$ m2 a+ z1 p  J+ Z( B7 \#include <NXOpen/PartCollection.hxx>
$ f' e/ M5 K% G8 Y$ m/ t( ?#pragma comment (lib, "libnxopencpp.lib")
( K' A4 ^2 }/ w. j* J' P$ i
0 c6 Q- A  N& G2 z+ k; J# D; o
/ I& Y9 z& |; z' [+ j( H//*.cpp文件% c* K1 \. c" A; q5 H3 d9 c, Q- I
NXOpen::Session *theSession = NXOpen::Session::GetSession();
3 b5 _8 ~+ S: y; B NXOpen:artCollection *partcol = theSession->arts();. f2 D6 I8 [8 L# A- Q: C' S8 e
NXOpen:art *displayPart(partcol->Display()); 1 c. T( z1 M. Y5 Z2 i# t
NXOpen::Assemblies::ComponentAssembly *compa = (NXOpen::Assemblies::ComponentAssembly *)NXOpen::NXObjectManager().Get(displayPart->Tag());
$ ~0 o: Z& y+ p! b$ L6 q: Z NXOpen::Assemblies::Component *comp = compa->RootComponent();
" d9 ]# T9 X$ Q7 l std::vector<NXOpen::Assemblies::Component*> vt;+ N; \+ _/ a9 S. v% n7 V
vt = comp->GetChildren();  //到这里就崩溃了,郁闷中。。。
) F3 C2 C" Y6 \6 k" O int nn = (int)vt.size();
 楼主| 发表于 2010-8-25 13:11 | 显示全部楼层
自己解决:. {) k% G/ `2 U* i4 b
UF_ASSEM_ask_all_part_occ_children方法遍历不到C
+ j+ |( ^& ]- n1 E% B* G6 V使用UF_OBJ_cycle_objs_in_part0 ]/ B) ~0 ?3 J. q9 v
type的参数用UF_component_type 就可以了。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-12 21:00 , Processed in 0.060372 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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