Skip to content

Commit

Permalink
add explicit interface support
Browse files Browse the repository at this point in the history
  • Loading branch information
dipinknair committed Jan 22, 2025
1 parent 05c268f commit 2d7f9cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ansys/mechanical/core/embedding/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions src/ansys/mechanical/core/embedding/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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")

0 comments on commit 2d7f9cc

Please sign in to comment.