[Closed] Buttons and script controllers
Hey guys, I created a rig and Im stuck when trying to make it name independent. So here it is:
How can I access a button, from within the script controller of an object?
The reason I ask this is because, from the script controller I can access and slider or a spinner, and this is mainly because it has either a float or an integer value. How ever buttons dont have a value (from what I understand) buttons are more or less just a UI element, in my case they are a UI element within an objects attribute holder.
A deeper explanation of what I’m trying to achieve.
I have created some custom attributes thats in an attribute holder, there are many buttons and sliders, and I created this just within the standard script window. From within the script and call on the buttons by just using the statement “on bt pressed do” and this works fine, the problem is that it then becomes name dependent, because Im calling on objects within my scene by name. So the way I’m trying to get around name dependency is by assign nodes to variables within a script controller, and because a button is just a ui element, I cannot assign it a node.
Hope is clear enough.
I appreciate all the help I can get.
Perhaps I’m going about it the wrong way, so just let me know.
I’m using Max 9
Thanks.
Manny
It’s been a while, but I experiemented with the idea of changing the custom attribute value directly. So when the button was clicked, you would change the value directly, not via the state of ui item. Else you could place an invisible control in the rollout, that the button event handler could update it self and then use that (invisible) control as you connection.
Like I say, it’s been a while, but you might want to play around with something like that.
I’m Pen also has some better ideas!
Shane
add a custom attributes to the script controller – on that CA store nodes or weak reference nodes – from the script controller you can access with
this.nameOFParam
or if weakreferrences this.nameOFParam.node
mark
Grabbed from Pen production, sorry Paul
--Called when the Add Node picked button has selected an object.
on addObject picked obj do
(
--Creates a nodeTransformMonitor from using the selected node and appends refNodes with it.
append refNodes (nodeTransformMonitor node:obj forwardTransformChangeMsgs:false)
updateList()
)
the above ” refNodes” is name independent , you can add it into your custAttr without worrying name changed.