[Closed] interactivity max/ms
I was wondering how i could make my script interactive with max.
for exemple;
I’ve a spinner in my script to control a box weight. if i change the value in the script, it will change the value in the max modify panel as well.
But if i change this value in the modify panel, it will not change the one in the script.
a spinner has a controller property, simply specify the box’s controller to it.
p.s. is ‘weight’ a mixture of width and height?
lol, i start to make some new words… hahahaha
but it was just an example.
I need it for a lot of parameters, like the object name’s, frame n° and a much more.
You can register some callbacks for these things, but it can be a big headache…
Actually, since 3ds Max 6 the dynamic assignment of an existing controller in the scene to a Maxscript UI spinner’s .controller property allows you to avoid the need for event handlers, object change handlers and callbacks to keep them in sync. (Before 3ds Max 6, you could only establish a controller for UI spinners when they were created, which made them mostly useless. After 3ds Max 6, you could reassign controllers to the same UI spinner any number of times. This addition was actually undocumented until I stumbled onto it around 3ds Max 8 or 9 and surprised BoBo with it…the developer’s never told the docs guru!)
MyUIspinner.controller = MyBox.height.controller;
Each time you assign the controller, the spinner’s existing value is ignored and replaced by the existing value of the controller. At this point, 3ds Max is handling the synchronizing seamlessly, so changes to that controller from ANYWHERE in the scene will update the Maxscript spinner and vice versa.
Before 3ds Max 6 introduced dynamic controller reassignment for UI spinners, you’d have to have use the spinner’s event handler and at least one object change handler tracking the box to keep them in sync. Much easier now…
thx, i gonna check this.
I love to have bigs headaches lol :banghead:
thanks a lot for this informations.
I started to use the callbacks and it’s works fine, but i m going to try ur way ^^
I forgot to mention another advantage: direct assignment of a controller to a Maxscript UI spinner also automatically controls the red brackets around the spinner buttons when that controller is animated and the time slider is on one of those keyframes.
Below is a simplified code sample from my LightRigger script, which is backward compatible all the way to 3D Studio MAX R3.1. (I set it up to take advantage of this behavior when running in 3ds Max 6 and higher. In 3ds Max 4-5, the .setKeyBrackets property was used to explicitly enable/disable the brackets. There was no scripted control of these brackets in 3D Studio MAX R3.)
local IsMax4andUp = (((maxVersion())[1])>=4000)
local IsMax6andUp = (((maxVersion())[1])>=6000)
if IsMax6andUp then (
MyRollout.MySpinner.controller = MyLight.samplerange.controller
) else (
MyRollout.MySpinner.value = MyLight.samplerange
local SRkeys = MyLight.samplerange.controller.keys
local SRkeypres = false
for i=1 to SRkeys.count where (SRkeys[i].time==curtime) do (SRkeypres = true)
if IsMax4andUp do (MyRollout.MySpinner.setKeyBrackets = SRkeypres)
)
i tried this one:
AnimationRangeRollout.spnStartFrame.controller = animationrange.start.controller
but got this error:
Unknown property: "controller" in 0f
The error is in the second half of your statement…here is a demo from the Maxscript Listener:
animationRange.start.controller
-- Unknown property: "controller" in 0f
Animatable tracks (i.e. any property that you can drill down to in TrackView) are the only properties that can be assigned controllers. The animation range for 3ds Max can be changed but not animated, so you got an error when you tried to access it.
When Maxscript tried to evaluate this statement, it recognized and called the reserved global variable “animationRange”, which evaluated an object with properties of its own. One of those properties was the one you requested (“start”), but because that property was not an animatable track, it had no “controller” property at all. Instead of “animationRange.start” returning another object that might have additional properties, the expression simply evaluated to a time value of “0f”, which caused an error when your statement requested its “.controller” property.
This is why “AnimationRangeRollout.spnStartFrame.controller” did not throw any error…your rollout (“AnimationRangeRollout”) had a UI spinner (“spnStartFrame”) that was animatable, so it did have a .controller property.
thx a lot for your explanations.
In this case, I will keep my callback for this spinner.