Development

Tips & code for programming Visio & using the ShapeSheet

Maps & Geography

Maps & geography shapes & templates galore!

Network

Shapes & tools for Visio network diagrams.

News

Find out what’s new in the Visio world!

Shapes

Download useful & attractive Visio shapes. For free!

where can i buy windows 7 cheapest buy windows 7 upgrade from xp windows vista purchase price buy inventor 2010 pctools spyware doctor 5.5 buy windows 7 best price norton ghost 12 product key windows 7 price future shop windows xp price singapore windows 2008 web server download omnipage coupon buy windows 7 starter download adobe indesign cs3 for mac buy vista to windows 7 microsoft project 2003 download buy windows xp operating system windows 7 home premium cheap mathcad pricing photoshop buy mac discount autocad 2009 purchase microsoft money 2007 deluxe download photoshop mac autodesk maya 2009 price windows vista business download windows 7 price 64 bit purchase windows 7 ultimate full version buy windows 7 home premium key lightroom for apple purchase windows xp india adobe cs4 photoshop buy where to buy encarta 2009 purchase vista oem buy windows 7 tesco cheap adobe fireworks windows 7 price online best price corel draw 11 mac discount powerpoint buy microsoft office for mac canada buy microsoft project 2002 adobe production premium mac turbotax 2009 deluxe best price windows 7 ultimate 64 bit best price buy windows 7 amazon adobe flash pricing adobe dreamweaver sale purchase windows 7 ultimate buy quickbooks pro 2007 roxio copy & convert 3 buy download photoshop elements 6 steinberg nuendo price uniblue registrybooster 2009 download cheap photoshop programs adobe photoshop elements cheapest buy windows 7 future shop adobe presenter 7 download microsoft office 2003 sale buy quarkxpress 8 for mac purchase adobe cs3 design premium purchase after effects cs3 paperport professional 12 prices cakewalk download parallels desktop price buy microsoft windows 7 home premium cheap adobe after effects for mac how to purchase windows 7 online download microsoft streets and trips 2008 microsoft office 2003 cheapest buy windows 7 online singapore purchase autodesk 3ds max 2009 buy windows xp pro best price adobe flash cs3 buy uniblue registrybooster 2009 cheap windows 7 ultimate retail buy autodesk autocad buy microsoft office document imaging purchase microsoft office 2003 buy windows xp media centre edition discount microsoft windows 7 ultimate windows 7 price upgrade cheap adobe photoshop software burnaware professional price buy acronis true image 2010 windows 7 price change buy acrobat 7 where to buy adobe flash cs3 quicken 2010 price buy windows xp corporate buy office 2007 student product key windows 7 price hong kong buy windows 7 64 buy acrobat professional 9 symantec winfax pro 10.4 buy cheap windows 7 keys adobe photoshop cs4 buy buy microsoft visio 2007 turbotax deluxe 2009 download windows xp price in rupees buy lightroom software buy windows 7 buy windows 7 serial key steinberg nuendo 3 download download autodesk 3ds max 9 buy ms project online windows 7 price egypt windows 2008 enterprise download parallels mac download adobe lightroom sale cheap cubase 5 where to buy windows xp service pack 2 purchase windows vista download cheap windows 7 in singapore lowest price microsoft office purchase windows 7 license key where can i buy windows 7 starter edition buy i.r.i.s. readiris pro 11 cheap windows xp operating system buy office 2003 key where to buy windows xp cheap autocad mechanical 2009 download buy matlab software buy 3ds max 2010 student download dragon naturally speaking autocad inventor download get autocad 2010 buy adobe illustrator cs2 buy windows 7 mac windows xp price canada steinberg cubase sx3 download cheap windows 2003 enterprise download adobe illustrator cs3 can i buy windows xp online windows xp price in malaysia buy adobe cs4 suite best price adobe illustrator cs3 download font folio 11 acdsee pro license key cs3 production premium mac ms streets and trips 2008 download download adobe illustrator mac windows 7 price in india where can i buy cubase sx3 windows vista download iso roxio creator 2010 coupon code microsoft office price student windows 7 home premium 64 bit oem buy microsoft frontpage software buy windows xp 64 pro cheap windows 7 home premium full version buy burnaware professional cheap microsoft works 9 microsoft visio download adobe cs4 web premium oem download disk director cheap adobe creative suite cs4 microsoft money home and business download buy parallels desktop 5 for mac cheapest norton 360 3.0 lightroom price buy windows vista pro microsoft money buy online buy microsoft expression blend 3 buy windows 7 full version for students purchase lightroom 2 buy microsoft office ultimate pdf converter professional 6 promotional code buy adobe cs3 design premium buy indesign cs3 software buy windows vista ultimate upgrade acdsee photo editor download microsoft office 2003 professional cheap windows 7 for college students illustrator cs3 download download adobe indesign cs4 cyberlink powerdirector prices buy windows vista ultimate license buy access 2003 online windows 7 price guide mathcad price buy after effects cs4 mac cheap fl studio 8 xxl cheap photoshop elements 8 buy windows vista home premium oem buy wordperfect x3 buy windows 7 home premium 64 bit buy windows 7 brisbane buy windows 7 bangkok autodesk mudbox price purchase vista license cheap adobe premiere elements 8 download adobe creative suite 4 design premium best price microsoft excel 2003 buy microsoft project 2000 microsoft expression price discount photoshop elements 8 cheap maya software 3ds max sale buy windows 7 ebay windows 7 price 2010 deskshare videoeditmagic 4.3 price buy windows xp 2010 norton 360 price comparison buy windows xp used adobe contribute mac purchase windows 7 for mac buy windows vista home premium product key buy windows 2003 datacenter buy windows 7 professional cheap microsoft windows 7 ultimate buy sony vegas pro 8 purchase access 2007 final cut express 4 cost download microsoft visio 2007 buy onenote 2003 photoshop lightroom for mac symantec pcanywhere download windows 7 price pakistan buy premiere pro cs3 cheap windows 7 for students in australia web page maker 3 download buy windows xp home sp3 adobe photoshop best buy cheap windows 2008 enterprise buy windows 7 direct download download microsoft mappoint 2009 buy windows xp home download microsoft autoroute 2007 europe ashampoo burning studio download buy windows xp calgary archicad 13 download adobe cs4 design premium trial price photoshop elements 8 windows 7 home premium cheapest autodesk lustre pricing purchase archicad 13 acdsee pro 2 download windows 7 discount canada vmware workstation 7 download discount autodesk 3ds max 2009 buy autodesk inventor professional buy windows xp home full version buy windows 7 language pack buy microsoft office 07 buy microsoft excel 2007 download propellerhead reason 4 mappoint 2009 european buy access 2007 only buy frontpage 2003 purchase windows 7 ultimate online purchase microsoft windows vista buy dragon naturally speaking 10 oil price vista gadget pinnacle studio 14 best price cheap corel video studio pro x2 buy photoshop 7 for mac buy adobe cs3 design premium mac download ashampoo burning studio 9 cheap microsoft project 2007 dvd ripper platinum 5 buy adobe premiere pro cs4 download best price microsoft windows vista windows 7 discount for high school students purchase windows 7 professional (64 bit) compare price photoshop buy windows 7 philippines buy microsoft office powerpoint 2007 purchase windows xp sp3 buy photoshop elements 8 mcafee total protection 2009 download best buy autocad 2009 buy windows vista singapore purchase windows 7 now buy windows xp mumbai buy windows 7 ultimate 64 bit oem windows 7 price kenya ms works download adobe acrobat 9 oem buy windows 7 downloadable adobe cs4 web premium trial cheap windows 7 professional best price windows 7 home premium oem download adobe photoshop elements 6 navisworks manage price windows 7 price comparison buy guitar pro 5.2 download acronis true image 11 buy nero 8 ultra edition acdsee price download adobe robohelp 8 buy powerdirector 7 ultra imsi turbofloorplan home and landscape pro 12 buy buy microsoft expression studio 2 windows 7 discount for military buy windows 7 30 download pinnacle studio 12 ultimate adobe acrobat price comparison mappoint 2009 europe buy cheap avanquest mylogomaker professional 2 buy windows xp cheap microsoft office discount code buy windows 7 switzerland buy windows xp volume license buy norton 360 download cheap adobe photoshop cs3 download microsoft expression studio 3 buy office 2010 professional fl studio 8 xxl download buy microsoft office 2007 home and student cheap adobe cs4 design premium abbyy finereader 9.0 express edition where to buy streets and trips 2010 office 2007 price student buy roxio creator 2010 cheap adobe cs4 master collection mac buy windows xp ebay cheap indesign software buy corel photoimpact x3 download avanquest mylogomaker professional 2 cheap ashampoo burning studio 8 adobe captivate pricing autocad architecture oem buy microsoft office pro 2007 where can i buy powerpoint 2003 turbo tax cost buy windows 7 india online purchase windows 7 license online buy adobe flash cs4 buy windows vista ultimate product key buy cs4 mac buy adobe indesign cs4 best buy microsoft windows 7 ultimate cheap adobe dreamweaver cs4 mac cheap windows 7 canada roxio creator 2009 special edition microsoft office 2010 price in india windows 7 price canadian buy windows xp embedded download corel draw 12 adobe creative suite 4 production premium download buy adobe photoshop cs3 extended buy windows vista business 64 bit buy ms office 2003 pro best buy quicken 2010 buy microsoft office for mac cheap buy adobe after effects cs4 cheap norton 360 3.0 best price adobe cs4 master collection windows 7 price for teachers buy windows xp student purchase adobe acrobat 8 professional buy sql server guitar pro 5 mac download
Home » ShapeSheet

