file_preset = open(filepath, 'w')
file_preset.write("import bpy\n")
+ if hasattr(self, "preset_defines"):
+ for rna_path in self.preset_defines:
+ exec(rna_path)
+ file_preset.write("%s\n" % rna_path)
+ file_preset.write("\n")
+
for rna_path in self.preset_values:
value = eval(rna_path)
# convert thin wrapped sequences to simple lists to repr()
bl_label = "Add Render Preset"
preset_menu = "RENDER_MT_presets"
+ preset_defines = [
+ "scene = bpy.context.scene"
+ ]
+
preset_values = [
- "bpy.context.scene.render.field_order",
- "bpy.context.scene.render.fps",
- "bpy.context.scene.render.fps_base",
- "bpy.context.scene.render.pixel_aspect_x",
- "bpy.context.scene.render.pixel_aspect_y",
- "bpy.context.scene.render.resolution_percentage",
- "bpy.context.scene.render.resolution_x",
- "bpy.context.scene.render.resolution_y",
- "bpy.context.scene.render.use_fields",
- "bpy.context.scene.render.use_fields_still",
+ "scene.render.field_order",
+ "scene.render.fps",
+ "scene.render.fps_base",
+ "scene.render.pixel_aspect_x",
+ "scene.render.pixel_aspect_y",
+ "scene.render.resolution_percentage",
+ "scene.render.resolution_x",
+ "scene.render.resolution_y",
+ "scene.render.use_fields",
+ "scene.render.use_fields_still",
]
preset_subdir = "render"
bl_label = "Add SSS Preset"
preset_menu = "MATERIAL_MT_sss_presets"
+ preset_defines = [
+ "material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)"
+ ]
+
preset_values = [
- "bpy.context.material.subsurface_scattering.back",
- "bpy.context.material.subsurface_scattering.color[0]",
- "bpy.context.material.subsurface_scattering.color[1]",
- "bpy.context.material.subsurface_scattering.color[2]",
- "bpy.context.material.subsurface_scattering.color_factor",
- "bpy.context.material.subsurface_scattering.error_threshold",
- "bpy.context.material.subsurface_scattering.front",
- "bpy.context.material.subsurface_scattering.ior",
- "bpy.context.material.subsurface_scattering.radius[0]",
- "bpy.context.material.subsurface_scattering.radius[1]",
- "bpy.context.material.subsurface_scattering.radius[2]",
- "bpy.context.material.subsurface_scattering.scale",
- "bpy.context.material.subsurface_scattering.texture_factor",
+ "material.subsurface_scattering.back",
+ "material.subsurface_scattering.color",
+ "material.subsurface_scattering.color_factor",
+ "material.subsurface_scattering.error_threshold",
+ "material.subsurface_scattering.front",
+ "material.subsurface_scattering.ior",
+ "material.subsurface_scattering.radius",
+ "material.subsurface_scattering.scale",
+ "material.subsurface_scattering.texture_factor",
]
preset_subdir = "sss"
bl_label = "Add Cloth Preset"
preset_menu = "CLOTH_MT_presets"
+ preset_defines = [
+ "cloth = bpy.context.cloth"
+ ]
+
preset_values = [
- "bpy.context.cloth.settings.air_damping",
- "bpy.context.cloth.settings.bending_stiffness",
- "bpy.context.cloth.settings.mass",
- "bpy.context.cloth.settings.quality",
- "bpy.context.cloth.settings.spring_damping",
- "bpy.context.cloth.settings.structural_stiffness",
+ "cloth.settings.air_damping",
+ "cloth.settings.bending_stiffness",
+ "cloth.settings.mass",
+ "cloth.settings.quality",
+ "cloth.settings.spring_damping",
+ "cloth.settings.structural_stiffness",
]
preset_subdir = "cloth"
bl_label = "Add Sunsky Preset"
preset_menu = "LAMP_MT_sunsky_presets"
+ preset_defines = [
+ "sky = bpy.context.object.data.sky"
+ ]
+
preset_values = [
- "bpy.context.object.data.sky.atmosphere_extinction",
- "bpy.context.object.data.sky.atmosphere_inscattering",
- "bpy.context.object.data.sky.atmosphere_turbidity",
- "bpy.context.object.data.sky.backscattered_light",
- "bpy.context.object.data.sky.horizon_brightness",
- "bpy.context.object.data.sky.spread",
- "bpy.context.object.data.sky.sun_brightness",
- "bpy.context.object.data.sky.sun_intensity",
- "bpy.context.object.data.sky.sun_size",
- "bpy.context.object.data.sky.use_sky_blend",
- "bpy.context.object.data.sky.use_sky_blend_type",
- "bpy.context.object.data.sky.use_sky_color_space",
- "bpy.context.object.data.sky.use_sky_exposure",
+ "sky.atmosphere_extinction",
+ "sky.atmosphere_inscattering",
+ "sky.atmosphere_turbidity",
+ "sky.backscattered_light",
+ "sky.horizon_brightness",
+ "sky.spread",
+ "sky.sun_brightness",
+ "sky.sun_intensity",
+ "sky.sun_size",
+ "sky.use_sky_blend",
+ "sky.use_sky_blend_type",
+ "sky.use_sky_color_space",
+ "sky.use_sky_exposure",
]
preset_subdir = "sunsky"
bl_label = "Add Interaction Preset"
preset_menu = "USERPREF_MT_interaction_presets"
+ preset_defines = [
+ "user_preferences = bpy.context.user_preferences"
+ ]
+
preset_values = [
- "bpy.context.user_preferences.edit.use_drag_immediately",
- "bpy.context.user_preferences.edit.use_insertkey_xyz_to_rgb",
- "bpy.context.user_preferences.inputs.invert_mouse_wheel_zoom",
- "bpy.context.user_preferences.inputs.select_mouse",
- "bpy.context.user_preferences.inputs.use_emulate_numpad",
- "bpy.context.user_preferences.inputs.use_mouse_continuous",
- "bpy.context.user_preferences.inputs.use_mouse_emulate_3_button",
- "bpy.context.user_preferences.inputs.view_rotate_method",
- "bpy.context.user_preferences.inputs.view_zoom_axis",
- "bpy.context.user_preferences.inputs.view_zoom_method",
+ "user_preferences.edit.use_drag_immediately",
+ "user_preferences.edit.use_insertkey_xyz_to_rgb",
+ "user_preferences.inputs.invert_mouse_wheel_zoom",
+ "user_preferences.inputs.select_mouse",
+ "user_preferences.inputs.use_emulate_numpad",
+ "user_preferences.inputs.use_mouse_continuous",
+ "user_preferences.inputs.use_mouse_emulate_3_button",
+ "user_preferences.inputs.view_rotate_method",
+ "user_preferences.inputs.view_zoom_axis",
+ "user_preferences.inputs.view_zoom_method",
]
preset_subdir = "interaction"
return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
}
-/* returns (optional) active node material in base material */
-static PointerRNA rna_Object_active_node_material_get(PointerRNA *ptr)
-{
- Object *ob= (Object*)ptr->id.data;
- Material *ma;
-
- ma= (ob->totcol)? give_current_material(ob, ob->actcol): NULL;
- if(ma) {
- Material *manode= give_node_material(ma);
- if(manode)
- return rna_pointer_inherit_refine(ptr, &RNA_Material, manode);
- }
-
- return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
-}
-
static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value)
{
Object *ob= (Object*)ptr->id.data;
RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_MaterialSlot_update");
- prop= RNA_def_property(srna, "active_node_material", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "Material");
- RNA_def_property_pointer_funcs(prop, "rna_Object_active_node_material_get", NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Active Material", "Active (node) material being displayed");
- RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
-
-
prop= RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "actcol");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);