NX二次开发源码分享: 报告所有的PMI显示的视图对象
NX二次开发源码分享: 报告所有的PMI显示的视图对象
extern "C" DllExport void ufusr(char *param, int *retcod, int param_len)
{
Session *theSession = Session::GetSession();
UI *ui = UI::GetUI();
Selection *sm = ui->SelectionManager();
std::vector<Selection::MaskTriple> mask(1);
mask = Selection::MaskTriple(UF_smart_model_instance_type, 0, 0);
std::vector<NXOpen::NXObject*> objects;
unsigned int ii, jj;
Annotations::Annotation *ann;
std::vector<View *> views;
NXMessageBox *mb = ui->NXMessageBox();
std::vector<NXString> messages;
Selection::Response resp = sm->SelectObjects("Select PMI notes",
"Select PMI notes", Selection::SelectionScopeWorkPart,
Selection::SelectionActionClearAndEnableSpecific, false, false, mask,
objects);
if (objects.size())
{
for (ii = 0; ii < objects.size(); ii++)
{
/*This may fail - see PR 5872709 */
ann = dynamic_cast<Annotations::Annotation *>(objects);
if (ann != NULL)
views = ann->GetViews();
else
{
mb->Show("Failure",
NXMessageBox::DialogTypeInformation,
"dynamic_cast did not work!");
/*This will work and is safe due to selection masking */
ann = (Annotations::Annotation *)objects;
views = ann->GetViews();
}
if (views.size())
{
for (jj = 0; jj < views.size(); jj++)
messages.push_back(views->Name());
mb->Show("GetViews results",
NXMessageBox::DialogTypeInformation,
messages);
messages.clear();
}
}
}
}
页:
[1]