Commit 04b3740a authored by sumpfralle's avatar sumpfralle

fixed mixing of default config with loaded condfig


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@497 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent f711455e
...@@ -115,6 +115,37 @@ class Settings: ...@@ -115,6 +115,37 @@ class Settings:
class ProcessSettings: class ProcessSettings:
BASIC_DEFAULT_CONFIG = """
[ToolDefault]
shape: CylindricalCutter
name: Cylindrical (d=3)
tool_radius: 1.5
torus_radius: 0.25
feedrate: 200
speed: 1000
[ProcessDefault]
name: Remove material
path_direction: x
safety_height: 5
engrave_offset: 0.0
path_generator: PushCutter
path_postprocessor: PolygonCutter
material_allowance: 0.5
step_down: 3.0
overlap_percent: 0
[BoundsDefault]
name: No Margin
type: relative_margin
x_low: 0.0
x_high: 0.0
y_low: 0.0
y_high: 0.0
z_low: 0.0
z_high: 0.0
"""
DEFAULT_CONFIG = """ DEFAULT_CONFIG = """
[ToolDefault] [ToolDefault]
torus_radius: 0.25 torus_radius: 0.25
...@@ -133,7 +164,7 @@ tool_radius: 1 ...@@ -133,7 +164,7 @@ tool_radius: 1
torus_radius: 0.2 torus_radius: 0.2
[Tool2] [Tool2]
name: Spherical (d=1.0) name: Spherical (d=1)
shape: SphericalCutter shape: SphericalCutter
tool_radius: 0.5 tool_radius: 0.5
...@@ -279,15 +310,26 @@ process: 3 ...@@ -279,15 +310,26 @@ process: 3
if config_text is None: if config_text is None:
config_text = StringIO.StringIO(self.DEFAULT_CONFIG) config_text = StringIO.StringIO(self.DEFAULT_CONFIG)
else: else:
# Read the basic default config first - in case some new options
# are missing in an older config file.
basic_default_config = StringIO.StringIO(self.BASIC_DEFAULT_CONFIG)
self.config.readfp(basic_default_config)
# Read the real config afterwards.
config_text = StringIO.StringIO(config_text) config_text = StringIO.StringIO(config_text)
self.config.readfp(config_text) self.config.readfp(config_text)
def load_file(self, filename): def load_file(self, filename):
try: try:
self.config.read([filename]) content = file(filename).read()
except IOError, err_msg:
log.error("Settings: Failed to read config file '%s': %s" \
% (filename, err_msg))
return False
try:
self.reset(content)
except ConfigParser.ParsingError, err_msg: except ConfigParser.ParsingError, err_msg:
log.error("Settings: Failed to parse config file '%s': %s" % \ log.error("Settings: Failed to parse config file '%s': %s" \
(filename, err_msg)) % (filename, err_msg))
return False return False
return True return True
...@@ -421,8 +463,8 @@ process: 3 ...@@ -421,8 +463,8 @@ process: 3
result["type"] = bounds_type_name result["type"] = bounds_type_name
low, high = b.get_bounds() low, high = b.get_bounds()
for index, axis in enumerate("xyz"): for index, axis in enumerate("xyz"):
result["%s_low"] = low[index] result["%s_low" % axis] = low[index]
result["%s_high"] = high[index] result["%s_high" % axis] = high[index]
return result return result
result = [] result = []
if tools is None: if tools is None:
......
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