PDA

View Full Version : Rotation based on one object

 newguy4life03-11-2011, 07:33 PMHello everybody, I am very new to scripting, and I'm sure this has been covered before but I had a hard time knowing what to search for to find my answer, so I apologize if this is redundant. I am trying to basically have a bunch of objects in a string rotate by a fraction of what the object before it does. So if I have objects A B and C, and I rotate A 100, B would be 90, C would be 81 etc. I have it working where I hit the button, and it positions them correctly, but I can't figure out how link them via an expression or something so that I can move object A and the other objects would move in relation to that without hitting the button. Here is my current script: // rotates the object 90% of object below string \$feathers[] = `ls -sl`; int \$i = 0; for (\$i=1; \$i
fatsumo
11-13-2011, 06:57 AM
cubeB.rotateY = cubeA.rotateY*0.9;
cubeC.rotateY = cubeA.rotateY*0.8;

//in the expression editor

mrcain
11-14-2011, 03:27 AM
You can also do this in Python.

create a bunch of cubes, select all of them apart from pCube1 and run this....

import maya.cmds as mc
driven = mc.ls(sl=True)
ct = 1

for i in range(0,len(driven),1):
multi = mc.createNode('multiplyDivide')
StoreMulti = mc.ls('multiply*')
mc.connectAttr ("pCube1" + '.ry',(StoreMulti[i])+'.input1X')
ct = ct - 0.1
sum = ct
print sum
mc.setAttr((StoreMulti[i])+'.input2X', sum)
mc.connectAttr((StoreMulti[i])+'.outputX',(driven[i]) + '.ry')

CGTalk Moderation
11-14-2011, 03:27 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.