• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

bVisual

  • Home
  • Services
    • How Visio smartness can help your business
    • Visio visual in Power BI
    • Visio Consulting Services
    • Visio Bureau Services
    • Visio Training and Support Services
  • Products
    • Visio Shape Report Converter
    • SS Plus
    • LayerManager
    • visViewer
    • Metro Icons
    • Rules Tools for Visio
    • The Visio 2010 Sessions App
    • Multi-Language Text for Visio
    • Document Imager for Visio
    • multiSelect for Visio
    • pdSelect for Visio
  • Case Studies
    • Case studies overview
    • Using Visio in Education for GIS
    • Visualizing Construction Project Schedules
    • Visio Online Business Process Mapping
    • Nexans Visio Template
    • CNEE Projects, WorldCom
    • Chase Manhattan Bank
  • News
    • Recent news
    • News archive
  • Resources
    • Articles➡
      • ShapeSheet Functions A-Z
      • Comparing Visio for the Web and Desktop
      • Customising Visio Shapes for the Web App
      • Key differences between the Visio desktop and web apps
      • Using the Visio Data Visualizer in Excel
      • Using Visio in Teams
      • Creating Visio Tabs and Apps for Teams with SharePoint Framework (SPFx)
      • Designing Power Automate Flows with Microsoft Visio
      • Innovative uses of Visio Lists
    • Webcasts ➡
      • Visio in Organizations
      • My session and other Visio sessions at MSIgnite 2019
      • Power up your Visio diagrams
      • Vision up your Visio diagrams
      • The Visio 2010 MVP Sessions
    • Visio Web Learning Resources
    • Books➡
      • Visualize Complex Processes with Microsoft Visio
      • Mastering Data Visualization with Microsoft Visio
      • Microsoft Visio Business Process Diagramming and Validation
      • Visualizing Information with Microsoft Visio
  • Blog
    • Browse blog articles
    • Visio Power BI articles
    • Visio for Web articles
    • A history of messaging and encryption
  • About us
    • About bVisual
    • Testimonials
    • Bio of David Parker
    • Contact Us
    • Website Privacy Policy
    • Website terms and conditions
    • Ariba Network

Visio

Published on April 21, 2010 by David Parker

Automating Area and Perimeter Length Shape Data

[UPDATE: Microsoft introduced a new function into Visio 2010 called PATHLENGTH(…), so some of the following is now not required. See Automatic Line and Segment Lengths in Visio )

Another newsgroup question has asked about automating the update of shape area and perimeter lengths.  Now, this is an area (no pun intended) that I am most interested in because I used to do a lot of space planning.  Visio Professional does include Space and Boundary shapes on the Resources stencil that use an add-in to update the area, but does nothing about the perimeter length.  These shapes do highlight some of the issues to be considered though…

  • Visio pages can be scaled, and indeed the various floor plan and site layout templates in Visio are pre-scaled.  Most templates are not scaled, and  therefore default to 1:1 scale.
  • Visio measures everything internally in inches, although you can display in almost whatever units you choose.
  • The Visio Application object has a handy ConvertResult (StringOrNumber, UnitsIn, UnitsOut) method, which can be used for linear and area measurements … and can also be used for date and times.
  • Visio can store decimal numbers to a very high degree of precision (I counted 14 decimal places), but you almost always want to format the display.
  • Visio can call a method in a VBA project when the values in specified cells are changed.
  • It is easy to display Shape Data in a shape, either by using Data Graphics or by Insert Field

[Read more…] about Automating Area and Perimeter Length Shape Data

Filed Under: Scale, ShapeSheet Formulas, VBA, Visio

Published on April 20, 2010 by David Parker

Controlling the pencil mode programmatically

Another interesting question in the newsgroups from a David Kelley recently set me athinking!  So, I thought I’d share my response here.

First, the question:

“Programmatically,  after I drop a new shape on the page, how can I then move into the "editing mode" tool to use the pencil (to allow moving the control points on a polygon).  And once this is done (and the user has moved all the points to be where they should) how can I detect that every point has been edited/moved so that I can then automatically lock the polygon shape into place and prevent further movement (I understand the lock, just not how to detect the event)?   My general need is to allow the user to refine the corner points to match an underlaying image before (in the next step) I do some math on the final position.”

