码迷,mamicode.com
首页 > 其他好文 > 详细

NX二次开发-遍历当前part所有component,把装配子部件设置成工作部件

时间:2019-06-05 21:43:36      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:int   option   ==   tor   style   显示   rop   display   agg   

 1 NX11+VS2013
 2 
 3 #include <uf.h>
 4 #include <uf_disp.h>
 5 #include <uf_modl.h>
 6 #include <uf_part.h>
 7 #include <uf_obj.h>
 8 #include <uf_assem.h>
 9 #include <uf_ui.h>
10 #include <string.h>
11 #include <NXOpen/NXObjectManager.hxx>
12 #include <NXOpen/NXException.hxx>
13 #include <NXOpen/Session.hxx>
14 #include <NXOpen/Assemblies_Component.hxx>
15 #include <NXOpen/Assemblies_ComponentAssembly.hxx>
16 #include <NXOpen/BasePart.hxx>
17 #include <NXOpen/MenuBar_ContextMenuProperties.hxx>
18 #include <NXOpen/Part.hxx>
19 #include <NXOpen/PartCollection.hxx>
20 #include <NXOpen/PartLoadStatus.hxx>
21 #include <NXOpen/Selection.hxx>
22 #include <NXOpen/Session.hxx>
23 #include <NXOpen/TaggedObject.hxx>
24 #include <algorithm>
25 #include <NXOpen/STLCreator.hxx>
26 #include <NXOpen/DexManager.hxx>
27 #include <iostream>
28 #include <string.h>
29 #include <algorithm>
30 #include <iterator>
31 #include <cctype>
32 
33 
34 
35 void MyClass::CycleComponent()
36 {
37     //遍历当前part所有component
38     tag_t ComponentTag = NULL_TAG;
39     UF_OBJ_cycle_objs_in_part(UF_ASSEM_ask_work_part(), UF_component_type, &ComponentTag);
40     while (ComponentTag != NULL_TAG)
41     {
42         //获的显示的体
43         UF_OBJ_disp_props_t Componentdisp_props;
44         UF_OBJ_ask_display_properties(ComponentTag, &Componentdisp_props);
45         int ComponentBlank = Componentdisp_props.blank_status;
46         if (ComponentBlank == UF_OBJ_NOT_BLANKED)
47         {
48             //把装配子部件设置成工作部件
49             NXOpen::Assemblies::Component *component1(dynamic_cast<NXOpen::Assemblies::Component *>(NXOpen::NXObjectManager::Get(ComponentTag)));
50             NXOpen::PartLoadStatus *partLoadStatus1;
51             theSession->Parts()->SetWorkComponent(component1, NXOpen::PartCollection::RefsetOptionEntire, NXOpen::PartCollection::WorkComponentOptionVisible, &partLoadStatus1);
52             workPart = theSession->Parts()->Work();
53             delete partLoadStatus1;
54 
55             //遍历工作部件里的体
56             CycleComponentBody();
57 
58             //恢复到装配部件
59             NXOpen::Assemblies::Component *nullNXOpen_Assemblies_Component(NULL);
60             NXOpen::PartLoadStatus *partLoadStatus2;
61             theSession->Parts()->SetWorkComponent(nullNXOpen_Assemblies_Component, NXOpen::PartCollection::RefsetOptionEntire, NXOpen::PartCollection::WorkComponentOptionVisible, &partLoadStatus2);
62             workPart = theSession->Parts()->Work();
63             delete partLoadStatus2;
64         }
65 
66 
67         UF_OBJ_cycle_objs_in_part(UF_ASSEM_ask_work_part(), UF_component_type, &ComponentTag);
68     }
69 
70 }

 

NX二次开发-遍历当前part所有component,把装配子部件设置成工作部件

标签:int   option   ==   tor   style   显示   rop   display   agg   

原文地址:https://www.cnblogs.com/nxopen2018/p/10981780.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!