Adjust shape size to text with tabulator at the end of the shape

Started by Tom131, March 18, 2015, 10:45:39 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tom131

Dear Visio experts,

I am relatively new to Visio and still reading into the ShapeSheet formulas. I already did a lot of trial and error and created master shapes and templates for the university. I have to improve one of these shapes but the following problem is driving me nuts.

I created a list master with some member shapes. The member shapes do have two ShapeData variables and the width of the shapes should dynamically adjust to the width of the text. The value of the ShapeData should be displayed in the text. So far this isn't a problem at all - I set the Width cell to GUARD(MAX(User.ListWidth,TEXTWIDTH(TheText))) with IFERROR(((LISTSHEETREF()!Width)-2 mm),50 mm).

And here comes the problem: I need to align the first ShapeData (simple text, name of a method) on the left side of the shape and the second ShapeData (decimal value) to the right side. I can do this dynamically by creating a tab stop with align "3" at position WIDTH. But because the shape width has to adjust to the text width this creates some kind of circular formula: The position of the tab stop depends on the width of the shape, the width of the shape depends on the width of the text and the width of the text depends on the position of the tap stop. Because of this the shape is getting wider and wider until visio stops the calculation.

I try to sketch the shape as it should look:

+--------------------------------------+
| name()                                    1.475 |
+--------------------------------------+

I would be very thankfully if you can give me a hint or point me in the right direction.

Thank you!

Cheers,

Tom131

Yacine

I posted some days ago a small tool adressing your problem.
It does not answer the specific positioning problem, but shows how to display different shape data in sub-shapes.
http://visguy.com/vgforum/index.php?topic=6318.0
Yacine

Tom131

Quote from: Yacine on March 18, 2015, 12:06:35 PM
I posted some days ago a small tool adressing your problem.
It does not answer the specific positioning problem, but shows how to display different shape data in sub-shapes.
http://visguy.com/vgforum/index.php?topic=6318.0

Dear Yacine,

Thank you for your post, but the shape data is already displayed. My problem is I cannot dynamically adjust the width of the shapes depending on the width of the text AND align one shapedata on the left and one shapedata on the right of the shape.

Another example:
+-----------------+
| name()    1.475 |
+-----------------+

+-----------------------------------------+
| muchMuchMuchLongerName()    1.475 |
+-----------------------------------------+

But again, thank you for your reply!

Tom


Tom131

Hi all,

After nearly a day of research I finally found a solution for the problem.

I created a group of three shapes:


  • Shape No. 1 for displaying the name ShapeData, Text aligned left, width dynamically adjusted to the length of the input (GUARD(MAX(40 mm,TEXTWIDTH(TheText)))
  • Shape No. 2 for displaying the value ShapeData, Text aligned right, width dynamicall adjusted (GUARD(MAX(10 mm,TEXTWIDTH(TheText))))
  • Shape No. 3 for the ShapeData

I set Shape 3 topmost and transparent, so a DblClick event can fire up the ShapeData prompt. In Shape 1 and 2 I get the ShapeData from Shape 3 for the output.

These three Shapes were grouped together and the width of the group shape is set as follows: MAX(IFERROR((LISTSHEETREF()!Width)-2 mm,50 mm),(Sheet.1!Width+Sheet.2!Width)). I substracted the "2 mm" because of the spacing of the list container.

The width and position of Shape 3 were set to the same as the group Shape - I did not use the group Shape for the ShapeData because I had some difficulties at the beginning. But I can imagine this is possible and a little bit cleaner than my solution with a third Shape.

The last thing to do is the alignment of the Shapes No. 1 and 2. I aligned them based on the group Shape at the leftmost and rightmost. Due to the adjustment of the group Shape to the width of the list smaller testshapes are positioned correctly, too.

That's it.

Have a nice day,

Tom

wapperdude

You might be interested in this topic:  What's with SETATREF anyway http://visguy.com/vgforum/index.php?topic=6383.0.  It covers controlling shape width using shapetext.  Based upon this post, I just added a reply re SETATREFEVAL and SETATREFEXPR to that post which addresses something similar to being done here.

It's a possible alternative.  I don't have V2010 so cannot exactly replicate what you've done as some of your formulas aren't available in earlier versions.

Wapperdude
Visio 2019 Pro

Tom131

Quote from: wapperdude on March 18, 2015, 06:07:48 PM
You might be interested in this topic:  What's with SETATREF anyway http://visguy.com/vgforum/index.php?topic=6383.0.  It covers controlling shape width using shapetext.  Based upon this post, I just added a reply re SETATREFEVAL and SETATREFEXPR to that post which addresses something similar to being done here.

It's a possible alternative.  I don't have V2010 so cannot exactly replicate what you've done as some of your formulas aren't available in earlier versions.

Wapperdude

Hi Wapperdude,

Thank you for your reply - I will look into it!

Cheers,

Tom