solidworks二次开发:获得点坐标

 LPMODELDOC pModelDoc=NULL;

 LPSELECTIONMGR pSelectMgr=NULL;  

double retval[3];  

CString string;  

long nSelCount=0;  

TheApplication->GetSWApp()->get_IActiveDoc(&pModelDoc);//获得指向活动文档的pModelDoc指针

 if(!pModelDoc) return;  

pModelDoc->get_ISelectionManager(&pSelectMgr);//获得选择管理器指针  

if(!pSelectMgr)  {   

pModelDoc->Release();   

return;  

}  

pSelectMgr->GetSelectedObjectCount(&nSelCount);//获得选择对象的数目  

if(nSelCount!=0)  {  

 pSelectMgr->IGetSelectionPoint(1,retval);//获得点坐标

 }  

string.Format(_T("Selected point(%.2f,%.2f,%.2f)"),retval[0],retval[1],retval[2]);//将坐标三维显示出来  AfxMessageBox(string);  

pModelDoc->Release();  

pSelectMgr->Release();

你可能感兴趣的:(solidworks二次开发)