[Closed] Reactor controller: get the master controller from the controlled slave
Hi guys first post here, the thing is I want to get the master controller of a float_Reactor controller via MAXScript to automate a pretty laborious process, but I can’t find the right function in the reference.
The float_Reactor controller has a series of get/set attributes for all parameters within a reaction, but I can’t find a sort of “getReactTo” to simply obtain the controller whose value is taken. reactTo just sets the reaction doesn’t return the actual value…
Any ideas?
I’ll try and rephrase my question, I have a series of Custom Attributes with reactions that I’d like to move to a PEN_Attribute_Holder_2. I thought the right way to go would be to iterate through the slave controllers, find its master controller (if there’s a way), copy all reactions and make it reactTo the new custom attributes in the PEN_Attribute_holder_2 modifier adding the saved reaction properties.
Maybe it’s completely absurd but I really need some pointers, transferring them by hand is just too painful. Any thoughts?
Thanks!
Not sure this will help but here is a script that sets up a reaction.
--Create a instance of the attribute holder
penMod='PEN_Attribute_Holder 2'()
--Create a custom attribute definition
def=attributes testDef
(
parameters params rollout:testR
(
spin type:#float ui:spinSp
)
rollout testR "Test"
(
spinner spinSp "The Value"
)
)
--Add the definition to the modifier
custAttributes.add penMod def
--Add a controller to the paramater in the controller.
--This needs to be done so reaction manager has a controller to work with.
penMod.testDef.spin.controller=bezier_float()
--Make a box and sphere
b=box()
s=sphere()
--Select the box
select b
--Add the attribute holder modifier to the box
addModifier b penMod
--Change to the modifier panel
max modify mode
--Reaction Manager.
--Create an instance of the float_reactor controller
fRc=float_reactor()
--Apply controller to radius of the sphere
s.radius.controller=fRc
--Make the radius of the sphere react to the spinner.
--This will set the frist reaction state as well.
reactTo fRc penMod.testDef.spin.controller
--Add a new reaction state
createReaction fRc
--Set the value of the controlling track to 100.
--This is the value that the spinner will reach when the reaction is at 100%
setReactionValue fRc 2 100
--Set the value of the state. When the reaction value hits 100 the state will be 50.
setReactionState fRc 2 50
--Get the values of the master and slave states for the second reaction.
getReactionValue fRc 2
getReactionState fRc 2
Hi Paul, thanks for the reply and sorry for the delay, I’ve been giving some thought to this and hopefully I can explain myself better this time.
I have a foot rig with several custom attributes that control its functionality in a standard Attribute Holder modifier on top of a control object. My goal is to copy all the custom attributes into a PEN_Attribute_Holder 2 modifier also on the control object.
Here’s the code I’ve been able to develop so far, hopefully it will clarify the situation:
-- Destination PEN_Attribute_Holder 2 modifier with custom attributes defined
pasteMod = $c_r_foot.modifiers[1].foot_controls
-- original float_reaction controller, my intention is to cycle through a series of objects
original_frc = $r_swivel_line.controller[2][3].controller
-- create a new float_reaction controller to create a copy of the original one
fRc = float_reactor()
-- create the bezier controller needed for the reactTo statement
pasteMod.flap.controller = bezier_float()
-- * I know that the original float reaction controller reacts to the "flap" attribute of the original Attribute Holder
-- * Is there a way to know to what custom attribute the original float_reaction reacts to?
reactTo fRc pasteMod.flap.controller
-- delete the first reaction to create a true copy of the original
deleteReaction frc 1
-- cycle through the reactions and create new ones in the copied float reaction controller with the same attributes
for i = 1 to (getReactionCount original_frc) do (
createReaction fRc
setReactionState fRc i (getReactionState original_frc i)
setReactionValue fRc i (getReactionValue original_frc i)
)
-- replace the original float_reaction controller with the new one
$.controller[2][3].controller = fRc
As you can see the main problem is the reactTo statement of the new float_reaction controller, because I can’t know the custom attribute to which the original float_reaction is reacting to. The only way I can come up with is the Reaction Manager dialog that would force me to copy each reaction manually which is not a lot of fun.
I hope this is a little clearer this time around.
BTW PEN, congratulations on your work, really outstanding stuff
I’m going to bump this topic as I found it after doing a search to answer the same question.
You can set a reactor controller to react to something, but you can’t seem to find out via maxscript what a reactor controller is reacting to!
Does anyone know of any work-arounds to find out this information?
Hmmm… no responses.
It seems like a big thing to overlook in the reaction manager/maxscript’s functionality.
I wonder if Bobo has some insight into why it’s absent… hint, hint
:¬)
I would like to bump this up, I am trying to write a Reaction Controller exporter that will then allow me to load to Relation Constraints in MotionBuilder or Set Driven in Maya. This would allow people to transfer rigging elements between the apps.
However, the reactTo relationships don’t seem query-able as stated previously in this post.
Anyone?
CE
ok, i kind of took a crack at this on my blog, so here’s the interesting part:
if you get the dependents of a master, and check all the controllers you will see the following on the 'driving' channel.
refs.dependents $.position.controller
#(Controller:Position_Rotation_Scale, ReferenceTarget:Reaction_Master, Controller:Position_Reaction, ReferenceTarget:Reaction_Set, ReferenceTarget:Reaction_Manager, ReferenceTarget:ReferenceTarget, ReferenceTarget:Scene, Controller:Position_Rotation_Scale, $Box:box02 @ [58.426544,76.195091,0.000000], $Box:box01 @ [-42.007244,70.495964,0.000000], ReferenceTarget:NodeSelection, ReferenceTarget:ReferenceTarget, ReferenceTarget:ReferenceTarget)
See the 'ReferenceTarget:Reaction_Master' bit? This is the distinguishing feature of a Master, and it's located on the channel that drives the slaves. You can query it to see what node it is driving, then go to that node and check it's controllers to see what is driven:
exprForMAXObject (refs.dependents $.position.controller)[2]
"<<Reaction Master instance>>"
getclassname (refs.dependents $.position.controller)[2]
"Reaction Master"
Very hacky, but at least it’s possible.
Not so fast!
I was trying to make a more general ‘Reaction Exporter’ today and when a coworker threw something complex at it, it fell apart.
For instance, I cannot figure out how to query an ‘expose transform’ node correctly to get it to show a ‘Master’.
shrug
This whole maxscript implementation/exposure is faulty imho, checking all dependents int he scene is a mess anyway.