Historical example · current JSON import unverified The reusable idea is the interface design. The attached 2023 JSON and companion script are reference material, not a current preset guarantee.
Outcome
Give one Macro a small set of explicit options: a value to act on, a choice that changes the action, and a choice about what happens after it runs. This makes the Macro understandable without creating a separate menu for every combination.
The source example renamed selected objects with three Properties:
| Property role | Example option | Purpose |
|---|---|---|
| Input | Text to add | The prefix or suffix to apply. |
| Choice | Prefix or suffix | Which side of the object name receives the text. |
| Reset | Clear after use | Whether the text should be kept for the next run. |
Build the interface before the command
- Write the outcome in plain language: for example, “rename the selected objects using this text.”
- Create only the Properties that change that outcome. Name them by role, not by implementation detail.
- Place the controls and the Macro action together in a Popup Dialog or other visible menu surface.
- Make the Macro read the values when it runs.
- If reset is enabled, clear only the input that should be one-shot; preserve choices users reasonably expect to keep.
The original macro used ternary expressions and list comprehensions because the command field was one line. That is an implementation constraint, not the design. Keep the decision readable first; move a long rename rule to an external Python script when needed.
A simple mental model
Think of the Macro as a function and the Properties as its visible arguments:
rename_selected(text, placement, reset_after_use)This is more discoverable than a collection of nearly identical commands such as “Add Prefix,” “Add Suffix,” “Add Prefix and Clear,” and “Add Suffix and Clear.” It also gives you one place to validate a bad or empty input before any object names change.
Pitfalls
- Do not save every option permanently by default. A one-shot input and a durable user preference are different kinds of state.
- Give the action a previewable name. “Rename selected with prefix/suffix” is clearer than an internal property identifier.
- Rename rules can produce duplicates or invalid names in a production file. Test against copies of objects first.
- If the command contains multiple branches, loops, and error handling, it has outgrown a one-line field.
- A Properties-driven Macro should expose its options where users can inspect them; hidden state makes automation feel unpredictable.
Explore the original
The source includes a PME JSON example and a readable standalone Python version. The latter is useful for understanding the intent before attempting to adapt the compact PME form.
Related
- Run a Macro from a menu or panel item
- Use props() to access a PME Property
- Change selected values relative to the active object