Skip to content

Commit

Permalink
use "OnWorkbenchReady" to update globals (#854)
Browse files Browse the repository at this point in the history
Co-authored-by: Mohamed Koubaa <koubaa@github.com>
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 6, 2024
1 parent 99fcd0a commit 3db977a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/854.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use "OnWorkbenchReady" to update globals
11 changes: 3 additions & 8 deletions src/ansys/mechanical/core/embedding/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,7 @@ def _subscribe(self):
try:
# This will throw an error when using pythonnet because
# EventSource isn't defined on the IApplication interface
self.ExtAPI.Application.EventSource.OnAfterNew += self._on_after_new
self.ExtAPI.Application.EventSource.OnAfterDatabaseLoad += self._on_after_open
self.ExtAPI.Application.EventSource.OnWorkbenchReady += self._on_workbench_ready
self._subscribed = True
except:
self._subscribed = False
Expand All @@ -345,13 +344,9 @@ def _unsubscribe(self):
if not self._subscribed:
return
self._subscribed = False
self.ExtAPI.Application.EventSource.OnAfterNew -= self._on_after_new
self.ExtAPI.Application.EventSource.OnAfterDatabaseLoad -= self._on_after_open
self.ExtAPI.Application.EventSource.OnWorkbenchReady -= self._on_workbench_ready

def _on_after_open(self, sender, args) -> None:
self._update_all_globals()

def _on_after_new(self, sender, args) -> None:
def _on_workbench_ready(self, sender, args) -> None:
self._update_all_globals()

def update_globals(
Expand Down

0 comments on commit 3db977a

Please sign in to comment.