Skip to content

Commit

Permalink
Merge pull request #2971 from t3du/firstUIChanges
Browse files Browse the repository at this point in the history
Armory Traits UI: Remove Traits and Print Scene Traits
  • Loading branch information
luboslenco committed Nov 29, 2023
2 parents 70fce1f + dbf7ed0 commit b79f72b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
19 changes: 19 additions & 0 deletions blender/arm/props_traits.py
Expand Up @@ -734,6 +734,23 @@ def draw(self, context):
obj = bpy.context.scene
draw_traits_panel(self.layout, obj, is_object=False)

class ARM_OT_RemoveTraitsFromActiveObjects(bpy.types.Operator):
bl_label = 'Remove Traits From Selected Objects'
bl_idname = 'arm.remove_traits_from_active_objects'
bl_description = 'Removes all traits from all selected objects'

@classmethod
def poll(cls, context):
return len(context.selected_objects) > 0

def execute(self, context):
for obj in bpy.context.selected_objects:
obj.arm_traitlist.clear()
obj.arm_traitlist_index = 0

return {"FINISHED"}


class ARM_OT_CopyTraitsFromActive(bpy.types.Operator):
bl_label = 'Copy Traits from Active Object'
bl_idname = 'arm.copy_traits_to_active'
Expand Down Expand Up @@ -814,6 +831,7 @@ def draw(self, _context):
layout = self.layout

layout.operator("arm.copy_traits_to_active", icon='PASTEDOWN')
layout.operator("arm.remove_traits_from_active_objects", icon='REMOVE')
layout.operator("arm.print_traits", icon='CONSOLE')

def draw_traits_panel(layout: bpy.types.UILayout, obj: Union[bpy.types.Object, bpy.types.Scene], is_object: bool) -> None:
Expand Down Expand Up @@ -977,6 +995,7 @@ def draw_traits_panel(layout: bpy.types.UILayout, obj: Union[bpy.types.Object, b
ARM_PT_SceneTraitPanel,
ARM_OT_CopyTraitsFromActive,
ARM_MT_context_menu,
ARM_OT_RemoveTraitsFromActiveObjects
)
__reg_classes, unregister = bpy.utils.register_classes_factory(__REG_CLASSES)

Expand Down
17 changes: 15 additions & 2 deletions blender/arm/props_ui.py
Expand Up @@ -2278,12 +2278,25 @@ def draw(self, context):

class ArmPrintTraitsButton(bpy.types.Operator):
bl_idname = 'arm.print_traits'
bl_label = 'Print All Scenes Traits'
bl_label = 'Print All Traits'
bl_description = 'Returns all traits in current blend'

def execute(self, context):
for s in bpy.data.scenes:
print('Scene: {0}'.format(s.name))
for t in s.arm_traitlist:
if not t.enabled_prop:
continue
tname = "undefined"
if t.type_prop == 'Haxe Script' or "Bundled":
tname = t.class_name_prop
if t.type_prop == 'Logic Nodes':
tname = t.node_tree_prop.name
if t.type_prop == 'UI Canvas':
tname = t.canvas_name_prop
if t.type_prop == 'WebAssembly':
tname = t.webassembly_prop
print('Scene Trait: {0} ("{1}")'.format(s.name, tname))
for o in s.objects:
for t in o.arm_traitlist:
if not t.enabled_prop:
Expand All @@ -2297,7 +2310,7 @@ def execute(self, context):
tname = t.canvas_name_prop
if t.type_prop == 'WebAssembly':
tname = t.webassembly_prop
print('Trait: {0} ("{1}")'.format(o.name, tname))
print(' Object Trait: {0} ("{1}")'.format(o.name, tname))
return{'FINISHED'}

class ARM_PT_MaterialNodePanel(bpy.types.Panel):
Expand Down

0 comments on commit b79f72b

Please sign in to comment.