[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3733] contrib/py/scripts/addons/ ui_layer_manager.py: Add th Layer Manager script in the contrib/py/script/ addons/ui_layer_manager.py

Alfonso Annarumma anfeo at libero.it
Thu Sep 13 01:15:22 CEST 2012


Revision: 3733
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3733
Author:   anfeo
Date:     2012-09-12 23:15:21 +0000 (Wed, 12 Sep 2012)
Log Message:
-----------
Add th Layer Manager script in the contrib/py/script/addons/ui_layer_manager.py

Added Paths:
-----------
    contrib/py/scripts/addons/ui_layer_manager.py

Added: contrib/py/scripts/addons/ui_layer_manager.py
===================================================================
--- contrib/py/scripts/addons/ui_layer_manager.py	                        (rev 0)
+++ contrib/py/scripts/addons/ui_layer_manager.py	2012-09-12 23:15:21 UTC (rev 3733)
@@ -0,0 +1,943 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+#
+bl_info = {
+    'name': 'Layer Management',
+    'author': 'Alfonso Annarumma',
+    'version': (1,4),
+    'blender': (2, 6, 3),
+    'location': 'View3D > Properties panel > Layer Management',
+    'warning': '',
+    'description': 'Display and Edit Layer Name',
+    'wiki_url': '',
+    'tracker_url': '',
+    'category': '3D View'}
+    
+import bpy
+from bpy.props import StringProperty, BoolProperty, IntProperty, CollectionProperty, BoolVectorProperty
+
+EDIT = ["EDIT_MESH", "EDIT_CURVE", "EDIT_SURFACE", "EDIT_METABALL", "EDIT_TEXT", "EDIT_ARMATURE"]
+
+
+class LayerGroups(bpy.types.PropertyGroup):
+    
+    toggle    = BoolProperty(name="",default=False)
+    
+    lock    = BoolProperty(name="",default=False)
+   
+    
+    layer_groups = BoolVectorProperty(name="Layer Groups", default = ([False]*20), size=20, subtype='LAYER')
+    
+    # A list of identifiers (colon-separated strings) which property’s controls should be displayed
+    # in a template_list.
+    # Note that the order is respected.
+    #template_list_controls = StringProperty(default="toggle", options={"HIDDEN"})
+ 
+bpy.utils.register_class(LayerGroups)
+ 
+bpy.types.Scene.layergroups = CollectionProperty(type=LayerGroups)
+# Unused, but this is needed for the TemplateList to work…
+bpy.types.Scene.layergroups_index = IntProperty(default=-1)
+
+
+class RemoveLayerGroup(bpy.types.Operator):
+    '''Tooltip'''
+    bl_idname = "object.layergroup_remove"
+    bl_label = "Remove select Layer Group"
+    
+    index_group = bpy.props.IntProperty()
+    
+    @classmethod
+    def poll(cls, context):
+        return context.scene is not None
+
+    def execute(self, context):
+        scene = context.scene
+        
+        index_group =self.index_group
+        
+        scene.layergroups.remove(index_group)
+       
+        scene.layergroups_index= index_group-1
+        
+        return {'FINISHED'}
+
+
+class AddLayerGroup(bpy.types.Operator):
+    '''Tooltip'''
+    bl_idname = "object.layergroup_add"
+    bl_label = "Add select Layer group"
+    
+    index = bpy.props.IntProperty()
+    layer = layer = BoolVectorProperty(name="Layer", default = ([False]*20), size=20)
+    
+    @classmethod
+    def poll(cls, context):
+        return context.scene is not None
+
+    def execute(self, context):
+        
+        scene = context.scene
+        layergroups = scene.layergroups
+        
+        index = self.index
+        layer = self.layer
+        
+        item = layergroups.add()
+        index_number= str(index)
+        
+        
+        
+        if len(index_number)==2:
+            index_number = "0"+index_number
+            if len(index_number)==3:
+                index_number = index_number
+        else:
+            index_number = "00"+index_number
+        item.name= 'LayerGroup.'+index_number
+        #item.use=True
+        scene.layergroups_index= index
+        scene.layergroups[index].layer_groups = layer
+        
+        return {'FINISHED'}
+
+
+class LayerToggle(bpy.types.Operator):
+    '''Visualize this Layer, Shift-Click to select multiple layers'''
+    bl_idname = "object.layertoggle"
+    bl_label = "Visualize this layer"
+    
+    #prop definition
+    #layer number
+    layerN = bpy.props.IntProperty()
+    spacecheck = bpy.props.BoolProperty()
+    index_group = bpy.props.IntProperty()
+
+    @classmethod
+ 
+    def poll(cls, context):
+        
+        return context.scene
+        
+    
+    def execute(self, context):
+        
+        
+        spacecheck = self.spacecheck
+        scene = context.scene
+        
+        layerN = self.layerN
+        
+        
+        
+        
+        
+        
+        if spacecheck:
+            
+            space = context.area.spaces.active
+        else:
+            space = context.scene
+        
+        
+        if layerN==-1:
+            index = self.index_group
+            groups = scene.layergroups[index].layer_groups
+            layergroups = scene.layergroups[index]
+            
+            layers = space.layers
+            union= [False]*20
+            
+            if not layergroups.toggle:
+                for i in range(0,20):
+                    
+                    union[i]= groups[i] or layers[i]
+                    
+                
+                space.layers=union  
+                layergroups.toggle=True
+            else:
+                for i in range(0,20):
+                    
+                    union[i]=  not groups[i]  and layers[i]
+                    
+                
+                space.layers=union  
+                layergroups.toggle=False
+                        
+        else:
+        
+            if self.shift:
+                
+                if space.layers[layerN]:
+                    toggle = False
+                else:
+            
+            
+                    toggle= True                            
+                space.layers[layerN]=toggle
+            
+            else:
+                
+              
+                layer = [False]*20
+                layer[layerN]=True
+                space.layers=layer
+    #                   
+                
+                if space.layers[layerN]:
+                    toggle = False   
+                        
+                
+            
+        return {'FINISHED'}
+    def invoke(self, context, event):
+        self.shift = event.shift
+        
+        return self.execute(context)
+
+    
+    
+class MergeSelected(bpy.types.Operator):
+    '''Move Selected Objects in this Layer Shift-Click to select multiple layers'''
+    bl_idname = "object.mergeselected"
+    bl_label = "Merge Selected object in this layer"
+    
+    #prop definition
+    #layer number
+    layerN = bpy.props.IntProperty()
+
+
+    @classmethod
+ 
+    def poll(cls, context):
+        
+        return context.scene
+        
+    
+    def execute(self, context):
+        
+        layerN = self.layerN
+
+           
+        #cyecle all object in the layer 
+        for obj in context.scene.objects:
+            if obj.select:
+                if self.shift:
+                    
+                    if obj.layers[layerN]:
+                        toggle = False
+                    else:
+                
+                
+                        toggle= True                            
+                    obj.layers[layerN]=toggle
+                
+                else:
+                    
+                  
+                    layer = [False]*20
+                    layer[layerN]=True
+                    obj.layers=layer
+#                   
+                    
+                    if obj.layers[layerN]:
+                        toggle = False   
+                    
+                
+            
+        return {'FINISHED'}
+    
+    def invoke(self, context, event):
+        self.shift = event.shift
+        
+        return self.execute(context)
+
+class LockSelected(bpy.types.Operator):
+    '''Loock All Objects on this Layer'''
+    bl_idname = "object.lockselected"
+    bl_label = "Hide Select of Selected"
+    
+    #prop definition
+    #layer number
+    layerN = bpy.props.IntProperty()
+    
+    #lock status
+    lock = bpy.props.BoolProperty()
+    
+             
+    index_group = bpy.props.IntProperty()
+    
+    @classmethod
+    
+    def poll(cls, context):
+        
+        return context.scene
+        
+    
+    def execute(self, context):
+        
+        scene = context.scene
+        layerN = self.layerN
+        lock =self.lock  
+        
+        view_3d = context.area.spaces.active
+        
+        #check if layer have some thing
+        if view_3d.layers_used[layerN] or  layerN==-1:
+            
+            #cyecle all object in the layer 
+            for obj in context.scene.objects:
+                
+                if layerN==-1:
+                    
+                    index = self.index_group
+                    groups = scene.layergroups[index].layer_groups
+                    layers = obj.layers
+                    
+                    layergroup=[False]*20
+                    
+                    
+                    
+                    for i in range (0,20):
+                        layergroup[i]= layers[i] and groups[i]
+                    
+                    if True in layergroup:
+                        obj.hide_select=not lock
+                        obj.select=False
+                        
+                        
+                        scene.layergroups[index].lock=not lock
+                        
+                        
+                
+                else:
+                    if obj.layers[layerN]:
+                        obj.hide_select=not lock
+                        obj.select=False
+                
+                        
+                        scene.LockLayer[layerN]= not lock
+               
+                
+     
+        
+            
+        return {'FINISHED'}
+
+class SelectObjectsLayer(bpy.types.Operator):
+    '''Select All the Objects on this Layer'''
+    bl_idname = "object.selectobjectslayer"
+    bl_label = "Select objects in Layer"
+    
+    select_obj = bpy.props.BoolProperty()
+    layerN = bpy.props.IntProperty()
+    
+    
+    @classmethod
+    def poll(cls, context):
+        return context.scene
+
+    def execute(self, context):
+        

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list