[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36250] trunk/blender/release/scripts/ startup/bl_operators/object_quick_effects.py: Bug fix: "make fur" gave errors with multiple selected objects.

Janne Karhu jhkarh at gmail.com
Wed Apr 20 19:51:56 CEST 2011


Revision: 36250
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36250
Author:   jhk
Date:     2011-04-20 17:51:56 +0000 (Wed, 20 Apr 2011)
Log Message:
-----------
Bug fix: "make fur" gave errors with multiple selected objects.
* Also some code changes for "make smoke" and "make fluid" to suppress some python messages that were printed to the console.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_operators/object_quick_effects.py

Modified: trunk/blender/release/scripts/startup/bl_operators/object_quick_effects.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/object_quick_effects.py	2011-04-20 17:15:33 UTC (rev 36249)
+++ trunk/blender/release/scripts/startup/bl_operators/object_quick_effects.py	2011-04-20 17:51:56 UTC (rev 36250)
@@ -55,7 +55,7 @@
         mat.strand.blend_distance = 0.5
 
         for obj in mesh_objects:
-            fake_context["active_object"] = obj
+            fake_context["object"] = obj
             bpy.ops.object.particle_system_add(fake_context)
 
             psys = obj.particle_systems[-1]
@@ -110,6 +110,7 @@
                 default=False)
 
     def execute(self, context):
+        fake_context = bpy.context.copy()
         mesh_objects = [obj for obj in context.selected_objects if obj.type == 'MESH']
         min_co = Vector((100000, 100000, 100000))
         max_co = Vector((-100000, -100000, -100000))
@@ -119,8 +120,9 @@
             return {'CANCELLED'}
 
         for obj in mesh_objects:
+            fake_context["object"] = obj
             # make each selected object a smoke flow
-            bpy.ops.object.modifier_add({"object": obj}, type='SMOKE')
+            bpy.ops.object.modifier_add(fake_context, type='SMOKE')
             obj.modifiers[-1].smoke_type = 'FLOW'
 
             psys = obj.particle_systems[-1]
@@ -153,7 +155,7 @@
         obj.scale = 0.5 * (max_co - min_co) + Vector((1.0, 1.0, 2.0))
 
         # setup smoke domain
-        bpy.ops.object.modifier_add({"object": obj}, type='SMOKE')
+        bpy.ops.object.modifier_add(type='SMOKE')
         obj.modifiers[-1].smoke_type = 'DOMAIN'
         if self.style == 'FIRE':
             obj.modifiers[-1].domain_settings.use_dissolve_smoke = True
@@ -161,7 +163,7 @@
             obj.modifiers[-1].domain_settings.use_high_resolution = True
 
         # create a volume material with a voxel data texture for the domain
-        bpy.ops.object.material_slot_add({"object": obj})
+        bpy.ops.object.material_slot_add()
 
         mat = bpy.data.materials.new("Smoke Domain Material")
         obj.material_slots[0].material = mat
@@ -224,6 +226,7 @@
                 default=False)
 
     def execute(self, context):
+        fake_context = bpy.context.copy()
         mesh_objects = [obj for obj in context.selected_objects if (obj.type == 'MESH' and not 0 in obj.dimensions)]
         min_co = Vector((100000, 100000, 100000))
         max_co = Vector((-100000, -100000, -100000))
@@ -233,8 +236,9 @@
             return {'CANCELLED'}
 
         for obj in mesh_objects:
+            fake_context["object"] = obj
             # make each selected object a fluid
-            bpy.ops.object.modifier_add({"object": obj}, type='FLUID_SIMULATION')
+            bpy.ops.object.modifier_add(fake_context, type='FLUID_SIMULATION')
 
             # fluid has to be before constructive modifiers, so it might not be the last modifier
             for mod in obj.modifiers:
@@ -266,14 +270,14 @@
         obj.scale = 0.5 * (max_co - min_co) + Vector((1.0, 1.0, 2.0)) + Vector((abs(v[0]), abs(v[1]), abs(v[2])))
 
         # setup smoke domain
-        bpy.ops.object.modifier_add({"object": obj}, type='FLUID_SIMULATION')
+        bpy.ops.object.modifier_add(type='FLUID_SIMULATION')
         obj.modifiers[-1].settings.type = 'DOMAIN'
 
         # make the domain smooth so it renders nicely
         bpy.ops.object.shade_smooth()
 
         # create a ray-transparent material for the domain
-        bpy.ops.object.material_slot_add({"object": obj})
+        bpy.ops.object.material_slot_add()
 
         mat = bpy.data.materials.new("Fluid Domain Material")
         obj.material_slots[0].material = mat




More information about the Bf-blender-cvs mailing list