How to call python animation node operator?

I have a problem i can't resolve. Here is the context : I have a blender file, i am using animation node addon. I have a animation node tree with a empty string list node. The elements in the list should be created programmatically with python.

When i call the create animation operator in a python console inside blender, the execution works:

Here is the create element operator :

bpy.ops.an.invoke_function_1(invokeWithData=False, confirm=False,
callback="#('executeNodeCallback', (('NodeTree', 'summary_list'), 'newInputSocket'))",
passEvent=False, data="None")


But when i call this operator from calling blender in the command line with a python script like so :

blender 'my blender file.blend' -P 'my python script.py'

Creation Operator is called in 'my python script.py'

I get this error in the command line terminal and the element is not created:

AttributeError: Calling operator "bpy.ops.an.invoke_function_1" error, could not be found

Any ideas of how to solve this error?

Thanks.

1 Answer

For Animation Nodes I developed a system that automatically generates operators for certain functions on nodes. Otherwise I would have to write a lot of overhead code all the time. This is why the operator has a weird name like invoke_function_1. It also explains why the operator does not exist when you run your script at first. The operators are only created when needed.

Those operators are only should only used on the UI. In all other cases you should call the underlying functions directly.

In your case you have to do something like this: bpy.data.node_groups["NodeTree"].nodes["summary_list"].newInputSocket().

• Thank you and again thanks for your work on this adddon it saved me a lot a time. Jun 23 '17 at 14:05