Keeping relative positioning (sequence) of two shapes and a connector

Started by visiouser50, September 14, 2017, 11:13:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

visiouser50

Is there a way to keep a shape to the left or right of another shape?  I am creating a pert chart on a timeline.  I would like to have two shapes connected by a side-to-side connector.  When the left shape moves to the left, the right one does not move.  When the left one moves to the right, the right one does not move until the left one starts to overlap it, then the right one is pushed to the right.  Also, when the right shape moves to the right, then the left one does not move.  When the right shape moves to the left, then the left one does not move until right one starts to overlap it, then the left one is pushed to left.  This way the sequence is preserved.   If the connection is broken, then I should be able to put both shapes in parallel on the timeline.  Can this be accomplished with the shapesheet or do I need to program VBA for this function?

Yacine

I had a try with your problem.
My first idea was to use pure shapesheet functions, where the shape moves it relative shapes by means of SETF/GetRef.
The result is not good because once the dragged shape moves others, they trigger the same formulas and the initial shape jumps partially back.
Which is logical, but unwanted.

2nd idea, I call a macro by means of CALLTHIS whenever the shape is moved (EventXFMod).
In there, I first check if the calling shape is selected and if only one shape is selected. This way the other shapes, which trigger the macro as well once moved, don't get handled directly by the macro.
The macro then traverses the whole branch of successors and predecessors and moves them so as to leave a gap (xMin).

Note, I was too lazy to fill in automatically the values in the predecessor and successor fields. I filled them manually. (The shapes show in the right top corner their IDs. Use them to write the values in semi-colon separated lists.
You may use the technique used in this post [ http://visguy.com/vgforum/index.php?topic=7994.0 ] to automate the job.

Download the vsd and move the shapes around to see the connected shapes move.

HTH,
Y.
Yacine

visiouser50

Thanks, Yacine.  That solution did exactly what I asked.  I think time-based pert charts would be a great stencil to add to Visio, especially if it linked to MS project.  Thanks for your help.