//遍历
PartCollection* Pc = theSession->Parts();
for (PartCollection::iterator ite = Pc->begin(); ite != Pc->end(); ite++)
{
NXOpen::BasePart* basePartPtr = (*ite); // 假设这是你的BasePart对象指针
NXOpen::Part* part = dynamic_cast<NXOpen::Part*>(basePartPtr);
if (part != nullptr)
{
// 转换成功,现在可以安全地使用part
//theSession->ListingWindow()->WriteLine("转换成功,现在可以安全地使用" );
NXString ALLpartfullpath = part->FullPath();
//theSession->ListingWindow()->WriteLine("部件路径:"+ALLpartfullpath);
ALLPartNameVector.push_back(ALLpartfullpath.GetLocaleText());
}
else {
// 转换失败,basePartPtr不是Part类型
theSession->ListingWindow()->WriteLine("转换失败,basePartPtr不是Part类型" );
}
}