I thought the first part, getting the Pencil Edit mode to become active, was going to be easy, but it turns out not so…  Every shape has an EventDrop cell, in which you can add ShapeSheet formula.  So, I initially entered =DOCMD(1221) because 1221 is the value of Visio.VisUICmds.visCmdDRLineTool.  Therefore, my theory was, that this would change the mode to Pencil Edit whenever a copy of the shape was dropped.  Not so.  It never changes out of Pointer mode.  However, if I wrapped the command in a method that can be called from CALLTHIS() then it does work!

I drew a simple rectangle, and added it as a new Master in my local document stencil, then renamed it as Mask.  I then edited the Master shape, opened the ShapeSheet of the rectnagle, and entered the formula =CALLTHIS(“PencilEdit”) into the EventDrop cell, and added the PencilEdit method to a module in the documents VBA project:

   1: Public Sub PencilEdit(ByVal shp As Visio.Shape)
   2:     Visio.Application.DoCmd Visio.visCmdDRLineTool
   3: End Sub

Okay, so now Visio automatically enters Pencil Edit mode when the Master is dropped on the page or copied.

Now, the second bit … how to detect if each vertex has been edited.  In the following screenshot, you can see that the PinX and PinY values, of the shape instance of my Mask Master, are blue, but all the rest are black.  This is because they are the only values that are not inherited from the Master shape.

image

If I change the size of the shape by dragging a corner, then you can see that the Width and Height values also become blue because they are no longer inherited:

image

If I were to move a vertex within the rectangle, then you can see that two of the LineTo rows in the Geometry 1 section become local, ie not inherited, and turn blue.

image

If I were to move a vertex outside of the original rectangle, then all of the rows become local.

imageAll of the points in a Visio ShapeSheet are measured relative to the bottom left corner of the enclosing rectangle.  In this case, the width and height of the shape has also changed, thus the formulae in the X and Y cells have to change, even if they need to maintain their absolute position, because they are relative to the Width or Height values.  For example, the second row had the formula Width*1 originally, when the Width was equal to 30 mm.  Now that the width is 35 mm, the formula has changed to Width*0.8571, so that the value can stay at 30 mm.  In other words, the vertex in the bottom right corner of the shape has not moved, but its formula has had to be updated just to stay where it is.

If I were to add (or delete) a vertex into the geometry, then again, all of the Geometry 1 section values become local.

imageNo vertex has been moved, but one has been added on the top edge, on the left side.

Therefore, it is very difficult to detect if every vertex has been adjusted since it was originally dropped on to the page.  In practice, I would probably position the bottom left corner over a required vertex position, and then alter all of the other vertices to suit.  Even adding or deleting vertices as required.  Consequently, row 1 may never be adjusted at all.

David wants to detect vertex changes, but the nearest event in the ShapeSheet is the EventXFMod cell, so I added a CALLTHIS(“CheckEdit”) formula in there.  This will fire whenever the Width, Height, PinX or PinY changes.  It will not fire if a vertex movement does not cause a resizing of the shape.

image

