I have a question about blender's python script. I would like to share variables among more than two operations, however I don't know how to.
If I use global variable, it's easy to solve this problem.
selected_faces = []
class SelectFace(bpy.types.Operator):
bl_label = "Select Face"
def execute(self, context):
global selected_faces
selected_faces = ... # get selected faces.
.....
class OperationAboutSelectedFaces(bpy.types.Operator):
bl_label = "Operation About selected Face"
def execute(self, context):
global selected_faces
# some operation to "selected_faces"
However, I want to avoid using global variable. So, I would like to rewrite this code as follows...
class SelectFace(bpy.types.Operator):
bl_label = "Select Face"
def execute(self, context):
selected_faces = ... # get selected faces.
.....
class OperationAboutSelectedFaces(bpy.types.Operator):
bl_label = "Operation About selected Face"
def execute(self, context):
# some operation to "selected_faces"
Assuming operation sequence are as follows.
- "Select Face"
- "Operation About selected faces"
Thanks!
SelectFace.your_global = 123
$\endgroup$__init__
) and pass yourselected_faces
into it. It would be something like this (check syntax):def __init__(self, selectedFaces):
$\endgroup$