青华模具培训学校

 找回密码
 注册

QQ登录

只需一步,快速开始

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

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

[复制链接]
发表于 2010-8-24 13:53 | 显示全部楼层 |阅读模式
aaa.jpg # C# {- x4 R% H# S7 m" w

# o; `0 A5 U6 S9 W# X使用UF_ASSEM_ask_all_part_occ_children方法只能取到B,返回的数量为1,我尝试着用NXopen/vs.net2008 c++,代码如下,请高手指点一下,小弟不胜感激
* H( D1 D6 ?$ i
+ b6 Y7 U+ I6 \6 L7 c6 @7 s" s3 @" E0 M
//*.h文件
* f$ \- d( d1 Q# ^, N#include <NXOpen/Session.hxx>3 E  D7 \' q( D! A4 R# Y
#include <NXOpen/NXObjectManager.hxx>8 u2 d; k, Z- T9 c  \3 t
#include <NXOpen/NXException.hxx>, P( e3 l0 ~* f7 V- B# U
#include <NXOpen/Assemblies_Assembly.hxx>
' i* \4 ^0 \6 _" D# q: J! t# Q#include <NXOpen/Assemblies_Component.hxx>, _- F$ S% }3 k. U
#include <NXOpen/Assemblies_ComponentAssembly.hxx>4 l; |( E' g6 q0 \
#include <NXOpen/Part.hxx>& e8 e5 W9 Q- V: U
#include <NXOpen/PartCollection.hxx>: O2 G+ T% d, L
#pragma comment (lib, "libnxopencpp.lib")6 D; G, M. ]2 J8 W6 |  i$ Z

' f' b- ~* F( \" \: G
# l4 }- c% F1 D. S//*.cpp文件) a9 ?8 r: c5 u  z$ Y0 j, v' S
NXOpen::Session *theSession = NXOpen::Session::GetSession();
4 r2 g4 ]$ U9 I; U. i NXOpen:artCollection *partcol = theSession->arts();
5 a# I$ e2 z' }# E/ j$ y NXOpen:art *displayPart(partcol->Display());
4 f' l/ k7 ^, B- Q4 J& c, ]9 M NXOpen::Assemblies::ComponentAssembly *compa = (NXOpen::Assemblies::ComponentAssembly *)NXOpen::NXObjectManager().Get(displayPart->Tag());8 D) T% U: Y5 |8 r! R& h
NXOpen::Assemblies::Component *comp = compa->RootComponent();
! R4 A/ c# Z0 O- X  O- } std::vector<NXOpen::Assemblies::Component*> vt;
: Q3 l! I! m# M. E vt = comp->GetChildren();  //到这里就崩溃了,郁闷中。。。
$ ~! S  t; \; Y0 s" }) H, J int nn = (int)vt.size();
 楼主| 发表于 2010-8-25 13:11 | 显示全部楼层
自己解决:
. |/ Z% @! J$ U0 d( c7 |* gUF_ASSEM_ask_all_part_occ_children方法遍历不到C7 B" C1 R3 Y) T- ~& V2 g7 G8 x0 R
使用UF_OBJ_cycle_objs_in_part
; z' \+ x3 p& B1 n, [9 y  \type的参数用UF_component_type 就可以了。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-4 03:17 , Processed in 0.202596 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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