Commit d9296fbd authored by sumpfralle's avatar sumpfralle

"inch to mm" scaling now only happens for PS files - not for a direct DXF import


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@957 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 9ffb1e87
...@@ -366,24 +366,19 @@ def import_model(filename, program_locations=None, unit=None, ...@@ -366,24 +366,19 @@ 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 # z scaling is always targeted at the 0..1 range
scale_z = 1.0
if unit == "mm":
# pstoedit uses inch internally - we need to scale
log.info("DXFImporter: scaling model from inch to mm")
scale_x = 25.4
scale_y = 25.4
else:
scale_x = 1.0
scale_y = 1.0
if color_as_height and (model.minz != model.maxz): if color_as_height and (model.minz != model.maxz):
# scale z to 1 # scale z to 1
scale_z /= (model.maxz - model.minz) scale_z = 1.0 / (model.maxz - model.minz)
if (scale_x != 1.0) or (scale_y != 1.0) or (scale_z != 1.0): if callback:
model.scale(scale_x=25.4, scale_y=25.4, scale_z=scale_z, callback(text="Scaling height for multi-layered 2D model")
log.info("DXFImporter: scaling height for multi-layered 2D model")
model.scale(scale_x=1.0, scale_y=1.0, scale_z=scale_z,
callback=callback) callback=callback)
# shift the model down to z=0 # shift the model down to z=0
if model.minz != 0: if model.minz != 0:
if callback:
callback(text="Shifting 2D model down to to z=0")
model.shift(0, 0, -model.minz, callback=callback) 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())))
......
...@@ -54,12 +54,22 @@ def import_model(filename, program_locations=None, unit=None, callback=None): ...@@ -54,12 +54,22 @@ def import_model(filename, program_locations=None, unit=None, callback=None):
if not success: if not success:
result = None result = None
elif callback and callback(): elif callback and callback():
log.warn("PSImporter: load model operation canceled") log.warn("PSImporter: load model operation cancelled")
result = None result = None
else: else:
log.info("Successfully converted PS file to DXF file") log.info("Successfully converted PS file to DXF file")
# pstoedit uses "inch" -> force a scale operation
result = pycam.Importers.DXFImporter.import_model(dxf_file_name, result = pycam.Importers.DXFImporter.import_model(dxf_file_name,
unit=unit, callback=callback) unit=unit, callback=callback)
if unit == "mm":
# pstoedit uses inch internally - we need to scale
if callback:
callback(text="Scaling model from inch to mm")
log.info("PSImporter: scaling model from inch to mm")
scale_x = 25.4
scale_y = 25.4
result.scale(scale_x=scale_x, scale_y=scale_y, scale_z=1.0,
callback=callback)
# always remove the dxf file # always remove the dxf file
remove_temp_file(dxf_file_name) remove_temp_file(dxf_file_name)
return result return result
......
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