| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | """Postprocessor to output real GCode for Max Computer GmbH nccad9.""" |
| | import FreeCAD |
| | import Path.Post.Utils as PostUtils |
| | import PathScripts.PathUtils as PathUtils |
| | import datetime |
| |
|
| |
|
| | TOOLTIP = """ |
| | This is a postprocessor file for the Path workbench. It is used to take |
| | a pseudo-G-code fragment output by a Path object and output real G-code |
| | suitable for the Max Computer GmbH nccad9 Computer Numeric Control. |
| | |
| | Supported features: |
| | |
| | - 3-axis milling |
| | - manual tool change with tool number as comment |
| | - spindle speed as comment |
| | |
| | !!! gCode files must use the suffix .knc !!! |
| | |
| | import nccad_post |
| | nccad_post.export([object], "/path/to/file.knc", "") |
| | """ |
| |
|
| | MACHINE_NAME = """Max Computer GmbH nccad9 MCS/KOSY""" |
| |
|
| | |
| | |
| | TOOL_CHANGE = """G77 ; Move to release position |
| | M10 O6.0 ; Stop spindle |
| | M01 Insert tool TOOL |
| | G76 ; Move to reference point to ensure correct coordinates after tool change |
| | M10 O6.1 ; Start spindle""" |
| |
|
| |
|
| | |
| | POSTAMBLE = """G77 ; Move to release position |
| | M10 O6.0 ; Stop spindle""" |
| |
|
| |
|
| | |
| | |
| | if FreeCAD.ActiveDocument: |
| | cam_file = FreeCAD.ActiveDocument.FileName |
| | else: |
| | cam_file = "<None>" |
| |
|
| | HEADER = """;Exported by FreeCAD |
| | ;Post Processor: {} |
| | ;CAM file: {} |
| | ;Output Time: {} |
| | """.format( |
| | __name__, cam_file, str(datetime.datetime.now()) |
| | ) |
| |
|
| |
|
| | def export(objectslist, filename, argstring): |
| | """Export the list of objects into a filename. |
| | |
| | Parameters |
| | ---------- |
| | objectslists: list |
| | List of objects. |
| | |
| | filename: str |
| | Name of the output file ending in `'.knc'`. |
| | """ |
| | gcode = HEADER |
| |
|
| | for obj in objectslist: |
| | for command in PathUtils.getPathWithPlacement(obj).Commands: |
| | |
| | if "M6" == command.Name: |
| | gcode += TOOL_CHANGE.replace("TOOL", str(int(command.Parameters["T"]))) |
| | elif "M3" == command.Name: |
| | |
| | gcode += ( |
| | "M01 Set spindle speed to " |
| | + str(int(command.Parameters["S"])) |
| | + " rounds per minute" |
| | ) |
| | else: |
| | |
| | gcode += command.Name |
| |
|
| | |
| | for parameter, value in command.Parameters.items(): |
| | |
| | |
| | if "F" == parameter: |
| | value *= 10 |
| | |
| | |
| | gcode += " " + parameter + str(round(value, 5)) |
| |
|
| | gcode += "\n" |
| |
|
| | gcode += POSTAMBLE + "\n" |
| |
|
| | |
| | if FreeCAD.GuiUp: |
| | dia = PostUtils.GCodeEditorDialog() |
| | dia.editor.setPlainText(gcode) |
| | result = dia.exec_() |
| | if result: |
| | gcode = dia.editor.toPlainText() |
| |
|
| | |
| | if filename != "-": |
| | gfile = open(filename, "w") |
| | gfile.write(gcode) |
| | gfile.close() |
| |
|
| | return filename |
| |
|