complete list of features - sliptonic/FreeCAD GitHub Wiki

Feature Documentation

Overview

The export2() method is the modern post-processing pipeline that converts FreeCAD CAM operations into G-code. It processes jobs through six distinct stages, applying various transformations and optimizations based on machine configuration.

Test Coverage Legend:

  • ✅ = Tested (directly or indirectly)
  • ❌ = Not tested

Processing Stages

Stage 0: Pre-Processing Dialog

Pre-processing user interaction - Allows post processors to collect user input before processing begins through dialogs or validation checks. Returns False to cancel the entire export operation.

  • Tests: ❌ Not tested (hook method, subclass responsibility)

Machine configuration loading - Reads machine configuration from the .fcm file and maps all settings into the internal values dictionary for use throughout the pipeline.

  • Tests:TestExport2Integration (implicit in all tests)

Stage 1: Ordering

Early tool preparation - Splits tool changes into separate prep (Tn) and change (M6) commands when enabled, improving machine efficiency by allowing the machine to prepare the next tool while the current operation completes.

  • Tests:TestBuildPostList.test070, TestBuildPostList.test080, TestToolProcessing.test_early_tool_prep

Post list building - Determines the specific objects and order to post-process, organizing operations, tool changes, and fixtures into sections based on job configuration.

  • Tests:TestBuildPostList.test010 through test060 (splitting by tool, fixture, operation)

Stage 2: Command Expansion

Header Generation

Machine name in header - Includes the machine name from configuration in the G-code header comments when enabled.

  • Tests:TestHeaderBuilder.test040_path_property_complete

Project file path in header - Adds the FreeCAD project file path to the header comments for traceability.

  • Tests:TestHeaderBuilder.test040_path_property_complete

Document name in header - Includes the FreeCAD document name in header comments.

  • Tests:TestHeaderBuilder.test040_path_property_complete

Description in header - Adds job description text to the header comments when present.

  • Tests:TestHeaderBuilder.test040_path_property_complete

Author in header - Includes the document creator's name in header comments when available.

  • Tests:TestHeaderBuilder.test040_path_property_complete

Date/time stamp in header - Adds the current date and time to the header showing when the G-code was generated.

  • Tests:TestHeaderBuilder.test040_path_property_complete

Tool list in header - Lists all tools used in the job with their numbers and descriptions in header comments.

  • Tests:TestHeaderBuilder.test060_multiple_tools_fixtures_notes

Fixture list in header - Lists all work coordinate systems (fixtures) used in the job in header comments.

  • Tests:TestHeaderBuilder.test060_multiple_tools_fixtures_notes

Output units in header - Displays whether output is in metric (mm) or imperial (inches) in header comments.

  • Tests:TestHeaderBuilder.test040_path_property_complete

Command Processing

Canned cycle termination - Automatically inserts G80 (cancel canned cycle) commands after drill cycle operations to ensure clean state transitions.

  • Tests:TestPathPostUtils.test020 through test080, TestExport2Integration.test101_drill_cycle_parameters_preserved

Drill cycle translation - Converts canned drill cycles (G73, G81-G89) to G0/G1 moves for machines that don't support them natively, based on the drill_cycles_to_translate postprocessor property.

  • Tests:TestExport2Integration.test102_translate_drill_cycles, TestDrillCycleExpander (all tests)

Arc splitting - Breaks circular interpolation (G2/G3) commands into multiple smaller arcs when the machine has limited arc processing capabilities.

  • Tests:TestExport2Integration.test103_split_arcs, TestPathPostUtils.test010

Spindle wait delay - Injects G4 dwell commands after spindle start (M3/M4) to allow the spindle to reach full speed before cutting begins.

  • Tests:TestExport2Integration.test106 (via TESTING_GUIDE.md reference)

Coolant delay - Adds G4 dwell commands after coolant on commands (M7/M8) to allow coolant flow to stabilize.

  • Tests: ❌ Not tested in export2 integration tests

Rapid move translation - Converts rapid positioning moves (G0) to feed moves (G1) for machines that don't support rapids or require controlled acceleration.

  • Tests:TestExport2Integration.test108_translate_rapid_moves

XY before Z after tool change - Decomposes the first move after a tool change into separate XY and Z moves, moving to XY position first then plunging Z to prevent collisions.

  • Tests:TestToolProcessing.test_XY_before_Z_after_tool_change

