Skip to content

Commit df91f27

Browse files
committed
add enable/disable selected; remove deselect all when chaning selected
1 parent 22ea9b9 commit df91f27

File tree

5 files changed

+43
-9
lines changed

5 files changed

+43
-9
lines changed

simloader/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .operators import SIMLOADER_OT_load, SIMLOADER_OT_edit, SIMLOADER_OT_resetpt, SIMLOADER_OT_resetmesh, SIMLOADER_OT_resetins,SIMLOADER_OT_set_as_split_norm,SIMLOADER_OT_remove_split_norm
1+
from .operators import SIMLOADER_OT_load, SIMLOADER_OT_edit, SIMLOADER_OT_resetpt, SIMLOADER_OT_resetmesh, SIMLOADER_OT_resetins,SIMLOADER_OT_set_as_split_norm,SIMLOADER_OT_remove_split_norm,SIMLOADER_OT_disable_selected,SIMLOADER_OT_enable_selected
22
from .properties import SIMLOADER_scene_property, SIMLOADER_obj_property,SIMLOADER_mesh_property
33
from .panels import SIMLOADER_UL_Obj_List, SIMLOADER_List_Panel, SIMLOADER_Settings, SIMLOADER_Import, SIMLOADER_Templates, SIMLOADER_UL_Att_List, draw_template
44
from .messanger import subscribe_to_selected, unsubscribe_to_selected
@@ -58,4 +58,6 @@ def SIMLOADER_initilize(scene):
5858
"SIMLOADER_OT_set_as_split_norm",
5959
"SIMLOADER_mesh_property",
6060
"SIMLOADER_OT_remove_split_norm",
61+
"SIMLOADER_OT_disable_selected",
62+
"SIMLOADER_OT_enable_selected",
6163
]

simloader/callback.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ def callback_fileseq(self, context):
3535

3636

3737
def update_selected_obj_num(self, context):
38+
3839
# Here is when select sequences, then change the corresponding object to active object
3940
index = context.scene.SIMLOADER.selected_obj_num
4041
obj = bpy.data.objects[index]
41-
bpy.ops.object.select_all(action="DESELECT")
42+
43+
# TODO: maybe better way to deal with this?
44+
# bpy.ops.object.select_all(action="DESELECT")
4245
obj.select_set(True)
4346
context.view_layer.objects.active = obj
4447

simloader/messanger.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ def selected_callback():
88
if idx >= 0:
99
bpy.context.scene.SIMLOADER.selected_obj_num = idx
1010

11-
1211
def subscribe_to_selected():
1312
# A known problem of this function,
1413
# This function will not be executed, when the first time this addon is installed.

simloader/operators.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,32 @@ def execute(self, context):
216216
if mesh.SIMLOADER.split_norm_att_name:
217217
mesh.SIMLOADER.split_norm_att_name = ""
218218

219+
return {"FINISHED"}
220+
221+
222+
class SIMLOADER_OT_disable_selected(bpy.types.Operator):
223+
'''
224+
This operator disable all selected sequence
225+
'''
226+
bl_label = "Disable Selected Sequence"
227+
bl_idname = "simloader.disableselected"
228+
bl_options = {"UNDO"}
229+
def execute(self, context):
230+
for obj in bpy.context.selected_objects:
231+
if obj.SIMLOADER.init and obj.SIMLOADER.enabled:
232+
obj.SIMLOADER.enabled = False
233+
return {"FINISHED"}
234+
235+
236+
class SIMLOADER_OT_enable_selected(bpy.types.Operator):
237+
'''
238+
This operator enable all selected sequence
239+
'''
240+
bl_label = "Enable Selected Sequence"
241+
bl_idname = "simloader.enableselected"
242+
bl_options = {"UNDO"}
243+
def execute(self, context):
244+
for obj in bpy.context.selected_objects:
245+
if obj.SIMLOADER.init and not obj.SIMLOADER.enabled:
246+
obj.SIMLOADER.enabled = True
219247
return {"FINISHED"}

simloader/panels.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,25 @@ def filter_items(self, context, data, property):
2323
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
2424
if item:
2525
layout.prop(item, "name", text='Name ', emboss=False)
26+
if item in bpy.context.selected_objects:
27+
layout.label(text="selected")
2628
else:
2729
# actually, I guess this line of code won't be executed?
2830
layout.label(text="", translate=False, icon_value=icon)
2931

3032

31-
3233
class SIMLOADER_UL_Att_List(bpy.types.UIList):
3334
'''
3435
This controls the list of attributes available for this sequence
3536
'''
37+
3638
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
3739
if item:
3840
layout.enabled = False
3941
layout.prop(item, "name", text='Name ', emboss=False)
4042
obj = bpy.data.objects[context.scene.SIMLOADER.selected_obj_num]
4143
mesh = obj.data
42-
if mesh.SIMLOADER.split_norm_att_name and mesh.SIMLOADER.split_norm_att_name ==item.name:
44+
if mesh.SIMLOADER.split_norm_att_name and mesh.SIMLOADER.split_norm_att_name == item.name:
4345
layout.label(text="using as split norm")
4446

4547
else:
@@ -63,6 +65,8 @@ def draw(self, context):
6365
sim_loader = context.scene.SIMLOADER
6466
row = layout.row()
6567
row.template_list("SIMLOADER_UL_Obj_List", "", bpy.data, "objects", sim_loader, "selected_obj_num", rows=2)
68+
layout.operator("simloader.enableselected")
69+
layout.operator("simloader.disableselected")
6670
layout.operator("sequence.edit")
6771

6872

@@ -81,7 +85,7 @@ class SIMLOADER_Settings(bpy.types.Panel):
8185
def draw(self, context):
8286
layout = self.layout
8387
sim_loader = context.scene.SIMLOADER
84-
if sim_loader.selected_obj_num>=len(bpy.data.objects):
88+
if sim_loader.selected_obj_num >= len(bpy.data.objects):
8589
return
8690
obj = bpy.data.objects[sim_loader.selected_obj_num]
8791
if not obj.SIMLOADER.init:
@@ -104,7 +108,6 @@ def draw(self, context):
104108
col2.operator('SIMLOADER.resetmesh', text="Mesh")
105109
col3.operator('SIMLOADER.resetins', text="Instances")
106110

107-
108111
# path settings
109112
layout.label(text="Path Information")
110113
box = layout.box()
@@ -119,15 +122,14 @@ def draw(self, context):
119122
col2.prop(obj.SIMLOADER, 'use_relative', text="")
120123
col1.label(text='Pattern')
121124
col2.prop(obj.SIMLOADER, 'pattern', text="")
122-
123125

124126
# attributes settings
125127
layout.label(text="Attributes Settings")
126128
box = layout.box()
127129
row = box.row()
128130
row.template_list("SIMLOADER_UL_Att_List", "", obj.data, "attributes", sim_loader, "selected_attribute_num", rows=2)
129131
box.operator("SIMLOADER.setsplitnorm")
130-
box.operator("SIMLOADER.removesplitnorm",text="remove split norm")
132+
box.operator("SIMLOADER.removesplitnorm", text="remove split norm")
131133

132134
# advance settings
133135
layout.label(text="Advance Settings")

0 commit comments

Comments
 (0)