I’ve been working on adding, for the lack of a better way to put it, support for a particular 3D model format to Blender, and so far, my code’s been structured in this way:
- the payload is all C code, and for each of the main functions(an import and an export), they are plugged as the
execparameter in their respective Operators. The codefile is in
- the way to access this functionality hooks into the interface via Python scripts that I’ve installed as addons and each addon adds a button to import/export menu.
The python code for adding the button:
def menu_func_import(self, context): self.layout.operator(OPERATOR_NAME, text=FILE_NAME_AND_EXTENSION) def register(): bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
You will notice there’s no usual class registration in
register(), as this method doesn’t require classes.
So far, it’s been working simply by finding the appropriate Operator I’ve added to
WM_operatortype_append();, however this is not only an incorrect way of connecting the Python and C code, there’s also no way to use OrientationHelper to correctly align the model on import, and format filter when you’re looking for the file to import.
So, the question thus is, how does one correctly invoke C code from Python parts that describe interface?