Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

3ds Max 2021 - Python Callbacks with pymxs

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
1762 Views, 3 Replies

3ds Max 2021 - Python Callbacks with pymxs

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:

http://help.autodesk.com/view/MAXDEV/2021/ENU/?guid=Max_Python_API_using_pymxs_pymxs_differences_pym... 

But cannot get this example to work with classes as it did with the MaxPlus method. 

Labels (4)
3 REPLIES 3
Message 2 of 4
eric.brosseau
in reply to: Anonymous

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()

 

 

Eric Brosseau
Senior Software Developer, 3ds Max, Autodesk
Message 3 of 4
Huston94
in reply to: eric.brosseau

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.

Message 4 of 4
Luna_Gu98
in reply to: Anonymous

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.

Post to forums  

Autodesk Design & Make Report