Commit 68a743b2 authored by sumpfralle's avatar sumpfralle

added expansion of unix homedir (~) for output filenames

removed selection of postprocessor (similar to the GUI)
added the milling style setting
added contour-follow and contour-polygon as available strategies


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@845 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 61893a20
...@@ -126,13 +126,13 @@ def get_default_model(): ...@@ -126,13 +126,13 @@ def get_default_model():
", ".join(EXAMPLE_MODEL_LOCATIONS))) ", ".join(EXAMPLE_MODEL_LOCATIONS)))
return pycam.Importers.TestModel.get_test_model() return pycam.Importers.TestModel.get_test_model()
def load_model_file(filename, program_locations): def load_model_file(filename, program_locations, unit=None):
filename = os.path.expanduser(filename) filename = os.path.expanduser(filename)
if not os.path.isfile(filename): if not os.path.isfile(filename):
log.warn("The input file ('%') was not found!" % filename) log.warn("The input file ('%') was not found!" % filename)
return None return None
filetype, importer = pycam.Importers.detect_file_type(filename) filetype, importer = pycam.Importers.detect_file_type(filename)
model = importer(filename, program_locations=program_locations) model = importer(filename, program_locations=program_locations, unit=unit)
if model is None: if model is None:
log.warn("Failed to load the model file (%s)." % filename) log.warn("Failed to load the model file (%s)." % filename)
return None return None
...@@ -144,6 +144,8 @@ def get_output_handler(destination): ...@@ -144,6 +144,8 @@ def get_output_handler(destination):
handler = sys.stdout handler = sys.stdout
closer = lambda: None closer = lambda: None
else: else:
# support paths with a tilde (~)
destination = os.path.expanduser(destination)
try: try:
handler = open(destination, "w") handler = open(destination, "w")
except IOError, err_msg: except IOError, err_msg:
...@@ -258,20 +260,21 @@ def execute(parser, opts, args, pycam): ...@@ -258,20 +260,21 @@ def execute(parser, opts, args, pycam):
if opts.collision_engine == "ode": if opts.collision_engine == "ode":
tps.set_calculation_backend("ODE") tps.set_calculation_backend("ODE")
tps.set_unit_size(opts.unit_size) tps.set_unit_size(opts.unit_size)
path_generator = {"layer": "PushCutter", path_generator, postprocessor = {
"surface": "DropCutter", "layer": ("PushCutter", "SimpleCutter"),
"engrave": "EngraveCutter", "contour-follow": ("ContourFollow", "SimpleCutter"),
}[opts.process_path_generator] "contour-polygon": ("PushCutter", "ContourCutter"),
postprocessor = {"zigzag": "ZigZagCutter", "surface": ("DropCutter", "PathAccumulator"),
"contour": "ContourCutter", "engrave": ("EngraveCutter", "SimpleCutter"),
"polygon": "PolygonCutter", }[opts.process_path_strategy]
}[opts.process_path_postprocessor]
# TODO: add the miling_style option # TODO: add the miling_style option
tps.set_process_settings(path_generator, postprocessor, tps.set_process_settings(path_generator, postprocessor,
opts.process_path_direction, reverse=False, opts.process_path_direction,
material_allowance=opts.process_material_allowance, material_allowance=opts.process_material_allowance,
overlap=opts.process_overlap_percent / 100.0, overlap=opts.process_overlap_percent / 100.0,
step_down=opts.process_step_down, engrave_offset=opts.process_engrave_offset) step_down=opts.process_step_down,
engrave_offset=opts.process_engrave_offset,
milling_style=opts.process_milling_style)
# set locations of external programs # set locations of external programs
program_locations = {} program_locations = {}
if opts.external_program_inkscape: if opts.external_program_inkscape:
...@@ -387,9 +390,9 @@ def execute(parser, opts, args, pycam): ...@@ -387,9 +390,9 @@ def execute(parser, opts, args, pycam):
opts.gcode_motion_tolerance, naive_tolerance) opts.gcode_motion_tolerance, naive_tolerance)
else: else:
generator.set_path_mode(PATH_MODES[opts.gcode_path_mode]) generator.set_path_mode(PATH_MODES[opts.gcode_path_mode])
generator.add_path_list(toolpath, generator.add_moves(tp_obj.get_moves(opts.safety_height),
max_skip_safety_distance=opts.tool_diameter,
comment=tp_obj.get_meta_data()) comment=tp_obj.get_meta_data())
generator.finish()
closer() closer()
if opts.export_task_config: if opts.export_task_config:
handler, closer = get_output_handler(opts.export_task_config) handler, closer = get_output_handler(opts.export_task_config)
...@@ -543,16 +546,12 @@ if __name__ == "__main__": ...@@ -543,16 +546,12 @@ if __name__ == "__main__":
dest="process_path_direction", default="x", action="store", dest="process_path_direction", default="x", action="store",
type="choice", choices=["x", "y", "xy"], type="choice", choices=["x", "y", "xy"],
help="primary direction of the generated toolpath (x/y/xy)") help="primary direction of the generated toolpath (x/y/xy)")
group_process.add_option("", "--process-path-generator", group_process.add_option("", "--process-path-strategy",
dest="process_path_generator", default="layer", action="store", dest="process_path_strategy", default="surface", action="store",
type="choice", choices=["layer", "surface", "engrave"], type="choice", choices=["layer", "contour-follow",
"contour-polygon", "surface", "engrave"],
help="one of the available toolpath strategies (layer, surface, " \ help="one of the available toolpath strategies (layer, surface, " \
+ "engrave)") + "contour-follow, contour-polygon, engrave)")
group_process.add_option("", "--process-path-postprocessor",
dest="process_path_postprocessor", default="polygon",
action="store", type="choice",
choices=["polygon", "contour", "zigzag"], help="one of the " \
+ "available toolpath postprocessors (polygon, zigzag, contour)")
group_process.add_option("", "--process-material-allowance", group_process.add_option("", "--process-material-allowance",
dest="process_material_allowance", default=0.0, action="store", dest="process_material_allowance", default=0.0, action="store",
type="float", help="minimum distance between the tool and the " \ type="float", help="minimum distance between the tool and the " \
...@@ -565,6 +564,11 @@ if __name__ == "__main__": ...@@ -565,6 +564,11 @@ if __name__ == "__main__":
dest="process_overlap_percent", default=0, action="store", dest="process_overlap_percent", default=0, action="store",
type="int", help="how much should two adjacent parallel " \ type="int", help="how much should two adjacent parallel " \
+ "toolpaths overlap each other (0..99)") + "toolpaths overlap each other (0..99)")
group_process.add_option("", "--process-milling-style",
dest="process_milling_style", default="ignore",
action="store", type="choice",
choices=["ignore", "conventional", "climb"],
help="milling style (conventional / climb / ignore)")
group_process.add_option("", "--safety-height", dest="safety_height", group_process.add_option("", "--safety-height", dest="safety_height",
default=25.0, action="store", type="float", default=25.0, action="store", type="float",
help="height for safe re-positioning moves") help="height for safe re-positioning moves")
......
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