Skip to content
Snippets Groups Projects
Commit 35086b9e authored by Campbell Barton's avatar Campbell Barton
Browse files

- enable this for the sequencer

- added option to copy from active to selected
- made the active display first
parent 6bfa9f8f
No related branches found
No related tags found
No related merge requests found
......@@ -35,29 +35,39 @@ bl_addon_info = {
import bpy
def _property_chart_data_get(self, context):
# eg. context.active_object
obj = eval("context.%s" % self.context_data_path_active)
class View3DEditProps(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
if obj is None:
return None, None
bl_label = "Property Chart"
bl_context = "objectmode"
# eg. context.selected_objects[:]
selected_objects = eval("context.%s" % self.context_data_path_selected)[:]
_PROP_STORAGE_ID = "view3d_edit_props"
if not selected_objects:
return None, None
def draw(self, context):
layout = self.layout
obj = context.object
return obj, selected_objects
if obj is None:
return
selected_objects = context.selected_objects
def _property_chart_draw(self, context):
'''
This function can run for different types.
'''
obj, selected_objects = _property_chart_data_get(self, context)
if not selected_objects:
if not obj:
return
# box = layout.separator()
# active first
try:
active_index = selected_objects.index(obj)
except ValueError:
active_index = -1
if active_index > 0: # not the first alredy
selected_objects[0], selected_objects[active_index] = selected_objects[active_index], selected_objects[0]
id_storage = context.scene
......@@ -97,7 +107,9 @@ class View3DEditProps(bpy.types.Panel):
# Collected all props, now display them all
row = layout.row()
layout = self.layout
row = layout.row(align=True)
col = row.column()
col.label(text="name")
......@@ -106,11 +118,19 @@ class View3DEditProps(bpy.types.Panel):
for i in range(len(strings)):
col = row.column()
col.label(text=strings[i].rsplit(".", 1)[-1])
# name and copy button
rowsub = col.row(align=False)
rowsub.label(text=strings[i].rsplit(".", 1)[-1])
props = rowsub.operator("wm.chart_copy", text="", icon='PASTEDOWN', emboss=False)
props.data_path_active = self.context_data_path_active
props.data_path_selected = self.context_data_path_selected
props.data_path_storage = self._PROP_STORAGE_ID
for obj, prop_pairs in prop_all:
data, attr = prop_pairs[i]
if data:
col.prop(data, attr, text="")
col.prop(data, attr, text="")# , emboss=obj==active_object
else:
col.label(text="<missing>")
......@@ -120,12 +140,96 @@ class View3DEditProps(bpy.types.Panel):
col.prop(id_storage, '["%s"]' % self._PROP_STORAGE_ID, text="")
class View3DEditProps(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Property Chart"
bl_context = "objectmode"
_PROP_STORAGE_ID = "view3d_edit_props"
# _property_chart_draw needs these
context_data_path_active = "active_object"
context_data_path_selected = "selected_objects"
draw = _property_chart_draw
class SequencerEditProps(bpy.types.Panel):
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'
bl_label = "Property Chart"
_PROP_STORAGE_ID = "sequencer_edit_props"
# _property_chart_draw needs these
context_data_path_active = "scene.sequence_editor.active_strip"
context_data_path_selected = "selected_sequences"
draw = _property_chart_draw
# Operator to copy properties
def _property_chart_copy(self, context):
obj, selected_objects = _property_chart_data_get(self, context)
if not obj:
return
id_storage = context.scene
strings = id_storage.get(self.properties.data_path_storage)
if strings:
strings = strings.split()
# quick & nasty method!
for obj_iter in selected_objects:
if obj != obj_iter:
for prop_path in strings:
try:
exec("obj_iter.%s = obj.%s" % (prop_path, prop_path))
except:
# just incase we need to know what went wrong!
import traceback
traceback.print_exc()
from bpy.props import StringProperty
class CopyPropertyChart(bpy.types.Operator):
"Open a path in a file browser"
bl_idname = "wm.chart_copy"
bl_label = "Copy properties from active to selected"
data_path_active = StringProperty()
data_path_selected = StringProperty()
data_path_storage = StringProperty()
def execute(self, context):
# so attributes are found for '_property_chart_data_get()'
self.context_data_path_active = self.properties.data_path_active
self.context_data_path_selected = self.properties.data_path_selected
_property_chart_copy(self, context)
return {'FINISHED'}
def register():
bpy.types.register(View3DEditProps)
bpy.types.register(SequencerEditProps)
bpy.types.register(CopyPropertyChart)
def unregister():
bpy.types.unregister(View3DEditProps)
bpy.types.unregister(SequencerEditProps)
bpy.types.unregister(CopyPropertyChart)
if __name__ == "__main__":
register()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment