Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2018-09-06 01:25:56 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-09-06 01:27:44 +0300
commitb0602483249d1184f2672cd5d5578955560335b5 (patch)
treed2dfb43271e62a919fc11d99c8901219712c81b3
parent85c9765d820c069cca2c7166d1726d30c8d4aa00 (diff)
Multi-Objects: UV_OT_follow_active_quads
Starring: the overengineered error report system to make sure only one error is reported.
-rw-r--r--release/scripts/startup/bl_operators/uvcalc_follow_active.py47
1 files changed, 37 insertions, 10 deletions
diff --git a/release/scripts/startup/bl_operators/uvcalc_follow_active.py b/release/scripts/startup/bl_operators/uvcalc_follow_active.py
index 9de2aa4e76e..38af5c69ef9 100644
--- a/release/scripts/startup/bl_operators/uvcalc_follow_active.py
+++ b/release/scripts/startup/bl_operators/uvcalc_follow_active.py
@@ -25,8 +25,12 @@ import bpy
from bpy.types import Operator
-def extend(obj, operator, EXTEND_MODE):
+STATUS_OK = (1 << 0)
+STATUS_ERR_ACTIVE_FACE = (1 << 1)
+STATUS_ERR_NOT_SELECTED = (1 << 2)
+STATUS_ERR_NOT_QUAD = (1 << 3)
+def extend(obj, operator, EXTEND_MODE):
import bmesh
me = obj.data
# script will fail without UVs
@@ -39,14 +43,11 @@ def extend(obj, operator, EXTEND_MODE):
uv_act = bm.loops.layers.uv.active
if f_act is None:
- operator.report({'ERROR'}, "No active face")
- return
+ return STATUS_ERR_ACTIVE_FACE
if not f_act.select:
- operator.report({'ERROR'}, "No active face is not selected")
- return
+ return STATUS_ERR_NOT_SELECTED
elif len(f_act.verts) != 4:
- operator.report({'ERROR'}, "Active face must be a quad")
- return
+ return STATUS_ERR_NOT_QUAD
faces = [f for f in bm.faces if f.select and len(f.verts) == 4]
@@ -212,12 +213,38 @@ def extend(obj, operator, EXTEND_MODE):
apply_uv(*f_triple)
bmesh.update_edit_mesh(me, False)
+ return STATUS_OK
def main(context, operator):
- obj = context.active_object
-
- extend(obj, operator, operator.properties.mode)
+ num_meshes = 0
+ num_errors = 0
+ status = 0
+
+ ob_list = [ob for ob in context.selected_objects if ob and ob.type == 'MESH']
+ for ob in ob_list:
+ ob.data.tag = False
+
+ for ob in ob_list:
+ if ob.data.tag:
+ continue
+
+ num_meshes += 1
+ ob.data.tag = True
+
+ ret = extend(ob, operator, operator.properties.mode)
+ if ret != STATUS_OK:
+ num_errors += 1
+ status |= ret
+
+ if num_errors == num_meshes:
+ if status & STATUS_ERR_NOT_QUAD:
+ operator.report({'ERROR'}, "Active face must be a quad")
+ elif status & STATUS_ERR_NOT_SELECTED:
+ operator.report({'ERROR'}, "Active face not selected")
+ else:
+ assert((status & STATUS_ERR_ACTIVE_FACE) != 0)
+ operator.report({'ERROR'}, "No active face")
class FollowActiveQuads(Operator):