## Adobe Support Community

• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
• Create a manual path object using size and roundne...

# Create a manual path object using size and roundness of a shapelayer rectangle

Participant ,
Apr 28, 2022 Apr 28, 2022

Copy link to clipboard

Copied

Hi there,

How to create realTime Path Object from size and roundness of rectangle?
How Path object looks like, what all elements are inside?
Is there any documentation regarding this path object data?

Please refer attachment for more details.

TOPICS
Expressions

Views

139

Likes

Report

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

## 1 Correct answer

Community Expert , Apr 28, 2022 Apr 28, 2022

Try this (I did it in a hurry, so there may still be bugs and it's probably not as efficient as it could be):

``````s = thisComp.layer("Shape Layer 1").content("Rectangle 1").content("Rectangle Path 1").size;
r = thisComp.layer("Shape Layer 1").content("Rectangle 1").content("Rectangle Path 1").roundness;

w = s[0]/2;
h = s[1]/2;
maxR = Math.min(w,h);
r = Math.min(maxR,r);
t = r*0.5525;

if (r == 0){ // 4 points
p = [[-w,-h],[w,-h],[w,h],[-w,h]];
iT = [];
oT = [];
}else if (r >= maxR){
if (w =``````
...

Likes

8 Replies 8
LEGEND ,
Apr 28, 2022 Apr 28, 2022

Copy link to clipboard

Copied

You cannot access the parametric entities' internal path and that is that. You have to fully reconstruct it using your own math, which is easy enough.

Mylenium

Likes

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 Expert ,
Apr 28, 2022 Apr 28, 2022

Copy link to clipboard

Copied

Try this (I did it in a hurry, so there may still be bugs and it's probably not as efficient as it could be):

``````s = thisComp.layer("Shape Layer 1").content("Rectangle 1").content("Rectangle Path 1").size;
r = thisComp.layer("Shape Layer 1").content("Rectangle 1").content("Rectangle Path 1").roundness;

w = s[0]/2;
h = s[1]/2;
maxR = Math.min(w,h);
r = Math.min(maxR,r);
t = r*0.5525;

if (r == 0){ // 4 points
p = [[-w,-h],[w,-h],[w,h],[-w,h]];
iT = [];
oT = [];
}else if (r >= maxR){
if (w == h){ // 4 points
p = [[0,-h],[w,0],[0,h],[-w,0]];
iT = [[-t,0],[0,-t],[t,0],[0,t]];
oT = [[t,0],[0,t],[-t,0],[0,-t]];
}else{ // 6 points
if (w > h){
p = [[-w+r,-h],[w-r,-h],[w,0],[w-r,h],[-w+r,h],[-w,0]];
iT = [[-t,0],[-t,0],[0,-t],[t,0],[t,0],[0,t]];
oT = [[t,0],[t,0],[0,t],[-t,0],[-t,0],[0,-t]];
}else{
p = [[-w,-h+r],[0,-h],[w,-h+r],[w,h-r],[0,h],[-w,h-r]];
iT = [[0,t],[-t,0],[0,-t],[0,-t],[t,0],[0,t]];
oT = [[0,-t],[t,0],[0,t],[0,t],[-t,0],[0,-t]];
}
}
}else{ // 8 points
p = [[-w,-h+r],[-w+r,-h],[w-r,-h],[w,-h+r],[w,h-r],[w-r,h],[-w+r,h],[-w,h-r]];
iT = [[0,t],[-t,0],[-t,0],[0,-t],[0,-t],[t,0],[t,0],[0,t]];
oT = [[0,-t],[t,0],[t,0],[0,t],[0,t],[-t,0],[-t,0],[0,-t]];
}
createPath(p,iT,oT,true)``````

Likes

Report

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

Copy link to clipboard

Copied

It is working fine Dan, thanks for quick reply.Your awesome.

Likes

Report

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

Copy link to clipboard

Copied

Hi dan,

May i know the speciality of  this below number while calculating tangents?

`t = r*0.5525;`

Likes

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 Expert ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

I think it should actually be closer to 0.5523 and it represents the ratio of the length of the tangent handle to the radius of the circle for the best bezier circle approximation. I think the actual formula is (4/3)*(Math.SQRT2 - 1).

Likes

Report

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

Copy link to clipboard

Copied

LATEST

Ok dan,

Thanks for the quick reply.

Likes

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 Expert ,
Apr 28, 2022 Apr 28, 2022

Copy link to clipboard

Copied

If you want to duplicate any shape on another shape layer, you can select the object (Rectangle 1) in the existing shape layer and choose Edit/Copy with Property Links from the menu (Alt/Option + Ctrl/Cmnd + c). Then create a new, empty shape layer and paste. The new layer will contain a new Rectangle 1 that matches the original Rectangle 1. You could also copy the entire shape layer with property links or Copy with Relative Property Links if you needed the new layer in a nested comp (pre-comp).

Copy with property links works with parametric shapes (Rectangle, Ellipse, Polygon, etc.) and paths drawn with the pen tool. With a bit of fiddling, you can also link a mask directly to a shape layer using the same expression for the path.

Try Dan's expression if you want to create a vector path from a parametric shape. It seems to be responsive and works for me. I have only tried it with a couple of rectangles and it works just fine. Adding it to more rectangles in the same comp may slow things down. You'll have to check.

Likes

Report

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

Copy link to clipboard

Copied

Yes Rick, Dan solution working fine here as well.

Thanks for your time.

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources
Troubleshooting FAQs
After Effects Community Recap
Getting started with After Effects