Constraining Angle with the BOUND ShapeSheet Function

Submitted by Visio Guy on December 14, 2006 – 10:35 am | | 5527 views One Comment

Read Full ArticleCori who writes the blog Elliptical… wrote this nice little piece on constraining a shape’s angle so that it can only be rotated in 90-degree increments. I thought I’d relay the information to you here, and explain a bit more about the BOUND ShapeSheet function.

Although you can use the keyboard shortcuts Ctrl+R and Ctrl+L to rotate shapes in 90-degree increments clockwise and counterclockwise, this does nothing to actually constrain the allowable values.

Enter the BOUND ShapeSheet function

Compass SouthThe shape at right is a compass dial shape that can only point to north, south, east or west. When you grab the shape’s green, lollipop rotation handle, it will snap nicely to one of these directions. The BOUND function makes this possible.

Even if a user tries to foil the constraint by typing an odd value into the Size & Position’s Angle field, the shape will still be rotated to the nearest 90-degree increment.

The magic is located in the shape’s Angle cell, located in the Shape Transform section of this shape’s ShapeSheet.

When you look at the Angle cell, you might be shocked. This is what you’ll see:

Angle = BOUND(0 deg, 0, 0, 0 deg, 0 deg, 0, 90 deg, 90 deg, 0, 180 deg, 180 deg, 0, 270 deg, 270 deg)

