Author Topic: Removing spaces between shapes  (Read 9357 times)

0 Members and 1 Guest are viewing this topic.

kellogg

  • Newbie
  • *
  • Posts: 4
Removing spaces between shapes
« on: April 14, 2014, 09:28:08 AM »
How do I select a group of shapes and automatically remove any spaces between them?

I'm creating a drawing of a data datacentre where each row of cabinets is made up of lots of different size cabinets.

I have a stencil with all the different cabinets in, which I pick from to build up each row. Once the row is completed it's very easy to automatically align the cabinets by top or bottom of the first cabinet using the Position / Align Shapes options. But, what I can't find a way of doing is to automatically remove the gaps between the cabinet shapes so that they all butt together.

I have to work my way down the row one cabinet at a time moving it slowly across the page until it meets the previous cabinet!

This in a room with three or four hundred cabinets can be very time consuming.

Does any one have any ideas?

Many thanks.


vojo

  • Hero Member
  • *****
  • Posts: 1577
Re: Removing spaces between shapes
« Reply #1 on: April 14, 2014, 03:59:37 PM »
rack shape takes care of that issue (assuming each of widgets are in Us).

If you want, you could do the following
   - make a line, say height of entire page
   - add connection points periodically on the line....so maybe 50 of them or whatever
   - Set you shapes to have connection points on lower left or right
   - attach to line
   - when all done, delete line

BTW, you can get fancy with this if want (let line scale and add or take away connection points, hide line instead of deleting line, etc)

Assuming you shapes are various sizes, I dont think you can use "distribute" to take care of spacing.

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4045
  • Ideas Visio-lized into solutions
Re: Removing spaces between shapes
« Reply #2 on: April 14, 2014, 05:09:58 PM »
It reads like you're not using a rack shape to hold your shapes.  Is that true?  Do the equipment shapes have uniform (identical) widths?  If both are true, then you ought to be able to use the distribute shapes functionality or you could use the align shapes functionality for each vertical column much as you did for each horizontal row.

As Vojo indicates, a rack shape would have setup the snap spacing to keep each piece of rack gear correctly aligned and placed as you do your initial drag and drop.  Without the predefined rack gear, you could create an array of ruler guides to get the desired vertical and horizontal spacings, and then drag your shapes over.  But, that doesn't help for a large amount of already placed shapes.

I suppose if the shapes are close to where they ought to be, then with some VBA code you search each shape, look at its current position and then move it to the nearest desired position, which ought to be some integer multiple of standard horizontal / vertical spacing parameter.  If the initial placements are close, it could be as simple as rounding or truncating the present location to an integer value.

HTH
Wapperdude
Visio 2019 Pro

kellogg

  • Newbie
  • *
  • Posts: 4
Re: Removing spaces between shapes
« Reply #3 on: April 15, 2014, 05:54:03 AM »
I'm not sure if I was clear about the problem.

I'm not trying to illustrate a cabinet elevation but just a simple overview of the rows of cabinets in the data centre.

The attached picture shows the problem.

I'd like to easily be able to align and distribute the cabinets in the bottom row so that they appear neatly lined up as per the top row and without any gaps between the cabinets. At the moment aligning is easy using the position / align top or bottom options but there doesn't seem to be an easy way to remove the gaps. I have to work my way along the row, moving each cabinet one at a time slowly to the left until it meets the previous cabinet.

Thanks.


vojo

  • Hero Member
  • *****
  • Posts: 1577
Re: Removing spaces between shapes
« Reply #4 on: April 15, 2014, 08:20:45 AM »
dont get caught up in the needles of the pine tree in the forest of pines....focus on the forest

Solution still stands....I do similar for isometric spacing.

horizontal line.....with connection points....evenly spaced or spaced 2x the density needed....attach your cabinets to the connection
points...when done, delete the line (or hide it).

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4045
  • Ideas Visio-lized into solutions
