删除对象

void DZWEIZHI::Dele()//删除对象

{
try
{
//---- Enter your callback code here -----

NXOpen::Session *theSession = NXOpen::Session::GetSession();
NXOpen::Part *workPart(theSession->Parts()->Work());
NXOpen::Part *displayPart(theSession->Parts()->Display());

//获取切换开关的值
PropertyList *blocktoggle02Pros = toggle02->GetProperties();
int theblocktoggle02 = blocktoggle02Pros->GetLogical("Value");
delete blocktoggle02Pros;
blocktoggle02Pros = NULL;

if (theblocktoggle02 != 1)
{
return;
}

bool notifyOnDelete1;
notifyOnDelete1 = theSession->Preferences()->Modeling()->NotifyOnDelete();

theSession->UpdateManager()->ClearErrorList();

std::vector<NXOpen::NXObject *> objects1(vecTAGtxt.size());

for (size_t i = 0; i < vecTAGtxt.size(); i++)
{
NXOpen::Features::Text *text1(dynamic_cast<NXOpen::Features::Text *>(vecTAGtxt[i]));
objects1[i] = text1;
}

int nErrs1;
nErrs1 = theSession->UpdateManager()->AddToDeleteList(objects1);

bool notifyOnDelete2;
notifyOnDelete2 = theSession->Preferences()->Modeling()->NotifyOnDelete();


}
catch (exception& ex)
{
//---- Enter your exception handling code here -----
DZWEIZHI::theUI->NXMessageBox()->Show("删除对象", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
}

posted @ 2023-02-18 12:02  firetuo  阅读(73)  评论(0)    收藏  举报