FeatureNamer
Name a feature in the dialog where you create or edit it. Features built from a named feature, and their type postfixes, are named for you.
Why
The tree of a real PartDesign body soon turns into Sketch007, Pad004, Pocket012. A feature is easiest to name right after you create it, while you still know what it is for. But FreeCAD's task dialogs have nowhere to type a name. You have to go back to the tree, find the item, rename it, and then return to your work.
Other CAD tools, Alibre Design for example, put a name field at the top of every feature dialog. FeatureNamer adds the same thing to FreeCAD. It can also ask for a name when a feature still has its default one.
Install
FeatureNamer is a plain Python addon in FreeCAD's modern addon layout, with a package.xml manifest. You don't need to compile anything. It works in every workbench and doesn't add a workbench of its own.
With the Addon Manager (recommended)
FeatureNamer isn't in the official addon list yet, so add it once as a custom repository:
- Open Edit ▸ Preferences ▸ Addon Manager ▸ Custom repositories and add
https://github.com/avongil/FreeCAD-FeatureNamerwith branchmain. - Open Tools ▸ Addon Manager, find FeatureNamer and click Install.
- Restart FreeCAD. The Addon Manager also tells you when there's an update.
By hand
- Download the repository from github.com/avongil/FreeCAD-FeatureNamer (Code ▸ Download ZIP) and unzip it.
- Rename the unzipped folder from
FreeCAD-FeatureNamer-maintoFeatureNamerand move it into theModfolder of your FreeCAD user folder. - Restart FreeCAD. To remove the addon, delete the folder.
After copying, your FreeCAD user folder looks like this:
<your FreeCAD user folder>/
└── Mod/
└── FeatureNamer/ # the unzipped folder, renamed
├── package.xml # addon manifest
└── freecad/
└── FeatureNamer/
├── init_gui.py # GUI entry point
├── core/naming.py # pure naming rules (unit-tested)
├── features.py # reads Profile / Base / Originals
├── preferences.py # settings in the parameter store
├── commands.py # Tools menu command
├── gui/ # observer, Name field, popup, preference page
└── resources/icons/
Where is my FreeCAD user folder? In FreeCAD, open View ▸ Panels ▸ Python console and type App.getUserAppDataDir(). It prints the path. On Windows it is usually %APPDATA%\FreeCAD\vXX-Y, on Linux ~/.local/share/FreeCAD/vXX-Y, and on macOS ~/Library/Application Support/FreeCAD/vXX-Y. If there is no Mod folder yet, create it.
How to use it
Creating a feature
Create a Sketch, Pad, Pocket, Fillet, Hole or any other PartDesign feature as usual. If the feature still has its default name when the edit dialog opens, a small dialog asks for one. The current name is already selected, so you can just start typing.
The name field
While a Sketch or PartDesign feature is in edit mode, a Name field sits at the top of the Tasks panel, above the feature's own settings.
- Live rename. The model tree updates as you type.
- Enter finishes. It confirms the name and returns focus to the 3D view, so Sketcher keyboard shortcuts work again straight away.
- Cancel reverts. The rename is part of the open edit transaction, so Cancel undoes it and one Ctrl+Z undoes the feature and its name together.
- Works on existing features. Double-click any feature in the tree and the field is there, so you can rename it whenever you like.
Automatic names
Most features are built from another feature. When that feature already has a name, FeatureNamer names the new one for you and doesn't show the popup.
Lid_PAD becomes Lid_PKT.- Postfix. When you name a feature yourself, in the popup or the Name field, its type postfix is added for you. Typing
OutsideMoatfor a sketch givesOutsideMoat_SKT. If you already typed the postfix, it isn't added twice. - Source feature. FeatureNamer takes the name from
Profile(Pad, Pocket, Revolution, Groove, Hole, Sweep, Loft, Helix), fromBase(Fillet, Chamfer, Draft, Thickness), or fromOriginals(patterns and Mirrored). - When it still asks. If the source feature still has a default name, such as a Pad from
Sketch004, you get the popup as usual. New sketches always ask, because a sketch on a face usually starts something new. - Patterns opened with nothing selected. The name is filled in as soon as you pick the feature to pattern. If you close the dialog without picking one, you're asked for a name then.
To change postfixes, open Edit ▸ Preferences ▸ FeatureNamer. Its Automatic names section has a table of feature types and their postfixes, where you can edit, add or remove rows, or reset everything to the defaults.
| Feature | Postfix | Feature | Postfix |
|---|---|---|---|
| Sketch | _SKT | Fillet | _FIL |
| Pad | _PAD | Chamfer | _CHF |
_PKT | Draft | _DFT | |
| Revolution | _REV | Thickness | _SHL |
| Groove | _GRV | Mirrored | _MIR |
| Hole | _HOLE | Linear pattern | _LPAT |
| Additive / subtractive pipe (Sweep) | _SWP / _SSWP | Polar pattern | _PPAT |
| Additive / subtractive loft | _LOFT / _SLOFT | MultiTransform | _MTR |
| Additive / subtractive helix | _HLX / _SHLX | Boolean | _BOOL |
| Datum plane / line / point | _PLN / _AXS / _PNT | Shape binder | _BND |
Settings
All options are on one page: Edit ▸ Preferences ▸ FeatureNamer. Tools ▸ FeatureNamer settings…, the entry with the green tag icon right below Edit Parameters, opens the same page, even while you're sketching. It has three groups: Naming features, Automatic names (with the postfix table) and Ignore these feature types. The settings are saved under BaseApp/Preferences/Mod/FeatureNamer.
HEX_SKT was named HEX_PAD automatically, and the dress-up features carry _CHF and _SHL.| Parameter | Default | Effect |
|---|---|---|
ShowNameField | on | Show the Name field at the top of the Tasks panel. |
PromptIfUnnamed | on | Show the popup when editing starts on a feature with a default name. |
NameFromBase | on | Name a feature after the feature it is built from, such as Moat_SKT → Moat_PAD, without asking. |
AutoPostfix | on | Add the type postfix to names you type. |
Postfixes | see table | One TypeId=postfix pair per line. Edit them on the preference page. |
FocusNameField | off | Put the cursor in the Name field instead of showing a popup. This is the less intrusive option. It only applies while PromptIfUnnamed is off. |
AskOnClose | off | After OK, ask again if the name is still the default, even if you skipped the first popup. This rename gets its own undo step. |
ExcludeTypes | PartDesign::Body | Comma-separated list of TypeIds to ignore, for example PartDesign::Plane. |
How it works
The addon uses only public FreeCAD Python APIs and reads one internal Qt class name. It doesn't patch any FreeCAD code.
freecad/FeatureNamer/init_gui.py waits until the main window exists, then registers a Gui document observer, a programmatic preference page, one FeatureNamer_Settings command (CmdType: ForEdit, with its own SVG icon), and a workbench manipulator that adds the command to the Tools menu after Std_DlgParameter. Qt comes through FreeCAD's PySide shim.vp.Object.TypeId starts with Sketcher:: or PartDesign:: and isn't excluded, that object becomes the current target. The rest of the work is deferred with QTimer.singleShot(0) so setEdit() can finish building its task dialog first.Gui::TaskView::TaskPanel widget and inserts a NameBox frame at index 0 of its QBoxLayout, above the dialog's first task box.Profile, Base (dress-up features only) or Originals. If the source has a real name, it removes the source's postfix and adds the new feature's postfix, so OutsideMoat_SKT becomes OutsideMoat_PAD. If the feature has no source yet, the watchdog keeps checking until one is picked.NameDialog and sets obj.Label. This happens inside the edit transaction.AskOnClose is on, it checks doc.getObject(name) is obj to see whether the feature survived (Cancel deletes new features) and asks again inside its own transaction.Detecting a default name
A label counts as default if it equals the internal Name, or if it is the name's alphabetic part followed only by digits. So a new Pad003 labelled Pad003, or Pad after a copy, counts as unnamed. Pad base plate doesn't.
# core/naming.py: no FreeCAD imports, covered by tests/test_naming.py
def is_default_label(label, name):
if label == name:
return True
base = kind_from_name(name) # "Pad003" -> "Pad"
return bool(base) and re.fullmatch(re.escape(base) + r"\d*", label) is not None
Finding the task panel
for w in Gui.getMainWindow().findChildren(QtWidgets.QWidget):
if w.metaObject().className() == "Gui::TaskView::TaskPanel" and w.isVisible():
w.layout().insertWidget(0, NameBox(obj, w))
Because the field writes to Label on every textEdited signal, the rename joins whatever transaction the task dialog has open. That is why Cancel and Undo treat it as part of the feature.
Known limits
Relies on an internal class name
The field depends on Gui::TaskView::TaskPanel having a box layout. If the task view is restructured, the field won't appear, but nothing else breaks.
Only covers features opened in edit mode
The addon only sees objects that enter edit mode through setEdit(). Dialogs that aren't tied to an object being edited, such as Part ▸ Extrude, aren't covered.
Keyboard focus
While the Name field has focus, single-key Sketcher shortcuts type into it. Enter hands focus back to the 3D view, which is why FocusNameField is off by default.
Duplicate labels
If duplicate labels aren't allowed, FreeCAD adds a suffix to the label. The field shows the final label once you finish editing.
Widget search cost
findChildren walks the whole main-window widget tree on each watchdog tick. This hasn't been noticeable, but it isn't free.
No translation
The interface text is English only. Default-name detection uses the internal Name, which isn't translated, so it works in any language.
Proposal for core
Most of the addon's code exists to work around the lack of a hook. In core, the feature could be small and robust:
- A label row on
Gui::TaskView::TaskDialog. Add an optional header showing the edited object'sLabel, on by default for dialogs opened fromViewProvider::setEdit(). Every PartDesign and Sketcher dialog would get it without per-dialog changes. - A preference under General ▸ Document: "Ask for a name when creating features", off by default.
- A Python hook such as
TaskDialog.addHeaderWidget(), so addons can extend a task dialog without searching the widget tree by class name.