[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4198] contrib/py/scripts/addons/ io_atomblend_utilities: I re-designed the code for replacing/ separating atoms: one can now

Clemens Barth barth at root-1.de
Wed Jan 23 07:20:20 CET 2013


Revision: 4198
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4198
Author:   blendphys
Date:     2013-01-23 06:20:17 +0000 (Wed, 23 Jan 2013)
Log Message:
-----------
I re-designed the code for replacing/separating atoms: one can now 
independently choose the shape and material. I think that this is 
much better.

Blendphys.

Modified Paths:
--------------
    contrib/py/scripts/addons/io_atomblend_utilities/__init__.py
    contrib/py/scripts/addons/io_atomblend_utilities/io_atomblend_utilities.py

Modified: contrib/py/scripts/addons/io_atomblend_utilities/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_atomblend_utilities/__init__.py	2013-01-23 05:23:13 UTC (rev 4197)
+++ contrib/py/scripts/addons/io_atomblend_utilities/__init__.py	2013-01-23 06:20:17 UTC (rev 4198)
@@ -24,7 +24,7 @@
 #
 #  Start of project              : 2011-12-01 by Clemens Barth
 #  First publication in Blender  : 2012-11-03
-#  Last modified                 : 2013-01-22
+#  Last modified                 : 2013-01-23
 #
 #  Acknowledgements 
 #  ================
@@ -119,10 +119,8 @@
         col = box.column(align=True)
         col.label(text="Change atom shape")
         col.prop(scn, "replace_objs")
+        col.prop(scn, "replace_objs_material")
         col.operator("atom_blend.replace_atom")  
-
-        box = layout.box()
-        col = box.column(align=True)
         col.label(text="Default values")
         col.operator("atom_blend.default_atoms") 
 
@@ -131,7 +129,8 @@
         col.label(text="Separate atoms")
         col2 = col.column()
         col2.active = (bpy.context.mode == 'EDIT_MESH')
-        col2.prop(scn, "draw_objs")
+        col2.prop(scn, "separate_objs")
+        col2.prop(scn, "separate_objs_material")        
         col2.operator("atom_blend.separate_atom")
         
 
