Author Topic: Align Shape - Top to Bottom or Left to Right  (Read 840 times)

0 Members and 1 Guest are viewing this topic.

caveman

  • Newbie
  • *
  • Posts: 2
Align Shape - Top to Bottom or Left to Right
« on: August 20, 2019, 02:25:00 AM »
Hi, I've been looking for a quick way to align shapes top to bottom and not found an easy way other than painstaking zoom and drag.

I've stumbled onto a (I think) an easier way. Last post about this I found was a few years back so thought I'd start a new thread.

Using the size and position X & Y coordinates.
For example
    E
A  B
    D
If Box A (central you want to alight next to):
X = 72.5mm
Y = 210mm
Width = 45mm
Height = 20mm

Align left of box B to right of box A:
72.5mm (x) + 45mm (width) x = 117.5mm

Align right of box C to left of box A:
72.5mm (x) -45mm (width) x = 27.5mm

Align top of box D to bottom of box A:
210 (y) -20mm (height) y = 190mm

Align bottom of box E to top of box A:
210 )y) + 20mm (height) y = 230mm
 
Hopefully this makes sense to someone.

Yacine

  • Hero Member
  • *****
  • Posts: 2698
Re: Align Shape - Top to Bottom or Left to Right
« Reply #1 on: August 20, 2019, 03:22:53 AM »
Hi caveman,
I don't really understand the problem.

If there are only 5 shapes like in your example, best would be to use proper snapping settings.
If there are a lot of shapes, where automation begins to make sense, then you would need to define more restrictions (same heigth and width? , how to define the central shape, ....)
Yacine

caveman

  • Newbie
  • *
  • Posts: 2
Re: Align Shape - Top to Bottom or Left to Right
« Reply #2 on: August 20, 2019, 04:37:01 AM »
Yacine,

I only used the example of 5 shapes to show how it can be done from each side.

Problem is how to align two shapes off centre of each other i.e. left hand of one shape with the right hand of another.

Please let me know an easier way if you know it.

Cheers

Yacine

  • Hero Member
  • *****
  • Posts: 2698
Re: Align Shape - Top to Bottom or Left to Right
« Reply #3 on: August 20, 2019, 07:13:44 AM »
There are different ways to do that.

1) Edit manually the shapesheet
You would define a master. Say "A"
Then you write the dependencies in the slave shapes.
Pseudoformula : B.pinX = A.PinX - A.LocPinX + A.Width + B.LocPinX
Formula: =GUARD(Sheet.1!PinX-Sheet.1!LocPinX+Sheet.1!Width+LocPinX)

2) Use a macro
check the tools from Wapperdude and myself.
http://visguy.com/vgforum/index.php?topic=5534.0

3) Use a generic tool
http://visguy.com/vgforum/index.php?topic=6914.15

4) There's a positioning feature in the GUI
which allows you to distribute the gap evenly through a selection. You can use it trying to minimize the gap.
« Last Edit: August 20, 2019, 07:20:27 AM by Yacine »
Yacine

vojo

  • Hero Member
  • *****
  • Posts: 1475
Re: Align Shape - Top to Bottom or Left to Right
« Reply #4 on: August 20, 2019, 07:33:30 AM »
Unless you are planning on a 1000 shapes or looking to do this 100 times a day, option 4 is the easiest/quickest way to do this (can even add buttons to the menu to make it a 8 click exercise)
1 select B A D
2 align top
3 distribute horizontally (gap or otherwise)
4 group
5 C group E
6 align middle
7 distribute vertically (gap or otherwise)
8 group or ungroup then group all

Croc

  • Full Member
  • ***
  • Posts: 244
    • Visioport
Re: Align Shape - Top to Bottom or Left to Right
« Reply #5 on: August 20, 2019, 08:31:16 AM »
In simple cases, guides can help.

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3794
  • Ideas Visio-lized into solutions
Re: Align Shape - Top to Bottom or Left to Right
« Reply #6 on: August 20, 2019, 09:14:08 AM »
Note:  my alignment tool has been updated to include more universal shape application.  It uses a User Form which needs to be in place for the alignment macros to work.  http://visguy.com/vgforum/index.php?topic=8870.0.  It would do exactly what you want...you could do the following:

1) select shape A, then a 2nd shape, e.g., B, select direction, e.g., left to right.  Shapes A & B are butted up to each other.
2) continue same process with remaining shape.

Note:  you could use my Visio file as basis for a template, not have copy all the coding.
« Last Edit: August 20, 2019, 09:30:00 AM by wapperdude »
Visio 2019 Pro

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1712
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Align Shape - Top to Bottom or Left to Right
« Reply #7 on: August 21, 2019, 10:55:24 AM »
Or better yet:
  • Copy the code to the stencil
  • Save the stencil to My Shapes
  • Whenever you need the functionality, open My Shapes/VBA Code Stencil or whatever you named it

This way, you don't need code in every document - just open "tool stencils" as needed to get access to automation.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1712
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Align Shape - Top to Bottom or Left to Right
« Reply #8 on: August 21, 2019, 11:36:42 AM »
FYI: I've just added the code-containing stencil to wapperdude's original post. Get it here:

http://visguy.com/vgforum/index.php?topic=8870.msg38972#msg38972
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010