From 2d7f9cc5a1ecdfd2f5a0ef2d9b48f74d20b93619 Mon Sep 17 00:00:00 2001 From: dkunhamb Date: Wed, 22 Jan 2025 14:27:33 -0600 Subject: [PATCH] add explicit interface support --- src/ansys/mechanical/core/embedding/app.py | 2 +- src/ansys/mechanical/core/embedding/runtime.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ansys/mechanical/core/embedding/app.py b/src/ansys/mechanical/core/embedding/app.py index 708b3151a..e1f743457 100644 --- a/src/ansys/mechanical/core/embedding/app.py +++ b/src/ansys/mechanical/core/embedding/app.py @@ -181,8 +181,8 @@ def __init__(self, db_file=None, private_appdata=False, **kwargs): profile.update_environment(os.environ) atexit.register(_cleanup_private_appdata, profile) - self._app = _start_application(configuration, self._version, db_file) runtime.initialize(self._version) + self._app = _start_application(configuration, self._version, db_file) connect_warnings(self) self._poster = None diff --git a/src/ansys/mechanical/core/embedding/runtime.py b/src/ansys/mechanical/core/embedding/runtime.py index f609808c7..a4b619277 100644 --- a/src/ansys/mechanical/core/embedding/runtime.py +++ b/src/ansys/mechanical/core/embedding/runtime.py @@ -44,6 +44,18 @@ def __register_function_codec(): Ansys.Mechanical.CPython.Codecs.FunctionCodec.Register() +def _bind_assembly_for_explicit_interface(assembly_name: str): + """Bind the assembly for explicit interface implementation.""" + import clr + + assembly = clr.AddReference(assembly_name) + from Python.Runtime import BindingManager, BindingOptions + + binding_options = BindingOptions() + binding_options.AllowExplicitInterfaceImplementation = True + BindingManager.SetBindingOptions(assembly, binding_options) + + def initialize(version: int) -> None: """Initialize the runtime. @@ -59,3 +71,5 @@ def initialize(version: int) -> None: # function codec is distributed with pymechanical on linux only # at version 242 or later __register_function_codec() + + _bind_assembly_for_explicit_interface("Ansys.ACT.WB1")