The CheckEdit method will loop through all of the vertices in the first geometry section, and check if the vertex is in a different position to the same vertex in the master shape.  If all of the vertices have been moved relative to the previous vertex, then Visio is put back into Pointer Tool mode, and the vertices on the shape are locked from further editing.

   1: Public Sub CheckEdit(ByVal shp As Visio.Shape)
   2: 'Abort if no Geometry section
   3:     If shp.SectionExists(Visio.visSectionFirstComponent, Visio.VisExistsFlags.visExistsAnywhere) = 0 Then
   4:         Exit Sub
   5:     End If
   6: 'Abort if no master
   7:     If shp.Master Is Nothing Then
   8:         Exit Sub
   9:     End If
  10:     
  11: Dim iSect As Integer
  12: Dim iRow As Integer
  13: Dim iCell As Integer
  14: Dim rowIsChanged As Boolean
  15: Dim iCountUnChangedRows As Integer
  16: Dim segmentAngleMaster As Double
  17: Dim segmentLengthMaster As Double
  18: Dim segmentAngle As Double
  19: Dim segmentLength As Double
  20: Dim deltaX As Double
  21: Dim deltaY As Double
  22:  
  23:     iSect = Visio.VisSectionIndices.visSectionFirstComponent
  24:     iRow = Visio.VisRowIndices.visRowComponent
  25:     'Ignore the first unchanged row because it may be left intact
  26:     iCountUnChangedRows = 0
  27:     For iRow = 1 To shp.RowCount(Visio.visSectionFirstComponent) - 1
  28:         rowIsChanged = False
  29:         If shp.CellsSRC(iSect, iRow, iCell).IsInherited Then
  30:             iCountUnChangedRows = iCountUnChangedRows + 1
  31:             If iCountUnChangedRows > 1 Then
  32:                 Exit For
  33:             End If
  34:         End If
  35:         If shp.MasterShape.CellsSRCExists(iSect, iRow, 0, Visio.VisExistsFlags.visExistsAnywhere) Then
  36:             'Check that the vertex has moved relative to the previous vertex
  37:             iCell = Visio.VisCellIndices.visX
  38:             deltaX = shp.MasterShape.CellsSRC(iSect, iRow, iCell).ResultIU - shp.MasterShape.CellsSRC(iSect, iRow - 1, iCell).ResultIU
  39:             iCell = Visio.VisCellIndices.visY
  40:             deltaY = shp.MasterShape.CellsSRC(iSect, iRow, iCell).ResultIU - shp.MasterShape.CellsSRC(iSect, iRow - 1, iCell).ResultIU
  41:             segmentLengthMaster = Sqr((deltaX ^ 2) + (deltaY ^ 2))
  42:             If deltaX = 0 Then
  43:                 segmentAngleMaster = 0
  44:             Else
  45:                 segmentAngleMaster = Math.Atn(deltaY / deltaX)
  46:             End If
  47:             
  48:             iCell = Visio.VisCellIndices.visX
  49:             deltaX = shp.CellsSRC(iSect, iRow, iCell).ResultIU - shp.CellsSRC(iSect, iRow - 1, iCell).ResultIU
  50:             iCell = Visio.VisCellIndices.visY
  51:             deltaY = shp.CellsSRC(iSect, iRow, iCell).ResultIU - shp.CellsSRC(iSect, iRow - 1, iCell).ResultIU
  52:             segmentLength = Sqr((deltaX ^ 2) + (deltaY ^ 2))
  53:             If deltaX = 0 Then
  54:                 segmentAngle = 0
  55:             Else
  56:                 segmentAngle = Math.Atn(deltaY / deltaX)
  57:             End If
  58:             '14 decimal places is too accurate
  59:             If CDbl(Format(segmentLengthMaster, "0.000000")) <> CDbl(Format(segmentLength, "0.000000")) Then
  60:                 rowIsChanged = True
  61:             ElseIf CDbl(Format(segmentAngleMaster, "0.000000")) <> CDbl(Format(segmentAngle, "0.000000")) Then
  62:                 rowIsChanged = True
  63:             End If
  64:         Else
  65:             rowIsChanged = True
  66:         End If
  67:         If rowIsChanged = False Then
  68:             iCountUnChangedRows = iCountUnChangedRows + 1
  69:             If iCountUnChangedRows > 1 Then
  70:                 Exit For
  71:             End If
  72:         End If
  73:     Next iRow
  74:  
  75:     If rowIsChanged And iCountUnChangedRows = 0 Then
  76:         'All rows have changed
  77:         shp.CellsSRC(Visio.VisSectionIndices.visSectionObject, Visio.VisRowIndices.visRowLock, Visio.VisCellIndices.visLockVtxEdit).Formula = 1
  78:         Visio.Application.DoCmd Visio.VisUICmds.visCmdDRPointerTool
  79:     End If
  80: End Sub

Hopefully, this will answer the original question!

image 

Looking forward to the launch of Visio 2010!

Filed Under: Visio

Published on April 16, 2010 by David Parker

Automating SaveAsWeb when a Linked DataRecordset refreshes

