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
path: root/doc
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2019-05-23 11:28:24 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2019-05-23 11:29:49 +0300
commit8022bd705908a0e0bfd615a4e64d5140f326a8d1 (patch)
tree5c260556431acfca4fdccb86d70ad1c1033d015b /doc
parent58c4b10a708fbc24bca105dbf26dd991154c91ad (diff)
Depsgraph examples: don't assign to names of built-in Python objects
`object` is the superclass of all objects. Old-style code could still be using `class SomeClass(object)` and assigning something else to `object` could have unexpected results. This is now also documented in the [Python style guide](https://wiki.blender.org/wiki/Style_Guide/Python) on the wiki. Differential Revision: https://developer.blender.org/D4922 Reviewed by: sergey
Diffstat (limited to 'doc')
-rw-r--r--doc/python_api/examples/bpy.types.Depsgraph.1.py6
-rw-r--r--doc/python_api/examples/bpy.types.Depsgraph.2.py8
-rw-r--r--doc/python_api/examples/bpy.types.Depsgraph.3.py6
-rw-r--r--doc/python_api/examples/bpy.types.Depsgraph.4.py12
-rw-r--r--doc/python_api/examples/bpy.types.Depsgraph.5.py8
5 files changed, 20 insertions, 20 deletions
diff --git a/doc/python_api/examples/bpy.types.Depsgraph.1.py b/doc/python_api/examples/bpy.types.Depsgraph.1.py
index d972c076c97..7425c0db15f 100644
--- a/doc/python_api/examples/bpy.types.Depsgraph.1.py
+++ b/doc/python_api/examples/bpy.types.Depsgraph.1.py
@@ -17,8 +17,8 @@ class OBJECT_OT_evaluated_example(bpy.types.Operator):
def execute(self, context):
# This is an original object. Its data does not have any modifiers applied.
- object = context.object
- if object is None or object.type != 'MESH':
+ obj = context.object
+ if obj is None or obj.type != 'MESH':
self.report({'INFO'}, "No active mesh object to get info from")
return {'CANCELLED'}
# Evaluated object exists within a specific dependency graph.
@@ -42,7 +42,7 @@ class OBJECT_OT_evaluated_example(bpy.types.Operator):
# but has animation applied.
#
# NOTE: All ID types have `evaluated_get()`, including materials, node trees, worlds.
- object_eval = object.evaluated_get(depsgraph)
+ object_eval = obj.evaluated_get(depsgraph)
mesh_eval = object_eval.data
self.report({'INFO'}, f"Number of evaluated vertices: {len(mesh_eval.vertices)}")
return {'FINISHED'}
diff --git a/doc/python_api/examples/bpy.types.Depsgraph.2.py b/doc/python_api/examples/bpy.types.Depsgraph.2.py
index 8639ffc0267..cad149873a3 100644
--- a/doc/python_api/examples/bpy.types.Depsgraph.2.py
+++ b/doc/python_api/examples/bpy.types.Depsgraph.2.py
@@ -18,16 +18,16 @@ class OBJECT_OT_original_example(bpy.types.Operator):
# to request the original object from the known evaluated one.
#
# NOTE: All ID types have an `original` field.
- object = object_eval.original
- return object.select_get()
+ obj = object_eval.original
+ return obj.select_get()
def execute(self, context):
# NOTE: It seems redundant to iterate over original objects to request evaluated ones
# just to get original back. But we want to keep example as short as possible, but in real
# world there are cases when evaluated object is coming from a more meaningful source.
depsgraph = context.evaluated_depsgraph_get()
- for object in context.editable_objects:
- object_eval = object.evaluated_get(depsgraph)
+ for obj in context.editable_objects:
+ object_eval = obj.evaluated_get(depsgraph)
if self.check_object_selected(object_eval):
self.report({'INFO'}, f"Object is selected: {object_eval.name}")
return {'FINISHED'}
diff --git a/doc/python_api/examples/bpy.types.Depsgraph.3.py b/doc/python_api/examples/bpy.types.Depsgraph.3.py
index 25411597dd3..dc542c1b2f4 100644
--- a/doc/python_api/examples/bpy.types.Depsgraph.3.py
+++ b/doc/python_api/examples/bpy.types.Depsgraph.3.py
@@ -18,15 +18,15 @@ class OBJECT_OT_object_instances(bpy.types.Operator):
depsgraph = context.evaluated_depsgraph_get()
for object_instance in depsgraph.object_instances:
# This is an object which is being instanced.
- object = object_instance.object
+ obj = object_instance.object
# `is_instance` denotes whether the object is coming from instances (as an opposite of
# being an emitting object. )
if not object_instance.is_instance:
- print(f"Object {object.name} at {object_instance.matrix_world}")
+ print(f"Object {obj.name} at {object_instance.matrix_world}")
else:
# Instanced will additionally have fields like uv, random_id and others which are
# specific for instances. See Python API for DepsgraphObjectInstance for details,
- print(f"Instance of {object.name} at {object_instance.matrix_world}")
+ print(f"Instance of {obj.name} at {object_instance.matrix_world}")
return {'FINISHED'}
diff --git a/doc/python_api/examples/bpy.types.Depsgraph.4.py b/doc/python_api/examples/bpy.types.Depsgraph.4.py
index c2017afa2f9..468f9610ca2 100644
--- a/doc/python_api/examples/bpy.types.Depsgraph.4.py
+++ b/doc/python_api/examples/bpy.types.Depsgraph.4.py
@@ -34,22 +34,22 @@ class OBJECT_OT_object_to_mesh(bpy.types.Operator):
def execute(self, context):
# Access input original object.
- object = context.object
- if object is None:
+ obj = context.object
+ if obj is None:
self.report({'INFO'}, "No active mesh object to convert to mesh")
return {'CANCELLED'}
# Avoid annoying None checks later on.
- if object.type not in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META'}:
+ if obj.type not in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META'}:
self.report({'INFO'}, "Object can not be converted to mesh")
return {'CANCELLED'}
depsgraph = context.evaluated_depsgraph_get()
# Invoke to_mesh() for original object.
- mesh_from_orig = object.to_mesh()
+ mesh_from_orig = obj.to_mesh()
self.report({'INFO'}, f"{len(mesh_from_orig.vertices)} in new mesh without modifiers.")
# Remove temporary mesh.
- object.to_mesh_clear()
+ obj.to_mesh_clear()
# Invoke to_mesh() for evaluated object.
- object_eval = object.evaluated_get(depsgraph)
+ object_eval = obj.evaluated_get(depsgraph)
mesh_from_eval = object_eval.to_mesh()
self.report({'INFO'}, f"{len(mesh_from_eval.vertices)} in new mesh with modifiers.")
# Remove temporary mesh.
diff --git a/doc/python_api/examples/bpy.types.Depsgraph.5.py b/doc/python_api/examples/bpy.types.Depsgraph.5.py
index 335e87071e5..0f578b37d47 100644
--- a/doc/python_api/examples/bpy.types.Depsgraph.5.py
+++ b/doc/python_api/examples/bpy.types.Depsgraph.5.py
@@ -30,16 +30,16 @@ class OBJECT_OT_mesh_from_object(bpy.types.Operator):
def execute(self, context):
# Access input original object.
- object = context.object
- if object is None:
+ obj = context.object
+ if obj is None:
self.report({'INFO'}, "No active mesh object to convert to mesh")
return {'CANCELLED'}
# Avoid annoying None checks later on.
- if object.type not in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META'}:
+ if obj.type not in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META'}:
self.report({'INFO'}, "Object can not be converted to mesh")
return {'CANCELLED'}
depsgraph = context.evaluated_depsgraph_get()
- object_eval = object.evaluated_get(depsgraph)
+ object_eval = obj.evaluated_get(depsgraph)
mesh_from_eval = bpy.data.meshes.new_from_object(object_eval)
self.report({'INFO'}, f"{len(mesh_from_eval.vertices)} in new mesh, and is ready for use!")
return {'FINISHED'}