@@ -173,29 +172,33 @@
     replace_objs = EnumProperty(
         name="Shape",
         description="Choose a different shape.",
-        items=(('-1',"Unchanged", "Use again a ball"),
-               ('0a',"Sphere", "Replace with a sphere"),
-               ('0b',"Sphere (NURBS)", "Replace with a sphere (NURBS)"),        
-               ('1',"Cube", "Replace with a cube"),
-               ('2',"Plane", "Replace with a plane"),
-               ('3a',"Circle", "Replace with a circle"),
-               ('3b',"Circle (NURBS)", "Replace with a circle (NURBS)"),               
-               ('4a',"Icosphere 1", "Replace with a icosphere, subd=1"),  
-               ('4b',"Icosphere 2", "Replace with a icosphere, subd=2"),  
-               ('4c',"Icosphere 3", "Replace with a icosphere, subd=3"),                             
-               ('4d',"Icosphere 4", "Replace with a icosphere, subd=4"),                             
-               ('4e',"Icosphere 5", "Replace with a icosphere, subd=5"),                             
-               ('5a',"Cylinder", "Replace with a cylinder"),
-               ('5b',"Cylinder (NURBS)", "Replace with a cylinder (NURBS)"),               
-               ('6',"Cone", "Replace with a cone"),
-               ('7a',"Torus", "Replace with a torus"),
-               ('7b',"Torus (NURBS)", "Replace with a torus (NURBS)"),
-               ('8',"Transparent cube", "Replace with a transparent cube"),      
-               ('9',"Transparent sphere", "Replace with a transparent sphere"),
-               ('10',"Transparent sphere (NURBS)", 
-                                  "Replace with a transparent sphere (NURBS)"),               
-               ('11',"Halo cloud", "Replace with a halo cloud")),
-               default='-1',)          
+        items=(('0',"Unchanged", "Do not change the shape"),
+               ('1a',"Sphere (Mesh)", "Replace with a sphere (Mesh)"),
+               ('1b',"Sphere (NURBS)", "Replace with a sphere (NURBS)"),        
+               ('2',"Cube", "Replace with a cube"),
+               ('3',"Plane", "Replace with a plane"),
+               ('4a',"Circle (Mesh)", "Replace with a circle (Mesh)"),
+               ('4b',"Circle (NURBS)", "Replace with a circle (NURBS)"),               
+               ('5a',"Icosphere 1", "Replace with a icosphere, subd=1"),  
+               ('5b',"Icosphere 2", "Replace with a icosphere, subd=2"),  
+               ('5c',"Icosphere 3", "Replace with a icosphere, subd=3"),  
+               ('5d',"Icosphere 4", "Replace with a icosphere, subd=4"),
+               ('5e',"Icosphere 5", "Replace with a icosphere, subd=5"),                                                         
+               ('6a',"Cylinder (Mesh)", "Replace with a cylinder (Mesh)"),
+               ('6b',"Cylinder (NURBS)", "Replace with a cylinder (NURBS)"),               
+               ('7',"Cone", "Replace with a cone"),
+               ('8a',"Torus (Mesh)", "Replace with a torus (Mesh)"),
+               ('8b',"Torus (NURBS)", "Replace with a torus (NURBS)")),
+               default='0',)     
+    replace_objs_material = EnumProperty(
+        name="Material",
+        description="Choose a different material.",
+        items=(('0',"Unchanged", "Leave the material unchanged"),
+               ('1',"Normal", "Use normal material (no transparency and reflection)"),
+               ('2',"Transparent", "Use transparent material"),
+               ('3',"Reflecting", "Use reflecting material"),
+               ('4',"Transparent + reflecting", "Use transparent and reflecting material")),
+               default='0',)                           
     obj_who = EnumProperty(
         name="",
         description="Which objects shall be modified?",
@@ -240,32 +243,37 @@
     sticks_all = FloatProperty(
         name="Scale", default = 1.05, min=1.0, max=5.0,
         description="Put in the scale factor")
-    draw_objs = EnumProperty(
+    separate_objs = EnumProperty(
         name="Shape",
         description="Choose a different shape.",
-        items=(('-1',"Unchanged", "Use again a ball"),
-               ('0a',"Sphere", "Replace with a sphere"),
-               ('0b',"Sphere (NURBS)", "Replace with a sphere (NURBS)"),        
-               ('1',"Cube", "Replace with a cube"),
-               ('2',"Plane", "Replace with a plane"),
-               ('3a',"Circle", "Replace with a circle"),
-               ('3b',"Circle (NURBS)", "Replace with a circle (NURBS)"),               
-               ('4a',"Icosphere 1", "Replace with a icosphere, subd=1"),  
-               ('4b',"Icosphere 2", "Replace with a icosphere, subd=2"),  
-               ('4c',"Icosphere 3", "Replace with a icosphere, subd=3"),                             
-               ('5a',"Cylinder", "Replace with a cylinder"),
-               ('5b',"Cylinder (NURBS)", "Replace with a cylinder (NURBS)"),               
-               ('6',"Cone", "Replace with a cone"),
-               ('7a',"Torus", "Replace with a torus"),
-               ('7b',"Torus (NURBS)", "Replace with a torus (NURBS)"),
-               ('8',"Transparent cube", "Replace with a transparent cube"),      
-               ('9',"Transparent sphere", "Replace with a transparent sphere"),
-               ('10',"Transparent sphere (NURBS)", 
-                                  "Replace with a transparent sphere (NURBS)"),               
-               ('11',"Halo cloud", "Replace with a halo cloud")),
-               default='-1',)     
+        items=(('0',"Unchanged", "Do not change the shape"),
+               ('1a',"Sphere (Mesh)", "Replace with a sphere (Mesh)"),
+               ('1b',"Sphere (NURBS)", "Replace with a sphere (NURBS)"),        
+               ('2',"Cube", "Replace with a cube"),
+               ('3',"Plane", "Replace with a plane"),
+               ('4a',"Circle (Mesh)", "Replace with a circle (Mesh)"),
+               ('4b',"Circle (NURBS)", "Replace with a circle (NURBS)"),               
+               ('5a',"Icosphere 1", "Replace with a icosphere, subd=1"),  
+               ('5b',"Icosphere 2", "Replace with a icosphere, subd=2"),  
+               ('5c',"Icosphere 3", "Replace with a icosphere, subd=3"),  
+               ('5d',"Icosphere 4", "Replace with a icosphere, subd=4"),
+               ('5e',"Icosphere 5", "Replace with a icosphere, subd=5"),                                                         
+               ('6a',"Cylinder (Mesh)", "Replace with a cylinder (Mesh)"),
+               ('6b',"Cylinder (NURBS)", "Replace with a cylinder (NURBS)"),               
+               ('7',"Cone", "Replace with a cone"),
+               ('8a',"Torus (Mesh)", "Replace with a torus (Mesh)"),
+               ('8b',"Torus (NURBS)", "Replace with a torus (NURBS)")),
+               default='0',)     
+    separate_objs_material = EnumProperty(
+        name="Material",
+        description="Choose a different material.",
+        items=(('0',"Unchanged", "Leave the material unchanged"),
+               ('1',"Normal", "Use normal material (no transparency and reflection)"),
+               ('2',"Transparent", "Use transparent material"),
+               ('3',"Reflecting", "Use reflecting material"),
+               ('4',"Transparent + reflecting", "Use transparent and reflecting material")),
+               default='0',)  
 
-
 # Button loading a custom data file
 class DatafileApply(Operator):
     bl_idname = "atom_blend.datafile_apply"

Modified: contrib/py/scripts/addons/io_atomblend_utilities/io_atomblend_utilities.py
===================================================================
--- contrib/py/scripts/addons/io_atomblend_utilities/io_atomblend_utilities.py	2013-01-23 05:23:13 UTC (rev 4197)
+++ contrib/py/scripts/addons/io_atomblend_utilities/io_atomblend_utilities.py	2013-01-23 06:20:17 UTC (rev 4198)
@@ -344,53 +344,53 @@
 
         scn = bpy.context.scene.atom_blend
         
-        # Copy all details from the object to be replaced.
-        name = obj.name
-        scale = Vector((0.0,0.0,0.0))
-        scale += obj.scale
-        material = obj.active_material
-        location = obj.location
-        parent = obj.parent       
+        new_material = draw_obj_material(scn.replace_objs_material, 
+                                         obj.active_material)
         
-        new_obj = draw_obj(scn.replace_objs,name,location,scale,material)
-        new_obj.parent = parent
-        if "_repl" not in new_obj.name:
-            new_obj.name = new_obj.name + "_repl"
-        if "_repl" not in new_obj.active_material.name:    
-            new_obj.active_material.name += "_repl"
+        # If the atom shape shall not be changed
+        if scn.replace_objs == '0':
+            obj.active_material = new_material 
+            if "_repl" not in obj.active_material.name:    
+                obj.active_material.name += "_repl"
+        # If the atom shape shall change
+        else:
+            new_atom = draw_obj(scn.replace_objs, obj)

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list