A loop to make this?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  11 November 2008
A loop to make this?

Please please, could someone help

I'd like to run a loop on $n (any amount) number of polyspheres that will scale them evenly from 0 to 100% in scale. Could anyone point me in the right direction??

Massive thanks in advance
Attached Images
File Type: png Picture 12.png (48.5 KB, 23 views)
  11 November 2008
this doesnt create creat the shpere with a scale of 0 because i didnt see the point in that as you wouldnt see it but if you need it to do that let me know, also the scale is changed using the radius attr instead of scale just because it was quicker to wright

//replace the * with the number of spheres you want to create
int $n = *;
float $f = 1.0 / $n;
float $s = $f;

for ($i=0; $i<=$n; $i++)
	polySphere -r $s;
	$s += $f;

  11 November 2008
Hi jaydru, thanks for your help. sorry Forgot to mention I already have the polyspheres made..

here's what I got ...

string $myselection[] = `ls -sl`;
int $numSelect = size($myselection);

int $t=0;

 for( $t=0 ; $t<$numSelect ; $t++) {
float $sizBall = ($t+1)/$numSelect;
setAttr ($myselection + ".scaleX") $sizBall;
setAttr ($myselection + ".scaleY") $sizBall;
setAttr ($myselection + ".scaleZ") $sizBall;

//print( $t + " " + $b + "\n" );
 print ($sizBall+ "\n" );

This has errors do you know why?


also don't worry about scaling to zero.

Last edited by johnjoe : 11 November 2008 at 02:45 PM.
  11 November 2008
think the main problem is your trying to change the attr on the array $myselection, try this,
string $myselection[] = `ls -sl`;
int $numSelect = size($myselection);

float $sizeIcrament = 1.0/$numSelect;
float $size = $sizeIcrament;

for ($sel in $myselection)
	setAttr ($sel + ".scaleX") $size;
	setAttr ($sel + ".scaleY") $size;
	setAttr ($sel + ".scaleZ") $size;
	$size += $sizeIcrament;

  11 November 2008
Thank you so much. Amazing stuff. Sorry If my knowlege seems a little thin.
I'm so grateful for your help, thank you

  11 November 2008
One last question!?

If I wanted to use this but instead of just scaling the spheres I'd like to use a set driven key..

How would I write the syntax?

thx again

		-currentDriver ($motionPathNode1 + ".uValue")
		-driverValue 0.25
		-attribute ???
		-value ???? ;
  11 November 2008
im not total sure what your trying to do if you can give a bit bit more of an explanation i might be able to help

  11 November 2008
Sure, sorry.

I'd like to have the scale attribute of some polySpheres controlled by a controller object eg a Locator with a value from one going from zero to one. when the control moves from zero to one the polysphere move in a wave action.

see image attached, Thanks for your help

Also when the scale is zero or one the polysphere scale is 0 ie not visible

Basically I need a loop that will set an incremented set driven key value on each polySphere when the controller value is at .25 and the reverse when the value is .75

If I can explain further please say
Attached Images
File Type: jpg explain.jpg (41.2 KB, 14 views)

Last edited by johnjoe : 11 November 2008 at 12:47 PM.
  11 November 2008
sorry about the no reply, been busy at work today,
im not sure if i can help you with this one, my knowledge of mel is quite basic,
is there a reason why you cant set the set driven key up manualy as opposed to doing it through mel?

  11 November 2008
No worries jaydru, You've helped me a lot aready

My reason for not wanting to use Set Driven Keys manually is please I have around 500 groups of ten polyspheres to animate, doing this 5,000 time would do my head in!

Thanks so much for all your help


If anyone else has any ideas please let me know.
  11 November 2008
Hey this is just a basic idea, but maybe it works if you script the setdrivenkey setup with variables one time. You`d have to select all groups and it loops through every single one
and does the setup for you by grabbing and keying each of the 10 spheres in each group.

here`s the mel command for setdriven keys:

// To set the keyframe on the selected object's translateX based on
// curve1's rotateZ:
setDrivenKeyframe -at translateX -cd curve1.rz;

When you put in variables / select the objects with variables in a for loop then
move the objects to the desired positions and setDrivenKeyframe,
it might work out.
  11 November 2008
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 08:59 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.