PDA

View Full Version : random scale selection/beginner question


edtheknife
12-08-2006, 01:45 PM
Hi,

this is, I am sure, a real simple question --- if you speak mel better than I do.
Lets say I have 5 cubes. I select them and want to run a script which scales each cubus to 1 1 1 or to 0.5 0.5 0.5 or to 0.75 0.75 0.75.
It is easy for me to scale them ALL at once to one of the three values :

float $test = rand (1);

if ( $test < 0.333) {
scale -r 0.5 0.5 0.5 ;};

if ( $test > 0.666) {
scale -r 0.75 0.75 0.75 ;};

print $test;

So my problem is more to make the script go through the selection step by step.
Any suggestions ?

mhovland
12-08-2006, 03:37 PM
Try this. Select all the cubes, and run this:


{
string $selected[] = `ls -sl -fl`;
for($currentObject in $selected)
{
float $test = rand (1);

if ( $test < 0.333)
{
scale -r 0.5 0.5 0.5 $currentObject;
}

if ( $test > 0.666)
{
scale -r 0.75 0.75 0.75 $currentObject ;
}
}
}

edtheknife
12-08-2006, 04:38 PM
thank you!

works beautyful !
whats the trick ?
To flatten the selection (-fl)?
And I do not really understand the term ($currentObject in $selected).
Do ytou use tis with the ls -sl -fl term ?
But do not worry to answer, Ill figure it out somehow someday, thanks anyway :)

PS: sorry for my bad mel

CGTalk Moderation
12-08-2006, 04:38 PM
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.