[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2878] contrib/py/scripts/addons/gyes: now Gyes works with all types of blender object and not just meshes , I have also beautified the gyes log messages

james bond thekilon at yahoo.co.uk
Wed Jan 11 12:17:25 CET 2012


Revision: 2878
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2878
Author:   kilon
Date:     2012-01-11 11:17:16 +0000 (Wed, 11 Jan 2012)
Log Message:
-----------
now Gyes works with all types of blender object and not just meshes , I have also beautified the gyes log messages 

Modified Paths:
--------------
    contrib/py/scripts/addons/gyes/random_material_generator.py
    contrib/py/scripts/addons/gyes/random_texture_generator.py

Modified: contrib/py/scripts/addons/gyes/random_material_generator.py
===================================================================
--- contrib/py/scripts/addons/gyes/random_material_generator.py	2012-01-11 06:03:40 UTC (rev 2877)
+++ contrib/py/scripts/addons/gyes/random_material_generator.py	2012-01-11 11:17:16 UTC (rev 2878)
@@ -66,7 +66,7 @@
         
         if hasattr(bpy.context.scene , "historybak")==False:
             bpy.types.Scene.historybak = StringProperty()
-            print("created history backup")
+            print("Gyes log : created history backup")
             
          # non read only material properties where keyframes can be inserted or removed
         self.animated_properties=["alpha",
@@ -231,7 +231,7 @@
         history_index = scn.history_index
         h_name = scn.h_selected
         self.rm_history[h_name][history_index]={"name" : mat.name}
-        print("mat stored : "+self.rm_history[h_name][history_index]["name"]+" in history name : "+h_name+" in index : "+str(history_index))
+        print("Gyes log : mat stored : "+self.rm_history[h_name][history_index]["name"]+" in history name : "+h_name+" in index : "+str(history_index))
         mat.use_fake_user = True
                  
         bpy.context.scene.historybak = str(self.rm_history)
@@ -241,19 +241,19 @@
         h_name = bpy.context.scene.h_selected
         for i in bpy.context.selected_objects :
             
-            if random_assign == False and i.type == 'MESH' and ( bpy.context.scene.history_index in rm.rm_history[h_name] ) and rm.rm_history[h_name][bpy.context.scene.history_index] and rm.rm_history[h_name][bpy.context.scene.history_index]["name"]:                
+            if random_assign == False and ( bpy.context.scene.history_index in rm.rm_history[h_name] ) and rm.rm_history[h_name][bpy.context.scene.history_index] and rm.rm_history[h_name][bpy.context.scene.history_index]["name"]:                
                 scn = bpy.context.scene
                 mat = i.active_material
                 index = scn.history_index
                 
                 if len(i.material_slots) == 0:
-                    print("no slot found creating a new one")
+                    print("Gyes log : no slot found creating a new one")
                     i.active_material= bpy.data.materials[self.rm_history[h_name][index]["name"]]
                 else:
-                    print("found slot assigning material")
+                    print("Gyes log : found slot assigning material")
                     i.material_slots[i.active_material_index].material= bpy.data.materials[self.rm_history[h_name][index]["name"]]
                 
-            if random_assign == True and i.type == 'MESH' and ( bpy.context.scene.history_index in rm.rm_history[h_name] ) and rm.rm_history[h_name][bpy.context.scene.history_index] and rm.rm_history[h_name][bpy.context.scene.history_index]["name"]:
+            if random_assign == True and ( bpy.context.scene.history_index in rm.rm_history[h_name] ) and rm.rm_history[h_name][bpy.context.scene.history_index] and rm.rm_history[h_name][bpy.context.scene.history_index]["name"]:
             
                 index = round(len(self.rm_history) * random.random())
                 
@@ -265,10 +265,10 @@
                 scn.history_index=index
                 
                 if len(i.material_slots) == 0:
-                    print("no slot found creating a new one")
+                    print("Gyes log : no slot found creating a new one")
                     i.active_material= bpy.data.materials[self.rm_history[h_name][index]["name"]]
                 else:
-                    print("found slot assigning material")
+                    print("Gyes log : found slot assigning material")
                     i.material_slots[i.active_material_index].material= bpy.data.materials[self.rm_history[h_name][index]["name"]]
               
             
@@ -452,25 +452,23 @@
     
     def execute(self, context):
         for i in context.selected_objects :
-            if i.type == 'MESH' :
+            if not i.material_slots:
+                print("Gyes log : no material_slot found , creating new with material")
+                new_random = bpy.data.materials.new("Random")
+                i.active_material=new_random
+                rm.random_material(i.active_material,'Random')
 
-                if not i.material_slots:
-                    print("no material_slot found , creating new with material")
-                    new_random = bpy.data.materials.new("Random")
-                    i.active_material=new_random
-                    rm.random_material(i.active_material,'Random')
 
+            if i.material_slots[0].material:
+                print("Gyes log : found an existing material, using this one ")
+                rm.random_material(i.active_material,'Random')
 
-                if i.material_slots[0].material:
-                    print("found an existing material, using this one ")
-                    rm.random_material(i.active_material,'Random')
+            if not i.material_slots[0].material:
+                print("Gyes log : no material found , creating new")
+                new_random = bpy.data.materials.new("Random")
+                i.active_material=new_random
+                rm.random_material(i.active_material,'Random')
 
-                if not i.material_slots[0].material:
-                    print("no material found , creating new")
-                    new_random = bpy.data.materials.new("Random")
-                    i.active_material=new_random
-                    rm.random_material(i.active_material,'Random')
-
         return{'FINISHED'}
 
 # Move to the first history index and activate it
@@ -634,7 +632,7 @@
        
         rm.rm_history=eval(s)
         
-        print("restored history dictionary") 
+        print("Gyes log : restored history dictionary") 
         
         return{'FINISHED'} 
     

Modified: contrib/py/scripts/addons/gyes/random_texture_generator.py
===================================================================
--- contrib/py/scripts/addons/gyes/random_texture_generator.py	2012-01-11 06:03:40 UTC (rev 2877)
+++ contrib/py/scripts/addons/gyes/random_texture_generator.py	2012-01-11 11:17:16 UTC (rev 2878)
@@ -159,9 +159,9 @@
         if material.texture_slots[material.active_texture_index] and material.texture_slots[material.active_texture_index].texture:
             texture = material.texture_slots[material.active_texture_index].texture
             if not scn.rtexture_type=='RANDOM':
-                texture.type = scn.rtexture_type
+               texture.type = scn.rtexture_type
             else:
-                texture.type = random.choice(['BLEND','CLOUDS','DISTORTED_NOISE','MAGIC','MARBLE','MUSGRAVE','NOISE','STUCCI','VORONOI','WOOD'])
+               texture.type = random.choice(['BLEND','CLOUDS','DISTORTED_NOISE','MAGIC','MARBLE','MUSGRAVE','NOISE','STUCCI','VORONOI','WOOD'])
             material.texture_slots[material.active_texture_index].texture = texture 
         else:
             material.texture_slots.create(material.active_texture_index)           
@@ -778,10 +778,8 @@
     
     def execute(self, context):
         for i in context.selected_objects :
-            if i.type == 'MESH' :
+            rt.random_texture(i.active_material)
 
-                rt.random_texture(i.active_material)
-
         return{'FINISHED'}
 
 #registration is necessary for the script to appear in the GUI



More information about the Bf-extensions-cvs mailing list