SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.


SM Forums / Maya Questions / Programming / Using expressions on multiple objects

Programming MEL Scripts, Expressions & Programming Related Topics

Join the conversation. Reply to post
 
Thread Tools
21-10-2008, 08:10 AM   #1
bendingiscool
Subscriber
 
bendingiscool's Avatar
 
Join Date: Jul 2006
Location: London
Posts: 567
Using expressions on multiple objects
Hey guys,
Basically what I am after is a way of running an expression on multiple objects, for instance...

polySphere -name "ball";
expression -s "ball.translateX = time;" -o pSphere1 -ae 1 -uc all ;

will make the ball head in the X direction over time, but how would I be able to select multiple objects and giving each of them this expression, as the expression above is only going to work on the first object.

Many thanks in advance as this is bugging me loads

Chris
  Reply with quote
22-10-2008, 01:46 AM   #2
gster123
Moderator
 
gster123's Avatar
 
Join Date: May 2005
Location: Manchester Uk
Posts: 6,300
Could you not create an array to hold the object names and have it go through that?
__________________
"No pressure, no diamonds" Thomas Carlyle
  Reply with quote
22-10-2008, 05:43 AM   #3
bendingiscool
Subscriber
 
bendingiscool's Avatar
 
Join Date: Jul 2006
Location: London
Posts: 567
Turns out I was just going at it in an overcomplicated fashion, here's the working script...

//give expression to all selected
for($n in `ls -sl`){

expression -s ($n + ".translateX = time;") -o $n -ae 1 -uc all ;

}

Cheers,

Chris
  Reply with quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
using mel to select multiple objects davad138 Programming 2 29-01-2020 03:10 PM
Objects move inconsistently when I move multiple MrSandman Maya Technical Issues 5 20-04-2015 08:13 PM
adjust multiple objects at once cobair Maya Materials & Textures 2 05-10-2012 01:23 PM
Strange Problem - Unable to change attributes for multiple objects anthonysw3 Maya Technical Issues 4 04-12-2010 11:56 PM
Problems with multiple collision objects Uglynakedguy Maya Technical Issues 1 08-05-2008 01:06 AM