Commit 036a5028 authored by sumpfralle's avatar sumpfralle

some changes of the DXFImporter:

* always scale the height of a multi-layer DXF file to z=1.0
* the bottom of the model is always z=0.0


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@935 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent b5070f6e
...@@ -307,15 +307,25 @@ def import_model(filename, program_locations=None, unit=None, ...@@ -307,15 +307,25 @@ def import_model(filename, program_locations=None, unit=None,
model = pycam.Geometry.Model.ContourModel() model = pycam.Geometry.Model.ContourModel()
for l in lines: for l in lines:
model.append(l) model.append(l)
# z scaling is always targetted at the 0..1 range
scale_z = 1.0
if unit == "mm": if unit == "mm":
# pstoedit uses inch internally - we need to scale # pstoedit uses inch internally - we need to scale
log.info("DXFImporter: scaling model from inch to mm") log.info("DXFImporter: scaling model from inch to mm")
if color_as_height: scale_x = 25.4
# don't scale z (should be between 0 and 1) scale_y = 25.4
model.scale(scale_x=25.4, scale_y=25.4, scale_z=1, else:
callback=callback) scale_x = 1.0
else: scale_y = 1.0
model.scale(25.4, callback=callback) if color_as_height and (model.minz != model.maxz):
# scale z to 1
scale_z /= (model.maxz - model.minz)
if (scale_x != 1.0) or (scale_y != 1.0) or (scale_z != 1.0):
model.scale(scale_x=25.4, scale_y=25.4, scale_z=scale_z,
callback=callback)
# shift the model down to z=0
if model.minz != 0:
model.shift(0, 0, -model.minz, callback=callback)
log.info("DXFImporter: Imported DXF model: %d lines / %d polygons" \ log.info("DXFImporter: Imported DXF model: %d lines / %d polygons" \
% (len(lines), len(model.get_polygons()))) % (len(lines), len(model.get_polygons())))
return model return model
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment