"No module named mech_dpf" error while importing mech_dpf in ACT extension
I have developed an ACT extension which uses DPF for post-processing. All relevant DPF libraries are imported correctly at the beginning of the Python file:
import mech_dpf import Ans.DataProcessing as dpf mech_dpf.setExtAPI(ExtAPI) dpf.DataProcessingCore.LoadLibrary( "math", r"C:\Program Files\ANSYS Inc\v211\aisol\bin\winx64\Ans.Dpf.Math.dll")
However, when I reload the extension I get the below shown error. This doesn't affect the result but how can I get around this error in the log?
Answers
-
When an ACT extension is loaded all the python files included in the ACT extension XML
script src=....py
tag are loaded and hence their imports.mech_dpf
library is not available in the WB project page scripting console and only in Mechanical. So, while importing the libraries check for the condition if the import is being done in Mechanical scripting console or in WB scripting console. Update the import as below and it will get rid of the error.if ExtAPI.Context == "Mechanical": import mech_dpf import Ans.DataProcessing as dpf mech_dpf.setExtAPI(ExtAPI) dpf.DataProcessingCore.LoadLibrary( "math", r"C:\Program Files\ANSYS Inc\v211\aisol\bin\winx64\Ans.Dpf.Math.dll")
6