Newer
Older
Alfonso Annarumma
committed
# ##### 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",
Sebastian Nell
committed
"version": (1, 5),
"blender": (2, 65, 4),
"location": "View3D > Properties panel > Layer Management",
"warning": "",
"description": "Display and Edit Layer Name",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
CoDEmanX
committed
"tracker_url": "https://developer.blender.org/T32472",
Sebastian Nell
committed
Alfonso Annarumma
committed
import bpy
from bpy.props import StringProperty, BoolProperty, IntProperty, CollectionProperty, BoolVectorProperty
CoDEmanX
committed
EDIT = {"EDIT_MESH", "EDIT_CURVE", "EDIT_SURFACE", "EDIT_METABALL", "EDIT_TEXT", "EDIT_ARMATURE"}
Alfonso Annarumma
committed
class LayerGroups(bpy.types.PropertyGroup):
Sebastian Nell
committed
toggle = BoolProperty(name="", default=False)
lock = BoolProperty(name="", default=False)
CoDEmanX
committed
layer_groups = BoolVectorProperty(name="Layer Groups", default=([False]*20), size=20, subtype='LAYER')
Sebastian Nell
committed
Alfonso Annarumma
committed
# 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"})
Sebastian Nell
committed
Alfonso Annarumma
committed
class RemoveLayerGroup(bpy.types.Operator):
'''Tooltip'''
bl_idname = "object.layergroup_remove"
bl_label = "Remove select Layer Group"
Sebastian Nell
committed
CoDEmanX
committed
index_group = IntProperty()
Sebastian Nell
committed
Alfonso Annarumma
committed
@classmethod
def poll(cls, context):
return context.scene is not None
def execute(self, context):
scene = context.scene
Sebastian Nell
committed
index_group = self.index_group
Alfonso Annarumma
committed
scene.layergroups.remove(index_group)
Sebastian Nell
committed
if index_group > 0:
scene.layergroups_index = index_group - 1
Alfonso Annarumma
committed
return {'FINISHED'}
class AddLayerGroup(bpy.types.Operator):
'''Tooltip'''
bl_idname = "object.layergroup_add"
bl_label = "Add select Layer group"
Sebastian Nell
committed
CoDEmanX
committed
index = IntProperty()
layer = layer = BoolVectorProperty(name="Layer", default=([False]*20), size=20)
Sebastian Nell
committed
Alfonso Annarumma
committed
@classmethod
def poll(cls, context):
return context.scene is not None
def execute(self, context):
Sebastian Nell
committed
Alfonso Annarumma
committed
scene = context.scene
layergroups = scene.layergroups
Sebastian Nell
committed
Alfonso Annarumma
committed
index = self.index
layer = self.layer
Sebastian Nell
committed
Alfonso Annarumma
committed
item = layergroups.add()
CoDEmanX
committed
index_number = str(index)
CoDEmanX
committed
if len(index_number) == 2:
index_number = "0" + index_number
if len(index_number) == 3:
Alfonso Annarumma
committed
index_number = index_number
else:
CoDEmanX
committed
index_number = "00" + index_number
item.name = 'LayerGroup.' + index_number
Alfonso Annarumma
committed
#item.use=True
Sebastian Nell
committed
scene.layergroups_index = index
Alfonso Annarumma
committed
scene.layergroups[index].layer_groups = layer
Sebastian Nell
committed
Alfonso Annarumma
committed
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"
Sebastian Nell
committed
Alfonso Annarumma
committed
#prop definition
#layer number
CoDEmanX
committed
layerN = IntProperty()
spacecheck = BoolProperty()
index_group = IntProperty()
Alfonso Annarumma
committed
@classmethod
Sebastian Nell
committed
Alfonso Annarumma
committed
def poll(cls, context):
Sebastian Nell
committed
Alfonso Annarumma
committed
return context.scene
Alfonso Annarumma
committed
def execute(self, context):
Alfonso Annarumma
committed
spacecheck = self.spacecheck
scene = context.scene
Sebastian Nell
committed
Alfonso Annarumma
committed
layerN = self.layerN
Alfonso Annarumma
committed
if spacecheck:
Sebastian Nell
committed
Alfonso Annarumma
committed
space = context.area.spaces.active
else:
space = context.scene
CoDEmanX
committed
if layerN == -1:
Alfonso Annarumma
committed
index = self.index_group
groups = scene.layergroups[index].layer_groups
layergroups = scene.layergroups[index]
Sebastian Nell
committed
Alfonso Annarumma
committed
layers = space.layers
CoDEmanX
committed
union = [False]*20
Sebastian Nell
committed
Alfonso Annarumma
committed
if not layergroups.toggle:
CoDEmanX
committed
for i in range(0, 20):
Sebastian Nell
committed
CoDEmanX
committed
union[i] = groups[i] or layers[i]
CoDEmanX
committed
space.layers = union
layergroups.toggle = True
Alfonso Annarumma
committed
else:
CoDEmanX
committed
for i in range(0, 20):
Sebastian Nell
committed
CoDEmanX
committed
union[i] = not groups[i] and layers[i]
CoDEmanX
committed
space.layers = union
layergroups.toggle = False
Sebastian Nell
committed
Alfonso Annarumma
committed
else:
Sebastian Nell
committed
Alfonso Annarumma
committed
if self.shift:
Sebastian Nell
committed
Alfonso Annarumma
committed
if space.layers[layerN]:
toggle = False
else:
CoDEmanX
committed
toggle = True
space.layers[layerN] = toggle
Sebastian Nell
committed
Alfonso Annarumma
committed
else:
CoDEmanX
committed
layer = [False] * 20
layer[layerN] = True
space.layers = layer
Alfonso Annarumma
committed
if space.layers[layerN]:
Sebastian Nell
committed
toggle = False
Alfonso Annarumma
committed
return {'FINISHED'}
CoDEmanX
committed
Alfonso Annarumma
committed
def invoke(self, context, event):
self.shift = event.shift
Sebastian Nell
committed
Alfonso Annarumma
committed
return self.execute(context)
CoDEmanX
committed
Alfonso Annarumma
committed
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"
Sebastian Nell
committed
Alfonso Annarumma
committed
#prop definition
#layer number
CoDEmanX
committed
layerN = IntProperty()
Alfonso Annarumma
committed
@classmethod
Sebastian Nell
committed
Alfonso Annarumma
committed
def poll(cls, context):
Sebastian Nell
committed
Alfonso Annarumma
committed
return context.scene
Alfonso Annarumma
committed
def execute(self, context):
Sebastian Nell
committed
Alfonso Annarumma
committed
layerN = self.layerN
Sebastian Nell
committed
CoDEmanX
committed
scene = context.scene
Sebastian Nell
committed
#cyecle all object in the layer
Sebastian Nell
committed
Alfonso Annarumma
committed
if obj.select:
CoDEmanX
committed
visible = False
Sebastian Nell
committed
CoDEmanX
committed
for i in range(0, 20):
CoDEmanX
committed
visible = True
Sebastian Nell
committed
Sebastian Nell
committed
CoDEmanX
committed
toggle = True
obj.layers[layerN] = toggle
Sebastian Nell
committed
CoDEmanX
committed
layer = [False] * 20
layer[layerN] = True
obj.layers = layer
Sebastian Nell
committed
toggle = False
Alfonso Annarumma
committed
return {'FINISHED'}
Sebastian Nell
committed
Alfonso Annarumma
committed
def invoke(self, context, event):
self.shift = event.shift
Sebastian Nell
committed
Alfonso Annarumma
committed
return self.execute(context)
CoDEmanX
committed
Alfonso Annarumma
committed
class LockSelected(bpy.types.Operator):
'''Loock All Objects on this Layer'''
bl_idname = "object.lockselected"
bl_label = "Hide Select of Selected"
Sebastian Nell
committed
Alfonso Annarumma
committed
#prop definition
#layer number
CoDEmanX
committed
layerN = IntProperty()
Sebastian Nell
committed
Alfonso Annarumma
committed
#lock status
CoDEmanX
committed
lock = BoolProperty()
CoDEmanX
committed
index_group = IntProperty()
Sebastian Nell
committed
Alfonso Annarumma
committed
@classmethod
Sebastian Nell
committed
Alfonso Annarumma
committed
def poll(cls, context):
Sebastian Nell
committed
Alfonso Annarumma
committed
return context.scene
Alfonso Annarumma
committed
def execute(self, context):
Sebastian Nell
committed
Alfonso Annarumma
committed
scene = context.scene
layerN = self.layerN
CoDEmanX
committed
lock = self.lock
Sebastian Nell
committed
Alfonso Annarumma
committed
view_3d = context.area.spaces.active
Sebastian Nell
committed
Alfonso Annarumma
committed
#check if layer have some thing
CoDEmanX
committed
if view_3d.layers_used[layerN] or layerN == -1:
Sebastian Nell
committed
#cyecle all object in the layer
Alfonso Annarumma
committed
for obj in context.scene.objects:
Sebastian Nell
committed
CoDEmanX
committed
if layerN == -1:
Sebastian Nell
committed
Alfonso Annarumma
committed
index = self.index_group
groups = scene.layergroups[index].layer_groups
layers = obj.layers
Sebastian Nell
committed
CoDEmanX
committed
layergroup=[False] * 20
CoDEmanX
committed
for i in range (0, 20):
layergroup[i] = layers[i] and groups[i]
Sebastian Nell
committed
Alfonso Annarumma
committed
if True in layergroup:
CoDEmanX
committed
obj.hide_select = not lock
obj.select = False
CoDEmanX
committed
scene.layergroups[index].lock = not lock
Alfonso Annarumma
committed
else:
if obj.layers[layerN]:
CoDEmanX
committed
obj.hide_select = not lock
obj.select = False
CoDEmanX
committed
scene.LockLayer[layerN] = not lock
Alfonso Annarumma
committed
return {'FINISHED'}
CoDEmanX
committed
Alfonso Annarumma
committed
class SelectObjectsLayer(bpy.types.Operator):
'''Select All the Objects on this Layer'''
bl_idname = "object.selectobjectslayer"
bl_label = "Select objects in Layer"
Sebastian Nell
committed
CoDEmanX
committed
select_obj = BoolProperty()
layerN = IntProperty()
Alfonso Annarumma
committed
@classmethod
def poll(cls, context):
return context.scene
def execute(self, context):
Sebastian Nell
committed
Alfonso Annarumma
committed
view_3d = context.area.spaces.active
select_obj= self.select_obj
layerN = self.layerN
scene = context.scene
CoDEmanX
committed
i = 0
s = 0
Sebastian Nell
committed
#check if layer have some thing
Alfonso Annarumma
committed
if view_3d.layers_used[layerN]:
Sebastian Nell
committed
Alfonso Annarumma
committed
for obj in context.scene.objects:
Alfonso Annarumma
committed
if obj.layers[layerN]:
CoDEmanX
committed
i += 1
Alfonso Annarumma
committed
if obj.layers[layerN] and obj.select:
CoDEmanX
committed
s += 1
CoDEmanX
committed
if s == i:
Alfonso Annarumma
committed
for obj in context.scene.objects:
Sebastian Nell
committed
Alfonso Annarumma
committed
if obj.layers[layerN]:
CoDEmanX
committed
obj.select = False
Alfonso Annarumma
committed
else:
Sebastian Nell
committed
bpy.ops.object.select_by_layer(extend=True, layers=layerN+1)
Alfonso Annarumma
committed
return {'FINISHED'}
CoDEmanX
committed
Alfonso Annarumma
committed
class AllLayersSelect(bpy.types.Operator):
'''Active all Layer in scene'''
bl_idname = "scene.layersselect"
bl_label = "Select All Layer"
Sebastian Nell
committed
CoDEmanX
committed
vis = BoolProperty()
Alfonso Annarumma
committed
@classmethod
def poll(cls, context):
return context.scene
def execute(self, context):
Sebastian Nell
committed
Alfonso Annarumma
committed
scene = context.scene
vis = self.vis
#store the active layer
active = scene.active_layer
Sebastian Nell
committed
Alfonso Annarumma
committed
view_3d = context.area.spaces.active
#check for lock camera and layer is active
if view_3d.lock_camera_and_layers is True:
CoDEmanX
committed
space = scene
Alfonso Annarumma
committed
else:
CoDEmanX
committed
space = view_3d
Alfonso Annarumma
committed
if not vis:
CoDEmanX
committed
for i in range (0, 20):
Sebastian Nell
committed
Alfonso Annarumma
committed
#keep selection of active layer
if active == i:
CoDEmanX
committed
space.layers[i] = True
Sebastian Nell
committed
Alfonso Annarumma
committed
#deselect the other...
Sebastian Nell
committed
else:
CoDEmanX
committed
space.layers[i] = False
Alfonso Annarumma
committed
else:
CoDEmanX
committed
for i in range (0, 20):
Alfonso Annarumma
committed
#select all layer
CoDEmanX
committed
space.layers[i] = True
Sebastian Nell
committed
#after the cycle, deselect and select the previus active layer
CoDEmanX
committed
space.layers[active] = False
space.layers[active] = True
Alfonso Annarumma
committed
return {'FINISHED'}
CoDEmanX
committed
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
class LayerGroupsUI(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Layer Groups"
bl_idname = "VIEW3D_PT_layer_groups"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(self, context):
try:
return (context.mode not in EDIT)
except (AttributeError, KeyError, TypeError):
return False
def draw(self, context):
scene = context.scene
view_3d = context.area.spaces.active
#check for lock camera and layer is active
if view_3d.lock_camera_and_layers is True:
space = scene
spacecheck = False
else:
space = view_3d
spacecheck = True
#######################
index_group = scene.layergroups_index
items =len(scene.layergroups)
viewIcon = 'RESTRICT_VIEW_OFF'
layout = self.layout
row = layout.row()
row.template_list("UI_UL_list", "ui_layer_groups", context.scene, "layergroups",
context.scene, "layergroups_index", rows=items)
col = row.column(align=True)
add = col.operator("object.layergroup_add", icon='ZOOMIN', text="")
add.index = items
add.layer = scene.layers
remove = col.operator("object.layergroup_remove", icon='ZOOMOUT', text="")
remove.index_group = index_group
if items > 0:
lock = scene.layergroups[index_group].lock
toggle = scene.layergroups[index_group].toggle
if lock:
iconLock= 'LOCKED'
else:
iconLock='UNLOCKED'
lk = col.operator("object.lockselected", text="", emboss=True, icon= iconLock)
lk.index_group = index_group
lk.lock = lock
lk.layerN = -1
#set icon for layer view
if toggle:
iconLayer = 'RESTRICT_VIEW_OFF'
#noitem = True
else:
iconLayer = 'RESTRICT_VIEW_ON'
#noitem = False
view = col.operator("object.layertoggle", text="", icon= iconLayer, emboss=True)
view.index_group = index_group
view.layerN = -1
view.spacecheck = spacecheck
layout.prop(scene.layergroups[index_group], "layer_groups", text="", toggle=True)
layout.prop(scene.layergroups[index_group], "name", text="Name:")
Alfonso Annarumma
committed
class LayerName(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Layer Management"
CoDEmanX
committed
bl_idname = "VIEW3D_PT_layer_management"
Alfonso Annarumma
committed
bl_options = {'DEFAULT_CLOSED'}
Sebastian Nell
committed
Alfonso Annarumma
committed
# layer name prop definition
CoDEmanX
committed
bpy.types.Scene.LayerName1 = StringProperty(name="Layer Name", default='layer1')
bpy.types.Scene.LayerName2 = StringProperty(name="Layer Name", default='layer2')
bpy.types.Scene.LayerName3 = StringProperty(name="Layer Name", default='layer3')
bpy.types.Scene.LayerName4 = StringProperty(name="Layer Name", default='layer4')
bpy.types.Scene.LayerName5 = StringProperty(name="Layer Name", default='layer5')
bpy.types.Scene.LayerName6 = StringProperty(name="Layer Name", default='layer6')
bpy.types.Scene.LayerName7 = StringProperty(name="Layer Name", default='layer7')
bpy.types.Scene.LayerName8 = StringProperty(name="Layer Name", default='layer8')
bpy.types.Scene.LayerName9 = StringProperty(name="Layer Name", default='layer9')
bpy.types.Scene.LayerName10 = StringProperty(name="Layer Name", default='layer10')
bpy.types.Scene.LayerName11 = StringProperty(name="Layer Name", default='layer11')
bpy.types.Scene.LayerName12 = StringProperty(name="Layer Name", default='layer12')
bpy.types.Scene.LayerName13 = StringProperty(name="Layer Name", default='layer13')
bpy.types.Scene.LayerName14 = StringProperty(name="Layer Name", default='layer14')
bpy.types.Scene.LayerName15 = StringProperty(name="Layer Name", default='layer15')
bpy.types.Scene.LayerName16 = StringProperty(name="Layer Name", default='layer16')
bpy.types.Scene.LayerName17 = StringProperty(name="Layer Name", default='layer17')
bpy.types.Scene.LayerName18 = StringProperty(name="Layer Name", default='layer18')
bpy.types.Scene.LayerName19 = StringProperty(name="Layer Name", default='layer19')
bpy.types.Scene.LayerName20 = StringProperty(name="Layer Name", default='layer20')
Sebastian Nell
committed
Alfonso Annarumma
committed
#prop for hide empty
CoDEmanX
committed
bpy.types.Scene.LayerVisibility = BoolProperty(name="Hide empty Layer", default=False)
Sebastian Nell
committed
Alfonso Annarumma
committed
#prop for extra option
CoDEmanX
committed
bpy.types.Scene.ExtraOptions = BoolProperty(name="Show extra options", default=True)
Sebastian Nell
committed
Alfonso Annarumma
committed
#lock layer status
CoDEmanX
committed
bpy.types.Scene.LockLayer = BoolVectorProperty(name="Lock Layer", default=([False]*20), size=20)
Alfonso Annarumma
committed
#prop for show index
CoDEmanX
committed
bpy.types.Scene.LayerIndex = BoolProperty(name="Show Index", default=False)
Sebastian Nell
committed
Alfonso Annarumma
committed
#prop for show classic
CoDEmanX
committed
bpy.types.Scene.Classic = BoolProperty(name="Classic", default=False,description="Use a classic layer selection visibility")
Alfonso Annarumma
committed
#Select object Status
CoDEmanX
committed
bpy.types.Scene.ObjectSelect = BoolVectorProperty(name="Object Select", default=([True]*20), size=20)
Sebastian Nell
committed
Alfonso Annarumma
committed
#toggle for merge
CoDEmanX
committed
#bpy.types.Scene.MergeToggle = BoolVectorProperty(name="Merge Toggle", default=(False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False), size=20)
Alfonso Annarumma
committed
@classmethod
def poll(self, context):
try:
return (context.mode not in EDIT)
except (AttributeError, KeyError, TypeError):
return False
def draw(self, context):
Alfonso Annarumma
committed
scene = context.scene
Alfonso Annarumma
committed
view_3d = context.area.spaces.active
#check for lock camera and layer is active
if view_3d.lock_camera_and_layers is True:
CoDEmanX
committed
space = scene
spacecheck = False
Sebastian Nell
committed
Alfonso Annarumma
committed
else:
CoDEmanX
committed
space = view_3d
spacecheck = True
Sebastian Nell
committed
Alfonso Annarumma
committed
#row = layout.row(align=True)
CoDEmanX
committed
vis = False
allIcon = 'RESTRICT_VIEW_OFF'
allText = "Isolate active"
Alfonso Annarumma
committed
#check if there is a layer off
for layer in space.layers:
Sebastian Nell
committed
Alfonso Annarumma
committed
if not layer:
CoDEmanX
committed
vis = True
allIcon = 'RESTRICT_VIEW_ON'
allText = "All Visible"
Alfonso Annarumma
committed
layout = self.layout
column = layout.column()
row = column.row()
CoDEmanX
committed
col2 = row.column()
Sebastian Nell
committed
#lock camera and layers button
Alfonso Annarumma
committed
col2.prop(view_3d, "lock_camera_and_layers", text="")
Sebastian Nell
committed
Alfonso Annarumma
committed
#select all
Sebastian Nell
committed
Alfonso Annarumma
committed
allView = col2.operator("scene.layersselect", emboss=False, icon=allIcon, text="")
CoDEmanX
committed
allView.vis = vis
Sebastian Nell
committed
CoDEmanX
committed
col = row.column()
#col.alignment = 'RIGHT'
Alfonso Annarumma
committed
#classic
col.prop(scene, "Classic", text="Classic")
Sebastian Nell
committed
Alfonso Annarumma
committed
#show extra option checkbox
Sebastian Nell
committed
CoDEmanX
committed
#col.alignment='RIGHT'
Alfonso Annarumma
committed
col.prop(scene, "ExtraOptions", text="Options")
CoDEmanX
committed
col1 = row.column()
Sebastian Nell
committed
#show index
Alfonso Annarumma
committed
col1.prop(scene, "LayerIndex", text="Index")
Sebastian Nell
committed
Alfonso Annarumma
committed
# hide empty
Alfonso Annarumma
committed
if context.object:
CoDEmanX
committed
col1.alignment = 'RIGHT'
Sebastian Nell
committed
col1.prop(scene, "LayerVisibility", toggle=False, text="Hide Empty")
Alfonso Annarumma
committed
Alfonso Annarumma
committed
#list the layer
CoDEmanX
committed
for i in range(0, 20):
Alfonso Annarumma
committed
Sebastian Nell
committed
#inizializing the icon
CoDEmanX
committed
#lockIcon = 'UNLOCKED'
iconUsed = 'RADIOBUT_OFF'
iconAc = 'NONE'
iconLayer = 'NONE'
Alfonso Annarumma
committed
#selectIcon ='RESTRICT_SELECT_OFF'
#inizializing the bool value
noitem = False
Sebastian Nell
committed
CoDEmanX
committed
active = False
Sebastian Nell
committed
CoDEmanX
committed
layer = 20
Alfonso Annarumma
committed
scene = context.scene
Sebastian Nell
committed
Alfonso Annarumma
committed
extra = scene.ExtraOptions
Sebastian Nell
committed
Alfonso Annarumma
committed
layer_used = view_3d.layers_used[i]
Sebastian Nell
committed
Alfonso Annarumma
committed
#check the hide empty value
if scene.LayerVisibility:
Sebastian Nell
committed
#find the empty layer
Alfonso Annarumma
committed
if layer_used:
#print (i)
layer = i
Sebastian Nell
committed
'Add ad object to see the layer'
Alfonso Annarumma
committed
else:
CoDEmanX
committed
layer = i
Alfonso Annarumma
committed
#the layer number
Sebastian Nell
committed
Alfonso Annarumma
committed
#set icon for lock layer
lock = scene.LockLayer[i]
Sebastian Nell
committed
Alfonso Annarumma
committed
if lock:
lockIcon= 'LOCKED'
else:
lockIcon= 'UNLOCKED'
Alfonso Annarumma
committed
#check if there are Selected obj in the layer
Sebastian Nell
committed
#check if layer have some thing
Alfonso Annarumma
committed
if layer_used:
Sebastian Nell
committed
Alfonso Annarumma
committed
iconUsed= 'LAYER_USED'
Sebastian Nell
committed
Alfonso Annarumma
committed
active_object = context.object
Sebastian Nell
committed
Alfonso Annarumma
committed
if active_object:
Sebastian Nell
committed
Alfonso Annarumma
committed
if context.object.layers[i]:
Sebastian Nell
committed
active = True
Alfonso Annarumma
committed
else:
CoDEmanX
committed
scene.ObjectSelect[i] = True
Alfonso Annarumma
committed
CoDEmanX
committed
if layer == i:
Sebastian Nell
committed
#check for active layer and set the icon
Alfonso Annarumma
committed
if view_3d.lock_camera_and_layers:
Sebastian Nell
committed
Alfonso Annarumma
committed
if scene.active_layer==layer:
iconAc = 'FILE_TICK'
noitem = True
Sebastian Nell
committed
Alfonso Annarumma
committed
if active:
iconUsed = 'LAYER_ACTIVE'
Sebastian Nell
committed
#set icon for layer view
Alfonso Annarumma
committed
if view_3d.layers[layer]:
viewIcon = 'RESTRICT_VIEW_OFF'
noitem = True
else:
viewIcon = 'RESTRICT_VIEW_ON'
noitem = False
CoDEmanX
committed
row2 = column.row(align=True)
Alfonso Annarumma
committed
# if space==scene:
Sebastian Nell
committed
#
Alfonso Annarumma
committed
# colb1= row2.column()
Sebastian Nell
committed
# #layer visibility operator
Alfonso Annarumma
committed
# tog = colb1.operator("view3d.layers", text="",icon=viewIcon, emboss=False)
# tog.nr=layer+1
# tog.toggle=True
# viewemboss = True
Sebastian Nell
committed
CoDEmanX
committed
iconLayer = viewIcon
Alfonso Annarumma
committed
# layer index
if scene.LayerIndex:
Sebastian Nell
committed
CoDEmanX
committed
col6 = row2.column(align=True)
col6.scale_x = 0.14
Alfonso Annarumma
committed
col6.label(text=str(i+1)+".")
Sebastian Nell
committed
# visualization
Alfonso Annarumma
committed
classic = scene.Classic
if not classic:
Sebastian Nell
committed
CoDEmanX
committed
colb2= row2.column(align=True)
Alfonso Annarumma
committed
colb2.prop(space, "layers", index=layer, emboss=True, icon=iconLayer, toggle=True, text="")
Sebastian Nell
committed
else:
CoDEmanX
committed
colb6 = row2.column(align=True)
Alfonso Annarumma
committed
used = colb6.operator("object.layertoggle", text="", icon= iconLayer, emboss=True)
CoDEmanX
committed
used.layerN = i
used.spacecheck = spacecheck
Alfonso Annarumma
committed
#text prop
CoDEmanX
committed
s = "LayerName" + str(i+1)
colb3= row2.column(align=True)
colb3.prop(scene, s, text="", icon=iconAc)
Alfonso Annarumma
committed
if extra:
Alfonso Annarumma
committed
#Select by type operator
CoDEmanX
committed
colb4 = row2.column(align=True)
select = colb4.operator("object.selectobjectslayer", icon='RESTRICT_SELECT_OFF', text="", emboss=True)
Sebastian Nell
committed
select.layerN = i
Alfonso Annarumma
committed
#select.select_obj= selobj
Sebastian Nell
committed
#lock operator
CoDEmanX
committed
colb5 = row2.column(align=True)
Alfonso Annarumma
committed
lk = colb5.operator("object.lockselected", text="", emboss=True, icon= lockIcon)
Sebastian Nell
committed
Alfonso Annarumma
committed
lk.layerN = i
lk.lock=lock
Alfonso Annarumma
committed
# #occuped layer
# colb6.label(text="", icon=iconUsed)
Alfonso Annarumma
committed
#merge layer
CoDEmanX
committed
colb7 = row2.column(align=True)
Alfonso Annarumma
committed
merge = colb7.operator("object.mergeselected", text="", emboss=True, icon= iconUsed)
CoDEmanX
committed
merge.layerN = i
Alfonso Annarumma
committed
if not scene.LayerVisibility:
CoDEmanX
committed
if i == 4 or i == 9 or i == 14 or i == 19:
row3 = column.row(align=True)
Alfonso Annarumma
committed
row3.separator()
CoDEmanX
committed
if len(scene.objects) == 0:
Alfonso Annarumma
committed
layout.label(text='No objects in scene')
Sebastian Nell
committed
Alfonso Annarumma
committed
def register():
CoDEmanX
committed
bpy.utils.register_module(__name__)
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)
Alfonso Annarumma
committed
def unregister():
CoDEmanX
committed
bpy.utils.register_module(__name__)
del bpy.types.Scene.layergroups
del bpy.types.Scene.layergroups_index
Alfonso Annarumma
committed
if __name__ == "__main__":
register()