My good friend and colleague, John Goldsmith, recently blogged about the Visio SaveAsWeb feature (see http://visualsignals.typepad.co.uk/vislog/2010/03/automating-visios-save-as-web-output.html ), and mentioned that I was going to blog about automating the SaveAsWeb when a linked DataRecordset refreshes … so here it is!  This is my version of a poor man’s Visio Services … which is only available with Visio 2010 Premium and SharePoint 2010 with an eCAL.

Firstly, the code is written in VBA, and utilises a module that is in the Visio SDK Samples library.  The modSaveAsWeb file can be found in the Publishing category:

image

[Read more…] about Automating SaveAsWeb when a Linked DataRecordset refreshes

Filed Under: Visio

Published on April 13, 2010 by David Parker

TechDays and MVP Conference

Busy times!  When I was over at the MVP Conference a few weeks ago, I, and a few other MVPs, were interviewed about our experiences with out specialist application.  Well, mine has been published now, and can be viewed at http://blogs.office.com/b/office_blog/archive/2010/04/08/visio-rack-diagrams-smarter-than-your-average-drawing.aspx
image

[Read more…] about TechDays and MVP Conference

Filed Under: Visio 2010 Tagged With: Visio Services

Published on March 15, 2010 by David Parker

Visio and Bing Maps for Travel Photos

I am not sure how to categorise this article because it covers Visio, Bing Maps and travel.  I went to Pisa and Florence for a weekend break this month, and took many photos that I stitched together with Microsoft ICE (Image Composite Editor).  Well, I wanted to show-off these photos as I have done on previous articles, but I wasn’t satisfied with how I presented them before. so I re-used and adapted some of my previous work (see http://bvisual.spaces.live.com/Blog/cns!3350D61BC93733A9!1005.entry), and some of John Goldsmith’s (see http://visualsignals.typepad.co.uk/vislog/2007/12/escaping-from-s.html#more), and one of Chris Roth’s blogs (see http://www.visguy.com/2007/07/13/map-distance-dimension-line/).

Firstly, I couldn’t resist taking this photo of a bollard, on the Lungarno Amerigo Vesspucci in Florence, that has been used over and over again to lock-up locals motorbikes:

LockedBollard

I created a series of panoramic images using Microsoft ICE, and then located them on Bing Maps.  I created two Bing Maps Collections (we flew into Pisa airport on the way to Florence for the weekend)  :

Florence : http://www.bing.com/maps/default.aspx?v=2&cp=43.7227~10.3944&lvl=17&sty=h&cid=3350D61BC93733A9!2115

Pisa : http://www.bing.com/maps/default.aspx?v=2&cp=43.72339418736733~10.396136865019798&lvl=17&sty=h&cid=3350D61BC93733A9!2100

I created a Camera Position master in Visio, and adapted my previous code to import the KML files from the above Bing Map collections into Visio.

image

I can adjust the splay and angle of the camera to approximate the vista covered by the panoramic views.

I then saved the Visio 2010 document (two pages) as web pages, and altered the frameset.js file, as shown by John, so that the PhotoUrl is displayed as a thumbnail, and the MoreInfoUrl and Bing Maps Url links are available in the Details panel.

image

In addition, clicking on a Camera Position shape opens the Deep Zoom web page for that view.

Here is the final output: http://www.bvisual.net/views/PisaAndFlorenceMarch2010.htm 

Enjoy (I hope).

Filed Under: Geographic, Visio

Published on March 9, 2010 by David Parker

Creating Linked Timelines From Project

A recent newsgroup question asked if it is possible to create shapes in Visio 2007 that are linked to tasks in a timeline in Project …. without lots of coding!  Well, that sounds like a challenge that I can’t resist, so here goes!

First, I am using Microsoft Project 2007 and I have loaded the Commercial Construction sample project that is in the Visio SDK.

image

[Read more…] about Creating Linked Timelines From Project

Filed Under: Visio

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 58
  • Page 59
  • Page 60
  • Page 61
  • Page 62
  • Interim pages omitted …
  • Page 69
  • Go to Next Page »

Primary Sidebar

  • LinkedIn
  • Twitter

Recent Posts

  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio
  • Grid Snapping Revisited

Categories

Tags

Accessibility Add-Ins Connectors Containers Data Export Data Graphics Data Import Data Visualizer Educational Excel GraphDatabase Hyperlinks Icon Sets JavaScript LayerManager Layers Legend Link Data to Shapes Lists MSIgnite MVP Office365 Org Chart PowerApps PowerBI PowerQuery Processes Setup and Deployment Shape Data Shape Design ShapeSheet ShapeSheet Functions SharePoint 2013 SQL Teams Validation VBA Video Visio Visio 2007 Visio for the Web Visio Online Visio Services Visio Viewer Webinar

Footer

bVisual Profile

The UK-based independent Visio consultancy with a worldwide reach. We have over 25 years experience of providing data visualization solutions to companies around the globe.

Learn more about bVisual

  • Amazon
  • E-mail
  • Facebook
  • LinkedIn
  • Twitter
  • YouTube

Search this website

Recent posts

  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio
  • Grid Snapping Revisited

Copyright © 2025 · Executive Pro on Genesis Framework · WordPress · Log in