Visio Guy

Visio Discussions => Shapes & Templates => Topic started by: caveman on August 20, 2019, 07:25:00 AM

Title: Align Shape - Top to Bottom or Left to Right
Post by: caveman on August 20, 2019, 07: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.
Title: Re: Align Shape - Top to Bottom or Left to Right
Post by: Yacine on August 20, 2019, 08: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, ....)
Title: Re: Align Shape - Top to Bottom or Left to Right
Post by: caveman on August 20, 2019, 09: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
Title: Re: Align Shape - Top to Bottom or Left to Right
Post by: Yacine on August 20, 2019, 12:13:44 PM
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 (http://visguy.com/vgforum/index.php?topic=5534.0)

3) Use a generic tool
http://visguy.com/vgforum/index.php?topic=6914.15 (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.
Title: Re: Align Shape - Top to Bottom or Left to Right
Post by: vojo on August 20, 2019, 12:33:30 PM
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
Title: Re: Align Shape - Top to Bottom or Left to Right
Post by: Croc on August 20, 2019, 01:31:16 PM
In simple cases, guides can help.
Title: Re: Align Shape - Top to Bottom or Left to Right
Post by: wapperdude on August 20, 2019, 02:14:08 PM
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 (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.
Title: Re: Align Shape - Top to Bottom or Left to Right
Post by: Visio Guy on August 21, 2019, 03:55:24 PM
Or better yet:

This way, you don't need code in every document - just open "tool stencils" as needed to get access to automation.
Title: Re: Align Shape - Top to Bottom or Left to Right
Post by: Visio Guy on August 21, 2019, 04:36:42 PM
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