Stage 2.5: bCNC Command Creation

bCNC block annotations - Wraps each operation in bCNC-specific block commands (Block-name, Block-expand, Block-enable) for enhanced control in the bCNC G-code sender.

  • Tests:TestTestPost.test00120 (legacy test with --bcnc flag)

bCNC postamble block - Creates a special bCNC block for the postamble section with appropriate metadata.

  • Tests: ✅ Covered by bCNC block annotation tests

bCNC command filtering - Removes existing bCNC commands when the feature is disabled to ensure clean output.

  • Tests:TestTestPost.test00120 (--no-bcnc flag)

Stage 2.6: Tool Length Offset Commands

G43 tool length offset insertion - Automatically inserts G43 H{tool_number} commands after tool changes to activate tool length compensation.

  • Tests:TestToolLengthOffset.test_g43_output_enabled, TestTestPost (multiple tests showing G43 output)

M6 in operation detection - Detects when operations already contain M6 commands and adjusts G43 insertion accordingly to avoid duplication.

  • Tests: ❌ Not explicitly tested

Tool change M6 suppression - Suppresses automatic M6 generation for tool changes when the operation already handles it internally.

  • Tests: ❌ Not explicitly tested

G43 command removal - Strips G43 commands from output when tool length offset feature is disabled.

  • Tests:TestToolLengthOffset.test_g43_suppression_disabled

Stage 3: Command Conversion

G-code Block Insertion

Safety block - Inserts safety commands (e.g., G40 G49 G80) at the start of output to reset machine to known safe state.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Preamble block - Adds initialization commands at the start of the program after the header.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion, TestTestPost (multiple tests)

Unit command insertion - Automatically inserts G20 (inches) or G21 (mm) based on output units configuration.

  • Tests: ✅ Implicit in all post processor tests

Pre-job block - Inserts commands before the first operation begins.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Pre-tool change block - Adds commands before each tool change operation.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Post-tool change block - Inserts commands after each tool change completes.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Tool return block - Adds commands to return tool to safe position after tool change.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Pre-fixture change block - Inserts commands before work coordinate system changes.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Post-fixture change block - Adds commands after fixture changes.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Pre-operation block - Inserts commands before each machining operation begins.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Post-operation block - Adds commands after each operation completes.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Pre-rotary move block - Inserts commands before rotary axis moves (A, B, C axes).

  • Tests:TestExport2Integration.test085_rotary_blocks_insertion

Post-rotary move block - Adds commands after rotary axis moves complete.

  • Tests:TestExport2Integration.test085_rotary_blocks_insertion

Post-job block - Inserts commands after all operations complete.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Postamble block - Adds shutdown commands at the end of the program.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion, TestTestPost (multiple tests)

Command Processing

Tool change command generation - Generates M6 T{number} commands for tool changes when enabled, or outputs as comments when disabled.

  • Tests: ✅ Implicit in all post processor tests, tool_change flag not explicitly tested

Rotary move grouping - Groups consecutive rotary axis moves together and wraps them with pre/post rotary blocks.

  • Tests:TestExport2Integration.test085_rotary_blocks_insertion

