Pin X dependent of Controls in a Microsoft Visio shape

Started by stygge, April 21, 2021, 08:18:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

stygge

I have created a Visio shape with two control handles for internal connectors. Now I want the shape to place itself mid between the two control handles. In other words I want Pin X of the shape to change when I move one of the control handles. But when I move the shape itself the control handles should follow. I have tried to figure out how the different GetRef and SetatRef functions could work in this case but I need help.

Surrogate


stygge


wapperdude

Not at my computer, but the technique to use involves the SetAtRef fcns.  Basically, the process uses dummy variables for both x- & y- locations of each control.  The uniqueness involves subtracting the shape's actual location from the variable before storing it.  That makes it relative to the shape.  Then, this variable is used by the control plus the current location added back in.  While not your specific example, but, as I recall, this technique was used here: 
http://visguy.com/vgforum/index.php?topic=494.msg2126#msg2126.  See last post entered.

For SetAtRef explanation / examples, see this:
http://visguy.com/vgforum/index.php?topic=6383.msg26308#msg26308
Visio 2019 Pro

vojo

pinx = guard((control1.x + control2.x)/2)

as controls move the pinx X is adjusted.
I am not sure you are really going to want this behavior, but here it is for you.


wapperdude

Had a chance to follow thru on example reference I suggested.  It wasn't what I recalled.  Sorry.
Visio 2019 Pro

wapperdude

#6
After some consideration and a few trials, I realized that the outlined approach was unnecessarily complicated and it doesn't work.  Neither suggested approaches work.  The problem requires isolating the control positions from the shape center repositioning.  Within a single shape, that's not possible.  In a grouped shape...doable...but has an unpleasant artifact... the group alignment box gets weird.

A solution is presented, that uses a straight line, with connection points on each end for gluing.  This avoids control points altogether.  A rectangle is added to form a group.  ( Well, actually, the line is 1st converted to a group, and then rectangle added.)  It is centered upon the middle of the line, that is, the half width.  As the line is shortened or lengthened, the box remains centered.  Problem solved.

However, grouping introduces it's own issues.  1st the line runs thru the box. This could be solved by moving the line behind the box, but. that would also move the text behind the box and would be obscured.  Solution, leave the line in front, but make it invisible and add two line segments to the group to complete the shape. 

The 2nd housekeeping includes setting the box size.  It must not change with he line length (aka, the group).  It should adjust to always encompass the text.  The 3rd issue is to make sure the line length is never shorter than the box width.  The box is added to provide framing for the text.  No other purpose for it.

What this approach doesn't do is allow only straight line extending from each side of he box.

Hope this helps.

Visio 2019 Pro

wapperdude

Updated file.  Page 2 has more "traditional" approaching using control points.  It is easy to get the shape shifted either left or right off center of the group.  Under extreme offset, one of the controls may be quasi-disfunctional.  The control points allow vertical freedom of movement of the end points.
Visio 2019 Pro

stygge

Quote from: wapperdude on April 25, 2021, 02:25:23 AM
Updated file.  Page 2 has more "traditional" approaching using control points.  It is easy to get the shape shifted either left or right off center of the group.  Under extreme offset, one of the controls may be quasi-disfunctional.  The control points allow vertical freedom of movement of the end points.

Thanks for your input! It gave me some new ideas to make it more simple. I found a ready made connector which I converted into a group and then added the square to the group. See attachment.

Quote from: vojo on April 21, 2021, 05:34:16 PM
pinx = guard((control1.x + control2.x)/2)
as controls move the pinx X is adjusted.
I am not sure you are really going to want this behavior, but here it is for you.

Thanks for your try but unfortunately the Pinx and Controls have different coordinate systems.

vojo


wapperdude

#10
I'm not sure everyone is on same page...
@Vojo:  do you have sample shape to share?

@All:  PinX and PinY refer to page coordinate system.  Controls refer to position relative to shape position, i.e., shape coordinate position.  Hence, as shape moves, so do controls.  Text position is relative to the shape also. 

1-D shapes, lines and connectors, have text, but no frame around it.  If frame is desired, then a 2nd shape must be added, the combination of the 1-D plus "frame" creates a group, and that in turn, creates a new coordinate system.  The 1-D and the "text frame" get their position relative to the group.  Alternatively, it is possible, to transform any shape into a group, e.g., the 1-D shape.  Thus, the group and 1-D shape would have identical, singular coordinate system.  The frame shape would must still be added to the group.  For some situations, the transformation of a shape to a group simplifies the overall structure.

Couple curious things...
1)  LOCTOPAR shapesheet fcn allows transformation from one coordinate system to another.  Related to this are the "point" functions:  PNT, PNTX, and PNTY

2)  It is possible to "slave" one shape to another without grouping.  This could involve one or more of the following fcns:  LOCTOPAR, GUARD, SETATREF family, POINTALONGPATH family, BOUND, SETF & GETREF, and others.

Hopefully, this makes sense and helps to expand the possibilities within Visio.
Visio 2019 Pro