[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4565] contrib/py/scripts/addons/ uv_texture_atlas.py: [TextureAtlas] refactoring according to IdeasMan42 review.
paul geraskin
paul_geraskin at mail.ru
Tue Jun 11 13:09:05 CEST 2013
Revision: 4565
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4565
Author: mifth
Date: 2013-06-11 11:09:04 +0000 (Tue, 11 Jun 2013)
Log Message:
-----------
[TextureAtlas] refactoring according to IdeasMan42 review.
Modified Paths:
--------------
contrib/py/scripts/addons/uv_texture_atlas.py
Modified: contrib/py/scripts/addons/uv_texture_atlas.py
===================================================================
--- contrib/py/scripts/addons/uv_texture_atlas.py 2013-06-11 07:24:36 UTC (rev 4564)
+++ contrib/py/scripts/addons/uv_texture_atlas.py 2013-06-11 11:09:04 UTC (rev 4565)
@@ -43,8 +43,8 @@
row = self.layout.row()
split = self.layout.split()
ob = context.object
- thisScene = context.scene
- row.template_list("UI_UL_list", "template_list_controls", thisScene, "ms_lightmap_groups", thisScene, "ms_lightmap_groups_index", rows=2, maxrows=5)
+ scene = context.scene
+ row.template_list("UI_UL_list", "template_list_controls", scene, "ms_lightmap_groups", scene, "ms_lightmap_groups_index", rows=2, maxrows=5)
col = row.column(align=True)
col.operator("scene.ms_add_lightmap_group", icon='ZOOMIN', text="")
col.operator("scene.ms_del_lightmap_group", icon='ZOOMOUT', text="")
@@ -52,10 +52,10 @@
row = self.layout.row(align=True)
# Resolution and Unwrap types (only if Lightmap group is added)
- if len(context.scene.ms_lightmap_groups) > 0:
- row.prop(context.scene.ms_lightmap_groups[context.scene.ms_lightmap_groups_index], 'resolution', text='Resolution',expand=True)
+ if context.scene.ms_lightmap_groups:
+ row.prop(scene.ms_lightmap_groups[scene.ms_lightmap_groups_index], 'resolution', text='Resolution',expand=True)
row = self.layout.row()
- row.prop(context.scene.ms_lightmap_groups[context.scene.ms_lightmap_groups_index], 'unwrap_type', text='Lightmap',expand=True)
+ row.prop(scene.ms_lightmap_groups[scene.ms_lightmap_groups_index], 'unwrap_type', text='Lightmap',expand=True)
row = self.layout.row()
row = self.layout.row()
@@ -81,15 +81,16 @@
bl_description = "Auto Unwrapping"
def execute(self, context):
+ scene = context.scene
old_context = context.area.type
- group = context.scene.ms_lightmap_groups[context.scene.ms_lightmap_groups_index]
+ group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
context.area.type = 'VIEW_3D'
- if context.scene.objects.active != None:
+ if scene.objects.active is not None:
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
- if group.bake == True and len(bpy.data.groups[group.name].objects) > 0:
+ if group.bake == True and bpy.data.groups[group.name].objects:
# Check if objects are all on the visible Layers.
@@ -97,17 +98,18 @@
bpy.ops.object.select_all(action='DESELECT')
for thisObject in bpy.data.groups[group.name].objects:
isThisObjectVisible = False
- context.scene.objects.active = thisObject
- layersNumber = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
+ scene.objects.active = thisObject
+ layersNumber = range(20)
for thisLayerNumb in layersNumber:
- if thisObject.layers[thisLayerNumb] == True and context.scene.layers[thisLayerNumb] == True:
+ if thisObject.layers[thisLayerNumb] == True and scene.layers[thisLayerNumb] == True:
isThisObjectVisible = True
+ break
# If Object is on an invisible Layer
if isThisObjectVisible == False:
isAllObjectsVisible = False
if isAllObjectsVisible == True:
- res = int(context.scene.ms_lightmap_groups[group.name].resolution)
+ res = int(scene.ms_lightmap_groups[group.name].resolution)
bpy.ops.object.ms_create_lightmap(group_name=group.name, resolution=res)
bpy.ops.object.ms_merge_objects(group_name=group.name, unwrap=True)
bpy.ops.object.ms_separate_objects(group_name=group.name)
@@ -125,32 +127,34 @@
bl_description = "Makes Manual Unwrapping Object"
def execute(self, context):
+ scene = context.scene
old_context = context.area.type
- group = context.scene.ms_lightmap_groups[context.scene.ms_lightmap_groups_index]
+ group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
context.area.type = 'VIEW_3D'
- if context.scene.objects.active != None:
+ if scene.objects.active is not None:
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
- if group.bake == True and len(bpy.data.groups[group.name].objects) > 0:
+ if group.bake == True and bpy.data.groups[group.name].objects:
# Check if objects are all on the visible Layers.
isAllObjectsVisible = True
bpy.ops.object.select_all(action='DESELECT')
for thisObject in bpy.data.groups[group.name].objects:
isThisObjectVisible = False
- context.scene.objects.active = thisObject
- layersNumber = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
+ scene.objects.active = thisObject
+ layersNumber = range(20)
for thisLayerNumb in layersNumber:
- if thisObject.layers[thisLayerNumb] == True and context.scene.layers[thisLayerNumb] == True:
+ if thisObject.layers[thisLayerNumb] == True and scene.layers[thisLayerNumb] == True:
isThisObjectVisible = True
+ break
# If Object is on an invisible Layer
if isThisObjectVisible == False:
isAllObjectsVisible = False
if isAllObjectsVisible == True:
- res = int(context.scene.ms_lightmap_groups[group.name].resolution)
+ res = int(scene.ms_lightmap_groups[group.name].resolution)
bpy.ops.object.ms_create_lightmap(group_name=group.name, resolution=res)
bpy.ops.object.ms_merge_objects(group_name=group.name, unwrap=False)
else:
@@ -166,26 +170,28 @@
bl_description = "Removes Manual Unwrapping Object"
def execute(self, context):
+ scene = context.scene
old_context = context.area.type
- group = context.scene.ms_lightmap_groups[context.scene.ms_lightmap_groups_index]
+ group = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index]
context.area.type = 'VIEW_3D'
- if context.scene.objects.active != None:
+ if scene.objects.active is not None:
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
- if group.bake == True and len(bpy.data.groups[group.name].objects) > 0:
+ if group.bake == True and bpy.data.groups[group.name].objects:
# Check if objects are all on the visible Layers.
isAllObjectsVisible = True
bpy.ops.object.select_all(action='DESELECT')
for thisObject in bpy.data.groups[group.name].objects:
isThisObjectVisible = False
- context.scene.objects.active = thisObject
- layersNumber = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
+ scene.objects.active = thisObject
+ layersNumber = range(20)
for thisLayerNumb in layersNumber:
- if thisObject.layers[thisLayerNumb] == True and context.scene.layers[thisLayerNumb] == True:
+ if thisObject.layers[thisLayerNumb] == True and scene.layers[thisLayerNumb] == True:
isThisObjectVisible = True
+ break
# If Object is on an invisible Layer
if isThisObjectVisible == False:
isAllObjectsVisible = False
@@ -236,13 +242,13 @@
class addSelectedToGroup(bpy.types.Operator):
bl_idname = "scene.ms_add_selected_to_group"
- bl_label = ""
+ bl_label = "Add to Group"
bl_description = "Adds selected Objects to current Group"
def execute(self, context):
-
- group_name = context.scene.ms_lightmap_groups[context.scene.ms_lightmap_groups_index].name
+ scene = context.scene
+ group_name = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index].name
#Create a New Group if it was deleted.
isExist = False
@@ -253,7 +259,7 @@
bpy.data.groups.new(group_name)
# Add objects to ag roup
- if context.scene.objects.active != None:
+ if scene.objects.active is not None:
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
for object in context.selected_objects:
@@ -264,15 +270,15 @@
class selectGroup(bpy.types.Operator):
bl_idname = "scene.ms_select_group"
- bl_label = ""
+ bl_label = "sel Group"
bl_description = "Selected Objects of current Group"
def execute(self, context):
-
- group_name = context.scene.ms_lightmap_groups[context.scene.ms_lightmap_groups_index].name
+ scene = context.scene
+ group_name = scene.ms_lightmap_groups[scene.ms_lightmap_groups_index].name
- if context.scene.objects.active != None:
+ if scene.objects.active is not None:
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
bpy.ops.object.select_all(action='DESELECT')
for object in bpy.data.groups[group_name].objects:
@@ -283,7 +289,7 @@
class removeFromGroup(bpy.types.Operator):
bl_idname = "scene.ms_remove_selected"
- bl_label = ""
+ bl_label = "del Selected"
bl_description = "Remove Selected Group and UVs"
### removeUV method
@@ -301,17 +307,18 @@
def execute(self, context):
### set 3dView context
+ scene = context.scene
old_context = context.area.type
context.area.type = 'VIEW_3D'
- if context.scene.objects.active != None:
+ if scene.objects.active is not None:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list