Is there a good algorithm for setting minimum width/height of a shape?

Started by iankoe, November 07, 2008, 12:17:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

iankoe

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?

Visio Guy

Hi iankoe,

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


  • GUARD()
  • BOUNDS()
  • SETATREF()
  • SETF()

Kind of depends on what you want to do...
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Paul Herber

to add to The Man's answer
set the width cell to something like:

=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.

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

iankoe

Quote from: Paul Herber on November 07, 2008, 04:36:46 PM
to add to The Man's answer
set the width cell to something like:

=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:


=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:

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.

Paul Herber

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?

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

wapperdude

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
Visio 2019 Pro

iankoe

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.