Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: iankoe on November 07, 2008, 07:17:09 AM

Title: Is there a good algorithm for setting minimum width/height of a shape?
Post by: iankoe on November 07, 2008, 07:17:09 AM
Is there a good way to set the minimum width / height of a shape using shapesheet functions?  If you just GUARD() the cells, then the user will quickly move the shape into never never land if they try to size it down.

If you also GUARD the PinX/Y, it works until you hit the minimum, then the shape wont move at all.

Is there something obvious I am missing?
Title: Re: Is there a good algorithm for setting minimum width/height of a shape?
Post by: Visio Guy on November 07, 2008, 09:57:34 AM
Hi iankoe,

In which way do you want to restrict the shape? I've used numerous methods:


Kind of depends on what you want to do...
Title: Re: Is there a good algorithm for setting minimum width/height of a shape?
Post by: Paul Herber on November 07, 2008, 11:36:46 AM
to add to The Man's answer
set the width cell to something like:
Code
=BOUND(20mm,0,FALSE,4mm,25mm)
will limit the shape to between 4mm and 25mm, make the maximum whatever you like. The 20mm part is the current size and will be the bit that varies as you resize the shape.

Title: Re: Is there a good algorithm for setting minimum width/height of a shape?
Post by: iankoe on November 07, 2008, 04:32:31 PM
to add to The Man's answer
set the width cell to something like:
Code
=BOUND(20mm,0,FALSE,4mm,25mm)
will limit the shape to between 4mm and 25mm, make the maximum whatever you like. The 20mm part is the current size and will be the bit that varies as you resize the shape.

Thanks.  This is exactly where I started, but this is too simple an answer.  Lets say What I want is a minimum Height of 1/8 inch (sorry to reset the units).  I put the following into the height cell:

Code
=GUARD(BOUND(1 in, 0, FALSE, 0.125 in, 4 in))


But if thats all I do, if the user tries to size below the minimum, the shape moves rapidly off the page, never to be found (without the drawing explorer).

This behavior can be stemmed by code like this:
Code
IF(Height<=0.125in,SETF(GetRef(PinY),User.PrevY)+SETF(GetRef(Height),0.125),SETF(GetRef(User.PrevY),PinY))+DEPENDSON(Height)
but while this does stop the shape from moving off the page, it also stops all movement when the minimum size has been reached, which is no good either.

Any ideas woudl be appreciated.

So the idea I am looking for is code that restricts the minimum height of my shape to 1/8 inch without stopping its movement around the page.

Thanks.
Title: Re: Is there a good algorithm for setting minimum width/height of a shape?
Post by: Paul Herber on November 07, 2008, 04:52:25 PM
You shouldn't need the Guard() around the formula, that will stop the Bound() from working properly anyway. Which shape are you working with? Does it have the Aspect Ratio locked? Are there other formulae depending upon the height cell?

Title: Re: Is there a good algorithm for setting minimum width/height of a shape?
Post by: wapperdude on November 07, 2008, 07:43:04 PM
I've seen weird behavior when control points are used to set the height and width.  Formulas, in the geometry section, are based on the positioning of the control x, y values, but, these are related back to the height and width.  As a result, when a control point tries to collapse the width to less than zero, the shape "walks", trying to maintain a width value of not less than 0.  As Al indicates, there may be additional formulae setting width and height behavior, but these could also be in the geometry and control sections, or buried in code somewhere.  A simple rectangle, with the bound formula listed, sans the guard fcn, is nicely behaved.

HTH
Wapperdude
Title: Re: Is there a good algorithm for setting minimum width/height of a shape?
Post by: iankoe on November 08, 2008, 07:04:09 AM
You know, you are right  :P  I guess in all the myriad things I tried, I must have missed the simplest thing of all.

My bad.

Thanks.