I need to access the string in 'my_type' string property which reside in the class Append_OT_Operator from the class Apply_OT_Operator. How can I make this 'my_type' a variable that I can access globally? Or is there a better way?
This is my code in my_operators.py:
class Append_OT_Operator(bpy.types.Operator):
bl_idname = "wm.appending_basic_objects"
bl_label = "Append the basic objects"
my_type : bpy.props.StringProperty()
def execute(self, context):
path = (r'C:/Users/')
blendfile = "Assets" + ".blend"
bpy.ops.wm.append(
filepath = blendfile,
directory = path + '/' + blendfile + "/Object/",
filename = self.my_type)
return {'FINISHED'}
class Apply_OT_Operator(bpy.types.Operator):
bl_idname = "wm.apply"
bl_label = "Apply most modifiers for UV unwrapping phase"
def execute(self, context):
print(my_type) #return an error, instead of printing my_type string
To clarify, 'my_type' is set when the user click on a button of the UI in my ui_panel.py:
class UI_PT_Panel(bpy.types.Panel):
bl_idname = "UI_PT_Panel"
bl_label = "Bijoux Panel"
bl_category = "Bijoux Addon"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
def draw(self, context):
layout = self.layout
row = layout.row()
row.operator('wm.appending_basic_objects', text = "append my_object1").my_type = 'my_object1'
row = layout.row()
row.operator('wm.appending_basic_objects', text = "append my_object2").my_type = 'my_object2'