BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

[SOLVED] Trouble with relative position of line shape's label

Started by VMey, October 01, 2014, 09:30:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.



This is my first time posting on any Visio forum so I apologize for not using the proper terminology.

I'm using a stencil developed by someone else and I am trying to resolve an annoying issue.  I've attached supporting files that should be descriptive enough that you don't need to read EVERYTHING below, but I've been detailed just in case.

The stencil is for data flow diagrams and the shape in question is a data flow shape, an arc-shaped line with an arrow and a descriptive label.  The arc is comprised of two end points and two control handles.  One control handle adjusts the arc shape (Control1), and the other control handle adjusts the label position independently (Control2).  (Control1 and Control2 are arbitrarily assigned for this post only, not official variables)

Upon initial placement and population of the label, any action upon the line results in the label and the line moving relative to each other, and this is how we want it to be.  Adjusting Control1 results in the label mirroring the position of that control handle, the same relative distance and position.  Increasing the height of the arc increases the height of the label, for example.  Similarly, adjusting the endpoints either by angle or by width results in the label moving relatively

However, this label can get decoupled and forever cease to move relatively anymore.  This happens by changing Control2, that is repositioning the label independently.  Once this occurs, it no longer moves relatively with Control1.  It DOES still move with the endpoints though.  So if I've lifted the label an inch above the arc, and then rotate using the endpoints, the label also rotates, maintaining horizontal orientation, but staying the same distance from the line.  But if I change the Control1 position, say change it from arcing upward to a steep downward arc, the label will remain where it was last dragged, and can never be recoupled again.  You just have to keep repositioning the label as you make adjustments, or delete the shape and drag from the stencil again.

I have attached sample files to demonstrate this, a .vss file and a .vsd file.

The cause identified, but solution unknown
Looking at the ShapeSheet, I have identified technically what has gone wrong, but I do not know how to fix it, as this is the first time I've attempted such an adjustment (I'm used to Excel Visual Basic, this is a whole different paradigm!)

When originally placed, the Controls section of the ShapeSheet contains two items, Controls.Row_1 and Controls.Row_1, which correspond to Line Arc Position, or Control1, and Label Position, or Control2.  By default, Controls.Row_2 column X and Y are populated with formulas, "Controls.Row_1" (aka align the centers), and "Controls.Row_1.Y+0.1875" (aka position the label 3/16ths of an inch above the line).  So when Control1 is moved up and down, these fields don't change, and that's why it works.

But when Control2 is moved, the formula-driven values go away and are replaced with actual, descriptive values, such as X=Width*.95 and Y=.5313 in, so there's no longer that relative, formula-based attachment to Control1.  The reason it stays relative with the endpoints is, I THINK, due to the Text Transform section, TxtPinX/Y and TxtLocPinX/Y, which both have formulas in them (Controls.Row_2, Controls.Row_2.Y, TxtWidth*0.5, and TxtHeight*0.5).

So!  What do I do to keep from decoupling Control2 from my Control1 movements when I want to make positional adjustments?

The attached VSD shows each stage, with 1a-1c demonstrating movement without changing the position of Control2, and 2a-2d demonstrating movement WITH changing position of Control2.

Thanks for any help.


Thorough is good!

The problem is that when the 2nd control point is moved, it clobbers any reference to the 1st control point.  To solve this, you need to use the setatref function.  See this post, and look at my solution:

I believe you need to do the similar steps.

Visio 2019 Pro


Ooops!  You're using inches.  OK.  Here are the specific changes, since there are already two rows in the User-defined cells.

Add two new rows, and set their initial values as:
User.Row_3 = 0
User.Row_4 = 0.15

Then in the Controls Section, Controls.Row_2 line:
X Value =SETATREF(User.Row_3,SETATREFEVAL(SETATREFEXPR(Width*0.425)-Controls.Row_1))+Controls.Row_1

Y Value =SETATREF(User.Row_4,SETATREFEVAL(SETATREFEXPR(0.25 in)-Controls.Row_1.Y))+Controls.Row_1.Y

That should do it.

Visio 2019 Pro



Thanks so much for your help.  I was able to apply this to a number of shapes in our stencil set, and I've passed on the changes to our Visio SME.  Everything appears to work wonderfully.

Later on I'll have to dig into those function names and see if I can understand exactly what's going on :)

All the best,



Just a warning about setatref:  it is not easy to understand, and less easy to use.

Visio 2019 Pro


I can confirm Wapperdude's statement. Everytime I need a setatrefexpr, I need to ask him for help.  :o ;D


Doesn't exactly make things all crystal clear, but for others who find their way to this question, here's the Microsoft article on the SETATREF Function.



That's a major part of the problem, setatref is not intuitively obvious, and the documentation is pretty sparse.

There was a site that had some helpful setatref examples and explanations: › Visio Insights.  I don't think it's actively supported any more since V2010 & V2013 came out.  The articles are still there, but the pictures (at least for me) have disappeared.  That's unfortunate, because you need the pictures to understand the articles.  But here's the references:

Unfortunately, those were two of the best articles dealing with setatref.

Visio 2019 Pro

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 303 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1140KB.
Tokens: post-login.
Cache hits: 14: 0.00140s for 26,767 bytes (show)
Cache misses: 3: (show)
Queries used: 15.

[Show Queries]