NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
NX二次开发源码: 使用NX OpenC++查询装配组件并判断加载状态
<p>static void getchildren(Assemblies::Component *rootcomponent,unsigned int indent)
{
unsigned int ii;
char space = { " " };
for (ii = 0; ii < indent; ii++) strcat(space, " ");
std::vector<Assemblies::Component *>components;
Session *theSession = Session::GetSession();
ListingWindow *lw = theSession->ListingWindow();
lw->Open();
components = rootcomponent->GetChildren();
for (int i = 0 ; i <components.size();i++)
{
Part *childpart = dynamic_cast<Part*>(components->Prototype());
if(childpart==NULL)
{
lw->WriteLine(space+components->DisplayName()+"\t"+"Status: not loaded!");
}
else
{
if (childpart->IsFullyLoaded())
{
lw->WriteLine(space+components->DisplayName()+"\t"+"Status: IsFullyLoaded!");
}
else
{
lw->WriteLine(space+components->DisplayName()+"\t"+"Status: IsPartiallyLoaded!");
}
getchildren(components,indent+5);
}
}
}</p><p>static void do_api()
{
//list the components
Session *theSession = Session::GetSession();
ListingWindow *lw = theSession->ListingWindow();
lw->Open();
Assemblies::Component * rootcomponent;
Part *workpart;
rootcomponent = theSession->Parts()->Display()->ComponentAssembly()->RootComponent();
workpart = theSession->Parts()->Work();
lw->WriteLine("The workpart is : "+workpart->FullPath()+ "\n" );
if(rootcomponent==NULL)
{
lw->WriteLine("The part is not an assembly ! \n " );
}
else
{
lw->WriteLine("The rootcomponent is : " +rootcomponent->DisplayName()+"\n");
lw->WriteLine("The children components are : \n");
getchildren(rootcomponent,4);
}</p><p>}
</p><p> </p>
嗯,这个不错
页:
[1]