• 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
    • 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
You are here: Home / Shape Design / ShapeSheet Formulas / Automatic Line and Segment Lengths in Visio

Published on July 16, 2021 by David Parker

Automatic Line and Segment Lengths in Visio

Many years ago, I wrote some VBA code to calculate the length of a multi-segment line in Visio, see Automating Area and Perimeter Length Shape Data , but Microsoft have since provided a handy ShapeSheet function, PATHLENGTH(…), to do the same without any VBA. The function is described on one of the pages in Visio ShapeSheet Functions O-R , but here is one way that it can be incorporated into a useful shape for, say, cabling or piping, and thus be available in Shape Reports. Moreover, the Shape Data can display the length of each of the segments in the line, in addition to the total length.

I chose to modify the Dynamic Connector master in this example, but it could be added to any 1D master shape.

I also chose to add in the ability to select the display units and the number of decimal places. The following images are of the ShapeSheet in both Value and Formula display modes.

User-defined Cells

NameValuePrompt
ShowUnitsTRUE“TRUE to Show Units, FALSE to Hide Units “
FormatString“0.”&
REPT(“0”,Prop.DecimalPlaces)&
IF(User.ShowUnits=1,” u”,””)
“The Format String for the length display”

The REPT(…) function will simply repeat the “0” character as many times as defined by the value of Prop.DecimalPlaces

Shape Data

NameLabelPromptTypeFormatValueInvisible
Length“Length”“The built-in units are inches”2“”GUARD(
PATHLENGTH(Geometry1.Path)
)
FALSE
TotalLength“Total Length”“The length in the selected units”0“”GUARD(
FORMATEX(
Prop.Length,
User.FormatString,
“in”,
Prop.DisplayUnits)
)
FALSE
DisplayUnits“Display Units”“Select a unit for the display”1“in;ft;yd;mm;cm;m”INDEX(3,Prop.DisplayUnits.Format)FALSE
DecimalPlaces“Decimal Places”“Select the number of decimal places”1“0;1;2;3;4;5;6;7;8;9”INDEX(1,Prop.DecimalPlaces.Format)FALSE
Segmentn“Segment n Length”“The length of segment n with the selected unit and decimal places”0“”GUARD(
FORMATEX(
IF(
ISERR(PATHLENGTH(Geometry1.Path,n)),
0,
PATHLENGTH(Geometry1.Path,n)
),
User.FormatString,
“in”,
Prop.DisplayUnits)
)
ISERR(PATHLENGTH(Geometry1.Path,n))

Where n is from 1 to as many as you expect to be the maximum number of segments.

The Length Shape Data row could be Invisible=TRUE.

The invisibility or each of the multiple Segmentn rows is controlled by checking if there is an error returned by the PATHLENGTH(…) function.

Actions

ActionMenu
SETF(GetRef(User.ShowUnits),NOT(User.ShowUnits))IF(User.ShowUnits=1,”Hide &Units”,”Show &Units”)

That is all that is required!

My new book on Visualizing Processes with Microsoft Visio has launched

Back in the early 1990s, there was an application called ABC Flowcharter that was the market leader for diagramming business flowcharts, but some of the brains behind Aldus PageMaker saw an opportunity to create something smarter, and left to write the Visio product, with the stated aim to overtake ABC Flowcharter within 2 years. They…

Interactive Demographics of the European Union in Visio

I was recently contacted by a reader, Stanley M. Max (Towson University lecturer), who had started creating a Visio map of the 27 countries in the European Union in 2020, along with the demographics culled from Wikipedia. He wanted to know if the map and stats could be combined to make a more appealing presentation.…

Understanding Visio Data Graphic’s Color by Value

The desktop Visio editions, Visio Professional and Visio Plan 2, have a great way of automatically displaying data as Data Bars, Icon Sets, Text Callouts and Color by Value. The first three types of Data Graphics require sub-shapes to be inserted into each shape that they are applied to, but the last one, Color by…

Pushing Data Visualizer in Visio beyond its limits

My last post was about some of the lessons learnt when trying to push Data Visualizer to its limits, but this one has some ways of overcoming these limitations. The main lesson learnt is that DV binds the shapes within the DV container shape, CFF Data Visualizer, and controls some of the ShapeSheet cells that…

Pushing Data Visualizer in Visio to the limits!

Regular readers of my blog will know that I like to use the Data Visualizer (DV) in Visio Plan 2, but I recently tried to help a user who really decided to push it to the limits. In this scenario, there were multiple connections, but with different labels, being created between the same flowchart shapes,…

Setting Theme defaults in Visio

I was recently asked how to change the default font size and line weight in Visio, and then saw then many others are asking the same sort of question. I found one reasonable answer suggesting that you should create a new document from your required template, then edit the Styles to suit, and then save…

Related

Filed Under: Shape Data, Shape Reports, ShapeSheet Formulas Tagged With: ShapeSheet, Visio

About David Parker

David Parker has 25 years' experience of providing data visualization solutions to companies around the globe. He is a Microsoft MVP and Visio expert.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

  • LinkedIn
  • Twitter

Recent Posts

  • Counting glued and connected shapes in Visio
  • My new book on Visualizing Processes with Microsoft Visio has launched
  • Layer Set menu options and calls from code added to LayerManager
  • Interactive Demographics of the European Union in Visio
  • Understanding Visio Data Graphic’s Color by Value

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 Shape Data Shape Design ShapeSheet ShapeSheet Functions SharePoint 2013 SQL Teams Themes 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

  • LinkedIn
  • Twitter

Search this website

Recent posts

  • Counting glued and connected shapes in Visio
  • My new book on Visualizing Processes with Microsoft Visio has launched
  • Layer Set menu options and calls from code added to LayerManager
  • Interactive Demographics of the European Union in Visio
  • Understanding Visio Data Graphic’s Color by Value

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