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 » Development, ShapeSheet

Smart LineWeight: Bigger Shape, Thicker Lines

Submitted by Visio Guy on March 29, 2008 – 9:00 am | | 4935 views 10 Comments

Smart LineWeight: Bigger Shape, Thicker LinesRecently we were introduced to the Cisco IP Telephone Shapes, and learned how they could be improved in the article: Making Shapes More Efficient: Using Fewer Shapes & Groups.

Today we’re going to focus on what happens when the Cisco shapes get resized, and discuss a technique for making the lineweight proportional to the size of the shape.

Resize Behavior

In Making Shapes More Efficient: Using Fewer Shapes & Groups, we hinted that there was work to be done when resizing the Cisco shapes.

When we resized the original shapes, we noticed a few oddities:

Cisco IP Telephone Shapes - Before Modifications

Nothing Earth-shaking, but if you look close, you’ll notice two things: the LineWeight for the shapes doesn’t get any thicker, and the headphones pull a weird squishy maneuver.

Smart LineWeight

It would be nice if we could get the LineWeight of the shape to change when the size of the shape changes. We can do this by using the ShapeSheet to link a sub-shape’s LineWeight to the size of the group.

Now, there is no “size” property for a shape, but there are Width and Height. And since these shapes should maintain aspect ratio, it doesn’t really matter if we choose the Height or the Width as the key for indicating size change–in most cases they should both be increasing by the same factor.

Using the ShapeSheet, we can construct a smart formula that compares the original height of the shape to the current height of the shape.

This ratio then serves as a multiplier for the LineWeight of each sub-shape. If you’ve read: Text Resizing with ShapeSheet Formulas then you might recognize this technique!

So let’s break it all down. The math looks like this:

LW_new = LW_old x GH_new/GH_old

(Edit: thanks to Ted for a correction here…)

where:

LW = LineWeight of a sub-shape

GH = Group’s Height

The ShapeSheet formula looks like this:

LineWeight = (Sheet.5!Height/0.75)*0.0167

where:

Sheet.5 = group’s ID

0.76 = group’s original height

0.0167 = original LineWeight

The end-result looks like this:

Cisco IP Phone Buttons - After Modifications

You can see that the LineWeight is now nicely tied to the size of the shape! (And the squishy headphone problem is also fixed. More on that later…)

Of course, I didn’t open the ShapeSheet for every single sub-shape on the page. I wrote some VBA automation code to get it done more quickly. Below, we have the code, which can also be used, with very little modification, in VB.NET.

The code operates on all shapes that are selected in the active window. So make a few duplicates, select them, and run the code on the guinea-pig shapes first!

Sub SetLineWeights()
 
    '// Links the LineWeights of sub-shapes to the
    '// size of the group.
    Dim shpGrp As Visio.Shape
    Dim shpSub As Visio.Shape

    Dim h As Double
    Dim lw As Double
    Dim fs As Double
 
    '// Operate on all shapes that are currently selected:
    For Each shpGrp In ActiveWindow.Selection
 
        '// Get the current size of the group:
        h = shpGrp.Cells("Height").ResultIU
 
         For Each shpSub In shpGrp.Shapes

            '// Get the current LineWeight of the sub-shape:
            lw = shpSub.Cells("LineWeight").ResultIU
 
            '// Set the LineWeight formula for the sub-shape
            '// by multiplying the current LineWeight by a ratio 
            '// of original-group-height / current-group-height:
            shpSub.Cells("LineWeight").Formula = "(" & shpGrp.NameID & "!Height/" & h & ")*" & lw
 
        Next shpSub
 
    Next shpGrp
 
End Sub

A few things might not be clear to folks who are new to SmartShape creation. I’ll try to address them here:

  • To see the ShapeSheet of a sub-shape, you need to sub-select the shape, then choose Window > Show ShapeSheet. To sub-select a shape, you first select the group, wait a split second, then click again on one of the sub-shapes. The sub-shape will be highlighted with light-green handles.
  • Alternatively, you can open the group window via Edit > Open Group or Edit > Open ShapeName. Inside the group window, you can select shapes as you normally do, and view their ShapeSheets via Window > Show ShapeSheet.
  • To get the ID for the group, just select the group and choose Format > Special. At the top of the dialog, you’ll see the ID field. When you want to refer to cells in the group from sub-shapes, you use the syntax: Sheet.ID!Property. Examples would look like this: Sheet.5!Width, Sheet.168!Angle, Sheet.99!Prop.Cost, and so on.
  • Visio 2007 users might not see the Format menu. If this is the case, you need to turn on Developer Mode by visiting the Tools > Options > Advanced tab.
  • If you’re wondering about the ShapeSheet, and how to run VBA code in Visio, have a look at the following articles: John Goldsmith: Just For Starters, Run VBA Code When Documents Open and VBA Macro Security

