LPSLDWORKS p_sldwork = TheApplication->GetSWApp();//定义p_sldwork指针
LPMODELDOC pModelDoc = NULL;//定义pModelDoc指针
LPPARTDOC pPartDoc = NULL;//定义pPartDoc指针
LPENTITY pEntity = NULL;//定义pEntity指针
long nSelCount = 0;//定义选择数
BSTR entityName;//定义实体名字符串
if (!p_sldwork) return;//如果无p_sldwork,则返回
p_sldwork->get_IActiveDoc(&pModelDoc);//获得pModelDoc指针
if (!pModelDoc) return;//如果没有pModelDoc,则返回
pModelDoc->QueryInterface(IID_IPartDoc,(LPVOID *)&pPartDoc);//获得pPartDoc指针
if (!pPartDoc) {
//如果没有pPartDoc,则释放指针
pModelDoc->Release();
return;
}
//用SelectionMgr获到m_Entity
LPUNKNOWN pUnk = NULL;//定义pUnk指针
LPSELECTIONMGR pSelectMgr = NULL;//定义pSelectMgr指针
pModelDoc->get_ISelectionManager(&pSelectMgr);//获得选择管理器指针