NX二次开发-获取装配根节点、所有子节点、部件原型
- 获取装配根节点tag;
1 tag_t GetRootComponent(tag_t part)
2 {
3 if (NULL_TAG == part)
4 {
5 return NULL_TAG;
6 }
7
8 return UF_ASSEM_ask_root_part_occ(part);
9 }
- 获取根节点下的所有子节点tag;
1 vector<tag_t> GetChildComponents(tag_t partOcc)
2 {
3 if (NULL_TAG == partOcc)
4 {
5 return vector<tag_t>();
6 }
7
8 vector<tag_t> res = vector<tag_t>();
9 tag_t *childPartOccs = NULL;
10 int count = UF_ASSEM_ask_all_part_occ_children(partOcc, &childPartOccs);
11
12 if (0 == count)
13 {
14 return res;
15 }
16
17 for (int i = 0; i < count; ++i)
18 {
19 res.push_back(childPartOccs[i]);
20 vector<tag_t> tmpContainer = GetChildComponents(childPartOccs[i]);
21 res.insert(res.end(), tmpContainer.begin(), tmpContainer.end());
22 }
23
24 return res;
25 }
- 获取部件原型tag(可能是part的tag或者是子组件part里对应的边、面、体)。
1 tag_t GetPartOfOcc(tag_t partOcc)
2 {
3 if (NULL_TAG == partOcc)
4 {
5 return NULL_TAG;
6 }
7
8 return UF_ASSEM_ask_prototype_of_occ(partOcc);
9 }