Is there any efficient debug ACT extensions way?

I am writing some ACT extensions in Ansys Mechanical and I wirte some function in different python file. Then import them as modules in the main.py. But when I modified the function module file, I need closed the Mechanical and reopen it. The ACT Reload button seams only work for main.py.
So I want to know is there any efficient way to reload the modified functional module file ?
Best Answer
-
You are correct in the behavior of the reload button. To reload imported modules, use this standard iron python code.
import SomeModule
reload(SomeModule)The reload function will reread the imported file and code behavior will be updated. When I am actively working on a project, I almost always reload after import to reflect changes being made on the fly. Once the project is done, I simply remove these lines.
2
Answers
-
@Mike.Thompson
Is it also possible to emulate the behavior of reloading that is happening regarding the ACT extensions on starting workbench? So that one would have a true reload but without having to restart WB or adding a reload() statement for every single module.0 -
When you have ACT debug mode = On (application preferences), then you should see a button to reload extensions in the UI. This will reload the extension like a WB restart. This also appears in mechanical when debug mode is on (in the automation tab).
0 -
@Mike.Thompson
As already discussed in this thread, this only reloads the main python file. Changes in modules that are imported are ignored. However, if I close workbench and open it again, the current state of all modules is captured correctly. So on the startup some processes related to ACT extensions are executed to achieve this. How can I initiate these processes or other processes which yield the same result (a true global reload)?
I want to avoid:- a lenghty close and reopen of WB
- adding a reload() statement for every single module
0