Commit 56cee7f2 authored by sumpfralle's avatar sumpfralle

added an option for using a profiler (cProfiler)


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@724 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 6b2570c4
......@@ -132,211 +132,7 @@ def get_output_handler(destination):
closer = handler.close
return (handler, closer)
# check if we were started as a separate program
if __name__ == "__main__":
parser = OptionParser(prog="PyCAM",
usage="usage: pycam [options] [inputfile]\n\n" \
+ "Start the PyCAM toolpath generator. Supplying one of " \
+ "the '--export-?' parameters will cause PyCAM to start " \
+ "in batch mode. Most parameters are useful only for " \
+ "batch mode.",
epilog="Take a look at the wiki for more information: " \
+ "http://sourceforge.net/apps/mediawiki/pycam/.\n" \
+ "Bug reports: http://sourceforge.net/tracker/?group_id=237831&atid=1104176")
group_general = parser.add_option_group("General options")
group_export = parser.add_option_group("Export formats",
"Export the resulting toolpath or meta-data in various formats. " \
+ "These options trigger the non-interactive mode. Thus the GUI " \
+ "is disabled.")
group_tool = parser.add_option_group("Tool definition",
"Specify the tool paramters. The default tool is spherical and " \
+ "has a diameter of 1 unit. The default speeds are 1000 " \
+ "units/minute (feedrate) and 250 (spindle rotations per minute)")
group_process = parser.add_option_group("Process definition",
"Specify the process parameters: toolpath strategy, layer height," \
+ " and others. A typical roughing operation is configured by " \
+ "default.")
group_bounds = parser.add_option_group("Boundary definition",
"Specify the outer limits of the processing area (x/y/z). " \
+ "You may choose between 'relative_margin' (margin is given as " \
+ "percentage of the respective model dimension), 'fixed_margin' " \
+ "(margin for each face given in absolute units of length) " \
+ "and 'custom' (absolute coordinates of the bounding box - " \
+ "regardless of the model size and position). Negative values " \
+ "are allowed and can make sense (e.g. negative margin).")
group_support_grid = parser.add_option_group("Support grid",
"An optional support grid can be used to keep the object in " \
+ "place during the mill operation. The support grid can be " \
+ "removed manually afterwards. The support grid can have a " \
+ "rectangular profile. By default the support grid is disabled.")
group_gcode = parser.add_option_group("GCode settings",
"Specify some details of the generated GCode.")
group_external_programs = parser.add_option_group("External programs",
"Some optional external programs are used for format conversions.")
# general options
group_general.add_option("-c", "--config", dest="config_file",
default=None, action="store", type="string",
help="load a task settings file")
group_general.add_option("", "--unit", dest="unit_size",
default="mm", action="store", type="choice",
choices=["mm", "inch"], help="choose 'mm' or 'inch' for all " \
+ "numbers. By default 'mm' is assumed.")
group_general.add_option("", "--collision-engine", dest="collision_engine",
default="triangles", action="store", type="choice",
choices=["triangles", "ode"],
help="choose a specific collision detection engine. The default " \
+ "is 'triangles'. Use 'help' to get a list of possible " \
+ "engines.")
group_general.add_option("", "--boundary-mode", dest="boundary_mode",
default="along", action="store", type="choice",
choices=["inside", "along", "outside"],
help="specify if the mill tool (including its radius) should " \
+ "move completely 'inside', 'along' or 'outside' the " \
+ "defined processing boundary.")
group_general.add_option("", "--disable-psyco", dest="disable_psyco",
default=False, action="store_true", help="disable the Psyco " \
+ "just-in-time-compiler even when it is available")
group_general.add_option("-q", "--quiet", dest="quiet",
default=False, action="store_true", help="show only warnings and " \
+ "errors.")
group_general.add_option("-d", "--debug", dest="debug",
default=False, action="store_true", help="enable output of debug " \
+ "messages.")
group_general.add_option("", "--progress", dest="progress",
default="text", action="store", type="choice",
choices=["none", "text", "bar", "dot"],
help="specify the type of progress bar used in non-GUI mode. " \
+ "The following options are available: text, none, bar, dot.")
group_general.add_option("-v", "--version", dest="show_version",
default=False, action="store_true", help="show the current " \
+ "version of PyCAM and exit")
# export options
group_export.add_option("", "--export-gcode", dest="export_gcode",
default=None, action="store", type="string",
help="export the generated toolpaths to a file")
group_export.add_option("", "--export-task-config",
dest="export_task_config", default=None, action="store",
type="string",
help="export the current task configuration (mainly for debugging)")
# tool options
group_tool.add_option("", "--tool-shape", dest="tool_shape",
default="cylindrical", action="store", type="choice",
choices=["cylindrical", "spherical", "toroidal"],
help="tool shape for the operation (cylindrical, spherical, " \
+ "toroidal)")
group_tool.add_option("", "--tool-size", dest="tool_diameter",
default=1.0, action="store", type="float",
help="diameter of the tool")
group_tool.add_option("", "--tool-torus-size", dest="tool_torus_diameter",
default=0.25, action="store", type="float",
help="torus diameter of the tool (only for toroidal tool shape)")
group_tool.add_option("", "--tool-feedrate", dest="tool_feedrate",
default=1000, action="store", type="float",
help="allowed movement velocity of the tool (units/minute)")
group_tool.add_option("", "--tool-spindle-speed", dest="tool_spindle_speed",
default=250, action="store", type="float",
help="rotation speed of the tool (per minute)")
group_tool.add_option("", "--tool-id", dest="tool_id",
default=1, action="store", type="int",
help="tool ID - to be used for tool selection via GCode " \
+ "(default: 1)")
# process options
group_process.add_option("", "--process-path-direction",
dest="process_path_direction", default="x", action="store",
type="choice", choices=["x", "y", "xy"],
help="primary direction of the generated toolpath (x/y/xy)")
group_process.add_option("", "--process-path-generator",
dest="process_path_generator", default="layer", action="store",
type="choice", choices=["layer", "surface", "engrave"],
help="one of the available toolpath strategies (layer, surface, " \
+ "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",
dest="process_material_allowance", default=0.0, action="store",
type="float", help="minimum distance between the tool and the " \
+ "object (for rough processing)")
group_process.add_option("", "--process-step-down",
dest="process_step_down", default=3.0, action="store", type="float",
help="the maximum thickness of each processed material layer " \
+ "(only for 'layer' strategy)")
group_process.add_option("", "--process-overlap-percent",
dest="process_overlap_percent", default=0, action="store",
type="int", help="how much should two adjacent parallel " \
+ "toolpaths overlap each other (0..99)")
group_process.add_option("", "--safety-height", dest="safety_height",
default=25.0, action="store", type="float",
help="height for safe re-positioning moves")
group_process.add_option("", "--process-engrave-offset",
dest="process_engrave_offset", default=0.0, action="store",
type="float", help="engrave along the contour of a model with a " \
+ "given distance (only for 'engrave' strategy)")
# bounds settings
group_bounds.add_option("", "--bounds-type", dest="bounds_type",
default="fixed-margin", action="store", type="choice",
choices=["relative-margin", "fixed-margin", "custom"],
help="type of the boundary definition (relative-margin, " \
+ "fixed-margin, custom)")
group_bounds.add_option("", "--bounds-lower", dest="bounds_lower",
default="", action="store", type="string",
help="comma-separated x/y/z combination of the lower boundary " \
+ "(e.g. '4,4,-0.5')")
group_bounds.add_option("", "--bounds-upper", dest="bounds_upper",
default="", action="store", type="string",
help="comma-separated x/y/z combination of the upper boundary " \
+ "(e.g. '12,5.5,0')")
# support grid settings
group_support_grid.add_option("", "--enable-support-grid",
dest="support_grid_enabled", default=False, action="store_true",
help="enable the support grid")
group_support_grid.add_option("", "--support-grid-distance-x",
dest="support_grid_distance_x", default=10.0, action="store",
type="float", help="distance along the x-axis between two " \
+ "adjacent parallel lines of the support grid pattern")
group_support_grid.add_option("", "--support-grid-distance-y",
dest="support_grid_distance_y", default=10.0, action="store",
type="float", help="distance along the y-axis between two " \
+ "adjacent parallel lines of the support grid pattern")
group_support_grid.add_option("", "--support-grid-height",
dest="support_grid_height", default=2.0, action="store",
type="float", help="height of the support grid profile")
group_support_grid.add_option("", "--support-grid-thickness",
dest="support_grid_thickness", default=0.5, action="store",
type="float", help="width of the support grid profile")
# gcode options
group_gcode.add_option("", "--gcode-no-start-stop-spindle",
dest="gcode_no_start_stop_spindle", default=True,
action="store_false", help="do not start the spindle before " \
+ "and stop it after each operation (M3/M5)")
group_gcode.add_option("", "--gcode-path-mode", dest="gcode_path_mode",
default="exact_path", action="store", type="choice",
choices=["exact_path", "exact_stop", "continuous"],
help="choose the GCode path mode from 'exact_path', 'exact_stop'" \
+ "and 'continuous'. See " \
+ "http://linuxcnc.org/docs/html/gcode_main.html for details")
group_gcode.add_option("", "--gcode-motion-tolerance",
dest="gcode_motion_tolerance", default=None,
action="store", help="the optional motion tolerance for " \
+ "'continuous' path mode (G64).")
group_gcode.add_option("", "--gcode-naive-tolerance",
dest="gcode_naive_tolerance", default=None,
action="store", help="the optional naive CAM tolerance for " \
+ "'continuous' path mode (G64).")
# external program settings
group_external_programs.add_option("", "--location-inkscape",
dest="external_program_inkscape", default="", action="store",
type="string", help="location of the Inkscape executable. " \
+ "This program is required for importing SVG files.")
group_external_programs.add_option("", "--location-pstoedit",
dest="external_program_pstoedit", default="", action="store",
type="string", help="location of the PStoEdit executable. " \
+ "This program is required for importing SVG files.")
(opts, args) = parser.parse_args()
def execute(opts, args):
if len(args) > 0:
inputfile = os.path.expanduser(args[0])
else:
......@@ -546,3 +342,217 @@ if __name__ == "__main__":
print >>handler, tps.get_string()
closer()
# define the commandline interface
if __name__ == "__main__":
parser = OptionParser(prog="PyCAM",
usage="usage: pycam [options] [inputfile]\n\n" \
+ "Start the PyCAM toolpath generator. Supplying one of " \
+ "the '--export-?' parameters will cause PyCAM to start " \
+ "in batch mode. Most parameters are useful only for " \
+ "batch mode.",
epilog="Take a look at the wiki for more information: " \
+ "http://sourceforge.net/apps/mediawiki/pycam/.\n" \
+ "Bug reports: http://sourceforge.net/tracker/?group_id=237831&atid=1104176")
group_general = parser.add_option_group("General options")
group_export = parser.add_option_group("Export formats",
"Export the resulting toolpath or meta-data in various formats. " \
+ "These options trigger the non-interactive mode. Thus the GUI " \
+ "is disabled.")
group_tool = parser.add_option_group("Tool definition",
"Specify the tool paramters. The default tool is spherical and " \
+ "has a diameter of 1 unit. The default speeds are 1000 " \
+ "units/minute (feedrate) and 250 (spindle rotations per minute)")
group_process = parser.add_option_group("Process definition",
"Specify the process parameters: toolpath strategy, layer height," \
+ " and others. A typical roughing operation is configured by " \
+ "default.")
group_bounds = parser.add_option_group("Boundary definition",
"Specify the outer limits of the processing area (x/y/z). " \
+ "You may choose between 'relative_margin' (margin is given as " \
+ "percentage of the respective model dimension), 'fixed_margin' " \
+ "(margin for each face given in absolute units of length) " \
+ "and 'custom' (absolute coordinates of the bounding box - " \
+ "regardless of the model size and position). Negative values " \
+ "are allowed and can make sense (e.g. negative margin).")
group_support_grid = parser.add_option_group("Support grid",
"An optional support grid can be used to keep the object in " \
+ "place during the mill operation. The support grid can be " \
+ "removed manually afterwards. The support grid can have a " \
+ "rectangular profile. By default the support grid is disabled.")
group_gcode = parser.add_option_group("GCode settings",
"Specify some details of the generated GCode.")
group_external_programs = parser.add_option_group("External programs",
"Some optional external programs are used for format conversions.")
# general options
group_general.add_option("-c", "--config", dest="config_file",
default=None, action="store", type="string",
help="load a task settings file")
group_general.add_option("", "--unit", dest="unit_size",
default="mm", action="store", type="choice",
choices=["mm", "inch"], help="choose 'mm' or 'inch' for all " \
+ "numbers. By default 'mm' is assumed.")
group_general.add_option("", "--collision-engine", dest="collision_engine",
default="triangles", action="store", type="choice",
choices=["triangles", "ode"],
help="choose a specific collision detection engine. The default " \
+ "is 'triangles'. Use 'help' to get a list of possible " \
+ "engines.")
group_general.add_option("", "--boundary-mode", dest="boundary_mode",
default="along", action="store", type="choice",
choices=["inside", "along", "outside"],
help="specify if the mill tool (including its radius) should " \
+ "move completely 'inside', 'along' or 'outside' the " \
+ "defined processing boundary.")
group_general.add_option("", "--disable-psyco", dest="disable_psyco",
default=False, action="store_true", help="disable the Psyco " \
+ "just-in-time-compiler even when it is available")
group_general.add_option("-q", "--quiet", dest="quiet",
default=False, action="store_true", help="show only warnings and " \
+ "errors.")
group_general.add_option("-d", "--debug", dest="debug",
default=False, action="store_true", help="enable output of debug " \
+ "messages.")
group_general.add_option("", "--progress", dest="progress",
default="text", action="store", type="choice",
choices=["none", "text", "bar", "dot"],
help="specify the type of progress bar used in non-GUI mode. " \
+ "The following options are available: text, none, bar, dot.")
group_general.add_option("", "--profiling", dest="profile_destination",
action="store", type="string",
help="store profiling statistics in a file (only for debugging)")
group_general.add_option("-v", "--version", dest="show_version",
default=False, action="store_true", help="show the current " \
+ "version of PyCAM and exit")
# export options
group_export.add_option("", "--export-gcode", dest="export_gcode",
default=None, action="store", type="string",
help="export the generated toolpaths to a file")
group_export.add_option("", "--export-task-config",
dest="export_task_config", default=None, action="store",
type="string",
help="export the current task configuration (mainly for debugging)")
# tool options
group_tool.add_option("", "--tool-shape", dest="tool_shape",
default="cylindrical", action="store", type="choice",
choices=["cylindrical", "spherical", "toroidal"],
help="tool shape for the operation (cylindrical, spherical, " \
+ "toroidal)")
group_tool.add_option("", "--tool-size", dest="tool_diameter",
default=1.0, action="store", type="float",
help="diameter of the tool")
group_tool.add_option("", "--tool-torus-size", dest="tool_torus_diameter",
default=0.25, action="store", type="float",
help="torus diameter of the tool (only for toroidal tool shape)")
group_tool.add_option("", "--tool-feedrate", dest="tool_feedrate",
default=1000, action="store", type="float",
help="allowed movement velocity of the tool (units/minute)")
group_tool.add_option("", "--tool-spindle-speed", dest="tool_spindle_speed",
default=250, action="store", type="float",
help="rotation speed of the tool (per minute)")
group_tool.add_option("", "--tool-id", dest="tool_id",
default=1, action="store", type="int",
help="tool ID - to be used for tool selection via GCode " \
+ "(default: 1)")
# process options
group_process.add_option("", "--process-path-direction",
dest="process_path_direction", default="x", action="store",
type="choice", choices=["x", "y", "xy"],
help="primary direction of the generated toolpath (x/y/xy)")
group_process.add_option("", "--process-path-generator",
dest="process_path_generator", default="layer", action="store",
type="choice", choices=["layer", "surface", "engrave"],
help="one of the available toolpath strategies (layer, surface, " \
+ "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",
dest="process_material_allowance", default=0.0, action="store",
type="float", help="minimum distance between the tool and the " \
+ "object (for rough processing)")
group_process.add_option("", "--process-step-down",
dest="process_step_down", default=3.0, action="store", type="float",
help="the maximum thickness of each processed material layer " \
+ "(only for 'layer' strategy)")
group_process.add_option("", "--process-overlap-percent",
dest="process_overlap_percent", default=0, action="store",
type="int", help="how much should two adjacent parallel " \
+ "toolpaths overlap each other (0..99)")
group_process.add_option("", "--safety-height", dest="safety_height",
default=25.0, action="store", type="float",
help="height for safe re-positioning moves")
group_process.add_option("", "--process-engrave-offset",
dest="process_engrave_offset", default=0.0, action="store",
type="float", help="engrave along the contour of a model with a " \
+ "given distance (only for 'engrave' strategy)")
# bounds settings
group_bounds.add_option("", "--bounds-type", dest="bounds_type",
default="fixed-margin", action="store", type="choice",
choices=["relative-margin", "fixed-margin", "custom"],
help="type of the boundary definition (relative-margin, " \
+ "fixed-margin, custom)")
group_bounds.add_option("", "--bounds-lower", dest="bounds_lower",
default="", action="store", type="string",
help="comma-separated x/y/z combination of the lower boundary " \
+ "(e.g. '4,4,-0.5')")
group_bounds.add_option("", "--bounds-upper", dest="bounds_upper",
default="", action="store", type="string",
help="comma-separated x/y/z combination of the upper boundary " \
+ "(e.g. '12,5.5,0')")
# support grid settings
group_support_grid.add_option("", "--enable-support-grid",
dest="support_grid_enabled", default=False, action="store_true",
help="enable the support grid")
group_support_grid.add_option("", "--support-grid-distance-x",
dest="support_grid_distance_x", default=10.0, action="store",
type="float", help="distance along the x-axis between two " \
+ "adjacent parallel lines of the support grid pattern")
group_support_grid.add_option("", "--support-grid-distance-y",
dest="support_grid_distance_y", default=10.0, action="store",
type="float", help="distance along the y-axis between two " \
+ "adjacent parallel lines of the support grid pattern")
group_support_grid.add_option("", "--support-grid-height",
dest="support_grid_height", default=2.0, action="store",
type="float", help="height of the support grid profile")
group_support_grid.add_option("", "--support-grid-thickness",
dest="support_grid_thickness", default=0.5, action="store",
type="float", help="width of the support grid profile")
# gcode options
group_gcode.add_option("", "--gcode-no-start-stop-spindle",
dest="gcode_no_start_stop_spindle", default=True,
action="store_false", help="do not start the spindle before " \
+ "and stop it after each operation (M3/M5)")
group_gcode.add_option("", "--gcode-path-mode", dest="gcode_path_mode",
default="exact_path", action="store", type="choice",
choices=["exact_path", "exact_stop", "continuous"],
help="choose the GCode path mode from 'exact_path', 'exact_stop'" \
+ "and 'continuous'. See " \
+ "http://linuxcnc.org/docs/html/gcode_main.html for details")
group_gcode.add_option("", "--gcode-motion-tolerance",
dest="gcode_motion_tolerance", default=None,
action="store", help="the optional motion tolerance for " \
+ "'continuous' path mode (G64).")
group_gcode.add_option("", "--gcode-naive-tolerance",
dest="gcode_naive_tolerance", default=None,
action="store", help="the optional naive CAM tolerance for " \
+ "'continuous' path mode (G64).")
# external program settings
group_external_programs.add_option("", "--location-inkscape",
dest="external_program_inkscape", default="", action="store",
type="string", help="location of the Inkscape executable. " \
+ "This program is required for importing SVG files.")
group_external_programs.add_option("", "--location-pstoedit",
dest="external_program_pstoedit", default="", action="store",
type="string", help="location of the PStoEdit executable. " \
+ "This program is required for importing SVG files.")
(opts, args) = parser.parse_args()
if opts.profile_destination:
import cProfile
cProfile.run('execute(opts, args)', opts.profile_destination)
else:
execute(opts, args)
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