Hi,
I'm currently working on an ACT extension in Ansys 2024 R2 with multiple Python files declared in the XML.
Everything works fine when compiled="false", but as soon as I switch to compiled="true" on the scripts, I can no longer import functions from one file to another.
Here is a minimal example:
XML :
<extension version="1" name="Test_TestImportACT">
<guid shortid="Test Chiffrement">17AAE05B-8762-4B3B-A7A2-EB4D7CFA1650</guid>
<script src="main.py" compiled="true"/>
<script src="utils.py" compiled="true"/>
<interface context="Project">
<toolbar name="TestToolbar" caption="Test">
<entry name="RunTest" caption="Run Test">
<callbacks>
<onclick>run_test</onclick>
</callbacks>
</entry>
</toolbar>
</interface>
</extension>
main.py:
Plain Text
from utils import log_message
def run_test(analysis):
ExtAPI.Log.WriteWarning("Call from main.py")
log_message()
utils.py:
Plain Text
def log_message():
ExtAPI.Log.WriteWarning("Message from utils.py")
When both scripts use compiled="false", everything works as expected.
However, when I set compiled="true", I get the error:
No module named utils.
I also tried using GetModule() to access functions from the other file, but I couldn't make it work.
What is the recommended approach for sharing code between encrypted (compiled) Python files in an ACT extension?
Thanks in advance!