Skip to main content
qndo1999
Participant
June 16, 2026
Answered

"expression result must be of dimension 2, not 1" when adding clamp expression

  • June 16, 2026
  • 1 reply
  • 22 views

Hi,

I’m trying to build a shape layer that adapts to the longest length between two text layers, but is limited to 850 pixels in size. Everything functions as it should until I add the clamp expression. The error “expression result must be of dimension 2, not 1” pops up on the first line. How can I fix it, or is there a better way to approach adding a limit to the size of the shape?

 

const line1 = thisComp.layer("First & Last Name, PhD"); // reference top line text layer 
const line2 = thisComp.layer("Title or Position"); // reference bottom line text layer
const boxWidth = Math.max(line1.sourceRectAtTime().width, line2.sourceRectAtTime().width) + 220; // compares the length of both text layers and returns the larger of the two including padding and leading
const boxHeight = line1.sourceRectAtTime().height + line2.sourceRectAtTime().height + 120; // height of box including padding

[boxWidth, boxHeight];

clamp(boxWidth, 0, 850);

Thanks in advance!

Correct answer Dan Ebberts

Try replacing the last 2 lines with this:

[Math.min(boxWidth,850), boxHeight];

 

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
June 17, 2026

Try replacing the last 2 lines with this:

[Math.min(boxWidth,850), boxHeight];

 

qndo1999
qndo1999Author
Participant
June 18, 2026

This works like a charm. Thanks! :)