当批量删除对象时单个循环删除速度很慢,录制了一份批量删除的,速度就得到了明显提升
void delObjs(vector<tag_t>objs) {
Session* theSession = Session::GetSession();
Part* workPart(theSession->Parts()->Work());
Part* displayPart(theSession->Parts()->Display());
bool notifyOnDelete1;
notifyOnDelete1 = theSession->Preferences()->Modeling()->NotifyOnDelete();
theSession->UpdateManager()->ClearErrorList();
Session::UndoMarkId markId2;
markId2 = theSession->SetUndoMark(Session::MarkVisibilityVisible, "Delete");
std::vector<NXObject*> objects1(objs.size());
for (int i = 0; i < objs.size(); i++) {
NXObject* body1(dynamic_cast<NXObject*>(NXObjectManager::Get(objs[i])));
objects1[i] = body1;
}
int nErrs1;
nErrs1 = theSession->UpdateManager()->AddToDeleteList(objects1);
bool notifyOnDelete2;
notifyOnDelete2 = theSession->Preferences()->Modeling()->NotifyOnDelete();
int nErrs2;
nErrs2 = theSession->UpdateManager()->DoUpdate(markId2);
}