I tried to port the fem-module but got lost with imports on C++ side, but it seems this is not the same:
When recording a macro then
Gui::Command::addModule aims to avoid duplicate import statement and puts them on top of the macro while
Gui::Command::doCommand doesn't do this.
However, the way how
Gui::Command::addModule is implemented it doesn't support importing of sub-modules at the moment. But this can be easily fixed by checking for a dot in the module name. Once it's fixed you can write
Gui::Command::addModule("Fem.FemGui") and internally it will split the string at the last dot and write
from Fem import FemGui
Wouldn't it be better to have them in the same place?
Yes it makes sense and it will simplify a few things. Like the Python search path we also extend the system path (
PATH) by all the module directories.