If you need to import files into the GUI that are not located in the same directory as the plug-in, you must augment the sys.path list as shown in the previous example. In addition, if you need to augment the kernel’s sys.path list, you should supply code similar to the following in the plug-in’s kernelInitString, in this example the name of the file containing the plug-in is myForm_plugin.py:
from abaqusGui import AFXForm, getAFXApp
class MyForm(AFXForm):
form code goes here
import os
# Full path (with name) to this file
absPath = os.path.abspath(__file__)
# Full directory specification
absDir = os.path.dirname(absPath)
# Full subdirectory specification
subDir = os.path.join(absDir, 'mySubDir')
initString = "sys.path.append('%s')\n" % subDir
# myModule is located in subDir
initString += 'import myModule'
toolset = getAFXApp().getAFXMainWindow().getPluginToolset()
toolset.registerGuiMenuButton(buttonText='My Utility',
object=MyForm(toolset), kernelInitString=initString )