1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
21 from rna_prop_ui import PropertyPanel
24 class SceneButtonsPanel():
25 bl_space_type = 'PROPERTIES'
26 bl_region_type = 'WINDOW'
30 def poll(cls, context):
34 class SCENE_PT_scene(SceneButtonsPanel, bpy.types.Panel):
36 COMPAT_ENGINES = {'BLENDER_RENDER'}
38 def draw(self, context):
42 layout.prop(scene, "camera")
43 layout.prop(scene, "background_set", text="Background")
46 class SCENE_PT_unit(SceneButtonsPanel, bpy.types.Panel):
48 COMPAT_ENGINES = {'BLENDER_RENDER'}
50 def draw(self, context):
52 unit = context.scene.unit_settings
55 col.row().prop(unit, "system", expand=True)
57 split = layout.split()
58 split.active = (unit.system != 'NONE')
61 col.prop(unit, "scale_length", text="Scale")
64 col.prop(unit, "use_separate")
66 layout.column().prop(unit, "rotation_units")
69 class SCENE_PT_keying_sets(SceneButtonsPanel, bpy.types.Panel):
70 bl_label = "Keying Sets"
72 def draw(self, context):
79 col.template_list(scene, "keying_sets", scene.keying_sets, "active_index", rows=2)
81 col = row.column(align=True)
82 col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
83 col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
85 ks = scene.keying_sets.active
86 if ks and ks.is_path_absolute:
93 subcol.operator_context = 'INVOKE_DEFAULT'
94 op = subcol.operator("anim.keying_set_export", text="Export to File")
95 op.filepath = "keyingset.py"
98 col.label(text="Keyframing Settings:")
99 col.prop(ks, "use_insertkey_needed", text="Needed")
100 col.prop(ks, "use_insertkey_visual", text="Visual")
101 col.prop(ks, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
104 class SCENE_PT_keying_set_paths(SceneButtonsPanel, bpy.types.Panel):
105 bl_label = "Active Keying Set"
108 def poll(cls, context):
109 ks = context.scene.keying_sets.active
110 return (ks and ks.is_path_absolute)
112 def draw(self, context):
115 scene = context.scene
116 ks = scene.keying_sets.active
119 row.label(text="Paths:")
124 col.template_list(ks, "paths", ks.paths, "active_index", rows=2)
126 col = row.column(align=True)
127 col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
128 col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="")
130 ksp = ks.paths.active
132 col = layout.column()
133 col.label(text="Target:")
134 col.template_any_ID(ksp, "id", "id_type")
135 col.template_path_builder(ksp, "data_path", ksp.id)
141 col.label(text="Array Target:")
142 col.prop(ksp, "use_entire_array")
143 if ksp.use_entire_array is False:
144 col.prop(ksp, "array_index")
147 col.label(text="F-Curve Grouping:")
148 col.prop(ksp, "group_method")
149 if ksp.group_method == 'NAMED':
150 col.prop(ksp, "group")
152 col.label(text="Keyframing Settings:")
153 col.prop(ksp, "use_insertkey_needed", text="Needed")
154 col.prop(ksp, "use_insertkey_visual", text="Visual")
155 col.prop(ksp, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
158 class SCENE_PT_physics(SceneButtonsPanel, bpy.types.Panel):
160 COMPAT_ENGINES = {'BLENDER_RENDER'}
162 def draw_header(self, context):
163 self.layout.prop(context.scene, "use_gravity", text="")
165 def draw(self, context):
168 scene = context.scene
170 layout.active = scene.use_gravity
172 layout.prop(scene, "gravity", text="")
175 class SCENE_PT_simplify(SceneButtonsPanel, bpy.types.Panel):
176 bl_label = "Simplify"
177 COMPAT_ENGINES = {'BLENDER_RENDER'}
179 def draw_header(self, context):
180 scene = context.scene
182 self.layout.prop(rd, "use_simplify", text="")
184 def draw(self, context):
186 scene = context.scene
189 layout.active = rd.use_simplify
191 split = layout.split()
194 col.prop(rd, "simplify_subdivision", text="Subdivision")
195 col.prop(rd, "simplify_child_particles", text="Child Particles")
197 col.prop(rd, "use_simplify_triangulate")
200 col.prop(rd, "simplify_shadow_samples", text="Shadow Samples")
201 col.prop(rd, "simplify_ao_sss", text="AO and SSS")
204 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, bpy.types.Panel):
205 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
206 _context_path = "scene"
209 from bpy.props import *
212 class ANIM_OT_keying_set_export(bpy.types.Operator):
213 "Export Keying Set to a python script."
214 bl_idname = "anim.keying_set_export"
215 bl_label = "Export Keying Set..."
217 filepath = bpy.props.StringProperty(name="File Path", description="Filepath to write file to.")
218 filter_folder = bpy.props.BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'})
219 filter_text = bpy.props.BoolProperty(name="Filter text", description="", default=True, options={'HIDDEN'})
220 filter_python = bpy.props.BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'})
222 def execute(self, context):
223 if not self.properties.filepath:
224 raise Exception("Filepath not set.")
226 f = open(self.properties.filepath, "w")
228 raise Exception("Could not open file.")
230 scene = context.scene
231 ks = scene.keying_sets.active
234 f.write("# Keying Set: %s\n" % ks.name)
236 f.write("import bpy\n\n")
237 f.write("scene= bpy.data.scenes[0]\n\n")
239 # Add KeyingSet and set general settings
240 f.write("# Keying Set Level declarations\n")
241 f.write("ks= scene.keying_sets.new(name=\"%s\")\n" % ks.name)
243 if not ks.is_path_absolute:
244 f.write("ks.is_path_absolute = False\n")
247 f.write("ks.use_insertkey_needed = %s\n" % ks.use_insertkey_needed)
248 f.write("ks.use_insertkey_visual = %s\n" % ks.use_insertkey_visual)
249 f.write("ks.use_insertkey_xyz_to_rgb = %s\n" % ks.use_insertkey_xyz_to_rgb)
253 # generate and write set of lookups for id's used in paths
254 id_to_paths_cache = {} # cache for syncing ID-blocks to bpy paths + shorthands
259 if ksp.id in id_to_paths_cache:
262 # - idtype_list is used to get the list of id-datablocks from bpy.data.*
263 # since this info isn't available elsewhere
264 # - id.bl_rna.name gives a name suitable for UI,
265 # with a capitalised first letter, but we need
266 # the plural form that's all lower case
267 idtype_list = ksp.id.bl_rna.name.lower() + "s"
268 id_bpy_path = "bpy.data.%s[\"%s\"]" % (idtype_list, ksp.id.name)
270 # shorthand ID for the ID-block (as used in the script)
271 short_id = "id_%d" % len(id_to_paths_cache)
273 # store this in the cache now
274 id_to_paths_cache[ksp.id] = [short_id, id_bpy_path]
276 f.write("# ID's that are commonly used\n")
277 for id_pair in id_to_paths_cache.values():
278 f.write("%s = %s\n" % (id_pair[0], id_pair[1]))
283 f.write("# Path Definitions\n")
285 f.write("ksp = ks.paths.add(")
287 # id-block + data_path
289 # find the relevant shorthand from the cache
290 id_bpy_path = id_to_paths_cache[ksp.id][0]
292 id_bpy_path = "None" # XXX...
293 f.write("%s, '%s'" % (id_bpy_path, ksp.data_path))
295 # array index settings (if applicable)
296 if ksp.use_entire_array:
297 f.write(", index=-1")
299 f.write(", index=%d" % ksp.array_index)
301 # grouping settings (if applicable)
302 # NOTE: the current default is KEYINGSET, but if this changes, change this code too
303 if ksp.group_method == 'NAMED':
304 f.write(", group_method='%s', group_name=\"%s\"" % (ksp.group_method, ksp.group))
305 elif ksp.group_method != 'KEYINGSET':
306 f.write(", group_method='%s'" % ksp.group_method)
316 def invoke(self, context, event):
318 wm.add_fileselect(self)
319 return {'RUNNING_MODAL'}
329 if __name__ == "__main__":