Units in STEP Files


with my OCCT based program I check and modify geometry and I am expecting lengths to be given in millimeter. For example when I measure distances between shapes, I expect the distance value to have unit millimeter.

Now I have recognized that STEP files can define geometry with arbitrary units and I can query the used units with STEPControl_Reader::FileUnits(...). To prevent having to mess around with inch, meter and so on I had intended to prevent reading in STEP files with non-standard units. Therefore I check whether the length unit is "millimetre", the planar angle unit is "radian" and the solid angle unit is "steradian". If this is not the case I refuse to read in that STEP file.

Unfortunately I have met a STEP file now that cannot be read in. STEPControl_Reader::FileUnits(...) returns one (planar) angle unit, which is "DEGREE". When I look into the STEP file, it contains the following lines:


This seems to me as if the planar angle unit was actually radian (see line staring with #309), but there is one measure given in degree (see line starting with #311). I wonder why STEPControl_Reader::FileUnits(...) states there was only one planar angle unit which is degree.

Now I have two questions:
- Is my way to care for STEP file units correct? Do I have to prevent reading in geometry with wrong units? Or is the STEP geometry converted to millimeter/radian/steradian anyway during read-in?
- Do I have to do some conversion when reading in STEP files with wrong units? Do I have to convert degree measures to radian measures? How and where can I do that?
- Why does STEPControl_Reader::FileUnits(...) state that the planar angle unit is degree?
- How do you handle units in your code?

Thank you very much,

Benjamin Bihler's picture

I have checked the documentation occt_step.pdf. It seems to me as if my questions were not answered there.

But I have also found information about other CAD systems which suggest that those systems need the STEP unit information only to interpret the geometry from those files, but the geometry is converted to the CAD-internal units after read-in.

Does OCCT also convert the geometry?

Benjamin Bihler's picture

I guess that unit conversion is done automatically. When I modify the unit definition lines in a STEP file and read in the same file again, the geometry has changed. This shows that the units are there not only for information, but also for automatic conversion.

Forum supervisor's picture

Dear Benjamin,

OCCT recognizes units used in the STEP file (which can be different for different sub-shapes) and converts all geometry to OCCT units (millimeters by default).
Best regards

Benjamin Bihler's picture

Thank you for that answer. This puts my mind at rest.