Do we have any callback notification mechanism for controllers? Let say I have a bezier controller and I want to get notified when value is changed or keyframe added.
Controller Callback
when construct works for any controller…
geometry, topology, parameters… those are for sure
Um… I don’t think we can track changes to the value of the controller by using When construct. Would you please show me an example?
Actually I want to create a two-way connection between a Max controller and a WPF spinner, writing the code inside C# also would be great.So I really appreciate if you help me to know whether is it possible also in C# or not.
Thanks!
How to pass a controller to the C#
It depends.
Change handlers are called only for user initiated events, and not for changes resulting from a change in controller values. For example, a change handler on the transform attribute of a node would be called when the user moves the node. If the position of the node is animated, and you play back the animation, the transform attribute change handler is not called
Actually I need both cases for different interactions, user Initiated and all changes.Mostly all.
Perhaps some trick, but you should explain what you are controlling and what should happen when changed.
I just created a WPF spinner and I want to create a property exactly like the built-in Max’s Spinner.controller property.
Updates are something like two-way binding in WPF. Cases are:
- Controller value change -> Spinner value update.
- User input value to spinner -> Controller value update.
- Spinner value change by code not user -> Controller will not change.
- Controller has keyframe -> spinner border will be red.
in general case you can’t make the true connection of a max controller and a wpf ui controller.
in other case you have to rewrite a lot of system base classes
you can write your own controller which will be able to send messages to a specified ui controller, but again… you can’t do it for any built-in controller
do you see any example in max UI (.net, wpf, qt, etc.) except built-in rollout controllers where a controller connected to a controller (or a subanim)? The answer is NO. Because it’s practically impossible.
the best (and only) you can do is to use all available built-in callbacks, events, and notifications (units change, time change, etc.) to update your “connected” UI control.
another why is connect a controller to a rollout control and use kindof ‘native window’, or ‘window monitor’, or system hooks to monitor messages of this rollout controls,. and update yours
Well, It seems there isn’t a general solution for this. What if I limit my request to very specific and managed situation:
We can create or extend our controller and use it for the property.
We need to only support float type.
We have also control over MSX side.
Performance is important but at least I need one working method.
you already have it built-in in recent max versions…
it has “getValue” handler. You can use it for updating your UI control
I already used this feature in my rigging a lot and works perfect.
Is it possible to create a plugin like this inside C#?
Another problem for me is I have to support Max 2014-2019.
Yes, you can create a Controller plugin with the NET.SDK, but it’s a pain in the ass.
The names in the UI won’t look fine and possibly you will need different versions for 2014, 2016 and possibly 2017 and up.
I think the user @48design knows how to overwrite the UI with WPF, but he has not time to write an snipet.
Sorry, What you mean by
The names in the UI won’t look fine and possibly you will need different versions for 2014, 2016 and possibly 2017 and up.
The strings for the parameters block are not encoded correctly, so in your UI you will see instead of your parameter name for example “width” you will see a mix of extrange characters. This was solved, if I remember, in version 2017.
For compatibility between versions, there are some methods you MUST override that have changed, for example:
- in Max 2014:
public override RefResult NotifyRefChanged(IInterval changeInt, IReferenceTarget hTarget, ref UIntPtr partID, RefMessage message) - in Max 2016
public override RefResult NotifyRefChanged(IInterval changeInt, IReferenceTarget hTarget, ref UIntPtr partID, RefMessage message, bool propagate)
There’s one more parameter! Surely someone with better knowledge of C# can avoid this problem by asking for the max version and creating an #if , but I don’t.
And there are things that desappear (I don’t remember exactly, but after days to get something working, when I tryed it with 2017 version this cammand didn’t exits).
Got it, Thanks, I guessed Autodesk.max is changed over the time.Note that I don’t want to replace native controls. My UI is completely separate window snapped over the Max UI, So I don’t need to interact with parameterblocks or any other max controls. My pipeline is to create a WPF library include my windows, panels and controls. then I will load it as runtime dll in max. I will add eventhandlers and properties and bindings as much as possible in C#, But sometimes I had to add some eventhandlers in Max. In case the custom controls such as spinner, I prefer to add controller property in C#, because I’m pretty sure is much faster than MSX.
You right, I shouldn’t say that without measuring…, But I want to say working with available methods inside a class like IControl is faster compare to call a MaxScript function by using C# and “ExecuteMAXScriptScript” to return a value.
Hi!
As I got mentioned here: indeed I didn’t have time, yet, because my little son was born and eats all of my time…
In fact I am not able to overwrite the UI with WPF, I do only open/close a WPF window when opening/closing the parameter dialog.
Best regards