mildcat 发表于 2013-12-2 14:28:54

NX二次开发源码分享:获取装配树上所有的组件名字

NX二次开发源码分享:获取装配树上所有的组件名字

这里使用了递归的方法,进行查询!




<p>
static void findallparts(tag_t part_tag)
{
char part_fspec;
char msg;
tag_t *child_part_occs;
char part_name[ MAX_FSPEC_BUFSIZE ];
char refset_name ;
char instance_name[ UF_CFI_MAX_FILE_NAME_BUFSIZE ] ;
double origin ;
double csys_matrix ;
double transform;
UF_UI_open_listing_window();
int count_occs = UF_ASSEM_ask_part_occ_children(part_tag,&child_part_occs);
//if want to get the suppressed components
// use UF_ASSEM_ask_all_part_occ_children
for (int i = 0 ; i < count_occs ; i++)
{
UF_ASSEM_ask_component_data(child_part_occs,part_name,refset_name,instance_name,origin,csys_matrix,transform);
sprintf(msg,"occ tag : %d \t part_name:%s\t instance_name:%s\t reference name : %s\t\n",
count_occs,part_name,instance_name,refset_name);
UF_UI_write_listing_window(msg);
findallparts(child_part_occs);
}
UF_free(child_part_occs);
}</p><p> </p><p>
static void do_ugopenapi()
{
tag_t part_tag = UF_ASSEM_ask_work_part();
if(part_tag!=NULL_TAG)
{
tag_t occ_tag = UF_ASSEM_ask_root_part_occ(part_tag);
findallparts(occ_tag);
}
}
</p>

airintheair 发表于 2015-7-8 09:02:58

为什么我用UF_ASSEM_ask_part_occ_children和UF_ASSEM_ask_all_part_occ_children得出的count_occs都是0,而child_part_occs也是空的,好郁闷啊

st_chris 发表于 2016-3-20 23:55:52

执行代码后闪退是什么情况?
页: [1]
查看完整版本: NX二次开发源码分享:获取装配树上所有的组件名字