Last active
June 28, 2016 18:26
-
-
Save natecraddock/3ded33edc98373266c0f3e1e129f643d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bl_info = { | |
| "name": "Custom Property Manager", | |
| "author": "Nathan Craddock", | |
| "version": (0, 1), | |
| "blender": (2, 77, 0), | |
| "location": "UI > Properties Panel", | |
| "description": "Add objects to track Custom Props on", | |
| "tracker_url": "", | |
| "category": "Object" | |
| } | |
| import bpy | |
| class AddObject(bpy.types.Operator): | |
| """Adds an object to the list""" | |
| bl_idname = "object.add_object_custom" | |
| bl_label = "Add Object" | |
| def execute(self, context): | |
| o = bpy.context.active_object | |
| if o not in context.scene.custom_props_objects: | |
| context.scene.custom_props_objects.append(bpy.context.active_object) | |
| return {'FINISHED'} | |
| class RemoveObject(bpy.types.Operator): | |
| """Removes an object from the list""" | |
| bl_idname = "object.remove_object_custom" | |
| bl_label = "Remove Object" | |
| def execute(self, context): | |
| if bpy.context.active_object in context.scene.custom_props_objects: | |
| context.scene.custom_props_objects.remove(bpy.context.active_object) | |
| return {'FINISHED'} | |
| class LayoutDemoPanel(bpy.types.Panel): | |
| """Creates a Panel in the scene context of the properties editor""" | |
| bl_label = "Custom Property Manager" | |
| bl_idname = "SCENE_PT_layout" | |
| bl_space_type = 'VIEW_3D' | |
| bl_region_type = 'UI' | |
| bl_context = "scene" | |
| def draw(self, context): | |
| layout = self.layout | |
| scene = context.scene | |
| row = layout.row() | |
| row.operator("object.add_object_custom") | |
| row.operator("object.remove_object_custom") | |
| objects = context.scene.custom_props_objects | |
| if objects: | |
| row = layout.row() | |
| row.label(text="Custom Properties:") | |
| for o in objects: | |
| box = layout.box() | |
| box.label(text=o.name) | |
| if o.type == "MESH": | |
| if o.keys(): | |
| for prop in o.keys(): | |
| row = box.row() | |
| row.prop(o, '["' + prop + '"]', slider=True) | |
| else: | |
| row = box.row() | |
| row.label(text=o.name + " has no CP for object") | |
| if o.data.keys(): | |
| for prop in o.data.keys(): | |
| row = box.row() | |
| row.prop(o.data, '["' + prop + '"]', slider=True) | |
| else: | |
| row = box.row() | |
| row.label(text=o.name + " has no CP for data") | |
| elif o.type == "ARMATURE": | |
| armature = bpy.data.armatures[o.name] | |
| if armature.keys(): | |
| for prop in armature.keys(): | |
| row = box.row() | |
| row.prop(armature, '["' + prop + '"]', slider=True) | |
| else: | |
| row = box.row() | |
| row.label(text=o.name + " has no custom properties") | |
| def register(): | |
| bpy.utils.register_module(__name__) | |
| bpy.types.Scene.custom_props_objects = [] | |
| def unregister(): | |
| bpy.utils.unregister_module(__name__) | |
| del bpy.types.Scene.custom_props_objects | |
| if __name__ == "__main__": | |
| register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment