diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-02-08 13:14:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-02-08 13:14:26 +0300 |
commit | 345c6298e995ea618c34282ba6d7ab5af032f191 (patch) | |
tree | f4fbc4798e17d0f19efc28b51a41425d0c552be8 /release/scripts/startup/bl_operators/object.py | |
parent | 14a19fed788af0cf3695eb5def92510841056e08 (diff) |
Object Mode: move to workspace struct
- Read-only access can often use EvaluationContext.object_mode
- Write access to go to WorkSpace.object_mode.
- Some TODO's remain (marked as "TODO/OBMODE")
- Add-ons will need updating
(context.active_object.mode -> context.workspace.object_mode)
- There will be small/medium issues that still need resolving
this does work on a basic level though.
See D3037
Diffstat (limited to 'release/scripts/startup/bl_operators/object.py')
-rw-r--r-- | release/scripts/startup/bl_operators/object.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index 566487d9d0e..58f3afa3d6c 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -63,12 +63,13 @@ class SelectPattern(Operator): pattern_match = (lambda a, b: fnmatch.fnmatchcase(a.upper(), b.upper())) is_ebone = False + workspace = context.workspace obj = context.object - if obj and obj.mode == 'POSE': + if obj and workspace.object_mode == 'POSE': items = obj.data.bones if not self.extend: bpy.ops.pose.select_all(action='DESELECT') - elif obj and obj.type == 'ARMATURE' and obj.mode == 'EDIT': + elif obj and obj.type == 'ARMATURE' and workspace.object_mode == 'EDIT': items = obj.data.edit_bones if not self.extend: bpy.ops.armature.select_all(action='DESELECT') @@ -248,6 +249,8 @@ class SubdivisionSet(Operator): if not relative and level < 0: self.level = level = 0 + workspace = context.workspace + def set_object_subd(obj): for mod in obj.modifiers: if mod.type == 'MULTIRES': @@ -257,18 +260,18 @@ class SubdivisionSet(Operator): for i in range(sub): bpy.ops.object.multires_subdivide(modifier="Multires") - if obj.mode == 'SCULPT': + if workspace.object_mode == 'SCULPT': if mod.sculpt_levels != level: mod.sculpt_levels = level - elif obj.mode == 'OBJECT': + elif workspace.object_mode == 'OBJECT': if mod.levels != level: mod.levels = level return else: - if obj.mode == 'SCULPT': + if workspace.object_mode == 'SCULPT': if mod.sculpt_levels + level <= mod.total_levels: mod.sculpt_levels += level - elif obj.mode == 'OBJECT': + elif workspace.object_mode == 'OBJECT': if mod.levels + level <= mod.total_levels: mod.levels += level return @@ -284,7 +287,7 @@ class SubdivisionSet(Operator): # add a new modifier try: - if obj.mode == 'SCULPT': + if workspace.object_mode == 'SCULPT': mod = obj.modifiers.new("Multires", 'MULTIRES') if level > 0: for i in range(0, level): @@ -467,8 +470,9 @@ class ShapeTransfer(Operator): @classmethod def poll(cls, context): + workspace = context.workspace obj = context.active_object - return (obj and obj.mode != 'EDIT') + return (obj and workspace.object_mode != 'EDIT') def execute(self, context): ob_act = context.active_object @@ -508,10 +512,11 @@ class JoinUVs(Operator): def _main(self, context): import array + workspace = context.workspace obj = context.active_object mesh = obj.data - is_editmode = (obj.mode == 'EDIT') + is_editmode = (workspace.object_mode == 'EDIT') if is_editmode: bpy.ops.object.mode_set(mode='OBJECT', toggle=False) |