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 =
...
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
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)
Copy link to clipboard
Copied
It is working fine Dan, thanks for quick reply.Your awesome.
Copy link to clipboard
Copied
Hi dan,
May i know the speciality of this below number while calculating tangents?
t = r*0.5525;
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).
Copy link to clipboard
Copied
Ok dan,
Thanks for the quick reply.
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.
Copy link to clipboard
Copied
Yes Rick, Dan solution working fine here as well.
Thanks for your time.