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.nodehas. Not operator properties. Most likely want to usebpy.ops.foo.bar(override, filepath="...")– batFINGER Oct 16 '20 at 16:17node = self.nodewas 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 acontextanymore, but then how I override it in this use case if possible. – ttsesm Oct 16 '20 at 16:33self.node = context.nodeis 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) – batFINGER Oct 16 '20 at 16:38context.window_manager.fileselect_add(self)which I do not want, since I want to bypass this part. – ttsesm Oct 16 '20 at 16:41context.nodeinstead. Not sure of the point of setting it as an operator property. – batFINGER Oct 16 '20 at 16:48self.nodeis defined in the invoke(). If I givebpy.ops.node.csvexport(override, filepath="test.csv")it still hangs in thenode = self.nodeline. – ttsesm Oct 16 '20 at 18:39