CAM Custom
CAM Custom
- Menu location
-
- Workbenches
- Default shortcut
-
None
- Introduced in version
-
-
- See also
Description
The CAM Custom command inserts an Operation which is built from hand coded custom G-code.
The Custom operation is a regular Operation with a Tool Controller and coolant mode; the Post-Processor emits the tool change and spindle commands for the selected Tool Controller before the custom G-code. Only write M6/M3 codes yourself if the snippet must use a different tool or spindle setting than the Tool Controller.
Note that feed rates (F words) in custom G-code are interpreted in FreeCAD’s internal units, millimetres per second, and are converted to the machine units by the Post-Processor (see the note in Inspect Toolpath).
Usage
-
Select . The command is not on any toolbar; a Job must exist in the document.
-
In the task panel choose the G-code source and type or load the G-code. Refer to the CAM scripting page for supported G-code commands.
-
Select the Tool Controller and press OK.
Task panel
-
G-code source:
Textto type the G-code in the editor below, orFileto read it from a file. introduced in 26.3 -
Editor: one G-code command per line; line numbers are displayed. introduced in 26.3
-
File name and …: path of the G-code file (relative paths are resolved against the document’s folder). introduced in 26.3
-
Tool Controller tab: Tool Controller and coolant mode used for this Operation.
Expressions
introduced in 26.3: an expression can be embedded anywhere in a line by enclosing it in double curly braces, for example G0 Z{{VarSet.HeightZ.Value+5}} or G0 X{{Profile.Path.Commands[3].x}} Y{{Profile.Path.Commands[3].y}}. The expression is evaluated in the context of the Custom object each recompute; if it cannot be evaluated, a warning with the line number is printed and the toolpath is cleared.
Error handling
The generated toolpath is wrapped in the comments (Begin Custom) and (End Custom). Lines that cannot be parsed as G-code are skipped and reported in the Report view with their line numbers. Blank lines are allowed. introduced in 26.3: lines from the Text source (not from a file) are marked as allowed-unsupported so that non-standard codes pass through to the Post-Processor unchanged.
Properties
-
Source (
Enumeration): Source of the G-code:Text(default) orFile. introduced in 26.3 -
Gcode (
StringList): The G-code to be inserted, one command per entry (only visible for Source =Text). -
GcodeFile (
File): File containing the G-code to be inserted (only visible for Source =File). introduced in 26.3 -
ToolController (
Link), CoolantMode (Enumeration), Active (Bool), Comment (String), UserLabel (String), CycleTime (String): standard Operation properties from the operation base.
Notes
-
Simple Copy creates a Custom operation pre-filled with the G-code of the copied Operations, so the copy can be edited with this task panel.
Scripting
See also: FreeCAD Scripting Basics.
Example:
import Path.Op.Custom
obj = Path.Op.Custom.Create("Custom", parentJob=job)
obj.Gcode = ["G0 Z10", "G0 X0 Y0"]
obj.ToolController = job.Tools.Group[0]
FreeCAD.ActiveDocument.recompute()