I am seeing some differences with the behavior of STEPControl_Writer and
xstep.cascade.unit between OpenCASCADE 7.5.3 and 7.6.3.
In my application, I use
xstep.cascade.unit to set the model's units, and
write.step.unit to control the units written to the STP file. This seems to have worked fine with 7.5.3, but no longer with 7.6.3.
Below is a snippet which:
- Creates a vertex at (1, 0, 0)
- Specifies that the model units are in "MM" and the output units should be "M"
- Writes the STEP file
Note, I am using the OCP bindings from Python.
from OCP import Interface, STEPControl, gp, BRepBuilderAPI # make a point pnt = gp.gp_Pnt(1, 0, 0) vertex = BRepBuilderAPI.BRepBuilderAPI_MakeVertex(pnt).Vertex() # instantiate writer w = STEPControl.STEPControl_Writer() # set units model_units = 'MM' output_units = 'M' if not Interface.Interface_Static.SetCVal_s('xstep.cascade.unit', model_units): raise ValueError if not Interface.Interface_Static.SetCVal_s('write.step.unit', output_units): raise ValueError # transfer shapes and write w.Transfer(vertex, STEPControl.STEPControl_AsIs) w.Write("test.stp")
I would expect the following to be true:
- The coordinates of the vertex are (1e-3, 0, 0) in the STP file
- The LENGTH_UNIT in the file is SI_UNIT($,.METRE.)
For both OpenCASCADE 7.5.3 and 7.6.3, #2 is true. However, with 7.6.3, the coordinates of the vertex are (1, 0, 0) - they are not converted.
Attached are the STEP files for both 7.5.3 and 7.6.3.
Is there a different API I should use if I wish to do unit conversion upon writing to STP?