Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

It’s possible to have multiple different units used inside of a same model, so that’s why the ModelFile and each ProductOccurrence can have its own unit (see both A3DAsmModelFileData::m_dUnit and A3DAsmProductOccurrenceData::m_dUnit).
In order to find the one global to the whole model, you’ll need to browse through its modelFile and sub-POs and find the first one for which m_bUnitFromCAD is set to true.

That’s basically what the function A3DAsmModelFileGetUnit (introduced since HE 2019) does.

Note

Be careful because the model unit found may look slightly different from what is rendered if a scale is also set inside of the A3DTopoContextData.

How can I overwrite units inside of a PRC file ?

The easiest and fastest way to proceed is to create a new modelFile (with the A3DAsmModelFileCreate function) or to edit the root PO (you can use A3DAsmProductOccurrenceEdit for example), by setting m_bUnitFromCAD to true and put the desired m_dUnit (defined as a mm multiple).

Please find below a code sample as an example:

Code Block
languagecpp
A3DAsmModelFileData sNewMFData;
A3D_INITIALIZE_DATA(A3DAsmModelFileData, sNewMFData);
sNewMFData.m_uiPOccurrencesSize = 1;
sNewMFData.m_ppPOccurrences = new A3DAsmProductOccurrence*[1];
sNewMFData.m_ppPOccurrences[0] = pRootPO;
sNewMFData.m_bUnitFromCAD = TRUE;
sNewMFData.m_dUnit = dDstUnit;
iRet = A3DAsmModelFileCreate(&sNewMFData, ppModelFile);