• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

distribute layers on a ring

Guest
Oct 21, 2009 Oct 21, 2009

Copy link to clipboard

Copied

hi

i've got an illustrator 2d ring file(1000*1000).i'd like to distibute a whole bunch of layers on this ring.

important is now that all layers have the same distance(degrees) to each other.i tried it manually but it is not really efficient.

orientation is also an issue, layers should point in ring's direction.

can anybody help me out with this expression plz?

thx

TOPICS
Expressions

Views

1.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 21, 2009 Oct 21, 2009

That last position expression doesn't work quite right if the layers are parented to the ring. This should be better:

offset = -50;
n = thisComp.numLayers - 2;
angle = index*Math.PI*2/n;

if (hasParent){
  center =[parent.width/2,parent.height/2,0];
  radius = parent.width/2 + offset;
center + [radius*Math.cos(angle),radius*Math.sin(angle),-height/2]
}else{
  ringLayer = thisComp.layer("ring");
  center = ringLayer.transform.position;
  radius = ringLayer.width/2 + offset;
  center + [radius*Math.cos(angle),

...

Votes

Translate

Translate
Community Expert ,
Oct 21, 2009 Oct 21, 2009

Copy link to clipboard

Copied

Assuming that your ring layer is at the bottom of your layer stack and is the only other layer in the comp besides the layers to be distributed (I'm also assuming it is named "ring"), you can distribute your layers with a position expression like this:

ringLayer = thisComp.layer("ring");
offset = -50;
radius = ringLayer.width/2 + offset;

center = ringLayer.transform.position;
n = thisComp.numLayers - 1;
angle = index*Math.PI*2/n;
center + radius*[Math.cos(angle),Math.sin(angle)]

Adjust the "offset" parameter (or connect it to a slider) to adjust the distance from each layer to the center of the ring.

A rotation expression like this should handle orienting each layer toward the center of the ring:

n = thisComp.numLayers - 1;
offset = 180;

index*360/n + offset;

Adjust the "offset" parameter as necessary (or connect to an angle control) to get the layers to point exactly where you want them to.

Dan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2009 Oct 21, 2009

Copy link to clipboard

Copied

It occured to me that you might want to parent the layers to the ring. If so, you'd need to change the position expression to something like this (which will handle both the parented and unparented cases):

if (hasParent){
  center =[parent.width,parent.height]/2;
  radius = parent.width/2;
}else{
  ringLayer = thisComp.layer("ring");
  center = ringLayer.transform.position;
  radius = ringLayer.width/2;
}

offset = -50;
radius += offset
n = thisComp.numLayers - 1;
angle = index*Math.PI*2/n;
center + radius*[Math.cos(angle),Math.sin(angle)]

Dan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 21, 2009 Oct 21, 2009

Copy link to clipboard

Copied

thank u very much dan for your help.

I forgot to mention that i'm working in 3d.The ring layer is like a floor and all distributed layers shall stand on this ring.

A camera will then fly to each layer on the ring.

your expression works perfectly for 2d but with 3d it gets tricky.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2009 Oct 21, 2009

Copy link to clipboard

Copied

For 3D, the position expression would look like this (now assuming there is a camera in the layer stack below the layers to be distributed):

if (hasParent){
  center =[parent.width/2,parent.height/2,0];
  radius = parent.width/2;
}else{
  ringLayer = thisComp.layer("ring");
  center = ringLayer.transform.position;
  radius = ringLayer.width/2;
}

offset = -50;
radius += offset
n = thisComp.numLayers - 2;
angle = index*Math.PI*2/n;
center + [radius*Math.cos(angle),-height/2,radius*Math.sin(angle)]

And y rotation like this:

n = thisComp.numLayers - 2;
offset = 90;

offset - index*360/n;

Dan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2009 Oct 21, 2009

Copy link to clipboard

Copied

That last position expression doesn't work quite right if the layers are parented to the ring. This should be better:

offset = -50;
n = thisComp.numLayers - 2;
angle = index*Math.PI*2/n;

if (hasParent){
  center =[parent.width/2,parent.height/2,0];
  radius = parent.width/2 + offset;
center + [radius*Math.cos(angle),radius*Math.sin(angle),-height/2]
}else{
  ringLayer = thisComp.layer("ring");
  center = ringLayer.transform.position;
  radius = ringLayer.width/2 + offset;
  center + [radius*Math.cos(angle),-height/2,radius*Math.sin(angle)]
}

Dan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 21, 2009 Oct 21, 2009

Copy link to clipboard

Copied

thx thx thx thx

it works like a charm,perfect

one question to this syntax dan:

n = thisComp.numLayers - 2;

you use -2 because you want to exclude the cam+ring layer from the pos expression,right?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2009 Oct 21, 2009

Copy link to clipboard

Copied

LATEST

Yes, that's correct.

Dan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines