On each component of an assembly I am calculating mass properties referencing a csys owned by the top-level assembly. I isolate each component by creating a simplified representation that only contains the component. I am finding that when I call ProMassPropertyGet() the results are not the same as if I created a Mass Properties analysis feature within Pro/ENGINEER. For example Pro/ENGINEER always reports the mass to be 1.209 lb whereas the results from the API are 0.966. Why is Pro/ENGINEER calculating a different mass than the API?
Code:
ProError AssemblyComponent::ComputeMassProperties(ProName csysName) {
char *szFuncName = "AssemblyComponent::ComputeMassProperties()";
int i = 0,
j = 0,
nWindowId = 0;
ProError pro_error = PRO_TK_NO_ERROR;
ProMdl pro_mdl = NULL;
ProModelitem pro_modelItem;
ProSimprepdata *pro_simpRepData = NULL;
ProSimprepAction pro_simpRepAction;
ProSimprepitem pro_simpRepItem;
ProSimprep pro_simpRepTemp;
//Determine if this is the top-level
if(m_pro_asmCompPath.table_num != 0) {
//Allocate the simprep data
pro_error = ProSimprepdataAlloc(L"MPRTempRep", PRO_B_FALSE, PRO_SIMPREP_EXCLUDE, &pro_simpRepData);
PROUTIL_CALL_REPORT("ProSimprepdataAlloc()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
//Initialize the action
pro_error = ProSimprepActionInit(PRO_SIMPREP_INCLUDE, NULL, &pro_simpRepAction);
PROUTIL_CALL_REPORT("ProSimprepActionInit()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
//Get the component model
pro_error = ProAsmcomppathMdlGet(&m_pro_asmCompPath, &pro_mdl);
PROUTIL_CALL_REPORT("ProAsmcomppathMdlGet()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
//Get the model item
pro_error = ProMdlToModelitem(pro_mdl, &pro_modelItem);
PROUTIL_CALL_REPORT("ProMdlToModelitem()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
//Initialize the simp rep data item
pro_error = ProSimprepdataitemInit(m_pro_asmCompPath.comp_id_table, m_pro_asmCompPath.table_num, pro_modelItem.id, &pro_simpRepAction, &pro_simpRepItem);
PROUTIL_CALL_REPORT("ProSimprepdataitemInit()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
//Add the simp rep data item
pro_error = ProSimprepdataitemAdd(pro_simpRepData, &pro_simpRepItem);
PROUTIL_CALL_REPORT("ProSimprepdataitemAdd()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
//Create the simp rep
pro_error = ProSimprepCreate((ProSolid)m_pro_asmCompPath.owner, pro_simpRepData, &pro_simpRepTemp);
PROUTIL_CALL_REPORT("ProSimprepCreate()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
//Activate the simp rep
pro_error = ProSimprepActivate((ProSolid)m_pro_asmCompPath.owner, &pro_simpRepTemp);
PROUTIL_CALL_REPORT("ProSimprepActivate()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
//Display the simp rep
pro_error = ProSolidDisplay((ProSolid)m_pro_asmCompPath.owner);
PROUTIL_CALL_REPORT("ProSolidDisplay()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR && pro_error!=PRO_TK_E_FOUND);
//Get the current window id
pro_error = ProWindowCurrentGet(&nWindowId);
PROUTIL_CALL_REPORT("ProWindowCurrentGet()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
//Refit the window
pro_error = ProWindowRefit(nWindowId);
PROUTIL_CALL_REPORT("ProWindowRefit()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
//Free the sim rep data
pro_error = ProSimprepdataFree(&pro_simpRepData);
PROUTIL_CALL_REPORT("ProSimprepdataFree()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
pro_error = ProModelitemMdlGet(&pro_simpRepTemp, &pro_mdl);
PROUTIL_CALL_REPORT("ProModelitemMdlGet()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
}
else
pro_mdl = m_pro_asmCompPath.owner;
//Calculate the mass properties
pro_error = ProSolidMassPropertyGet((ProSolid)pro_mdl, csysName, &m_pro_massProperties);
PROUTIL_CALL_REPORT("ProSolidMassPropertyGet()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
//Switch the sign of the intertia tensor at COG
for(i=0;i<3;i++) {
m_pro_massProperties.cg_inertia_tensor[i][0] *= -1;
m_pro_massProperties.cg_inertia_tensor[i][1] *= -1;
m_pro_massProperties.cg_inertia_tensor[i][2] *= -1;
}
//Determine if this is the top-level
if(m_pro_asmCompPath.table_num != 0) {
//Remove the temp simp rep
pro_error = ProSimprepDelete(&pro_simpRepTemp);
ProUtilCallReport("ProSimprepDelete()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);
}
return PRO_TK_NO_ERROR;
}