I'm looking for the source code of the operator bpy.ops.wm.save_mainfile.
I searched on their github repo, but I couldn't find the class linked to this operator. As I want to rewrite this operator, I would like to see how it is implemented to adapt it.
save_mainfileis a function in which I can get idname through python code. So, even if it calls a C++ function, it should be written somewhere in python code isn't it? – Squelletton Jan 22 '24 at 19:37type(bpy.ops.wm.save_mainfile)in the Python console it will tell you that it's a<class 'bpy.ops._BPyOpsSubModOp'>, a wrapper defined in blender/scripts/modules/bpy/ops.py:22. So,save_mainfile()is the constructor? andsave_mainfile.id_name()is one of its methods that gives you the C++ id='WM_OT_save_mainfile'. There is also a py id='wm.save_mainfile'. – Blunder Jan 23 '24 at 20:52ret = _op_call(self.idname_py(), .... This _op_call seems to do the magic and calls the C++ code. It's imported from _bpy. I have no idea where this _bpy module comes from. But you can call the operator when you do afrom _bpy import ops as ops_moduleand thenops_module.call('wm.save_mainfile', { 'filepath': 'c:/tmp/test.blend'})for example. Related question: How to call original operator from operator's override? – Blunder Jan 23 '24 at 21:11_bpyis a C module, that why we cannot find it. If you post it as an offical answer, I will accept it, unless I might post answer to my own question. – Squelletton Jan 26 '24 at 20:37