Hello,
I have a question regarding callbacks and Python classes. In previous versions of Max, this was relatively simple to setup via MaxPlus. In the example below, I call 3 different functions that belong to a class depending on the callback that is triggered within Max.
self.selection_callback = MaxPlus.NotificationManager.Register(MaxPlus.NotificationCodes.SelectionsetChanged, self.test_function_A)
self.modifier_callback = MaxPlus.NotificationManager.Register(MaxPlus.NotificationCodes.PostModifierAdded, self.test_function_B)
self.node_change_callback = MaxPlus.NotificationManager.Register(MaxPlus.NotificationCodes.PostNodeUserPropChanged, self.test_function_C)
Seeing as MaxPlus is no longer supported in 2021. What would the equivalent solution to this be using pymxs?
I noticed an example at the following link:
But cannot get this example to work with classes as it did with the MaxPlus method.
Thank you for your question @Anonymous
I would refer you to those reference pages. They will probably help you more:
I was able to create a small sample code to verify callback methods could be class methods. I am wondering where you are facing issues with your code. I may not fully understand your question.
from pymxs import runtime as mxs
class MyCallbackListener:
def __init__(self):
print("My Callback Listener Created")
mxs.callbacks.addScript(mxs.Name('selectionSetChanged'), self.CallMeLaterAlligator, id=mxs.Name('MyListenerCallbacks'))
def CallMeLaterAlligator(self):
print("You fired a callback")
notification = mxs.callbacks.notificationParam()
print(" returning these params: ", notification)
myObject = MyCallbackListener()
Is this solution backwards compatible with previous versions of 3ds Max (2019 specifically) or was this only added to pymxs in 2021 to account from the discontinuation of MaxPlus?
Thanks.
I tried @eric.brosseau 's solution and the solution in 3ds Max 2020 Help | Registering Python Callbacks | Autodesk, they work with max 2022 but don't work with max 2020 😞
@Anonymous thanks for your MaxPlus solution that helps me to find a walk-around in older versions!
Can't find what you're looking for? Ask the community or share your knowledge.