Import and Export

Okay I can define in say init.py an Import for a file type with FreeCAD.addImportType(string, string) and it looks for either an open() function
or an import() function in the named python file . I can also define an export type with FreeCAD. addExportType(string, string) and it looks for an export() function in a named python file.

Now if I make the import and export python files the same name can I use a global variable in the python file and have access for both import and export i.e. could I pass some data between import and export without storing the data in the FreeCAD doc.

I’m not sure what you would need to pass around. Maybe provide an example?

The importFile.py is able to hold the import functions and export functions in the same file. There is no need to have two separate files, although this is probably better to better organize the code; see importIFC module refactor.

For example, in the Draft Workbench the importer and exported are under the same namespace.

import importSVG

importSVG,open("/home/user/whatever.svg")

importSVG.export([object1, object2, object3], "/home/user/out.svg")