单位为立方米。由于V6对Product的打开机制是VisualMode,故获取速度会很慢。
ExportedByARKGlobal void GetVolume(CATIPLMNavOccurrence *ipOcc,double &oVolume)
{
CATApplicationFrame *pappFrame = CATApplicationFrame::GetFrame();
CATIAApplication *ptApp = NULL;
pappFrame -> QueryInterface(IID_CATIAApplication, (void**) &ptApp);
CATIAEditor *ptEditor = NULL;
ptApp -> get_ActiveEditor(ptEditor);
CATIAService *pService=NULL;
UString servicename("InertiaService");
CATBSTR servicenameBSTR;
servicename.ConvertToBSTR(&servicenameBSTR);
ptEditor -> GetService(servicenameBSTR,pService);
CATIAInertiaService *pInerService=(CATIAInertiaService *)pService;
CATIPLMNavInstance *pInstOnOcc=NULL;
ipOcc -> GetRelatedInstance(pInstOnOcc);
CATIPLMNavReference *pRefOnOcc=NULL;
pInstOnOcc -> GetReferenceInstanceOf(pRefOnOcc);
ReleaseInterface(pInstOnOcc);
CATIPrdOccurrenceMngt* pOccMngt = NULL;
CATPrdGetOccurrenceMngt(pOccMngt);
CATIPLMNavOccurrence_var spOccOnRef;
pOccMngt -> GetOrCreateRootOccurrence(pRefOnOcc,spOccOnRef);
ReleaseInterface(pRefOnOcc);
ReleaseInterface(pOccMngt);
CATIABase *pRefBase=NULL;
spOccOnRef -> QueryInterface(IID_CATIABase,(void**)&pRefBase);
CATIAInertia *pInertia=NULL;
pInerService -> GetInertiaElement(pRefBase,pInertia);
pInertia -> GetVolume(oVolume);
ReleaseInterface(pInertia);
ReleaseInterface(pRefBase);
ReleaseInterface(pService);
ReleaseInterface(ptApp);
}