Author Topic: Is there a good algorithm for setting minimum width/height of a shape?  (Read 6937 times)

0 Members and 1 Guest are viewing this topic.

iankoe

• Jr. Member
• Posts: 18
Is there a good algorithm for setting minimum width/height of a shape?
« 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?

Visio Guy

• Hero Member
• Posts: 1718
• Smart Graphics for Visual People...n' Stuff
Re: Is there a good algorithm for setting minimum width/height of a shape?
« Reply #1 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:

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

Kind of depends on what you want to do...
« Last Edit: November 07, 2008, 02:15:03 PM by Visio Guy »
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

• Global Moderator
• Hero Member
• Posts: 2954
Re: Is there a good algorithm for setting minimum width/height of a shape?
« Reply #2 on: November 07, 2008, 11:36:46 AM »
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.

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

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

iankoe

• Jr. Member
• Posts: 18
Re: Is there a good algorithm for setting minimum width/height of a shape?
« Reply #3 on: November 07, 2008, 04:32:31 PM »
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.

Paul Herber

• Global Moderator
• Hero Member
• Posts: 2954
Re: Is there a good algorithm for setting minimum width/height of a shape?
« Reply #4 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?

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

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

wapperdude

• Global Moderator
• Hero Member
• Posts: 3833
• Ideas Visio-lized into solutions
Re: Is there a good algorithm for setting minimum width/height of a shape?
« Reply #5 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
Visio 2019 Pro

iankoe

• Jr. Member
• Posts: 18
Re: Is there a good algorithm for setting minimum width/height of a shape?
« Reply #6 on: November 08, 2008, 07:04:09 AM »
You know, you are right    I guess in all the myriad things I tried, I must have missed the simplest thing of all.