[Closed] On linking node properties
Here’s a little experiment I’ve been playing with. For some time I’ve wanted to have in MAX the ability to “link” individual object properties so that whenever one changes the other does too. Think of it as “selective instancing”, changing one object modifies another, but on a predefined way.
The following bit of code will create a rollout, where you can choose a Source Box and a Target Box and link them. Then, changing the height of the first will modify the width of the second. If this was extended so you could choose any two properties in any object (easy), or maybe something more elaborate like the distance between vertices (not so easy?), it could become useful perhaps.
IF LinkItArray == undefined DO LinkItArray = #()
struct linkItLink
(
sourceObj,
targetObj,
sourceProp,
sourcePropValue,
targetProp
)
rollout linkRoll "Link It!"
(
local sourceObj
local targetObj
pickButton linkSource "Source"
pickButton linkTarget "Target"
button linkBtn "Link It!"
ON linkSource PICKED arg DO
(
IF classOf arg == Box DO
(
sourceObj = arg
linkSource.text = arg.name
)
)
ON linkTarget PICKED arg DO
(
IF classOf arg == Box DO
(
targetObj = arg
linkTarget.text = arg.name
)
)
ON linkBtn PRESSED DO
(
IF targetObj != undefined AND sourceObj != undefined THEN
(
local newLink = linkItLink sourceObj:sourceObj targetObj:targetObj sourceProp:"height" sourcePropValue:sourceObj.height targetProp:"width"
append LinkItArray newLink
destroyDialog linkRoll
fn callbackFn theEvent theNode =
(
--print "Object Geometry Changed"
local objToCheck = GetAnimByHandle theNode[1]
FOR theLink in linkItArray DO
(
IF theLink.sourceObj == objToCheck DO
(
--print "Match Found!"
local theDifference = (theLink.sourcePropValue-(getProperty theLink.sourceObj theLink.sourceProp))
theLink.sourcePropValue = (getProperty theLink.sourceObj theLink.sourceProp)
setProperty theLink.targetObj theLink.targetProp ((getProperty theLink.targetObj theLink.targetProp)+theDifference)
)
)
)
local callbackItem = NodeEventCallback mouseUp:false geometryChanged:callbackFn
)
ELSE
(
messageBox "Select some boxes shmuck!" title:"DOH!"
)
)
)
createDialog linkRoll
isn’t that called parameter wiring? :curious:
Edit: let me clarify, as I know you’re familiar with parameter wiring… so my (implied) question was: how does this differ, where might you use it instead of parameter wiring, etc.
…
.
.
.
.
NOTE TO SELF: check animation tutorials
REPLY TO THE EDIT: I actually was not familiar with this. I’ve never done much animating as 99% my work has been on the arch VIZ business (where you hardly ever need more than a door opening or a cemera moving). In fact I was thinking of use this as a way to link architectural elements, so that when changing one I did not have to remodel the other parts…
Me thinks I’ve just made an arse of myself… I’ll go hide in a hole for the rest of the day
d’oh! I could’ve sworn you did (see my edit)
hey, on the up side, though… here’s a good response to self: Marco’s implementation doesn’t crash, or lose settings (once stored in globals/a CA), etc.
You might want to have a look at Parameter Wires, Reaction Manager, Script Controllers, Expression Controllers, Instancing Controllers, all of these could do what you are looking for. Instanced controllers would be the best solution I would think as it would be fast, stable and two way.
yeah, but instanced controllers don’t let you do all the fun and exciting stuff that you usually want to do.
It’s great if you want two boxes to be the same height, but now get one box to always be half the height of the other.
( yes, that can be done with an instanced controller – cookies for who can say how But I’m thinking that’s only one-way. )
That’s where parameter wiring, expression controllers, and script controllers come in
Straight instanced controllers, no but nested inside a List controller, it could be done.
-Eric
pfff… much easier – multiplier curve!
no cookies for anyone, then!
cedes and makes sure to get PiX cookies next encounter
I’d go with paramWire, it can wire to a controllers parent and so you can swap the x controller with another type of controller. Heck you can wire to a list controller and change all controller is the list controller and still be able to get feedback, instanced controllers don’t allow that!
Wire controller for president (single way that is!) oh and when a wire breaks the animation is still preserved!
-Johan Wired Boekhoven