[size=13.333333969116211px]www.mcadex.com
IModelDoc2 * pMdl;
iSwApp->get_IActiveDoc2(&pMdl);
if (pMdl == NULL)
return S_FALSE;
//获取Part
CComPtr<IPartDoc> pPart;
pMdl->QueryInterface(IID_IPartDoc, (LPVOID*)&pPart);
if (pPart == NULL)
return S_FALSE;
//获取PartBox
VARIANT dPoint;
pPart->GetPartBox(FALSE, &dPoint);
//转换Box为double
SAFEARRAY * psaBox = V_ARRAY(&dPoint);
double dExtent[6];//box的个顶点坐标
for ( long j=0; j < 6; j += 1 )
{
double dValue;
SafeArrayGetElement(psaBox, &j, (VOID *)(&(dValue)));
dExtent[j] = dValue;
}
CString csMsg("");
csMsg.Format(_T("Point1: X %lf, Y %lf, Z %lf; Point2: X %lf, Y %lf, Z %lf"), dExtent[0], dExtent[1], dExtent[2], dExtent[3], dExtent[4], dExtent[5]);
MessageBox(NULL, (LPCWSTR)csMsg, _T("提示"), MB_OK);