NX11+VS2013 #include <uf.h>
#include <uf_disp.h>
#include <uf_modl.h>
#include <uf_part.h>
#include <uf_obj.h>
#include <uf_assem.h>
#include <uf_ui.h>
#include <string.h>
#include <NXOpen/NXObjectManager.hxx>
#include <NXOpen/NXException.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/Assemblies_Component.hxx>
#include <NXOpen/Assemblies_ComponentAssembly.hxx>
#include <NXOpen/BasePart.hxx>
#include <NXOpen/MenuBar_ContextMenuProperties.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/PartLoadStatus.hxx>
#include <NXOpen/Selection.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/TaggedObject.hxx>
#include <algorithm>
#include <NXOpen/STLCreator.hxx>
#include <NXOpen/DexManager.hxx>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <iterator>
#include <cctype> void MyClass::CycleComponent()
{
//遍历当前part所有component
tag_t ComponentTag = NULL_TAG;
UF_OBJ_cycle_objs_in_part(UF_ASSEM_ask_work_part(), UF_component_type, &ComponentTag);
while (ComponentTag != NULL_TAG)
{
//获的显示的体
UF_OBJ_disp_props_t Componentdisp_props;
UF_OBJ_ask_display_properties(ComponentTag, &Componentdisp_props);
int ComponentBlank = Componentdisp_props.blank_status;
if (ComponentBlank == UF_OBJ_NOT_BLANKED)
{
//把装配子部件设置成工作部件
NXOpen::Assemblies::Component *component1(dynamic_cast<NXOpen::Assemblies::Component *>(NXOpen::NXObjectManager::Get(ComponentTag)));
NXOpen::PartLoadStatus *partLoadStatus1;
theSession->Parts()->SetWorkComponent(component1, NXOpen::PartCollection::RefsetOptionEntire, NXOpen::PartCollection::WorkComponentOptionVisible, &partLoadStatus1);
workPart = theSession->Parts()->Work();
delete partLoadStatus1; //遍历工作部件里的体
CycleComponentBody(); //恢复到装配部件
NXOpen::Assemblies::Component *nullNXOpen_Assemblies_Component(NULL);
NXOpen::PartLoadStatus *partLoadStatus2;
theSession->Parts()->SetWorkComponent(nullNXOpen_Assemblies_Component, NXOpen::PartCollection::RefsetOptionEntire, NXOpen::PartCollection::WorkComponentOptionVisible, &partLoadStatus2);
workPart = theSession->Parts()->Work();
delete partLoadStatus2;
} UF_OBJ_cycle_objs_in_part(UF_ASSEM_ask_work_part(), UF_component_type, &ComponentTag);
} }