4

I want to align an object to the top of a shape with an angled side. like so:Desired result

Let's say this is my starting position of the object I want to move:

starting point

If I select both and do 'vertical align top'. It's obviously going to align the object with the highest point of the shape it can find. like so: Vertical align top

Is there a way for the object to align with the top side of the shape? It can't be a manual solution as I'm trying to figure this out for a script I'm writing.

Thank you.

3
  • I can think of a couple of semi-automatic ways to do this involving snapping to point and Smart Guides. Would those work for you? If so I can add an answer.
    – Billy Kerr
    Commented Jul 9, 2021 at 13:26
  • @BillyKerr I think he'll need the coordinates of slope.
    – Vikas
    Commented Jul 9, 2021 at 15:06
  • Don't think this can be automated, at least not easily. You'd need to detect the pixel at the top where overlap stops.
    – Scott
    Commented Jul 9, 2021 at 21:21

1 Answer 1

1
  1. Make sure View > Smart Guides is enabled.
  2. Using the Line Segment tool \, move your mouse over the top-left corner of the square until the word anchor appears, then click and drag up to the angled top side of the other shape, hold Shift to make the line straight, and let go when you see intersect appear. Now you have a line whose length is the exact distance that you need to move the blue square.
  3. Check the length of the line in the Transform panel and make a note of it or copy it to clipboard.
  4. Switch to Selection tool V and select the blue square, then press Enter to open the Move dialog. Paste the value you copied/noted but add a hyphen to make it negative (to move up instead of down), then press OK.

Now the top left corner of the square is perfectly aligned with the angled top edge of the other shape.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.