Related to the question here I wanted now to use the export custom node from the same addon. Considering that the invoke()
function calls the file browser for setting the path the filename I would like to call the execution()
function directly but by overriding the self.filepath
variable. I've tried to follow the same trick as in the linked question, meaning:
override = {'node': bpy.data.node_groups['<node_group_name>'].nodes['VI CSV Export'], 'self.filepath':'<path_to_save_file>.csv'}
bpy.ops.node.csvexport(override, 'EXEC_DEFAULT')
But this complaints with the following error:
Error: Traceback (most recent call last):
File "/ttsesm/blender-2.83.6-linux64/2.83/scripts/addons/vi-suite06/vi_operators.py", line 2200, in execute
node = self.node
File "/ttsesm/blender-2.83.6-linux64/2.83/scripts/modules/bpy_types.py", line 713, in __getattribute__
return super().__getattribute__(attr)
AttributeError: 'NODE_OT_CSV' object has no attribute 'node'
location: /ttsesm/blender-2.83.6-linux64/2.83/scripts/modules/bpy/ops.py:199
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "/ttsesm/blender-2.83.6-linux64/2.83/scripts/modules/bpy/ops.py", line 199, in __call__
ret = op_call(self.idname_py(), C_dict, kw, C_exec, C_undo)
RuntimeError: Error: Traceback (most recent call last):
File "/ttsesm/blender-2.83.6-linux64/2.83/scripts/addons/vi-suite06/vi_operators.py", line 2200, in execute
node = self.node
File "/ttsesm/blender-2.83.6-linux64/2.83/scripts/modules/bpy_types.py", line 713, in __getattribute__
return super().__getattribute__(attr)
AttributeError: 'NODE_OT_CSV' object has no attribute 'node'
location: /ttsesm/blender-2.83.6-linux64/2.83/scripts/modules/bpy/ops.py:199
My questions are why the node = self.node
cannot be overridden and whether the way that I am overriding the self.filepath
variable is the correct one.
context.node
has. Not operator properties. Most likely want to usebpy.ops.foo.bar(override, filepath="...")
$\endgroup$node = self.node
was not overridden by the{'node': bpy.data.node_groups['<node_group_name>'].nodes['VI CSV Export']}
though? Like in the other case. I guess because it is not acontext
anymore, but then how I override it in this use case if possible. $\endgroup$self.node = context.node
is set in the invoke method of the operator also put in 'INVOKE_DEFAULT' as second argument like the other time. The operator is designed to be invoked by pressing its button in the UI of the node. (in this case you cannot bypass the invoke method by the looks) $\endgroup$context.window_manager.fileselect_add(self)
which I do not want, since I want to bypass this part. $\endgroup$context.node
instead. Not sure of the point of setting it as an operator property. $\endgroup$