Post #4872: Like you, I also struggle with the inaccessibility of the Tool Options.
📋 Metadata
- Author: Pluglug
- Date: 2023-11-05 17:28:43
- Type:
answer - Quality Score: 8/10
- Reply to: post_04871
- Replies (1): post_04873
🏷️ Tags
popup-dialog macro tool-options intermediate solved
⚙️ Related PME Features
- Interactive Panels
- Macro Editor
- Modal Editor
- Python Scripting
- Custom UI Layout
💬 Content
Like you, I also struggle with the inaccessibility of the Tool Options.
As a first suggestion, we could consider placing the properties in a more visible location. If the text and icons were to change according to the state of the properties, it would likely become even more user-friendly.
To begin with, please use PME’s Interactive Panels to create a menu in a highly visible location. This will automatically generate a pop-up dialog with any given menu ID. Then, write the following code in the custom tab for slots:
st = C.scene.tool_settings; text, icon = ('CFA On', 'SEQUENCE_COLOR_01') if st.use_transform_correct_face_attributes else ('CFA Off', 'SEQUENCE_COLOR_09'); L.prop(st, 'use_transform_correct_face_attributes', text=text, icon=icon)
This script operates as follows:
- Retrieves
bpy.context.scene.tool_settingsasst. - Prepares the text ‘CFA On’ with a red icon if
use_transform_correct_face_attributes(CFA) is True, or the text ‘CFA Off’ with a grey icon if False. - Displays the property using
L.prop()with the text and icon set in step 2.
API Reference: L.prop
Next, there is a second suggestion to create a specialized transformation feature.
When creating a function with PME, you’ll have to choose between a macro or a modal operator. Since Blender’s standard transform operators already operate modally, using PME’s modal operators can lead to redundant modal behavior, making it less user-friendly.
Therefore, it’s better to use a macro, but with caution. (This is a bit of a hack, so if anyone knows the official way to do this, please share.)
Follow the instructions below to create three slots and enter the commands as directed.
-
Save the current state of the property and set the property to True.
st = C.scene.tool_settings; current_status = st.use_transform_correct_face_attributes; st.use_transform_correct_face_attributes = True
-
Perform a transform operation (scaling, in this example).
bpy.ops.transform.resize('INVOKE_DEFAULT', True) #
-
Revert to the property state saved in step 1.
C.scene.tool_settings.use_transform_correct_face_attributes = current_status
Pay special attention to step 2.
- Explicitly specify
INVOKE_DEFAULT. - Add some text at the end of the command (here we use
#).
Neglecting these points may result in step 3 not executing if the transform is canceled during the operation. This hack aims to make the transform operator be recognized as just a snippet by PME.
I have prepared similar code for operations other than scaling, for you to use in step 2.
bpy.ops.transform.translate('INVOKE_DEFAULT', True) #
bpy.ops.transform.rotate('INVOKE_DEFAULT', True) #
These are the ideas I have concerning the Tool Options. I am utilizing this method, but in reality, depending on your workflow, there could be a variety of alternatives. If you have your own ideal method, please do share it.
❤️ 2 likes