Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: RhesusMinus on October 21, 2010, 04:06:44 PM

Title: Control shape width with a list of valid widths
Post by: RhesusMinus on October 21, 2010, 04:06:44 PM
Hi.

Is it possible to enter a formla in the shape sheet that controls the valid width of a shape?
If I have a rectangle, I only want the users to be able to change the width of the shape to 20, 40 and 60 mm.

THL
Title: Re: Control shape width with a list of valid widths
Post by: wapperdude on October 21, 2010, 07:36:35 PM
There are a variety of ways to do this...here's one which uses Shape Data.

Right click your shape to add Data > shape data.  In the menu fill in label & name with something meaningful, e.g. Wth.  For TYPE, select "fixed list".  In the format box, enter your values, separated by ";".  At the bottom, check "Ask on drop".

Next, open the shapesheet and in the Width cell enter the formula: Guard(prop.Wth)
That should do it.


Another way would be to use the shape's right click, context menu.  You can do this by adding the "Actions" section to the shapesheet.  This is a little more involved, but provides the user with slightly more direct access to the values.

HTH
Wapperdude
Title: Re: Control shape width with a list of valid widths
Post by: RhesusMinus on October 21, 2010, 09:38:01 PM
Thanks for replying Wapperdude.

Just to be difficult... I want the user th use the handles on the shape to resize it. Much more intuiive for the users. Is t still possible to pre-define valid widths/heights?

THL
Title: Re: Control shape width with a list of valid widths
Post by: wapperdude on October 22, 2010, 01:38:25 AM
Not a problem!  :D

Use the "bound" function.  Check out this link:  http://msdn.microsoft.com/en-us/library/ms406650(v=office.12).aspx.  Actually, the 2nd example does exactly what you want!!!   :o

Wapperdude
Title: Re: Control shape width with a list of valid widths
Post by: RhesusMinus on October 22, 2010, 07:18:46 AM
Thank you!
That's ALMOST perfect :)

Now, just to be even more difficult... I want the users to be able to choose between the widths EITHER by dragging the handle, og by changing the Shape Data property (a fixed list :)).
So.. if one drag the handles, the Shape Data should update, and if one changes in the Shape Data, the shape should update :)

Possible?

THL
Title: Re: Control shape width with a list of valid widths
Post by: Jumpy on October 22, 2010, 07:43:28 AM
Then you need some user defined cells filled with SETF-functions. For example:

User.PushShapeData: =SETF(GetRef(Widht),Prop.Width)+DEPENDSON(Prop.Width)

Whenever u change the ShapeData, the Value gets pushed to the Width.
The Dependson is popably not neccessary, but for the sake of understanding.

From that on I would create SETF functions, that monitor the width and push the value to the nearest possible ShapeDate Values.
The change in the ShapeData Value will then trigger a new shape of the width...

Don't know if this will work, because you will have circular references that may lead to undisired loops. But Visio is often clever enough to break those loops... Try it out.
Title: Re: Control shape width with a list of valid widths
Post by: Yacine on October 26, 2010, 06:04:21 AM
http://blogs.msdn.com/b/visio/archive/2006/09/29/777101.aspx
Title: Re: Control shape width with a list of valid widths
Post by: RhesusMinus on October 27, 2010, 07:44:04 AM
Thank you, you've been most helpful!

Everything worked perfectly, just till now.
I need the shape to behave like a 1-dimensional shape. Suddenly my formulas wont work when i stretch the 1D handles... :(


Anyone that can give me a clue?

I'm really starting to enjoy Visio now :)

THL
Title: Re: Control shape width with a list of valid widths
Post by: Yacine on October 27, 2010, 02:05:41 PM
When you switch your shape from 2 to 1 D you will notice that the first section changes.
The width is not anymore a defining property, but a result of a formula depeding on the start and the end points.
You definitely need to adjust your formulas.