How to Bind Shortcuts to Custom FreeCAD Macros

Assigning keyboard shortcuts to custom macros in FreeCAD allows you to automate repetitive modeling tasks and trigger custom Python scripts with a single keystroke. This process involves using FreeCAD's built-in customization settings to register the macro as an accessible GUI command and then binding that command to your preferred key combination. Below is a direct, step-by-step guide to setting up your custom shortcut.

Step 1: Open the Customize Window

  1. Launch FreeCAD.
  2. In the top navigation menu, click on Tools.
  3. Select Customize... from the dropdown menu to open the customization dialog.

Step 2: Register the Macro as a Command

Before FreeCAD can assign a keyboard shortcut to a script, the macro must be converted into a recognized interface action.

  1. In the Customize dialog, select the Macros tab.
  2. In the Macro dropdown list, select the macro script you want to use.
  3. Fill in the Menu text field with a descriptive name (e.g., My Custom Macro). This is how the command will appear in shortcut listings.
  4. (Optional) Provide a Tool tip or assign a Pixmap (icon) if you also plan to add it to a toolbar.
  5. Click the Add button located on the right side of the window. Your macro is now registered as a custom command.

Step 3: Assign the Keyboard Shortcut

  1. Switch to the Keyboard tab inside the same Customize dialog.
  2. In the Category dropdown menu, select Macros.
  3. In the list of commands below the category, scroll to and select the name of the macro you defined in Step 2.
  4. Click into the Press keys input field at the bottom of the window.
  5. Press the physical keys on your keyboard that you want to use as the shortcut (for example, Ctrl + Shift + M).
  6. Click the Assign button to link the key combination to the macro.

Step 4: Save and Test

  1. Click the Close button at the bottom of the Customize dialog to save your changes.
  2. Return to the active 3D view or workbench and press your assigned shortcut to verify that the macro executes properly.