Session* theSession1 = Session::GetSession();
ExpressionCollection* exp_collection = theSession1->Parts()->Work()->Expressions();
//删除所有表达式:迭代器遍历所有表达式 然后删除
int count = 0;
vector< NXOpen::Expression*> tmpExpsVec;
for (NXOpen::ExpressionCollection::iterator it = exp_collection->begin(); it != exp_collection->end(); it++)
{
NXOpen::Expression* exp_ = (*it);
tmpExpsVec.push_back(exp_);
}
while (count < 10 && tmpExpsVec.size() != 0)//按设计理念,不会存在表达式累计引用长度超过10的情况
{
count++;
for (size_t i = 0; i < tmpExpsVec.size(); i++)
{
try
{
exp_collection->Delete(tmpExpsVec[i]);
tmpExpsVec[i] = NULL;
}
catch (const std::exception& ex)
{
}
}
tmpExpsVec.clear();
for (NXOpen::ExpressionCollection::iterator it = exp_collection->begin(); it != exp_collection->end(); it++)
{
NXOpen::Expression* exp_ = (*it);
tmpExpsVec.push_back(exp_);
}
}
【UG\NX二次开发】NXOPEN 删除所有表达式
最新推荐文章于 2024-07-17 17:03:28 发布