#include "ProToolkit.h"
#include "ProCore.h"
#include "ProMdl.h"
#include "ProSolid.h"
#include "ProUtil.h"
/*====================================================================*\
FUNCTION : UsrMassGet()
PURPOSE : Output the mass of a specified Pro/ENGINEER solid
\*====================================================================*/
int UsrMassGet(
ProCharName name,
ProMdlType type,
double *mass)
{
ProName wname;
ProError status;
ProMdl mdl;
ProMassProperty massprops;
/*--------------------------------------------------------------------*\
Check that the model is a part or assembly
\*--------------------------------------------------------------------*/
if(type != PRO_MDL_PART &&
type != PRO_MDL_ASSEMBLY)
return(0);
/*--------------------------------------------------------------------*\
Retrieve it
\*--------------------------------------------------------------------*/
ProStringToWstring(wname, name);
if(ProMdlRetrieve(wname, type, &mdl) != PRO_TK_NO_ERROR)
return(0);
/*--------------------------------------------------------------------*\
Get the mass properties
\*--------------------------------------------------------------------*/
if(ProSolidMassPropertyGet((ProSolid)mdl, NULL, &massprops) !=
PRO_TK_NO_ERROR)
return(0);
*mass = massprops.mass;
/*--------------------------------------------------------------------*\
Erase it from memory
\*--------------------------------------------------------------------*/
ProMdlErase(mdl);
return(1);
}
网友评论