I have some automated tests setup for one of my add-ons. However, one of my operators initializes its own collection property parameter upon invoke()
- which doesn't get called when running an operator from a script. How do I initialize and set the collection property parameters for a given execution?
Here is example code, derivative of Blender API : pass collection as parameter of python operator:
import bpy
class Item(bpy.types.PropertyGroup):
is_true: bpy.props.BoolProperty()
class ExampleOperator(bpy.types.Operator):
bl_idname = "object.example_op"
bl_label = "Example Operator"
bl_options = {'REGISTER'}
collection: bpy.props.CollectionProperty(type=Item)
@classmethod
def poll(self, context):
return True
def execute(self, context):
for item in self.collection:
print(item.name, item.is_true)
return {'FINISHED'}
def register():
bpy.utils.register_class(Item)
bpy.utils.register_class(ExampleOperator)
if __name__ == "__main__":
register()
Any suggestions ? Tried with PointerProperty, but don't know exactly how to use it, and got same error. Thanks :)
bpy.ops.object.example_op("INVOKE_DEFAULT")
see docs.blender.org/api/current/bpy.types.Operator.html $\endgroup$