How to read the units of a STEP file

Can anyone point me into the right direction how to read the measurement units and the accuracy specified in a STEP file that is specified within the STEP that is generated with a CAD package like Creo?
 

#644=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.E-2),#638,'closure',

#638=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.));

I've tried to do that with

    const Handle(XSControl_WorkSession)& theSession = aReader.WS();
    const Handle(Interface_InterfaceModel)& theModel = theSession->Model();

    Standard_Integer nb = theModel->NbEntities(); // Returns count of contained Entities.
    for (Standard_Integer i = 1; i <= nb; i++)
    {
        Handle(StepRepr_Representation) ent = Handle(StepRepr_Representation)::DownCast(theModel->Value(i));
        if (ent.IsNull())
            continue;
        if (ent->Name().IsNull())
            continue;
        printf("%s\n", ent->Name()->ToCString());
    }

Apparently this is not the correct way.
Any advice is much appreciated.

John Bijnens's picture

I've tried to use the methode FileUnits*
I read however that this doesn't work when the STEP geometry is already converted to a BREP model in OCC.
So I tried
    Handle(StepData_StepModel) hModel = Handle(StepData_StepModel)::DownCast(aReader.Model());
    for (int i = 1; i <= hModel->NbEntities(); ++i)
    {
        if ((hModel->Entity(i))->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit)))
        {
            Handle(StepBasic_ConversionBasedUnitAndLengthUnit) convUnit = Handle(StepBasic_ConversionBasedUnitAndLengthUnit)::DownCast(hModel->Entity(i));
            TCollection_HAsciiString unitName = convUnit->Name();
            unitName.Print(cout);
            break;
        }
    }

The line if ((hModel->Entity(i))->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit)))

gives a false so this doesn't work either.

Any hint or advice is very much appreciated.