Cleanup: consistent naming for tool_settings & operator properties

Use names:
- `tool_settings` instead of `ts`.

- `props` instead of `op` / `prop` / `op_props`
  As Python may reference operators, don't confuse the operator
  properties with an instance of the operator.

In both cases these names were already used for most scripts.
This commit is contained in:
2023-04-13 13:14:01 +10:00
parent b0edd63752
commit ab64bd264a
11 changed files with 300 additions and 290 deletions

View File

@@ -120,15 +120,15 @@ def _draw_add_remove_buttons(
list_length,
):
"""Draw the +/- buttons to add and remove list entries."""
add_op = layout.operator(UILIST_OT_entry_add.bl_idname, text="", icon='ADD')
add_op.list_path = list_path
add_op.active_index_path = active_index_path
props = layout.operator(UILIST_OT_entry_add.bl_idname, text="", icon='ADD')
props.list_path = list_path
props.active_index_path = active_index_path
row = layout.row()
row.enabled = list_length > 0
remove_op = row.operator(UILIST_OT_entry_remove.bl_idname, text="", icon='REMOVE')
remove_op.list_path = list_path
remove_op.active_index_path = active_index_path
props = row.operator(UILIST_OT_entry_remove.bl_idname, text="", icon='REMOVE')
props.list_path = list_path
props.active_index_path = active_index_path
def _draw_move_buttons(
@@ -141,15 +141,15 @@ def _draw_move_buttons(
"""Draw the up/down arrows to move elements in the list."""
col = layout.column()
col.enabled = list_length > 1
move_up_op = layout.operator(UILIST_OT_entry_move.bl_idname, text="", icon='TRIA_UP')
move_up_op.direction = 'UP'
move_up_op.list_path = list_path
move_up_op.active_index_path = active_index_path
props = layout.operator(UILIST_OT_entry_move.bl_idname, text="", icon='TRIA_UP')
props.direction = 'UP'
props.list_path = list_path
props.active_index_path = active_index_path
move_down_op = layout.operator(UILIST_OT_entry_move.bl_idname, text="", icon='TRIA_DOWN')
move_down_op.direction = 'DOWN'
move_down_op.list_path = list_path
move_down_op.active_index_path = active_index_path
props = layout.operator(UILIST_OT_entry_move.bl_idname, text="", icon='TRIA_DOWN')
props.direction = 'DOWN'
props.list_path = list_path
props.active_index_path = active_index_path
def _get_context_attr(context, data_path):

View File

@@ -63,12 +63,12 @@ class MESH_MT_shape_key_context_menu(Menu):
layout.operator("object.join_shapes")
layout.operator("object.shape_key_transfer")
layout.separator()
op = layout.operator("object.shape_key_remove", icon='X', text="Delete All Shape Keys")
op.all = True
op.apply_mix = False
op = layout.operator("object.shape_key_remove", text="Apply All Shape Keys")
op.all = True
op.apply_mix = True
props = layout.operator("object.shape_key_remove", icon='X', text="Delete All Shape Keys")
props.all = True
props.apply_mix = False
props = layout.operator("object.shape_key_remove", text="Apply All Shape Keys")
props.all = True
props.apply_mix = True
layout.separator()
layout.operator("object.shape_key_move", icon='TRIA_UP_BAR', text="Move to Top").type = 'TOP'
layout.operator("object.shape_key_move", icon='TRIA_DOWN_BAR', text="Move to Bottom").type = 'BOTTOM'
@@ -674,12 +674,12 @@ class MESH_UL_color_attributes(UIList, ColorAttributesListBase):
row = layout.row()
row.emboss = 'NONE'
prop = row.operator(
props = row.operator(
"geometry.color_attribute_render_set",
text="",
icon='RESTRICT_RENDER_OFF' if active_render else 'RESTRICT_RENDER_ON',
)
prop.name = attribute.name
props.name = attribute.name
class MESH_UL_color_attributes_selector(UIList, ColorAttributesListBase):

View File

@@ -739,15 +739,15 @@ class VIEWLAYER_PT_freestyle_linestyle_color(ViewLayerFreestyleLineStyle, Panel)
elif modifier.type == 'DISTANCE_FROM_OBJECT':
box.prop(modifier, "target")
draw_modifier_color_ramp_common(box, modifier, True)
prop = box.operator("scene.freestyle_fill_range_by_selection")
prop.type = 'COLOR'
prop.name = modifier.name
props = box.operator("scene.freestyle_fill_range_by_selection")
props.type = 'COLOR'
props.name = modifier.name
elif modifier.type == 'DISTANCE_FROM_CAMERA':
draw_modifier_color_ramp_common(box, modifier, True)
prop = box.operator("scene.freestyle_fill_range_by_selection")
prop.type = 'COLOR'
prop.name = modifier.name
props = box.operator("scene.freestyle_fill_range_by_selection")
props.type = 'COLOR'
props.name = modifier.name
elif modifier.type == 'MATERIAL':
row = box.row()
@@ -842,15 +842,15 @@ class VIEWLAYER_PT_freestyle_linestyle_alpha(ViewLayerFreestyleLineStyle, Panel)
elif modifier.type == 'DISTANCE_FROM_OBJECT':
box.prop(modifier, "target")
draw_modifier_curve_common(box, modifier, True, False)
prop = box.operator("scene.freestyle_fill_range_by_selection")
prop.type = 'ALPHA'
prop.name = modifier.name
props = box.operator("scene.freestyle_fill_range_by_selection")
props.type = 'ALPHA'
props.name = modifier.name
elif modifier.type == 'DISTANCE_FROM_CAMERA':
draw_modifier_curve_common(box, modifier, True, False)
prop = box.operator("scene.freestyle_fill_range_by_selection")
prop.type = 'ALPHA'
prop.name = modifier.name
props = box.operator("scene.freestyle_fill_range_by_selection")
props.type = 'ALPHA'
props.name = modifier.name
elif modifier.type == 'MATERIAL':
box.prop(modifier, "material_attribute", text="Material Attribute")
@@ -934,15 +934,15 @@ class VIEWLAYER_PT_freestyle_linestyle_thickness(ViewLayerFreestyleLineStyle, Pa
elif modifier.type == 'DISTANCE_FROM_OBJECT':
box.prop(modifier, "target")
draw_modifier_curve_common(box, modifier, True, True)
prop = box.operator("scene.freestyle_fill_range_by_selection")
prop.type = 'THICKNESS'
prop.name = modifier.name
props = box.operator("scene.freestyle_fill_range_by_selection")
props.type = 'THICKNESS'
props.name = modifier.name
elif modifier.type == 'DISTANCE_FROM_CAMERA':
draw_modifier_curve_common(box, modifier, True, True)
prop = box.operator("scene.freestyle_fill_range_by_selection")
prop.type = 'THICKNESS'
prop.name = modifier.name
props = box.operator("scene.freestyle_fill_range_by_selection")
props.type = 'THICKNESS'
props.name = modifier.name
elif modifier.type == 'MATERIAL':
box.prop(modifier, "material_attribute", text="Material Attribute")

View File

@@ -148,16 +148,16 @@ class GreasePencilBrushFalloff:
def draw(self, context):
layout = self.layout
ts = context.tool_settings
tool_settings = context.tool_settings
settings = None
if context.mode == 'PAINT_GPENCIL':
settings = ts.gpencil_paint
settings = tool_settings.gpencil_paint
if context.mode == 'SCULPT_GPENCIL':
settings = ts.gpencil_sculpt_paint
settings = tool_settings.gpencil_sculpt_paint
elif context.mode == 'WEIGHT_GPENCIL':
settings = ts.gpencil_weight_paint
settings = tool_settings.gpencil_weight_paint
elif context.mode == 'VERTEX_GPENCIL':
settings = ts.gpencil_vertex_paint
settings = tool_settings.gpencil_vertex_paint
if settings:
brush = settings.brush
@@ -588,9 +588,9 @@ class GreasePencilVertexcolorPanel:
layout.use_property_split = True
layout.use_property_decorate = False
ts = context.scene.tool_settings
tool_settings = context.scene.tool_settings
is_vertex = context.mode == 'VERTEX_GPENCIL'
gpencil_paint = ts.gpencil_vertex_paint if is_vertex else ts.gpencil_paint
gpencil_paint = tool_settings.gpencil_vertex_paint if is_vertex else tool_settings.gpencil_paint
brush = gpencil_paint.brush
gp_settings = brush.gpencil_settings
tool = brush.gpencil_vertex_tool if is_vertex else brush.gpencil_tool
@@ -858,30 +858,30 @@ class GreasePencilFlipTintColors(Operator):
@classmethod
def poll(cls, context):
ts = context.tool_settings
tool_settings = context.tool_settings
settings = None
if context.mode == 'PAINT_GPENCIL':
settings = ts.gpencil_paint
settings = tool_settings.gpencil_paint
if context.mode == 'SCULPT_GPENCIL':
settings = ts.gpencil_sculpt_paint
settings = tool_settings.gpencil_sculpt_paint
elif context.mode == 'WEIGHT_GPENCIL':
settings = ts.gpencil_weight_paint
settings = tool_settings.gpencil_weight_paint
elif context.mode == 'VERTEX_GPENCIL':
settings = ts.gpencil_vertex_paint
settings = tool_settings.gpencil_vertex_paint
return settings and settings.brush
def execute(self, context):
ts = context.tool_settings
tool_settings = context.tool_settings
settings = None
if context.mode == 'PAINT_GPENCIL':
settings = ts.gpencil_paint
settings = tool_settings.gpencil_paint
if context.mode == 'SCULPT_GPENCIL':
settings = ts.gpencil_sculpt_paint
settings = tool_settings.gpencil_sculpt_paint
elif context.mode == 'WEIGHT_GPENCIL':
settings = ts.gpencil_weight_paint
settings = tool_settings.gpencil_weight_paint
elif context.mode == 'VERTEX_GPENCIL':
settings = ts.gpencil_vertex_paint
settings = tool_settings.gpencil_vertex_paint
brush = settings.brush
color = brush.color

View File

@@ -1732,13 +1732,13 @@ class CLIP_MT_marker_pie(Menu):
layout = self.layout
pie = layout.menu_pie()
# Use Location Tracking
prop = pie.operator("wm.context_set_enum", text="Location")
prop.data_path = "space_data.clip.tracking.tracks.active.motion_model"
prop.value = "Loc"
props = pie.operator("wm.context_set_enum", text="Location")
props.data_path = "space_data.clip.tracking.tracks.active.motion_model"
props.value = "Loc"
# Use Affine Tracking
prop = pie.operator("wm.context_set_enum", text="Affine")
prop.data_path = "space_data.clip.tracking.tracks.active.motion_model"
prop.value = "Affine"
props = pie.operator("wm.context_set_enum", text="Affine")
props.data_path = "space_data.clip.tracking.tracks.active.motion_model"
props.value = "Affine"
# Copy Settings From Active To Selected
pie.operator("clip.track_settings_to_track", icon='COPYDOWN')
# Make Settings Default
@@ -1749,13 +1749,13 @@ class CLIP_MT_marker_pie(Menu):
# Use Brute Force
pie.prop(track_active, "use_brute", text="Use Brute Force")
# Match Keyframe
prop = pie.operator("wm.context_set_enum", text="Match Previous", icon='KEYFRAME_HLT')
prop.data_path = "space_data.clip.tracking.tracks.active.pattern_match"
prop.value = 'PREV_FRAME'
props = pie.operator("wm.context_set_enum", text="Match Previous", icon='KEYFRAME_HLT')
props.data_path = "space_data.clip.tracking.tracks.active.pattern_match"
props.value = 'PREV_FRAME'
# Match Previous Frame
prop = pie.operator("wm.context_set_enum", text="Match Keyframe", icon='KEYFRAME')
prop.data_path = "space_data.clip.tracking.tracks.active.pattern_match"
prop.value = 'KEYFRAME'
props = pie.operator("wm.context_set_enum", text="Match Keyframe", icon='KEYFRAME')
props.data_path = "space_data.clip.tracking.tracks.active.pattern_match"
props.value = 'KEYFRAME'
class CLIP_MT_tracking_pie(Menu):
@@ -1773,13 +1773,13 @@ class CLIP_MT_tracking_pie(Menu):
pie = layout.menu_pie()
# Track Backwards
prop = pie.operator("clip.track_markers", icon='TRACKING_BACKWARDS')
prop.backwards = True
prop.sequence = True
props = pie.operator("clip.track_markers", icon='TRACKING_BACKWARDS')
props.backwards = True
props.sequence = True
# Track Forwards
prop = pie.operator("clip.track_markers", icon='TRACKING_FORWARDS')
prop.backwards = False
prop.sequence = True
props = pie.operator("clip.track_markers", icon='TRACKING_FORWARDS')
props.backwards = False
props.sequence = True
# Disable Marker
pie.operator("clip.disable_markers", icon='HIDE_OFF').action = 'TOGGLE'
# Detect Features
@@ -1831,11 +1831,11 @@ class CLIP_MT_solving_pie(Menu):
icon='KEYFRAME',
).keyframe = 'KEYFRAME_B'
# Clean Tracks
prop = pie.operator("clip.clean_tracks", icon='X')
props = pie.operator("clip.clean_tracks", icon='X')
props.frames = 15
props.error = 2
# Filter Tracks
pie.operator("clip.filter_tracks", icon='FILTER')
prop.frames = 15
prop.error = 2
class CLIP_MT_reconstruction_pie(Menu):

View File

@@ -621,17 +621,17 @@ class SEQUENCER_MT_change(Menu):
layout.operator_context = 'INVOKE_DEFAULT'
layout.operator_menu_enum("sequencer.change_effect_input", "swap")
layout.operator_menu_enum("sequencer.change_effect_type", "type")
prop = layout.operator("sequencer.change_path", text="Path/Files")
props = layout.operator("sequencer.change_path", text="Path/Files")
if strip:
strip_type = strip.type
if strip_type == 'IMAGE':
prop.filter_image = True
props.filter_image = True
elif strip_type == 'MOVIE':
prop.filter_movie = True
props.filter_movie = True
elif strip_type == 'SOUND':
prop.filter_sound = True
props.filter_sound = True
class SEQUENCER_MT_navigation(Menu):
@@ -865,18 +865,18 @@ class SEQUENCER_MT_strip_input(Menu):
layout.operator("sequencer.reload", text="Reload Strips")
layout.operator("sequencer.reload", text="Reload Strips and Adjust Length").adjust_length = True
prop = layout.operator("sequencer.change_path", text="Change Path/Files")
props = layout.operator("sequencer.change_path", text="Change Path/Files")
layout.operator("sequencer.swap_data", text="Swap Data")
if strip:
strip_type = strip.type
if strip_type == 'IMAGE':
prop.filter_image = True
props.filter_image = True
elif strip_type == 'MOVIE':
prop.filter_movie = True
props.filter_movie = True
elif strip_type == 'SOUND':
prop.filter_sound = True
props.filter_sound = True
class SEQUENCER_MT_strip_lock_mute(Menu):

View File

@@ -2094,13 +2094,13 @@ class _defs_gpencil_paint:
class _defs_gpencil_edit:
def is_segment(context):
ts = context.scene.tool_settings
tool_settings = context.scene.tool_settings
if context.mode == 'EDIT_GPENCIL':
return ts.gpencil_selectmode_edit == 'SEGMENT'
return tool_settings.gpencil_selectmode_edit == 'SEGMENT'
elif context.mode == 'SCULPT_GPENCIL':
return ts.use_gpencil_select_mask_segment
return tool_settings.use_gpencil_select_mask_segment
elif context.mode == 'VERTEX_GPENCIL':
return ts.use_gpencil_vertex_select_mask_segment
return tool_settings.use_gpencil_vertex_select_mask_segment
else:
return False
@@ -2283,10 +2283,15 @@ class _defs_gpencil_sculpt:
if context is None:
return True
ob = context.active_object
ts = context.scene.tool_settings
return ob and ob.type == 'GPENCIL' and (ts.use_gpencil_select_mask_point or
ts.use_gpencil_select_mask_stroke or
ts.use_gpencil_select_mask_segment)
tool_settings = context.scene.tool_settings
return (
ob is not None and
ob.type == 'GPENCIL' and (
tool_settings.use_gpencil_select_mask_point or
tool_settings.use_gpencil_select_mask_stroke or
tool_settings.use_gpencil_select_mask_segment
)
)
@staticmethod
def generate_from_brushes(context):
@@ -2427,10 +2432,15 @@ class _defs_gpencil_vertex:
if context is None:
return True
ob = context.active_object
ts = context.scene.tool_settings
return ob and ob.type == 'GPENCIL' and (ts.use_gpencil_vertex_select_mask_point or
ts.use_gpencil_vertex_select_mask_stroke or
ts.use_gpencil_vertex_select_mask_segment)
tool_settings = context.scene.tool_settings
return (
ob is not None and
ob.type == 'GPENCIL' and (
tool_settings.use_gpencil_vertex_select_mask_point or
tool_settings.use_gpencil_vertex_select_mask_stroke or
tool_settings.use_gpencil_vertex_select_mask_segment
)
)
@staticmethod
def generate_from_brushes(context):

View File

@@ -235,34 +235,34 @@ class TOPBAR_MT_file_cleanup(Menu):
layout = self.layout
layout.separator()
op_props = layout.operator("outliner.orphans_purge", text="Unused Data-Blocks")
op_props.do_local_ids = True
op_props.do_linked_ids = True
op_props.do_recursive = False
op_props = layout.operator("outliner.orphans_purge", text="Recursive Unused Data-Blocks")
op_props.do_local_ids = True
op_props.do_linked_ids = True
op_props.do_recursive = True
props = layout.operator("outliner.orphans_purge", text="Unused Data-Blocks")
props.do_local_ids = True
props.do_linked_ids = True
props.do_recursive = False
props = layout.operator("outliner.orphans_purge", text="Recursive Unused Data-Blocks")
props.do_local_ids = True
props.do_linked_ids = True
props.do_recursive = True
layout.separator()
op_props = layout.operator("outliner.orphans_purge", text="Unused Linked Data-Blocks")
op_props.do_local_ids = False
op_props.do_linked_ids = True
op_props.do_recursive = False
op_props = layout.operator("outliner.orphans_purge", text="Recursive Unused Linked Data-Blocks")
op_props.do_local_ids = False
op_props.do_linked_ids = True
op_props.do_recursive = True
props = layout.operator("outliner.orphans_purge", text="Unused Linked Data-Blocks")
props.do_local_ids = False
props.do_linked_ids = True
props.do_recursive = False
props = layout.operator("outliner.orphans_purge", text="Recursive Unused Linked Data-Blocks")
props.do_local_ids = False
props.do_linked_ids = True
props.do_recursive = True
layout.separator()
op_props = layout.operator("outliner.orphans_purge", text="Unused Local Data-Blocks")
op_props.do_local_ids = True
op_props.do_linked_ids = False
op_props.do_recursive = False
op_props = layout.operator("outliner.orphans_purge", text="Recursive Unused Local Data-Blocks")
op_props.do_local_ids = True
op_props.do_linked_ids = False
op_props.do_recursive = True
props = layout.operator("outliner.orphans_purge", text="Unused Local Data-Blocks")
props.do_local_ids = True
props.do_linked_ids = False
props.do_recursive = False
props = layout.operator("outliner.orphans_purge", text="Recursive Unused Local Data-Blocks")
props.do_local_ids = True
props.do_linked_ids = False
props.do_recursive = True
class TOPBAR_MT_file(Menu):

View File

@@ -2205,12 +2205,12 @@ class StudioLightPanelMixin:
row.template_icon(layout.icon(studio_light), scale=3.0)
col = row.column()
op = col.operator("preferences.studiolight_uninstall", text="", icon='REMOVE')
op.index = studio_light.index
props = col.operator("preferences.studiolight_uninstall", text="", icon='REMOVE')
props.index = studio_light.index
if studio_light.type == 'STUDIO':
op = col.operator("preferences.studiolight_copy_settings", text="", icon='IMPORT')
op.index = studio_light.index
props = col.operator("preferences.studiolight_copy_settings", text="", icon='IMPORT')
props.index = studio_light.index
box.label(text=studio_light.name)
@@ -2247,9 +2247,9 @@ class USERPREF_PT_studiolight_lights(StudioLightPanel, StudioLightPanelMixin, Pa
def draw_header_preset(self, _context):
layout = self.layout
op = layout.operator("preferences.studiolight_install", icon='IMPORT', text="Install...")
op.type = 'STUDIO'
op.filter_glob = ".sl"
props = layout.operator("preferences.studiolight_install", icon='IMPORT', text="Install...")
props.type = 'STUDIO'
props.filter_glob = ".sl"
layout.separator()
def get_error_message(self):

View File

@@ -927,7 +927,7 @@ class VIEW3D_MT_editor_menus(Menu):
edit_object = context.edit_object
gp_edit = obj and obj.mode in {'EDIT_GPENCIL', 'PAINT_GPENCIL', 'SCULPT_GPENCIL',
'WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}
ts = context.scene.tool_settings
tool_settings = context.scene.tool_settings
layout.menu("VIEW3D_MT_view")
@@ -936,9 +936,9 @@ class VIEW3D_MT_editor_menus(Menu):
if mode_string not in {'PAINT_GPENCIL', 'WEIGHT_GPENCIL'}:
if (
mode_string == 'SCULPT_GPENCIL' and
(ts.use_gpencil_select_mask_point or
ts.use_gpencil_select_mask_stroke or
ts.use_gpencil_select_mask_segment)
(tool_settings.use_gpencil_select_mask_point or
tool_settings.use_gpencil_select_mask_stroke or
tool_settings.use_gpencil_select_mask_segment)
):
layout.menu("VIEW3D_MT_select_gpencil")
elif mode_string == 'EDIT_GPENCIL':
@@ -3143,36 +3143,36 @@ class VIEW3D_MT_paint_weight_lock(Menu):
def draw(self, _context):
layout = self.layout
op = layout.operator("object.vertex_group_lock", icon='LOCKED', text="Lock All")
op.action, op.mask = 'LOCK', 'ALL'
props = layout.operator("object.vertex_group_lock", icon='LOCKED', text="Lock All")
props.action, props.mask = 'LOCK', 'ALL'
op = layout.operator("object.vertex_group_lock", text="Lock Selected")
op.action, op.mask = 'LOCK', 'SELECTED'
props = layout.operator("object.vertex_group_lock", text="Lock Selected")
props.action, props.mask = 'LOCK', 'SELECTED'
op = layout.operator("object.vertex_group_lock", text="Lock Unselected")
op.action, op.mask = 'LOCK', 'UNSELECTED'
props = layout.operator("object.vertex_group_lock", text="Lock Unselected")
props.action, props.mask = 'LOCK', 'UNSELECTED'
op = layout.operator("object.vertex_group_lock", text="Lock Only Selected")
op.action, op.mask = 'LOCK', 'INVERT_UNSELECTED'
props = layout.operator("object.vertex_group_lock", text="Lock Only Selected")
props.action, props.mask = 'LOCK', 'INVERT_UNSELECTED'
op = layout.operator("object.vertex_group_lock", text="Lock Only Unselected")
op.action, op.mask = 'UNLOCK', 'INVERT_UNSELECTED'
props = layout.operator("object.vertex_group_lock", text="Lock Only Unselected")
props.action, props.mask = 'UNLOCK', 'INVERT_UNSELECTED'
layout.separator()
op = layout.operator("object.vertex_group_lock", icon='UNLOCKED', text="Unlock All")
op.action, op.mask = 'UNLOCK', 'ALL'
props = layout.operator("object.vertex_group_lock", icon='UNLOCKED', text="Unlock All")
props.action, props.mask = 'UNLOCK', 'ALL'
op = layout.operator("object.vertex_group_lock", text="Unlock Selected")
op.action, op.mask = 'UNLOCK', 'SELECTED'
props = layout.operator("object.vertex_group_lock", text="Unlock Selected")
props.action, props.mask = 'UNLOCK', 'SELECTED'
op = layout.operator("object.vertex_group_lock", text="Unlock Unselected")
op.action, op.mask = 'UNLOCK', 'UNSELECTED'
props = layout.operator("object.vertex_group_lock", text="Unlock Unselected")
props.action, props.mask = 'UNLOCK', 'UNSELECTED'
layout.separator()
op = layout.operator("object.vertex_group_lock", icon='ARROW_LEFTRIGHT', text="Invert Locks")
op.action, op.mask = 'INVERT', 'ALL'
props = layout.operator("object.vertex_group_lock", icon='ARROW_LEFTRIGHT', text="Invert Locks")
props.action, props.mask = 'INVERT', 'ALL'
class VIEW3D_MT_paint_weight(Menu):
@@ -3417,14 +3417,14 @@ class VIEW3D_MT_face_sets(Menu):
def draw(self, _context):
layout = self.layout
op = layout.operator("sculpt.face_sets_create", text="Face Set from Masked")
op.mode = 'MASKED'
props = layout.operator("sculpt.face_sets_create", text="Face Set from Masked")
props.mode = 'MASKED'
op = layout.operator("sculpt.face_sets_create", text="Face Set from Visible")
op.mode = 'VISIBLE'
props = layout.operator("sculpt.face_sets_create", text="Face Set from Visible")
props.mode = 'VISIBLE'
op = layout.operator("sculpt.face_sets_create", text="Face Set from Edit Mode Selection")
op.mode = 'SELECTION'
props = layout.operator("sculpt.face_sets_create", text="Face Set from Edit Mode Selection")
props.mode = 'SELECTION'
layout.separator()
@@ -3432,11 +3432,11 @@ class VIEW3D_MT_face_sets(Menu):
layout.separator()
op = layout.operator("sculpt.face_set_edit", text="Grow Face Set")
op.mode = 'GROW'
props = layout.operator("sculpt.face_set_edit", text="Grow Face Set")
props.mode = 'GROW'
op = layout.operator("sculpt.face_set_edit", text="Shrink Face Set")
op.mode = 'SHRINK'
props = layout.operator("sculpt.face_set_edit", text="Shrink Face Set")
props.mode = 'SHRINK'
layout.separator()
@@ -3454,18 +3454,18 @@ class VIEW3D_MT_face_sets(Menu):
layout.separator()
op = layout.operator("mesh.face_set_extract", text="Extract Face Set")
props = layout.operator("mesh.face_set_extract", text="Extract Face Set")
layout.separator()
op = layout.operator("sculpt.face_set_change_visibility", text="Invert Visible Face Sets")
op.mode = 'INVERT'
props = layout.operator("sculpt.face_set_change_visibility", text="Invert Visible Face Sets")
props.mode = 'INVERT'
op = layout.operator("sculpt.reveal_all", text="Show All Face Sets")
props = layout.operator("sculpt.reveal_all", text="Show All Face Sets")
layout.separator()
op = layout.operator("sculpt.face_sets_randomize_colors", text="Randomize Colors")
props = layout.operator("sculpt.face_sets_randomize_colors", text="Randomize Colors")
class VIEW3D_MT_sculpt_set_pivot(Menu):
@@ -3496,32 +3496,32 @@ class VIEW3D_MT_face_sets_init(Menu):
def draw(self, _context):
layout = self.layout
op = layout.operator("sculpt.face_sets_init", text="By Loose Parts")
op.mode = 'LOOSE_PARTS'
props = layout.operator("sculpt.face_sets_init", text="By Loose Parts")
props.mode = 'LOOSE_PARTS'
op = layout.operator("sculpt.face_sets_init", text="By Face Set Boundaries")
op.mode = 'FACE_SET_BOUNDARIES'
props = layout.operator("sculpt.face_sets_init", text="By Face Set Boundaries")
props.mode = 'FACE_SET_BOUNDARIES'
op = layout.operator("sculpt.face_sets_init", text="By Materials")
op.mode = 'MATERIALS'
props = layout.operator("sculpt.face_sets_init", text="By Materials")
props.mode = 'MATERIALS'
op = layout.operator("sculpt.face_sets_init", text="By Normals")
op.mode = 'NORMALS'
props = layout.operator("sculpt.face_sets_init", text="By Normals")
props.mode = 'NORMALS'
op = layout.operator("sculpt.face_sets_init", text="By UV Seams")
op.mode = 'UV_SEAMS'
props = layout.operator("sculpt.face_sets_init", text="By UV Seams")
props.mode = 'UV_SEAMS'
op = layout.operator("sculpt.face_sets_init", text="By Edge Creases")
op.mode = 'CREASES'
props = layout.operator("sculpt.face_sets_init", text="By Edge Creases")
props.mode = 'CREASES'
op = layout.operator("sculpt.face_sets_init", text="By Edge Bevel Weight")
op.mode = 'BEVEL_WEIGHT'
props = layout.operator("sculpt.face_sets_init", text="By Edge Bevel Weight")
props.mode = 'BEVEL_WEIGHT'
op = layout.operator("sculpt.face_sets_init", text="By Sharp Edges")
op.mode = 'SHARP_EDGES'
props = layout.operator("sculpt.face_sets_init", text="By Sharp Edges")
props.mode = 'SHARP_EDGES'
op = layout.operator("sculpt.face_sets_init", text="By Face Maps")
op.mode = 'FACE_MAPS'
props = layout.operator("sculpt.face_sets_init", text="By Face Maps")
props.mode = 'FACE_MAPS'
class VIEW3D_MT_random_mask(Menu):
@@ -3530,14 +3530,14 @@ class VIEW3D_MT_random_mask(Menu):
def draw(self, _context):
layout = self.layout
op = layout.operator("sculpt.mask_init", text="Per Vertex")
op.mode = 'RANDOM_PER_VERTEX'
props = layout.operator("sculpt.mask_init", text="Per Vertex")
props.mode = 'RANDOM_PER_VERTEX'
op = layout.operator("sculpt.mask_init", text="Per Face Set")
op.mode = 'RANDOM_PER_FACE_SET'
props = layout.operator("sculpt.mask_init", text="Per Face Set")
props.mode = 'RANDOM_PER_FACE_SET'
op = layout.operator("sculpt.mask_init", text="Per Loose Part")
op.mode = 'RANDOM_PER_LOOSE_PART'
props = layout.operator("sculpt.mask_init", text="Per Loose Part")
props.mode = 'RANDOM_PER_LOOSE_PART'
class VIEW3D_MT_particle(Menu):
@@ -4431,17 +4431,17 @@ class VIEW3D_MT_edit_mesh_normals_select_strength(Menu):
def draw(self, _context):
layout = self.layout
op = layout.operator("mesh.mod_weighted_strength", text="Weak")
op.set = False
op.face_strength = 'WEAK'
props = layout.operator("mesh.mod_weighted_strength", text="Weak")
props.set = False
props.face_strength = 'WEAK'
op = layout.operator("mesh.mod_weighted_strength", text="Medium")
op.set = False
op.face_strength = 'MEDIUM'
props = layout.operator("mesh.mod_weighted_strength", text="Medium")
props.set = False
props.face_strength = 'MEDIUM'
op = layout.operator("mesh.mod_weighted_strength", text="Strong")
op.set = False
op.face_strength = 'STRONG'
props = layout.operator("mesh.mod_weighted_strength", text="Strong")
props.set = False
props.face_strength = 'STRONG'
class VIEW3D_MT_edit_mesh_normals_set_strength(Menu):
@@ -4450,17 +4450,17 @@ class VIEW3D_MT_edit_mesh_normals_set_strength(Menu):
def draw(self, _context):
layout = self.layout
op = layout.operator("mesh.mod_weighted_strength", text="Weak")
op.set = True
op.face_strength = 'WEAK'
props = layout.operator("mesh.mod_weighted_strength", text="Weak")
props.set = True
props.face_strength = 'WEAK'
op = layout.operator("mesh.mod_weighted_strength", text="Medium")
op.set = True
op.face_strength = 'MEDIUM'
props = layout.operator("mesh.mod_weighted_strength", text="Medium")
props.set = True
props.face_strength = 'MEDIUM'
op = layout.operator("mesh.mod_weighted_strength", text="Strong")
op.set = True
op.face_strength = 'STRONG'
props = layout.operator("mesh.mod_weighted_strength", text="Strong")
props.set = True
props.face_strength = 'STRONG'
class VIEW3D_MT_edit_mesh_normals_average(Menu):
@@ -5276,9 +5276,9 @@ class VIEW3D_MT_edit_gpencil_stroke(Menu):
layout.separator()
# Convert
op = layout.operator("gpencil.stroke_cyclical_set", text="Close")
op.type = 'CLOSE'
op.geometry = True
props = layout.operator("gpencil.stroke_cyclical_set", text="Close")
props.type = 'CLOSE'
props.geometry = True
layout.operator("gpencil.stroke_cyclical_set", text="Toggle Cyclic").type = 'TOGGLE'
layout.operator_menu_enum("gpencil.stroke_caps_set", text="Toggle Caps", property="type")
layout.operator("gpencil.stroke_flip", text="Switch Direction")
@@ -5569,25 +5569,25 @@ class VIEW3D_MT_sculpt_mask_edit_pie(Menu):
layout = self.layout
pie = layout.menu_pie()
op = pie.operator("paint.mask_flood_fill", text="Invert Mask")
op.mode = 'INVERT'
op = pie.operator("paint.mask_flood_fill", text="Clear Mask")
op.mode = 'VALUE'
op.value = 0.0
op = pie.operator("sculpt.mask_filter", text="Smooth Mask")
op.filter_type = 'SMOOTH'
op = pie.operator("sculpt.mask_filter", text="Sharpen Mask")
op.filter_type = 'SHARPEN'
op = pie.operator("sculpt.mask_filter", text="Grow Mask")
op.filter_type = 'GROW'
op = pie.operator("sculpt.mask_filter", text="Shrink Mask")
op.filter_type = 'SHRINK'
op = pie.operator("sculpt.mask_filter", text="Increase Contrast")
op.filter_type = 'CONTRAST_INCREASE'
op.auto_iteration_count = False
op = pie.operator("sculpt.mask_filter", text="Decrease Contrast")
op.filter_type = 'CONTRAST_DECREASE'
op.auto_iteration_count = False
props = pie.operator("paint.mask_flood_fill", text="Invert Mask")
props.mode = 'INVERT'
props = pie.operator("paint.mask_flood_fill", text="Clear Mask")
props.mode = 'VALUE'
props.value = 0.0
props = pie.operator("sculpt.mask_filter", text="Smooth Mask")
props.filter_type = 'SMOOTH'
props = pie.operator("sculpt.mask_filter", text="Sharpen Mask")
props.filter_type = 'SHARPEN'
props = pie.operator("sculpt.mask_filter", text="Grow Mask")
props.filter_type = 'GROW'
props = pie.operator("sculpt.mask_filter", text="Shrink Mask")
props.filter_type = 'SHRINK'
props = pie.operator("sculpt.mask_filter", text="Increase Contrast")
props.filter_type = 'CONTRAST_INCREASE'
props.auto_iteration_count = False
props = pie.operator("sculpt.mask_filter", text="Decrease Contrast")
props.filter_type = 'CONTRAST_DECREASE'
props.auto_iteration_count = False
class VIEW3D_MT_sculpt_automasking_pie(Menu):
@@ -5634,16 +5634,16 @@ class VIEW3D_MT_sculpt_face_sets_edit_pie(Menu):
layout = self.layout
pie = layout.menu_pie()
op = pie.operator("sculpt.face_sets_create", text="Face Set from Masked")
op.mode = 'MASKED'
props = pie.operator("sculpt.face_sets_create", text="Face Set from Masked")
props.mode = 'MASKED'
op = pie.operator("sculpt.face_sets_create", text="Face Set from Visible")
op.mode = 'VISIBLE'
props = pie.operator("sculpt.face_sets_create", text="Face Set from Visible")
props.mode = 'VISIBLE'
op = pie.operator("sculpt.face_set_change_visibility", text="Invert Visible")
op.mode = 'INVERT'
props = pie.operator("sculpt.face_set_change_visibility", text="Invert Visible")
props.mode = 'INVERT'
op = pie.operator("sculpt.reveal_all", text="Show All")
props = pie.operator("sculpt.reveal_all", text="Show All")
class VIEW3D_MT_wpaint_vgroup_lock_pie(Menu):
@@ -5654,29 +5654,29 @@ class VIEW3D_MT_wpaint_vgroup_lock_pie(Menu):
pie = layout.menu_pie()
# 1: Left
op = pie.operator("object.vertex_group_lock", icon='LOCKED', text="Lock All")
op.action, op.mask = 'LOCK', 'ALL'
props = pie.operator("object.vertex_group_lock", icon='LOCKED', text="Lock All")
props.action, props.mask = 'LOCK', 'ALL'
# 2: Right
op = pie.operator("object.vertex_group_lock", icon='UNLOCKED', text="Unlock All")
op.action, op.mask = 'UNLOCK', 'ALL'
props = pie.operator("object.vertex_group_lock", icon='UNLOCKED', text="Unlock All")
props.action, props.mask = 'UNLOCK', 'ALL'
# 3: Down
op = pie.operator("object.vertex_group_lock", icon='UNLOCKED', text="Unlock Selected")
op.action, op.mask = 'UNLOCK', 'SELECTED'
props = pie.operator("object.vertex_group_lock", icon='UNLOCKED', text="Unlock Selected")
props.action, props.mask = 'UNLOCK', 'SELECTED'
# 4: Up
op = pie.operator("object.vertex_group_lock", icon='LOCKED', text="Lock Selected")
op.action, op.mask = 'LOCK', 'SELECTED'
props = pie.operator("object.vertex_group_lock", icon='LOCKED', text="Lock Selected")
props.action, props.mask = 'LOCK', 'SELECTED'
# 5: Up/Left
op = pie.operator("object.vertex_group_lock", icon='LOCKED', text="Lock Unselected")
op.action, op.mask = 'LOCK', 'UNSELECTED'
props = pie.operator("object.vertex_group_lock", icon='LOCKED', text="Lock Unselected")
props.action, props.mask = 'LOCK', 'UNSELECTED'
# 6: Up/Right
op = pie.operator("object.vertex_group_lock", text="Lock Only Selected")
op.action, op.mask = 'LOCK', 'INVERT_UNSELECTED'
props = pie.operator("object.vertex_group_lock", text="Lock Only Selected")
props.action, props.mask = 'LOCK', 'INVERT_UNSELECTED'
# 7: Down/Left
op = pie.operator("object.vertex_group_lock", text="Lock Only Unselected")
op.action, op.mask = 'UNLOCK', 'INVERT_UNSELECTED'
props = pie.operator("object.vertex_group_lock", text="Lock Only Unselected")
props.action, props.mask = 'UNLOCK', 'INVERT_UNSELECTED'
# 8: Down/Right
op = pie.operator("object.vertex_group_lock", text="Invert Locks")
op.action, op.mask = 'INVERT', 'ALL'
props = pie.operator("object.vertex_group_lock", text="Invert Locks")
props.action, props.mask = 'INVERT', 'ALL'
# ********** Panel **********
@@ -7628,8 +7628,8 @@ class VIEW3D_PT_gpencil_sculpt_context_menu(Panel):
bl_ui_units_x = 12
def draw(self, context):
ts = context.tool_settings
settings = ts.gpencil_sculpt_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_sculpt_paint
brush = settings.brush
layout = self.layout
@@ -7648,8 +7648,8 @@ class VIEW3D_PT_gpencil_weight_context_menu(Panel):
bl_ui_units_x = 12
def draw(self, context):
ts = context.tool_settings
settings = ts.gpencil_weight_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_weight_paint
brush = settings.brush
layout = self.layout
@@ -7669,8 +7669,8 @@ class VIEW3D_PT_gpencil_draw_context_menu(Panel):
bl_ui_units_x = 12
def draw(self, context):
ts = context.tool_settings
settings = ts.gpencil_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_paint
brush = settings.brush
gp_settings = brush.gpencil_settings
@@ -7708,8 +7708,8 @@ class VIEW3D_PT_gpencil_vertex_context_menu(Panel):
def draw(self, context):
layout = self.layout
ts = context.tool_settings
settings = ts.gpencil_vertex_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_vertex_paint
brush = settings.brush
gp_settings = brush.gpencil_settings

View File

@@ -61,17 +61,17 @@ class VIEW3D_MT_brush_gpencil_context_menu(Menu):
def draw(self, context):
layout = self.layout
ts = context.tool_settings
tool_settings = context.tool_settings
settings = None
if context.mode == 'PAINT_GPENCIL':
settings = ts.gpencil_paint
settings = tool_settings.gpencil_paint
if context.mode == 'SCULPT_GPENCIL':
settings = ts.gpencil_sculpt_paint
settings = tool_settings.gpencil_sculpt_paint
elif context.mode == 'WEIGHT_GPENCIL':
settings = ts.gpencil_weight_paint
settings = tool_settings.gpencil_weight_paint
elif context.mode == 'VERTEX_GPENCIL':
settings = ts.gpencil_vertex_paint
settings = tool_settings.gpencil_vertex_paint
brush = getattr(settings, "brush", None)
# skip if no active brush
@@ -1816,8 +1816,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_paint_falloff(GreasePencilBrushFalloff
@classmethod
def poll(cls, context):
ts = context.tool_settings
settings = ts.gpencil_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_paint
brush = settings.brush
if brush is None:
return False
@@ -1934,8 +1934,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_sculpt_falloff(GreasePencilBrushFallof
@classmethod
def poll(cls, context):
ts = context.tool_settings
settings = ts.gpencil_sculpt_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_sculpt_paint
return (settings and settings.brush and settings.brush.curve)
@@ -2043,8 +2043,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_weight_falloff(GreasePencilBrushFallof
@classmethod
def poll(cls, context):
ts = context.tool_settings
settings = ts.gpencil_weight_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_weight_paint
brush = settings.brush
return (brush and brush.curve)
@@ -2119,8 +2119,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_vertex_color(View3DPanel, Panel):
@classmethod
def poll(cls, context):
ob = context.object
ts = context.tool_settings
settings = ts.gpencil_vertex_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_vertex_paint
brush = settings.brush
if ob is None or brush is None:
@@ -2135,8 +2135,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_vertex_color(View3DPanel, Panel):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
ts = context.tool_settings
settings = ts.gpencil_vertex_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_vertex_paint
brush = settings.brush
col = layout.column()
@@ -2157,8 +2157,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_vertex_falloff(GreasePencilBrushFallof
@classmethod
def poll(cls, context):
ts = context.tool_settings
settings = ts.gpencil_vertex_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_vertex_paint
return (settings and settings.brush and settings.brush.curve)
@@ -2171,8 +2171,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_vertex_palette(View3DPanel, Panel):
@classmethod
def poll(cls, context):
ob = context.object
ts = context.tool_settings
settings = ts.gpencil_vertex_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_vertex_paint
brush = settings.brush
if ob is None or brush is None:
@@ -2187,8 +2187,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_vertex_palette(View3DPanel, Panel):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
ts = context.tool_settings
settings = ts.gpencil_vertex_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_vertex_paint
col = layout.column()
@@ -2206,8 +2206,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel):
@classmethod
def poll(cls, context):
ob = context.object
ts = context.tool_settings
settings = ts.gpencil_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_paint
brush = settings.brush
if ob is None or brush is None:
@@ -2231,8 +2231,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel):
def draw(self, context):
layout = self.layout
ts = context.tool_settings
settings = ts.gpencil_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_paint
brush = settings.brush
gp_settings = brush.gpencil_settings
@@ -2270,8 +2270,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_mix_palette(View3DPanel, Panel):
@classmethod
def poll(cls, context):
ob = context.object
ts = context.tool_settings
settings = ts.gpencil_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_paint
brush = settings.brush
if ob is None or brush is None:
@@ -2294,8 +2294,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_mix_palette(View3DPanel, Panel):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
ts = context.tool_settings
settings = ts.gpencil_paint
tool_settings = context.tool_settings
settings = tool_settings.gpencil_paint
brush = settings.brush
col = layout.column()