feat: hide some operators in edit mode and add some notify for grouping oper.
- now grouping, ungrouping clear groups operators will show a report at the bottom of blender to indicate their work have done. - disable fix material, 3ds max align, select by virtools group operators in edit mode to prevent any possible undefined behavior.
This commit is contained in:
parent
c58af8ce48
commit
84e7e8380f
@ -1,4 +1,5 @@
|
||||
import bpy
|
||||
from . import UTIL_functions
|
||||
from . import PROP_virtools_material, PROP_preferences
|
||||
|
||||
class BBP_OT_fix_all_material(bpy.types.Operator):
|
||||
@ -9,7 +10,9 @@ class BBP_OT_fix_all_material(bpy.types.Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return PROP_preferences.get_raw_preferences().has_valid_blc_tex_folder()
|
||||
# only enable this when plugin have a valid ballance texture folder
|
||||
# and we are in object mode
|
||||
return PROP_preferences.get_raw_preferences().has_valid_blc_tex_folder() and UTIL_functions.is_in_object_mode()
|
||||
|
||||
def invoke(self, context, event):
|
||||
wm = context.window_manager
|
||||
|
@ -43,25 +43,25 @@ class BBP_PG_legacy_align_history(bpy.types.PropertyGroup):
|
||||
align_x: bpy.props.BoolProperty(
|
||||
name = "X Position",
|
||||
default = False,
|
||||
)
|
||||
) # type: ignore
|
||||
align_y: bpy.props.BoolProperty(
|
||||
name = "Y Position",
|
||||
default = False,
|
||||
)
|
||||
) # type: ignore
|
||||
align_z: bpy.props.BoolProperty(
|
||||
name = "Z Position",
|
||||
default = False,
|
||||
)
|
||||
) # type: ignore
|
||||
current_align_mode: bpy.props.EnumProperty(
|
||||
name = "Current Object (Active Object)",
|
||||
items = _g_EnumHelper_AlignMode.generate_items(),
|
||||
default = _g_EnumHelper_AlignMode.to_selection(AlignMode.AxisCenter),
|
||||
)
|
||||
) # type: ignore
|
||||
target_align_mode: bpy.props.EnumProperty(
|
||||
name = "Target Objects (Other Objects)",
|
||||
items = _g_EnumHelper_AlignMode.generate_items(),
|
||||
default = _g_EnumHelper_AlignMode.to_selection(AlignMode.AxisCenter),
|
||||
)
|
||||
) # type: ignore
|
||||
|
||||
#endregion
|
||||
|
||||
@ -109,21 +109,21 @@ class BBP_OT_legacy_align(bpy.types.Operator):
|
||||
options = {'HIDDEN', 'SKIP_SAVE'},
|
||||
default = True, # default True value to make it as a "light" button, not a grey one.
|
||||
update = apply_flag_updated,
|
||||
)
|
||||
) # type: ignore
|
||||
recursive_hinder: bpy.props.BoolProperty(
|
||||
name = "Recursive Hinder",
|
||||
description = "An internal flag to prevent the loop calling to apply_flags's updator.",
|
||||
options = {'HIDDEN', 'SKIP_SAVE'},
|
||||
default = False,
|
||||
)
|
||||
) # type: ignore
|
||||
align_history : bpy.props.CollectionProperty(
|
||||
name = "Historys",
|
||||
description = "Align history.",
|
||||
type = BBP_PG_legacy_align_history,
|
||||
)
|
||||
) # type: ignore
|
||||
|
||||
@classmethod
|
||||
def poll(self, context):
|
||||
def poll(cls, context):
|
||||
return _check_align_requirement()
|
||||
|
||||
def invoke(self, context, event):
|
||||
@ -180,10 +180,13 @@ class BBP_OT_legacy_align(bpy.types.Operator):
|
||||
#region Core Functions
|
||||
|
||||
def _check_align_requirement() -> bool:
|
||||
# if we are not in object mode, do not do legacy align
|
||||
if not UTIL_functions.is_in_object_mode():
|
||||
return False
|
||||
|
||||
# check current obj
|
||||
if bpy.context.active_object is None:
|
||||
return False
|
||||
|
||||
# check target obj with filter of current obj
|
||||
length = len(bpy.context.selected_objects)
|
||||
if bpy.context.active_object in bpy.context.selected_objects:
|
||||
|
@ -38,7 +38,11 @@ class BBP_OT_select_object_by_virtools_group(bpy.types.Operator, PROP_virtools_g
|
||||
description = "Selection mode",
|
||||
items = _g_EnumHelper_SelectMode.generate_items(),
|
||||
default = _g_EnumHelper_SelectMode.to_selection(SelectMode.Intersect)
|
||||
)
|
||||
) # type: ignore
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return UTIL_functions.is_in_object_mode()
|
||||
|
||||
def invoke(self, context, event):
|
||||
wm = context.window_manager
|
||||
@ -119,7 +123,7 @@ class BBP_OT_add_objects_virtools_group(bpy.types.Operator, PROP_virtools_group.
|
||||
bl_options = {'UNDO'}
|
||||
|
||||
@classmethod
|
||||
def poll(self, context):
|
||||
def poll(cls, context):
|
||||
return len(bpy.context.selected_objects) != 0
|
||||
|
||||
def invoke(self, context, event):
|
||||
@ -131,6 +135,7 @@ class BBP_OT_add_objects_virtools_group(bpy.types.Operator, PROP_virtools_group.
|
||||
for obj in bpy.context.selected_objects:
|
||||
with PROP_virtools_group.VirtoolsGroupsHelper(obj) as gp:
|
||||
gp.add_group(group_name)
|
||||
self.report({'INFO'}, "Grouping objects successfully.")
|
||||
return {'FINISHED'}
|
||||
|
||||
def draw(self, context):
|
||||
@ -143,7 +148,7 @@ class BBP_OT_rm_objects_virtools_group(bpy.types.Operator, PROP_virtools_group.S
|
||||
bl_options = {'UNDO'}
|
||||
|
||||
@classmethod
|
||||
def poll(self, context):
|
||||
def poll(cls, context):
|
||||
return len(bpy.context.selected_objects) != 0
|
||||
|
||||
def invoke(self, context, event):
|
||||
@ -155,6 +160,7 @@ class BBP_OT_rm_objects_virtools_group(bpy.types.Operator, PROP_virtools_group.S
|
||||
for obj in bpy.context.selected_objects:
|
||||
with PROP_virtools_group.VirtoolsGroupsHelper(obj) as gp:
|
||||
gp.remove_group(group_name)
|
||||
self.report({'INFO'}, "Ungrouping objects successfully.")
|
||||
return {'FINISHED'}
|
||||
|
||||
def draw(self, context):
|
||||
@ -167,7 +173,7 @@ class BBP_OT_clear_objects_virtools_group(bpy.types.Operator):
|
||||
bl_options = {'UNDO'}
|
||||
|
||||
@classmethod
|
||||
def poll(self, context):
|
||||
def poll(cls, context):
|
||||
return len(bpy.context.selected_objects) != 0
|
||||
|
||||
def invoke(self, context, event):
|
||||
@ -179,6 +185,7 @@ class BBP_OT_clear_objects_virtools_group(bpy.types.Operator):
|
||||
for obj in bpy.context.selected_objects:
|
||||
with PROP_virtools_group.VirtoolsGroupsHelper(obj) as gp:
|
||||
gp.clear_groups()
|
||||
self.report({'INFO'}, "Clear objects groups successfully.")
|
||||
return {'FINISHED'}
|
||||
|
||||
#endregion
|
||||
|
@ -80,6 +80,16 @@ def select_certain_objects(objs: tuple[bpy.types.Object, ...]) -> None:
|
||||
# select first object as active object
|
||||
bpy.context.view_layer.objects.active = objs[0]
|
||||
|
||||
def is_in_object_mode() -> bool:
|
||||
# get active object from context
|
||||
obj = bpy.context.active_object
|
||||
|
||||
# if there is no active object, we think it is in object mode
|
||||
if obj is None: return True
|
||||
|
||||
# simply check active object mode
|
||||
return obj.mode == 'OBJECT'
|
||||
|
||||
class EnumPropHelper():
|
||||
"""
|
||||
These class contain all functions related to EnumProperty, including generating `items`,
|
||||
|
Loading…
Reference in New Issue
Block a user