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

Explorer ,
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

93

Likes

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

Adobe Community Professional , 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

Translate

Translate
Adobe Community Professional ,
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

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
Adobe Community Professional ,
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

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

Copy link to clipboard

Copied

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

Likes

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
Adobe Community Professional ,
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

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
Explorer ,
Apr 29, 2022 Apr 29, 2022

Copy link to clipboard

Copied

LATEST

Yes Rick, Dan solution working fine here as well.

Thanks for your time.

Likes

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