Position Expression to place a layer on edge of solid

l = thisComp.layer("bar") //the control layer
startX = l.transform.position[0]; //the position of the control layer
s = l.transform.scale[0]/100; //the scale divided by 100 to get a decimal

//This checks the index of the layer and uses it to flip the sign
halfWidth = l.width/2;
if(index%2!=0){
halfWidth *= -1;
}

posX = startX + (-halfWidth*s); // the original pos + half the width * the scale

[posX, value[1]]; // setting the value


Learn More :