How do I install and load an extension in Mechanical using PyMechanical?

Ayush Kumar
Member, Moderator, Employee Posts: 505
✭✭✭✭
in Structures
How do I install and load an extension in Mechanical using PyMechanical?
Tagged:
0
Comments
-
Supported from 2025R1
import os from ansys.mechanical.core import launch_mechanical, Mechanical DOCKER_RUN = False BATCH = False if not DOCKER_RUN: mech_242 = r"C:/Program Files/ANSYS Inc/v251/aisol/bin/winx64/AnsysWBU.exe" mechanical = launch_mechanical(exec_file=mech_242, batch=BATCH, cleanup_on_exit=False) else: mechanical = Mechanical() print(mechanical) ext_path = "C:\\Path\\To\\Extension.wbex" cmd = ''' ext_path = r"{0}" ExtAPI.MechanicalExtensionManager.Binary.InstallExtension(ext_path) extensions = ExtAPI.MechanicalExtensionManager.AvailableExtensions for extension in extensions: if extension.Name == "APDLEditor": apdl_extension = extension if apdl_extension is not None: ExtAPI.MechanicalExtensionManager.LoadExtension(apdl_extension.GUID, "Binary", apdl_extension.Version) '''.format(ext_path) mechanical.run_python_script(cmd)
0