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:
authorCampbell Barton <ideasman42@gmail.com>2018-02-08 13:14:26 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-02-08 13:14:26 +0300
commit345c6298e995ea618c34282ba6d7ab5af032f191 (patch)
treef4fbc4798e17d0f19efc28b51a41425d0c552be8 /release/scripts/modules
parent14a19fed788af0cf3695eb5def92510841056e08 (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/modules')
-rw-r--r--release/scripts/modules/bpy_extras/object_utils.py15
-rw-r--r--release/scripts/modules/keyingsets_utils.py9
2 files changed, 16 insertions, 8 deletions
diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py
index 04b3858bb0d..31938f3ad3e 100644
--- a/release/scripts/modules/bpy_extras/object_utils.py
+++ b/release/scripts/modules/bpy_extras/object_utils.py
@@ -119,6 +119,7 @@ def object_data_add(context, obdata, operator=None, name=None):
:return: the newly created object in the scene.
:rtype: :class:`bpy.types.Object`
"""
+ workspace = context.workspace
scene = context.scene
layer = context.view_layer
layer_collection = context.layer_collection
@@ -146,9 +147,9 @@ def object_data_add(context, obdata, operator=None, name=None):
# caused because entering edit-mode does not add a empty undo slot!
if context.user_preferences.edit.use_enter_edit_mode:
if not (obj_act and
- obj_act.mode == 'EDIT' and
- obj_act.type == obj_new.type):
-
+ obj_act.type == obj_new.type and
+ workspace.object_mode == 'EDIT'
+ ):
_obdata = bpy.data.meshes.new(name)
obj_act = bpy.data.objects.new(_obdata.name, _obdata)
obj_act.matrix_world = obj_new.matrix_world
@@ -159,7 +160,10 @@ def object_data_add(context, obdata, operator=None, name=None):
bpy.ops.ed.undo_push(message="Enter Editmode")
# XXX
- if obj_act and obj_act.mode == 'EDIT' and obj_act.type == obj_new.type:
+ if (obj_act and
+ obj_act.type == obj_new.type and
+ workspace.object_mode == 'EDIT'
+ ):
bpy.ops.mesh.select_all(action='DESELECT')
obj_act.select_set(action='SELECT')
bpy.ops.object.mode_set(mode='OBJECT')
@@ -249,9 +253,10 @@ def object_image_guess(obj, bm=None):
first checking the texture-faces, then the material.
"""
# TODO, cycles/nodes materials
+ workspace = context.workspace
me = obj.data
if bm is None:
- if obj.mode == 'EDIT':
+ if workspace.object_mode == 'EDIT':
import bmesh
bm = bmesh.from_edit_mesh(me)
diff --git a/release/scripts/modules/keyingsets_utils.py b/release/scripts/modules/keyingsets_utils.py
index 7ce5f3e029b..40e74e27ed2 100644
--- a/release/scripts/modules/keyingsets_utils.py
+++ b/release/scripts/modules/keyingsets_utils.py
@@ -57,9 +57,10 @@ def path_add_property(path, prop):
# selected objects (active object must be in object mode)
def RKS_POLL_selected_objects(ksi, context):
+ workspace = context.workspace
ob = context.active_object
if ob:
- return ob.mode == 'OBJECT'
+ return workspace.object_mode == 'OBJECT'
else:
return bool(context.selected_objects)
@@ -67,8 +68,9 @@ def RKS_POLL_selected_objects(ksi, context):
# selected bones
def RKS_POLL_selected_bones(ksi, context):
# we must be in Pose Mode, and there must be some bones selected
+ workspace = context.workspace
ob = context.active_object
- if ob and ob.mode == 'POSE':
+ if ob and workspace.object_mode == 'POSE':
if context.active_pose_bone or context.selected_pose_bones:
return True
@@ -87,8 +89,9 @@ def RKS_POLL_selected_items(ksi, context):
# all selected objects or pose bones, depending on which we've got
def RKS_ITER_selected_item(ksi, context, ks):
+ workspace = context.workspace
ob = context.active_object
- if ob and ob.mode == 'POSE':
+ if ob and workspace.object_mode == 'POSE':
for bone in context.selected_pose_bones:
ksi.generate(context, ks, bone)
else: