Visio Guy

Visio Discussions => General Visio => Topic started by: mti on January 18, 2019, 02:29:51 PM

Title: Keep shape connectors always aligned to grid?
Post by: mti on January 18, 2019, 02:29:51 PM
I want to keep everything aligned to grid, even when I resize shapes. Is there a way to make Visio keep a shape's connectors firmly aligned to the grid, even when resizing the shape? See attached picture.

(As a consequence, Visio would need to add/remove connectors as needed.)
Title: Re: Keep shape connectors always aligned to grid?
Post by: wapperdude on January 18, 2019, 02:56:02 PM
There is no native mechanism within Visio to do that.  Connection points are located on a shape relatively to its width and

Removing points and "re-gridding" them might be done with a macro.  But, there are many issues...is a connection point used, which point to eliminate, minimum spacing, maximum spacing...how to trigger macro, which shapes, etc.  Gets to be quite involved.

Wapperdude
Title: Re: Keep shape connectors always aligned to grid?
Post by: vojo on January 18, 2019, 03:12:02 PM
one incredibly tedious option would be to do following

1:  take your shape and open shapesheet
2:  add connector section
3:  create the worst case number of connectors
4:  for each connector
         Y cell = Height-<a> mm - N*<connector delta>...similar for X cell
         connector 1 might be  Height*1-13mm- 0* 3mm
         connector 2 might be  Height*1-13mm-1*3mm
         connector 3 might be  Height*1-13mm-2*3mm
         etc.
5. User.N = (height*1-13mm)/3mm     // gives you number of connectors that fits when scaling
6. So connector now is
         connector 4 might be Height*1-13mm-if(user.N >4,4,0)*3mm
         connector 5 might be height*1-13mm-if(user.N>5,5,0)*3mm
 

May want to guard these cells so the don't change

Up side:  Connectors are constant spacing
down side: if shape gets too large, run out of connectors. (maybe you do 25 connectors, but usually 10 get used)

This will be tedious to develop...but would do what you want
Title: Re: Keep shape connectors always aligned to grid?
Post by: wapperdude on January 19, 2019, 06:16:34 PM
Reading Vojo's response, a memory neuron was triggered, and I recall doing something quite similar to his suggestion.  So, from 2015 and 2017, here are two files that add / subtract connection points as the size of the shape is changed.  The max number of connection points is hard coded in the shapesheet.  Fundamentally, it's similar to Vojo's approach.  Basically, the max # of connection points is coded into the shapesheet.  Similarly, the shape size is constrained to be fixed increments of pin spacing.
Then, as the shape size is changed, excess connection points collapse to location of 1st connection point.  Some formula work needed for each point.  The 2017 version is simplist implementation and, thus, easiest to understand.

The 2017 version only has connections along one edge.  There are two variants.  The 2nd shape which has some shape text, uses shape data to set the number of points and their spacing.  The number of pins is set via a pulldown list. 

The earlier, 2015 version, allows points to be either on one or two sides.  Either case, the max is 6 pts for the shape.
Title: Re: Keep shape connectors always aligned to grid?
Post by: mti on January 22, 2019, 09:45:17 PM
Thank you all for great responses. Clearly Visio was not designed for this, but it can be done.