Hello,
Function ProMdlUnitsCollect() returns all the units available to a model.
To get unit assigned to model, functions ProMdlPrincipalunitsystemGet() and ProUnitsystemUnitGet() can be used.
E.g.
ProMdl model;
ProUnititem *mass_unit_items;
int iMassUnits = 0;
ProUnitsystem model_unit_system;
ProUnititem model_mass_unit;
ProCharName cMassUnitName;
// Get current model
ProMdlCurrentGet(&model);
// Collect all units avaliable to model for mass
ProMdlUnitsCollect(model, PRO_UNITTYPE_MASS, &mass_unit_items);
// Display information
ProArraySizeGet(mass_unit_items, &iMassUnits);
ProMessageDisplay(L"umsg.txt", "USER %0s", "Mass units available to model: ");
ProMessageClear();
for(int i=0; i<imassunits; i++)<br="/>{
ProWstringToString(cMassUnitName, mass_unit_items[i].name);
ProMessageDisplay(L"umsg.txt", "USER %0s", cMassUnitName);
ProMessageClear();
}
// Free allocated memory
ProArrayFree((ProArray *)&mass_unit_items);
// Get principal system of units currently assigned to the model
ProMdlPrincipalunitsystemGet(model, &model_unit_system);
// Get mass unit from principle system of units
ProUnitsystemUnitGet(&model_unit_system, PRO_UNITTYPE_MASS, &model_mass_unit);
ProWstringToString(cMassUnitName, model_mass_unit.name);
ProMessageDisplay(L"umsg.txt", "USER %0s", "Mass unit assigned to model: ");
ProMessageClear();
ProMessageDisplay(L"umsg.txt", "USER %0s", cMassUnitName);
ProMessageClear();
Output:
Mass units available to model:
lbm
kg
g
mg
tonne
ounce-m
slug
ton-m
IPS_mass_unit
Mass unit assigned to model:
lbm
Regards,
Amar Junankar
Sr. Application Engineer
Imagecom, Inc.
www.aspire3d.com