I am using the following code to extract the geometry from a STEP file:
from OCC.Extend.DataExchange import read_step_file
from OCC.Core.BRepBndLib import brepbndlib
from OCC.Core.GProp import
shape = read_step_file(file_path)
if shape is None:
raise Exception("Failed to load model " + model_filepath)
bbox = Bnd_Box()
brepbndlib.AddOptimal(shape, bbox)
xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
gprops = GProp_GProps()
brepgprop.VolumeProperties(shape, gprops)
volume = gprops.Mass()
brepgprop.SurfaceProperties(shape, gprops)
area = gprops.Mass()
dimensions = {
"x": xmax - xmin,
"y": ymax - ymin,
"z": zmax - zmin,
}
return {
"volume": volume,
"area": area,
"dimensions": dimensions,
}
Now it appears that OCC converts the geometry of the design to mm, even if it was originally designed in inch for example? Is that observation correct?
Is there a way to extract the original file unit from the STEP file in order to convert the values back to the original file unit, if needed?
Hello,
I am using the following code to extract the geometry from a STEP file:
Now it appears that OCC converts the geometry of the design to
mm
, even if it was originally designed ininch
for example? Is that observation correct?Is there a way to extract the original file unit from the STEP file in order to convert the values back to the original file unit, if needed?
Thank you for your help!
Kind regards Alex