NX二次开发遍历工作部件所有体的显示属性(图层, 颜色, 隐藏状态, 线宽, 字体, 高亮状态)

VS2019 NX1946

#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>

#include <NXOpen/ListingWindow.hxx>

#include <uf_layer.h>
#include<uf_obj.h>

UF_initialize();

Part* workPart;//定义工作部件
workPart = theSession->Parts()->Work();//获取工作部件

char msg[256];

std::vector<int> BodyTagVector;//对象TAG容器
BodyTagVector.clear();

//遍历工作部件所有体的显示属性
BodyCollection* bodys = workPart->Bodies();
for (BodyCollection::iterator ite = bodys->begin(); ite != bodys->end(); ite++)
{
Body* bodys = (*ite);
BodyTagVector.push_back(bodys->Tag());

//获得对象信息
UF_OBJ_disp_props_s dispprops;
UF_OBJ_ask_display_properties(bodys->Tag(), &dispprops); //获取对象的显示属性(图层, 颜色, 隐藏状态, 线宽, 字体, 高亮状态)
sprintf(msg, "体的TAG: %d", bodys->Tag());
theSession->ListingWindow()->WriteLine(msg);
sprintf(msg, "体的图层:%d", dispprops.layer);
theSession->ListingWindow()->WriteLine(msg);
sprintf(msg, "体的颜色:%d", dispprops.color);
theSession->ListingWindow()->WriteLine(msg);
sprintf(msg, "体的隐藏状态:%d", dispprops.blank_status);
theSession->ListingWindow()->WriteLine(msg);
}

UF_terminate();

怡宁塑胶模具设计
原文地址:https://www.cnblogs.com/hqsalanhuang/p/14957772.html