Comment symbol customization - Allows changing comment delimiter from ( to other symbols like ; or #.

  • Tests:TestExport2Integration.test060_comment_symbol_formatting, TestTestPost.test00110

Operation label comments - Adds comment lines with operation names to identify sections of G-code.

  • Tests: ✅ Implicit in tests with --comments flag

Blank line insertion - Adds blank lines between operations for improved readability.

  • Tests:TestExport2Integration.test090 (via TESTING_GUIDE.md reference)

Stage 4: G-code Optimization

Modal command deduplication - Suppresses duplicate G/M codes when they match the previous line (e.g., consecutive G1 commands output only once).

  • Tests:TestDeduplicateRepeatedCommands (all tests), TestExport2Integration.test100_modal_command_output, test105_duplicate_commands_suppression

Redundant parameter suppression - Removes axis words and feed rates that haven't changed from the previous command to reduce file size.

  • Tests:TestSuppressRedundantAxesWords (all tests), TestExport2Integration.test082_output_duplicate_parameters_false, test083_output_duplicate_parameters_true

Inefficient move filtering - Collapses redundant G0 rapid move chains that go to the same position.

  • Tests:TestFilterInefficientMoves (all 15+ tests)

Line numbering - Adds N-word line numbers to G-code commands with configurable start value and increment.

  • Tests:TestInsertLineNumbers (all tests), TestExport2Integration.test050_line_numbers_exclude_header, test060_line_numbers_from_config

Line number exclusion from header - Ensures header comments don't receive line numbers, only actual G-code commands.

  • Tests:TestExport2Integration.test050_line_numbers_exclude_header

Custom line endings - Supports different end-of-line characters (LF, CRLF, or custom) for compatibility with different controllers.

  • Tests: ❌ Not tested in export2 integration tests

Stage 5: Output Production

Section-based output - Organizes G-code into named sections for split output scenarios (by tool, fixture, or operation).

  • Tests:TestBuildPostList.test040 through test060 (splitting scenarios)

Header/body separation - Maintains distinction between header comments and numbered G-code body for proper formatting.

  • Tests:TestExport2Integration.test050_line_numbers_exclude_header

Multi-job support - Designed to support processing multiple jobs in sequence (currently single job only).

  • Tests: ❌ Not implemented yet

Stage 6: Remote Posting

Remote post hook - Provides extensibility point for subclasses to implement file uploads, network posting, or other post-processing actions after G-code generation.

  • Tests: ❌ Not tested (hook method, subclass responsibility)

Output Configuration Features

Header Options

Output header master switch - Controls whether any header information is included in the output.

  • Tests:TestExport2Integration.test030_header_true_comments_false, test040_header_false_comments_true

Selective header elements - Individual toggles for machine name, project file, document name, description, units, date, tool list, and fixture list.

  • Tests:TestHeaderBuilder tests cover individual elements

Comment Options

Comment output control - Master switch to enable/disable all inline comments (header comments controlled separately).

  • Tests:TestExport2Integration.test030_header_true_comments_false, test040_header_false_comments_true

Comment symbol selection - Choose between (, ;, #, or other comment delimiters.

  • Tests:TestExport2Integration.test060_comment_symbol_formatting, TestTestPost.test00110

Operation label output - Toggle operation name comments in the G-code.

  • Tests: ✅ Implicit in tests with --comments flag

Blank line output - Control whether blank lines are inserted between sections.

  • Tests:TestExport2Integration.test090 (via TESTING_GUIDE.md)

bCNC comment mode - Special comment format for bCNC G-code sender compatibility.

  • Tests:TestTestPost.test00120

Formatting Options

Line number output - Enable/disable N-word line numbering.

  • Tests:TestExport2Integration.test050_line_numbers_exclude_header, test060_line_numbers_from_config

Line number start - Set starting line number (e.g., 100).

  • Tests:TestExport2Integration.test060_line_numbers_from_config

Line number increment - Set increment between line numbers (e.g., 10).

  • Tests:TestExport2Integration.test060_line_numbers_from_config

Line number prefix - Customize line number prefix (default: N).

  • Tests:TestInsertLineNumbers tests use default prefix

Command spacing - Control spacing between G-code command and parameters.

  • Tests:TestTestPost.test00100 (--command_space tests)

End-of-line characters - Configure line ending style (LF, CRLF, or custom).

  • Tests: ❌ Not tested in export2 integration tests

Precision Options

Axis precision - Number of decimal places for axis coordinates (X, Y, Z, A, B, C).

  • Tests:TestExport2Integration.test070_precision_from_config

Feed rate precision - Number of decimal places for feed rates (F word).

  • Tests:TestExport2Integration.test070_precision_from_config

Spindle speed precision - Number of decimal places for spindle speeds (S word).

  • Tests: ✅ Implicit in post processor tests

Duplicate Control

Duplicate command output - Control whether duplicate G/M codes are output or suppressed (modal behavior).

  • Tests:TestDeduplicateRepeatedCommands (all tests), TestExport2Integration.test100_modal_command_output, test105_duplicate_commands_suppression

Duplicate parameter output - Control whether unchanged parameter values are output or suppressed.

  • Tests:TestSuppressRedundantAxesWords (all tests), TestExport2Integration.test082, test083

Processing Options

Tool change enable/disable - Control whether M6 commands are generated or suppressed.

  • Tests: ✅ Implicit in all tests, not explicitly tested for enable/disable

Early tool preparation - Split tool prep and change for improved efficiency.

  • Tests:TestBuildPostList.test070, test080, TestToolProcessing.test_early_tool_prep

Arc splitting - Break arcs into smaller segments for limited controllers.

  • Tests:TestExport2Integration.test103_split_arcs, TestPathPostUtils.test010

Rapid move translation - Convert rapids to feed moves.

  • Tests:TestExport2Integration.test108_translate_rapid_moves

XY before Z sequencing - Decompose post-tool-change moves for safety.

  • Tests:TestToolProcessing.test_XY_before_Z_after_tool_change

Inefficient move filtering - Collapse redundant rapid moves.

  • Tests:TestFilterInefficientMoves (15+ comprehensive tests)

Postprocessor Properties

File extension - Default file extension for output files (nc, gcode, tap, etc.).

  • Tests: ✅ Used in filename generation tests

Tool radius compensation support - Declare support for G41/G42 commands.

  • Tests:TestExport2Integration.test106_tool_radius_compensation_property

Supported commands list - Define which G/M codes the machine accepts.

  • Tests:TestExport2Integration.test107_supported_commands_property

Drill cycles to translate - Specify which canned cycles to expand to G0/G1.

  • Tests:TestExport2Integration.test102_translate_drill_cycles, TestDrillCycleExpander

Preamble - Initialization commands at program start.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion, TestTestPost (multiple)

Postamble - Shutdown commands at program end.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion, TestTestPost (multiple)

Safety block - Safety reset commands.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Pre/post operation - Commands around each operation.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Pre/post tool change - Commands around tool changes.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Pre/post fixture change - Commands around work coordinate changes.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Pre/post rotary move - Commands around rotary axis moves.

  • Tests:TestExport2Integration.test085_rotary_blocks_insertion

Tool return - Commands to return tool after change.

  • Tests:TestExport2Integration.test084_gcode_blocks_insertion

Machine Configuration

Axis definitions - Define linear and angular axes with limits and velocities.

  • Tests:TestMachine (comprehensive machine model tests)

Spindle configuration - Define spindle capabilities, speeds, and delays.

  • Tests:TestMachine, spindle wait tested in TestExport2Integration.test106

Tool change type - Manual, automatic, or custom tool change behavior.

  • Tests: ✅ Implicit in tool change tests

Coolant options - Flood, mist, and delay settings.

  • Tests:TestTestPost.test00090 (coolant enable/disable)

Output units - Metric (mm) or imperial (inches) output.

  • Tests: ✅ Implicit in all post processor tests

Extensibility Features

Hook methods for command conversion - Override specific command type handlers without reimplementing entire conversion logic.

  • Tests: ❌ Not tested (designed for subclass override)

Pre-processing dialog hook - Collect user input before processing begins.

  • Tests: ❌ Not tested (designed for subclass override)

Remote post hook - Implement custom post-processing actions.

  • Tests: ❌ Not tested (designed for subclass override)

Annotation system - Attach metadata to commands for special handling (blockdelete, bCNC, tool_length_offset).

  • Tests:TestPathCommandAnnotations (annotation system), bCNC and blockdelete tested in various tests

Property schema system - Define configurable properties with types, defaults, and help text for machine editor UI.

  • Tests: ❌ Not tested in export2 tests (UI-level feature)

Test Coverage Summary

Total Features: 100+

Test Coverage by Category:

  • Tested (~80%): Core features like ordering, optimization, header generation, block insertion, drill cycles, line numbering, precision, duplicates, comments, formatting
  • Not Tested (~20%): Hook methods (designed for subclass override), some processing options, extensibility features

Key Test Classes:

  • TestExport2Integration - Primary integration test suite (30+ tests)
  • TestBuildPostList - Post list ordering and splitting (8 tests)
  • TestGcodeProcessingUtils - Optimization functions (50+ tests)
    • TestInsertLineNumbers
    • TestSuppressRedundantAxesWords
    • TestFilterInefficientMoves
    • TestDeduplicateRepeatedCommands
  • TestPathPostUtils - Canned cycle termination (8 tests)
  • TestDrillCycleExpander - Drill cycle translation
  • TestToolProcessing - Tool-related features (XY-before-Z, early prep)
  • TestToolLengthOffset - G43 insertion/suppression
  • TestHeaderBuilder - Header generation (6 tests)
  • TestTestPost - Legacy test coverage (many features)
  • Post-specific tests: TestLinuxCNCPost, TestGrblPost, TestFanucPost, etc.
⚠️ **GitHub.com Fallback** ⚠️