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
- Launch FreeCAD.
- In the top navigation menu, click on Tools.
- 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.
- In the Customize dialog, select the Macros tab.
- In the Macro dropdown list, select the macro script you want to use.
- 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. - (Optional) Provide a Tool tip or assign a Pixmap (icon) if you also plan to add it to a toolbar.
- 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
- Switch to the Keyboard tab inside the same Customize dialog.
- In the Category dropdown menu, select Macros.
- In the list of commands below the category, scroll to and select the name of the macro you defined in Step 2.
- Click into the Press keys input field at the bottom of the window.
- Press the physical keys on your keyboard that you want to use as the
shortcut (for example,
Ctrl+Shift+M). - Click the Assign button to link the key combination to the macro.
Step 4: Save and Test
- Click the Close button at the bottom of the Customize dialog to save your changes.
- Return to the active 3D view or workbench and press your assigned shortcut to verify that the macro executes properly.