Re: Removing spaces between shapes
« Reply #5 on: April 15, 2014, 11:16:04 AM »
Visio does not have a "butting" alignment functionality.  I guess, it was (is) believed that snapping/gluing to shapes would solve that problem.  Unfortunately, that's not the case when there are many shapes involved.  It looks like your case is further complicated by the fact that the shapes do not have identical sizes...some look narrower than others.  That rules out using the distribute functionality.

That means you will either have to go and touch each shape or you need code that can go thru do look at each shape and its neighbor and apply the appropriate placement correction.

I don't see an easy solution for the already placed shapes.  Vojo's solution is interesting and could help, but still involves touching every shape to add a connection point (if there aren't any already).  Plus, if I understand it correctly, it only helps for vertical row stacking.  (Apologies, Vojo, if I misunderstood.) 

Since the heights look uniform, you could
  a.  align the shapes so that a row has uniform vertical alignment (e.g, all of the tops are aligned).
  b.  group the shapes
  c.  drag the group to stack onto the previous row.

However, within a row, since the shapes are not uniform, you will have to move each shape individually.  I would do this before grouping. 

For future placements, make sure that snapping to geometry is on.  That will take care of the butting issue in the future.

Finally, if all of the shapes could have identical widths, you could
   a. select all shapes, <cntl> A
   b. in the Size and Position window, enter the desired width.  Once you have uniform shapes, deselect all, and
   c. set the 1st and last shape of a row to desired location
   d. select all the shapes for that row and then use distribute function.  The interior row shapes will be evenly distributed between the two end shapes.
   e.  repeat for each row

But, alas, no Easy button.

Wapperdude

« Last Edit: April 15, 2014, 11:21:08 AM by wapperdude »
Visio 2019 Pro

vojo

  • Hero Member
  • *****
  • Posts: 1577
Re: Removing spaces between shapes
« Reply #6 on: April 16, 2014, 09:47:57 AM »
this is what I mean

Yacine

  • Hero Member
  • *****
  • Posts: 2739
Re: Removing spaces between shapes
« Reply #7 on: April 16, 2014, 02:29:44 PM »
Hi Kellogg,
I think that a gap feature should indeed be part of the basic features of Visio.
I wrote a small macro, that I attached.
The difficulty is to realise, that the shapes can be rotated or have centres, that are not in the middle of the shape.
So working with widths, heights, PinX and PinY is not sufficient.
The trick is to use boundingbox, which really gives the boundaries of the shapes.
The rest is only a matter of sorting the shapes, getting the actual gap between two shapes, correcting the position.
The macro uses millimeters. A busy coder would add an option to chose the unit to use.  ;)
Open the attached stencil in your drawing, then drop the gap master on your drawing to run the macro.
HTH,
Y.
Yacine

YossiD

  • Jr. Member
  • **
  • Posts: 72
Re: Removing spaces between shapes
« Reply #8 on: June 27, 2017, 07:00:00 AM »
I have been wanting a function like this for a long time.

Unfortunately, when I try to run the macro I get a Run-time error '-2032464666 (86db0ce6)': message. Any idea what might be causing that?

I found a posting online saying that 203 errors are memory related, so I rebooted and tried again with nothing else running, but the error persisted.

I'm using Visio 2003 on WinXP SP3. Any reason that would be a problem?

Thanks

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4045
  • Ideas Visio-lized into solutions
Re: Removing spaces between shapes
« Reply #9 on: June 27, 2017, 09:25:23 AM »
You might want to look at this post:  http://visguy.com/vgforum/index.php?topic=6730.0

Wapperdude.
Visio 2019 Pro

Yacine

  • Hero Member
  • *****
  • Posts: 2739
Re: Removing spaces between shapes
« Reply #10 on: June 27, 2017, 02:00:50 PM »
Wapperdude's tool is certainly better than mine. So I don't think it's worth debugging mine.
Yacine