Replies: 1 comment 1 reply
-
|
Hi, there are events that you can add to your main module , one of which is import traceback
from pyrx import Ap, Ax, Db, Ed, Ge, Rx, Gi
import _helper
"""
PyRx Basic Command Module with Event Handling
Event Handlers:
- OnPyInitApp: Called when the Python application is initialized
- OnPyUnloadApp: Called when the Python application is unloaded
- OnPyReload: Called when the module is reloaded via pyreload command
- OnPyLoadDwg: Called when a drawing document is opened
- OnPyUnloadDwg: Called when a drawing document is closed
"""
# === Application Lifecycle Events ===
def OnPyInitApp():
print("\nOnPyInitApp")
def OnPyUnloadApp():
print("\nOnPyUnloadApp")
def OnPyLoadDwg():
print("\nOnPyLoadDwg")
def OnPyUnloadDwg():
print("\nOnPyUnloadDwg")
def OnPyReload() -> None:
print("\nOnPyReload")
import importlib
importlib.reload(_helper)
# === Command Definitions ===
@Ap.Command()
def doit():
try:
_helper.foo()
except Exception:
print(traceback.format_exc())
# === Lisp Function Integration ===
@Ap.LispFunction()
def mylisp(args):
try:
_helper.foo()
return args
except Exception as err:
print(err) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
If my program contains multiple files, such as main.py, utils.py, and ui.py, when I load main.py and modify the content of non main.py files (like utils.py), after using pyreload to update, the changes made to utils.py do not take effect. Even if I use pyload or pyreload to load utils.py separately, it also doesn't work.
Beta Was this translation helpful? Give feedback.
All reactions