Squishy Headphone Problem

While we were focusing on the resize behavior of the Cisco shapes, we also fixed the problem with the squishy headphone arc. The source of the problem is that the arc from which the headphones were drawn was still a 1D shape.

1D shapes are defined by their endpoints, as opposed to a Width, Height, and Pin location, like normal 2D shapes (ie: boxes.) When 1D shapes are grouped, their endpoints resize proportional to the group, but the height of the sub-shape isn’t affected.

You can read more about the problems (and solutions) of 1D shapes in groups here: Understanding Arc-Resize Problems in Visio

Related Posts

  1. Making Shapes More Efficient: Using Fewer Shapes & Groups
  2. Understanding Arc-Resize Problems in Visio
  3. Title Block #3: Smart Tabs, Smart Text
  4. Top 9 Reasons for Turning-on Developer Mode
  5. Smart Chamfer – A Corner That Doesn’t Stretch

10 Comments »

  • [...] Smart LineWeight: Bigger Shape, Thicker Lines [...]

  • Ted says:

    A couple of things:
    – I think the equation is wrong…..should be LW_new = LW_old *(GH_new/GH_old).
    Current approach would give you the inverse of what you want (bigger shape==>thinner lines)
    – Wouldnt it be far easier to do this in the shapesheet alone
    – user.linescaler = Shapeheight / shapeheight defined at creation
    (at creation is when first done…..aka user.linescaler = shapeheight/2.9831mm
    – Lineweight = creation_wt*user.linescaler
    (aka lineweight = 5pt * user.linescaler)

    This is similar to how text can be autoscaled

    Also, even with your approach, either aspect ratio must be held or some sorted combination of
    shapeheight and shapewidth folded into user.linescaler. (aka make a user.linescalerx and user.linescalery
    and user.linescaler = (user.linescalerx+user.linescalery)/2 kind of thing)

  • Visio Guy says:

    Hi Ted,

    Thanks for the correction.

    These shapes are likely to have their aspect-ratios maintained, so keying the LineWeight off of the height is just fine.

    But for shapes that could be resized in either dimension, you are right, the width needs to be taken into account.

    Not sure what you mean by “far easier in the ShapeSheet”. This technique is 100% ShapeSheet, but without the numerical reduction that you’ve suggested. The VBA code simply sets the smarts automatically in all the sub-shapes, so that you don’t have to do it by hand!

    And you’re right, a top-level “scale-factor” could be implemented, with a reduction of the fixed numbers. But for instructional purposes, I’ve left some of the simplifications out. I also didn’t want to add user-cells to the shapes, because that unnecessarily complicates the code for this simple example.

    Cheers,

    - Chris

  • Ted says:

    thanks…just did not catch the shapesheet cell view…probably me…apologies

  • Visio Guy says:

    Sorry Ted, didn’t mean to bite! :)

  • YossiD says:

    Terrific.

    It looks like you intended to include character scaling as well (assuming the fs variable is font size). Can you provide the code to do that?

  • Paul says:

    Wondering about the VB sub code… In a lot of cases I have shapes that are nested more then two deep in most cases in complex shapes I have at least 4 levels of shapes. Your Sub routine only accounts for one or does it?

    I’ve written similar code that uses recursion. My question is would recursion be needed here if my shapes are more than one level deep, or does Visio handle this differently than I expect?

    Thanks

  • Visio Guy says:

    Hi Paul,

    Yeah, you’d have to write some recursive code. It’s not too hard as every Visio shape has a shapes collection, so you can get at sub-shapes via shp.Shapes.

    There’s a bit of an inconsistency between code and the UI. If, for example you select a group in a drawing window and apply a fill color, that color will apply all the way down to the deepest sub-shape.

    If you do the same in code, you only set the group’s FillForegnd cell. Often, the group has no geometry at all, so you won’t see anything. The sub-shapes remain untouched. This can sometimes work in your favor, but other times force you to write recursive routines :)

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.