how can i do that input to output connection

how can i do that input to output connection

jarniksetucom
New Member New Member
71 Views
1 Reply
Message 1 of 2

how can i do that input to output connection

jarniksetucom
New Member
New Member

In Maya, I want to make an eyebrow blendshape with attributes on two different transform nodes. If I change the attribute on one node, the other should update automatically, and vice versa. But I don’t want the attributes to be locked or show a normal one-way connection. How can I set this up?

jarniksetucom_0-1757075419452.png

 

0 Likes
72 Views
1 Reply
Reply (1)
Message 2 of 2

Kahylan
Advisor
Advisor

Hi!

 

This is what we call a proxy attribute. This can only be done through code as far as I know. You set up your attribute on one control as you normally would. On the other control you set it up through code. By using the addAttr command and the pxy flag with the attribute you want it to be linked to as a string. Here is an example:

#import the maya commands library so you can use the maya commands
import maya.cmds as mc

#setting some variable names for easy exchange
parentObjectName = 'example_cube'
proxyObjectName = 'example_sphere'
nameOfTheAttribute = 'example_attribute'
#creating a cube and a sphere, setting up the base attribute on the cube. This can be done in editor as well
parentObject = mc.polyCube(n= parentObjectName)[0]
proxyObject = mc.polySphere(n = proxyObjectName)[0]

mc.addAttr(parentObject, ln = nameOfTheAttribute, k =1)

#setting up the proxy attribute on the sphere, this can not be done in the editor

mc.addAttr(proxyObject, ln = nameOfTheAttribute, pxy = parentObject + '.' + nameOfTheAttribute)

#for coding beginners variables can be a bit confusing, so here is what maya is actually seeing in the last line
#the name of the object that gets the attribute, followed by the longname of the attribute, followed by the full path of the attribute it proxies
        
mc.addAttr('example_sphere', ln = 'example_attribute', pxy = 'example_cube.example_attribute')

Please note that the last line is simply for demonstration, you don't need that in your script. If you already have created all your objects in maya and have also created all the attributes on one object, you could simply add all of them by running the script below in a python tab and switching out the nameOfTheAttribute attr:

#import the maya commands library so you can use the maya commands
import maya.cmds as mc

#setting some variable names for easy exchange, type in the name of the object that already has the attribute as parentObject, and the one that needs the proxy attribute as proxyObject
parentObject = 'example_cube'
proxyObject = 'example_sphere'
nameOfTheAttribute = 'example_attribute_1'


mc.addAttr(proxyObject, ln = nameOfTheAttribute, pxy = parentObject + '.' + nameOfTheAttribute)

But that would be quite tedious, since you have to change attriubte names over and over and then run the script. we would rather provide all the attributes at once and then run the script once. And you can do that with a list and a loop, like this:

#import the maya commands library so you can use the maya commands
import maya.cmds as mc

#setting some variable names for easy exchange, type in the name of the object that already has the attribute as parentObject, and the one that needs the proxy attribute as proxyObject
#provide all the attributes existing on the parentObject that you would like to add on the proxyObject in a list like shown below
parentObject = 'example_cube'
proxyObject = 'example_sphere'
nameOfTheAttributeList = ['crunch','inner','mid','outer','lashes_down']

    
for nameOfTheAttribute in nameOfTheAttributeList:
    mc.addAttr(proxyObject, ln = nameOfTheAttribute, pxy = parentObject + '.' + nameOfTheAttribute)

 

If you have any further questions, don't hesitate to ask. And if this solved your problem, please mark my answer as accepted Solution, so others can easily find it in the future 😉

I hope it helps!

0 Likes