Anybody still there? It’s not so formidable if you break it down. Let’s add some line breaks to make it more digestible:

BOUND(0 deg,0,
0, 0 deg, 0 deg,
0, 90 deg, 90 deg,
0, 180 deg, 180 deg,
0, 270 deg, 270 deg)

You can see right away that there are four triplets of information that correspond to our four allowable angles: 0 deg, 90 deg, 180 deg and 270 deg. So the west-constraining triplet would be:

0, 180 deg, 180 deg

The second two arguments could be described as the from-value and the to-value. Since we are constraining to specific points, these values are the same for each compass direction. In this example, we have from 180 deg and to 180 deg, which means: west.

The 0 that you see at the beginning of each triplet is an ignore parameter. If you set this to 1, then the constraint will be turned off. You could put various IF conditions or true/false flags in each individual ignore parameter to make a seriously whacky shape! Or you could reference all of the ignore flags to, say a User.debug cell, which would allow you to turn off the constraints to perhaps make development of the shape easier.

You’ll notice that the BOUND function doesn’t get deleted when you rotate the shape, and that GUARD is not used to accomplish this. BOUND is part of a new class of functions, first introduced in Visio 2003 that allow better coexistence between parameter-input and user-interaction. When you rotate the shape, the angle to which you rotate will be stored in the very first argument. So if I rotate the shape to -75.9 deg, the function will display as follows:

BOUND(-75.9 deg., …

The rest of the function will then work with that value to decide which constraint to use. So the user-interface generated angle is written inside of the function, without blasting the entire formula away! This is a a really cool concept that enables a lot of new possibilities for your shapes. The tyranny of GUARD is over!

We’ve almost forgotten the second argument, just after the value place-holder. This argument specifies the constraint type. The type can be one of three values: 0 = inclusive, 1 = exclusive, 2 = disabled. In our compass example, we have used 0, for inclusive constraints. Exclusive means “places where the value can’t go”, which adds interesting possibilites, and Disabled allows you to turn off the whole BOUND function. This could also be cool for debugging a shape.

Smart Text

If you’re interested in how the N, S, E, W shows in the text, have a look at the User-defined Cells section in the ShapeSheet. There, you’ll see two cells:

User.directions = “E;N;W;S”

User.direction = INDEX(INT(ANG360(Angle)/90 deg),User.directions)

The first cell is just a list of text to display. The second figures out which of those elements to use. By dividing the 360-degree-normalized angle by 90 degrees, the INT-ing it, we get a value of 0, 1, 2 or 3. This value is used to index one of the elements in the directions list.

The User.direction cell is then linked to the shape’s text using the Insert > Field dialog. Some gyrations were also performed in the Text Transform section to keep the text right-side-up as the shape rotates. Notably:

TxtAngle = -Angle

This causes the text to anti-rotate relative to the shape. A more complete formula is TxtAngle = IF(BITXOR(FlipX, FlipY), 1, -1)*Angle. This calculate the proper anti-angle even when the shape flips. But we could write many articles on text behavior, and probably will, so I’ll leave that for another time.

Hopefully you’ll find the BOUND function as fun and interesting as I have. Here’s the Visio file for download:

Download: BoundsCompassShape.zip (24 KB)

More Info

We talked about how BOUND doesn’t get overwritten by user-interface actions. Here’s some links to the MSDN Visio 2003 SDK Documentation for ShapeSheet functions that support this “don’t overwrite me” behavior:

Related Posts

  1. User-defined ShapeSheet Functions in Visio 2007
  2. Text Resizing with ShapeSheet Formulas
  3. Casting Units in Visio’s ShapeSheet
  4. Center-sizing Smart Shapes
  5. Angle Shapes Help You Illustrate Geometry in Visio

One Comment »

  • Yacine says:

    Hi Chris,
    grossartiger Artikel, ich habe aber trotzdem eine Frage :)
    How would you bind a control point to a set of points.
    To explain myself:
    The control point shall only snap to certain points of a sub-shape and
    I certainly can bind the x values and the y values to sets of values. But how do I define that this particuliar y value corresponds to this other x value?
    Trials with loc(pnt()) did not work.
    Any idea?

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.