Visio Insights
The official blog of the Microsoft Visio product team

  • Visio Insights

    The Visio 2010 Connectivity API

    • 2 Comments

    Our previous post on AutoConnect in Visio 2010 discussed how Visio 2010 makes it simpler and faster for end users to create connected diagrams such as flowcharts. Many developers will be pleased to hear that Visio 2010 also brings greatly simplified utilities for working with connected diagrams programmatically. The Visio 2010 API contains new methods that let developers manipulate and traverse connected diagrams or graphs at a higher level of abstraction than previously, which can result in greater programmer productivity and more concise, readable code.

    In this blog post, we will introduce the new Visio 2010 methods used for working with connected diagrams. Then we will see these methods in action by doing a visual walk-through of a program that manipulates a flowchart. (The source code and diagram used below are also available for download here.)

    New connectivity methods in Visio 2010

    For each of the following API methods, we give a brief description on what the method does, along with an explanation of the method’s arguments. This is not meant to be a complete reference; the forthcoming Visio 2010 SDK will contain much more complete documentation on these methods.

    Shape.ConnectedShapes(Flags, CategoryFilter)

    Returns an array of identifiers (IDs) of shapes that are one degree of separation away from the given shape (i.e. separated by a 1-D connector).

    Arguments:

    • Flags: Filters the list of returned shape IDs by the directionality of the connectors.
    • CategoryFilter: Filters the list of returned shape IDs by limiting it to IDs of shapes that match the specified category. A shape’s categories can be found in the User.msvShapeCategories cell of its ShapeSheet.

    Shape.GluedShapes(Flags, CategoryFilter, pOtherConnectedShape)

    Returns an array of identifiers for the shapes that are glued to a shape. For instance, if the given shape is a 2-D shape that has multiple connectors attached to it, this method would return the IDs of those connectors. If the given shape is a connector, this method would return the IDs of the shapes to which its ends are glued.

    Arguments:

    • Flags: Specifies dimensionality and directionality of connectors of shapes returned.
    • CategoryFilter: Specifies category of shapes returned.
    • pOtherConnectedShape: Optional additional shape to which returned shapes must also be glued

    Page.DropConnected(ObjectToDrop, TargetShape, PlacementDir, [Connector])

    Creates a new Shape object on the page, places the new shape relative to the specified existing target shape, and adds a connector from the existing shape to the new shape. Returns the newly created shape. This feature parallels the AutoConnect feature in the Visio user interface.

    Arguments:

    • ObjectToDrop: The shape to be added to the page
    • TargetShape: The existing shape from which to align, space, and connect
    • PlacementDir: The direction from TargetShape in which to place ObjectToDrop
    • Connector: The connector to use (optional). This overrides usage of the default Dynamic Connector.

    Page.SplitConnector(ConnectorToSplit, Shape)

    Splits the specified connector with the specified shape. Returns the new, duplicated connector.

    Arguments:

    • ConnectorToSplit: The connector to split. Must be a routable 1-D connector.
    • Shape: The shape to use to split the connector. Must be a 2-D shape.

    Shape.Disconnect(ConnectorEnd, OffsetX, OffsetY, Units)

    Unglues the specified connector end points and offsets them the specified amount from the shapes they were joined to.

    Arguments:

    • ConnectorEnd: The end of the connector to disconnect
    • OffsetX: The x-distance that the connector end is moved away from the shape
    • OffsetY: The y-distance that the connector end is moved away from the shape
    • Units: The units of measure for the assigned offset values

    Page.AutoConnectMany(FromShapeIDs(), ToShapeIDs(), PlacementDirs(), [Connector])

    Automatically draws multiple connections in the specified directions between the specified shapes. Returns the number of shapes connected.

    Arguments:

    • FromShapeIDs(): An array of identifers of the shapes from which to draw a connection
    • ToShapeIDs(): An array of identifers of the shapes to which to draw a connection
    • PlacementDirs(): An array of constants that represent the directions in which to draw the connection
    • Connector: The connector to use (optional). This overrides usage of the default Dynamic Connector.

    Let’s try it out!

    Here is a screenshot of a Visio drawing we will be manipulating and traversing:

    1

    Using a few of the above listed methods, we’ll add to this flowchart and traverse it. Each step along the way, we’ll show you the corresponding line of C# code along with a screenshot of the change it caused.

    Note: In the below code snippets, page refers to the active drawing page, and the Visio namespace is an abbreviation of Microsoft.Office.Interop.Visio. The meanings of most other variables should be apparent from the context.

    First, let's split the connector that currently connects "Start Event" to "Task" and insert a Sub-Process shape. We can access that connector using the GluedShapes method. Once we’ve accessed the connector, we use SplitConnector to split it.

    Array shapesGluedToStartEvent =
        startEvent.GluedShapes(Visio.VisGluedShapesFlags.visGluedShapesOutgoing1D, "", null);
    // In this example, the above array has 1 element. Let's get that element.
    int splittableConnectorID = (int)shapesGluedToStartEvent.GetValue(0);
    Visio.Shape splittableConnector = page.Shapes.get_ItemFromID(splittableConnectorID);
    page.SplitConnector(splittableConnector, subprocessMaster);

    This yields the following result:

    2

    Let's say we want to programmatically access the "Task" shape. If we have a reference to "Start Event", we can access "Task" by traversing across "Sub-Process", using ConnectedShapes.

    Array shapesConnectedToByStartEvent =
        startEvent.ConnectedShapes(Visio.VisConnectedShapesFlags.visConnectedShapesOutgoingNodes, "");
    // In this example, the above array has 1 element. Let's get that element.
    int subProcessID = (int)shapesConnectedToByStartEvent.GetValue(0);
    Visio.Shape subProcess = page.Shapes.get_ItemFromID(subProcessID);

    // Repeating the same action as above to get from "Sub-Process" to "Task".
    Array shapesConnectedToBySubProcess =
        subProcess.ConnectedShapes(Visio.VisConnectedShapesFlags.visConnectedShapesOutgoingNodes, "");
    int taskID = (int)shapesConnectedToBySubProcess.GetValue(0);
    Visio.Shape task = page.Shapes.get_ItemFromID(taskID);

    Now let's use DropConnected to drop an End Event shape onto the page and have "Task" connect to it. We use the default connector, so the last argument can be null.

    Visio.Shape endEvent = page.DropConnected(endEventMaster,
        task,
        Visio.VisAutoConnectDir.visAutoConnectDirRight,
        null);

    This yields the following result:

    3

    We hope this walk-through was a helpful illustration of Visio 2010’s new API utilities for working with connected diagrams. This article covers only a small part of the enhancements made to Visio’s API for the 2010 release; more information will come in future posts on this blog, and with the release of the Visio 2010 SDK.

    We’re interested to hear what developers think of this API functionality, so please use the Send a Smile feedback tool or leave a comment below.

  • Visio Insights

    Make Your Own Data Graphic – Data Bars

    • 5 Comments

    This is the second post in a series demonstrating how you can create data graphic callout shapes for use in Visio 2007 Professional.  The first post discussed Text Callouts.  There is also an article on MSDN that covers the full spectrum of customization possibilities for Data Graphics.

     

    Data Bar example 

     

    A Data Bar is one of the four ways you can visualize data using Data Graphics.  It displays numeric data in a graphical form using the geometry of the callout shape to indicate the magnitude of the data value.  Data Bars may also display text and can even display multiple fields at once.  As with the other Data Graphics callouts, the visualization is as customized as you want to make it.

    In this post we are going to create the “slider” shape shown above.  This callout has two parts.  A long, thin bar shows the full range of possible data values, and a circle slides along the bar to indicate the current data value.  The circle also displays the current data value as text expressed as a percentage.  Let’s start with the bar and perform the minimum tasks necessary to create a Data Graphic callout.

     

     

     

    We draw a rectangle on the page and open its Shapesheet.  In the Shapesheet, we need to insert a User-defined section and a Shape Data section.  To make this shape a Data Graphic callout, first change the row name of the User-defined row to User.msvCalloutType (click on the row name and type "msvCalloutType").  In the Value cell enter "Data Bar" - including the quotation marks here.  Next change the row name of the Shape Data row to Prop.msvCalloutField (click on the row name and type "msvCalloutField").  Data Bars also have Shape Data rows for the minimum and maximum values that the callout field can have.  Add two more Shape Data rows named Prop.msvCalloutPropMin and Prop.msvCalloutPropMax.  Enter labels in the Label column and the word “Number” in the Prompt column as shown in the screenshot.

    Visio uses the User.msvCalloutType value to determine where to surface your custom callout shape in the Data Graphics user interface.  This shape will appear in the Callouts list in the New Data Bar / Edit Data Bar dialog.  Visio populates the Prop.msvCalloutField value (the Value cell in this row) with the data to display at the time the data graphic is applied to a shape on the page.  Visio also will fill in values for Min and Max based on the data recordset, and these are exposed in the Data Bar dialog as well.  This shape will now be treated as a Data Graphic callout if you drag it into the Document Stencil, but right now it doesn’t do anything with the data from Visio.  We need to build out the rest of the shape to make it work like a data bar.

     

    Label display

    Our rectangle will serve as the long, skinny part of the data bar - indicating the full range of field values.  It also is responsible for displaying the field label.  We want this label to be optionally hidden as is the case in the sample callout above.  Visio will place the field label in the Prop.msvCalloutField.SortKey cell (a strange place, yes, but the Label cell is already used for exposing properties in the Data Bar dialog).  Enter some default text such as “Label” (including quotation marks) in this cell.  Then select the rectangle in the drawing window and choose Insert > Field.  Choose Custom Formula and then enter the formula: “=Prop.msvCalloutField.SortKey” (no quotation marks) and press OK.  We want the label to be outside the rectangle on the right side.  In the Shapesheet insert a Text Transform section and fill it out as shown below:

     

     

     

    We want the user to be able to choose whether the field label is shown or hidden.  Data Graphics allows us to create our own callout property to display in the Data Bar dialog.  Add a new Shape Data row and name it Prop.msvCalloutPropShowLabel.  The row name must include the prefix “msvCalloutProp” to be recognized as a callout property.  Then place a human-readable name in the Label column and the word “Bool” in the Prompt column.  The Label value appears in the dialog as the name of the property.  The Prompt value tells Data Graphics what type of control to use in the dialog – in this case a simple True / False dropdown.  Visio will put the user’s choice in the Value cell.  Go ahead and enter the default value True here.  A full explanation of the syntax for custom callout properties is included in the MSDN article.  Finally tie the visibility of the shape’s text to this Value cell by entering this formula in the HideText cell:  “=NOT(Prop.msvCalloutPropShowLabel)”.

     

     

     

    Data bar value

    Next we will create the circle shape that represents the current value for the data bar.  The rectangle and circle together form the callout shape, so we need to make a group.  Select the rectangle shape and choose Shape > Grouping > Convert to Group to make this the top-level group shape.  In the rectangle’s Shapesheet set the LockCalcWH cell to 1 so that further grouping operations do not change the shape’s size.  Also set the DisplayMode cell to 1 so that the rectangle will appear behind its subshapes.  Now draw a circle on the page.  Select the rectangle, then Ctrl-click on the circle to select it as well.  Choose Shape > Grouping > Add to Group to make the circle a subshape of the rectangle.

     

     

     

    The position of the circle is dependent on the current field value and its relative size versus the Min and Max values.  We’ll add a User-defined cell to the rectangle shape to calculate the percentage of the total range.  In the rectangle’s Shapesheet add a User-defined row named User.PercentFilled and enter this formula:

    =BOUND((Prop.msvCalloutField-Prop.msvCalloutPropMin)/IF((Prop.msvCalloutPropMax-Prop.msvCalloutPropMin)<>0,Prop.msvCalloutPropMax-Prop.msvCalloutPropMin,1),0,FALSE,0,1)

    This expression calculates the current percentage of the field value between Min and Max.  It also prevents division by zero and checks to make sure that the result stays between 0 and 1 so that our data bar behaves predictably.

     

     

     

    Value display

    The User.PercentFilled value will be used by the circle subshape to control its position and to display the value as text.  We’ll start with the value display.  In the circle’s Shapesheet insert a User-defined section and add a User.PercentFilled row that references the value from the rectangle.  Since we will use this value multiple times, it is good practice to use a single cross-sheet reference and then multiple local cell references.  (Note that your sheet ID’s may be different than those shown here.)

     

     

     

    Now select the circle in the drawing window and choose Insert > Field.  Choose User-defined Cells and select the PercentFilled cell.  Before closing the dialog click on the Data Format button.  Choose Percentage and 0 decimal places.  Then click OK twice.  Next we want to tie the size of the circle to the size of the text so that the text always fits.  Add another User-defined row named User.CircleDiameter to track the size of the circle.  Then add this expression for the value: “=CEILING(TEXTWIDTH(TheText),2 pt)”  (omit quotation marks).  This expression calculates the current width of the text and rounds it up to the nearest 2 pt to get rid of tiny variations in text width based on proportional character spacing.  We add formulas to the Width and Height cells of the circle to tie its size to User.CircleDiameter.  The formulas are GUARDed to prevent accidental resizes by the user.  Set the NoObjHandles cell to 1 to hide the resize handles since they are not needed.

     

     

     

    Value position

    We’re ready to tie the position of the circle to User.PercentFilled.  The circle should move from one end of the rectangle to the other.  We must account for the circle diameter when calculating the range of movement so that the circle does not move overlap the ends of the rectangle.  Add this formula to the PinX cell:

    =GUARD(User.CircleDiameter*0.5+User.PercentFilled*(Sheet.5!Width-User.CircleDiameter))

    Also set the PinY cell:  “GUARD(Sheet.1!Height*0.5)”.

     

     

     

    Finishing touches

    Our callout is now functional enough to test.  Open the rectangle’s Shapesheet and enter sample values for Prop.msvCalloutField as well as the Min and Max properties.  You should see the circle move and display the proper value as text.  The only remaining work is to enhance the appearance of the data bar.  The rectangle height should be a fraction of the circle diameter.  Actually, the height of the rectangle shape should encompass both the rectangle and the circle, so we’ll just make the geometry of the rectangle shape smaller.  Add a User-defined row named User.CircleDiameter to the rectangle and reference the circle’s User.CircleDiameter cell.  Then add a User-defined row named User.BarHeight and set it to be a fraction of the circle size.  The geometry of the rectangle is then modified to depend on User.BarHeight as shown in the screenshot below.

     

     

     

    The overall size of the callout should be fixed; the width is set to a constant value and the height is large enough to hold the circle.  Enter the formulas for Width and Height as shown in the image below.  Note that DropOnPageScale is a factor that adjusts the size in cases where a scale other than 1:1 is used in the drawing.  This is a good practice whenever hard-coding measurement values like the ones in these formulas.

     

     

     

    One final change is to set the LockFromGroupFormat cell to 1.  This prevents formatting changes applied to the main shape from propagating to the callout.  Generally we want the callout to retain its own formatting unless the user directly selects the shape and modifies it.  Our callout shape is complete.  The rest of the look is achieved through Themes.  Apply a color theme and effects theme to the page.  Our sample uses the “Office” color theme and “Button” effects theme, but the callout will pick up whatever theme is applied in your document.  Sub-select the circle shape and change the fill color to make it stand out from the rectangle.  Accent 2 is a good choice here.  The finished shape is below.

     

     

     

    Testing the callout

    To use this callout, we need to make it a master shape in the Document Stencil.  Go to File > Shapes > Show Document Stencil and then drag the shape in.  Rename the master to “Slider”.  Now we need to apply it to a shape.  Draw a text box on the page and type some text.  Then right-click on the shape and choose Data > Shape Data.  Answer Yes to define new shape data.  Add a Label, set the Type to Number and enter a sample Value before clicking OK.  Click OK once more to finish adding data to the text shape.

     

     

     

    Right-click the shape again and choose Data > Edit Data Graphic.  Choose New Item > Data Bar to open the New Data Bar dialog.  Choose “Rating” for the data field and make sure that our Slider master is selected as the callout.  Then turn off the label by setting Show Label to No.  Click OK twice to apply the data graphic.

     

     

     

    The final result is shown below.

     

     

     

    As you can see there are quite a few steps.  However, most of the work is creating the custom behavior and appearance you want.  The end result is quite professional and easily integrates into the Data Graphics feature.  In the next post we will create the final type of callout used in Data Graphics: the Icon Set.

     

  • Visio Insights

    Improved Flowchart Routing in Visio 2010

    • 5 Comments

    When creating and maintaining flowcharts, a pain point users suffer from is ensuring that the connectors between shapes look good. Visio introduced the dynamic connector many releases ago to help simplify diagram maintenance. Dynamic connectors in combination with dynamic glue allow Visio to choose the sides of shapes to glue your connectors for the best looking results.

    In Visio 2010 we made improvements to Visio's routing engine to address some common flowcharting pain points. (For more on the dynamic connector and why you should use dynamic glue, see this previous post titled "Gluing It All Together". )

    Improving Flowchart Readability

    Clarity is important in flowcharts. Overlapping connectors flowing in opposite directions can create ambiguity about the meaning of the diagram. It is easy to get into a situation where two connectors appear visually to be connected, but were not explicitly connected by the diagram author. Visio 2010's routing engine detects such ambiguous situations and relocates connectors to actively avoid them.

    Consider the example below where I draw two dynamic connectors: one from shape A to B and the other from B to C. In Visio 2007, this leads to an ambiguous drawing, where it appears as if shape A is connected to shape C. Visio 2010 moves the connector between A and B to an alternate side of shape B to resolve the ambiguity.

    incoming conflict

    We made this design change based on user feedback. It scales to handle more than just a few connectors, and allows connectors to overlap when they are flowing in the same direction.

    A consequence of this change is that if you open a diagram that was created in older versions of Visio in Visio 2010, as you edit your diagram, you may see connectors relocate to different sides of shapes. Note that Visio doesn't move glue points of connectors that are statically glued.

    Relaxing Constraints on Flowchart Direction

    Visio flowcharts that use the "Flowchart" routing style have a routing direction, like "Top to Bottom" or "Left to Right". In flowchart routing, this controls what sides of shapes dynamic connectors (mostly) connect to. Strict adherence to this direction can easily lead to situations where a dynamic connector takes a path around a shape with 5 segments.

    Using "Top to Bottom" as my routing direction, routes generally exit from the bottom of a shape and connect to the top of the shape, except in cases where shapes line up exactly.

    In Visio 2010, we enable dynamic connectors to connect to alternate sides of shapes when the shapes are close to each other.

    virtual overlap

    To strike a balance between having simple looking connectors and still adhering to the flowchart direction, Visio connects to non-standard sides of shapes when two shapes are close to each other in the axis of the routing direction.

    As always, we're interested in your feedback on routing, so use the Send a Smile feedback tool or comment on this post to let us know what you think.

  • Visio Insights

    Visio Services: Details for Administrators

    • 0 Comments

    In previous posts we've introduced Visio Services and shown you how you can publish your Visio diagrams to SharePoint. We've also given you a quick introduction on how to install and configure Visio Services. In this post, we'll cover more details for IT Administrators about running Visio Services in SharePoint 2010. This post contains lots of links to detailed documentation on TechNet as well as other blog posts.

    image

    Overview

    Visio Services is implemented as a service application in SharePoint Server 2010. The service allows users to share and view Microsoft Visio Web drawings (*.vdw files). The service also enables viewing of data-connected web drawings, and the underlying data and drawing can be updated from various data sources. Drawings can be embedded in SharePoint pages using the Visio Web Access web part.

    Extensibility

    There are several ways in which you can build on top of Visio diagrams with Visio Services:

    • Visio web drawings can be used as the basis for visual mash-ups. You can build code free mashups using Web Part Connections , or you can use the JavaScript API to create custom mashups.
    • Visio Services supports OLEDB or ODBC data sources. The driver for the data source must be installed on every application server that is running Visio Services, and it must be a trusted data provider. When using Visio client to create the Web Drawing that contains the data connection to the data source, the machine used must also have the driver installed.
    • You can write custom data providers to connect to any data source. Custom data providers need to be implemented as .NET assemblies that accept connection strings and return data as ADO.NET data sets. Look for a blog post next week with more information about custom data providers!

    Service Administration

    Because Visio Services is implemented as a service application, managing the service is simple through both SharePoint Central Administration and Windows PowerShell.

    For detailed information about common administrative tasks, see the Visio Services Operations Guide.

    Visio Services maintains a few performance and caching settings, as well as a list of trusted data providers. For more details, see this article that explains the various service settings.

    Connecting to Data

    Visio Services supports connecting to various data sources. Administrators need to understand how their organizations will use data with Visio Services and plan appropriately. The Visio Services Planning Guide will help you understand the implications of data connected web drawings.

    By default, Visio Services supports connecting to the following data sources:

    • Microsoft SQL Server
    • Excel Services (Excel workbooks stored on a SharePoint Server 2010 that is running Excel Services)
    • SharePoint lists
    • OLEDB or ODBC connections
    • Custom Data Providers implemented as .NET Framework assemblies

    Administrators have the ability to control what data sources the service is allowed to connect to by managing the Trusted Data Providers.

    Connecting a web drawing to SharePoint lists and Excel Services does not require any additional configuration.

    To connect web drawings to external data sources (like SQL or an OLEDB data source), the administrator must setup an unattended service account with the Secure Store Service. The unattended account is a low-privilege domain account that is used by Visio Services when connecting to external data sources. The credentials for this account must be stored in a Secure Store target application, and Visio Services must know the name of this target application. For more information about the unattended account and the security implications of connecting to external data, and other authentication methods, see this article on Visio Services security.

    Security

    Visio Services gives administrators a significant level of fine-grained control for the processing and displaying of Visio Web Drawings and what data sources they can connect to. This article on planning Visio Services security details the security implications that you should consider when deploying Visio Services.

    Documentation

    The following is a list of resources that are available on TechNet for administrators planning to deploy Visio Services:

    The following is a list of posts on this blog that contain more information about Visio Services:

    We hope this overview and set of links will make it easy for IT administrators to deploy and use Visio Services. Let us know what you think by commenting on the blog or using Send a Smile.

  • Visio Insights

    Visio 2010 Technical Beta program

    • 11 Comments

    We’re excited to announce that the Visio team is taking nominations to participate in the Visio 2010 Technical Beta program! We will be sending out a limited number of invitations to download and install Visio 2010 Technical Preview in July. The team is excited to get valuable feedback and early testing from our community that will help us make this a great release. Here is your opportunity to nominate yourself to participate in the program (space is limited). If you’re interested, please go here to sign up for Microsoft Connect and apply to be part of the Technical Preview. When asked, select Visio as the application you’re most interested in testing (question 13 on the survey).

    We look forward to hearing from you.

    P.S. Visio MVPs are already nominated and need not apply.

  • Visio Insights

    BPMN Diagramming Basics Course Available

    • 6 Comments

    A new series of training videos have been posted on Office.com to introduce Visio users to Business Process Modeling Notation (BPMN).  The videos are packaged as a course named BPMN Diagramming Basics.

    image

    The course provides both an introduction to the BPMN notation and a tutorial on creating BPMN diagrams with Visio 2010 Premium.  Along the way you can see some of the other new features of Visio 2010 including Swimlanes, AutoConnect, Subprocesses, and Diagram Validation.  The complete course takes less than 30 minutes to view.

    Please remember that the BPMN, Subprocess, and Diagram Validation features are part of the Premium Edition of Visio 2010.

    Be sure to let us know what you think!

  • Visio Insights

    Building Shapes the Easy Way

    • 4 Comments

    Shape design is somewhat of an art in Visio.  There are so many things that go into creating professional-looking content that a certain level of expertise is required.  One of the goals of the Visio Insights blog is to provide that expertise in an understandable format.  Another goal is to demonstrate best practices to help you use Visio in the most effective manner.  This week we will demonstrate shape construction techniques by  creating a new shape from scratch.

     

    Our example is a digital clock shape.  The numerals in the clock – the digits – are drawn in geometry instead of text.  This allows us to be more creative with the appearance of the digits.  We want the digit to appear as it is shown in a Liquid Crystal Display.

     

     

    Today’s post focuses on ways to use the power of Visio to create shape geometry.  There are several approaches to constructing geometry.  You can use Visio’s drawing tools to manually draw the lines and arcs needed for the shape.  This works well for simple geometry, but the tools are not suitable for complex geometries.  You can also build geometry using the Shapesheet window by entering the actual formulas in the Geometry sections.  This approach is very precise but can be extremely slow and difficult to get things right.  A third approach is to build a complex shape by assembling it from simpler pieces.  This is the simplest approach because it makes Visio do the heavy lifting to create the final geometry.

     

    Let’s construct a shape to represent a digit for our clock using this assembly approach.  A digit is composed of seven individual polygons, which are shown or hidden to generate each possible numeral.  These polygons have tiny gaps separating them.  Also a slight rounding is applied for aesthetics.  We start by drawing a rectangle 1/2 in. wide by 1 in. tall.  Then we use the Offset command found in the Shape > Operations menu to create two additional rectangles 1/16 in. away from the original shape.  The outermost rectangle is not needed, so it is deleted.  We select the remaining two rectangles and use the Subtract command from the Shape > Operations menu to create a single shape with its middle removed.

     

     

    The crossbar is added by drawing a rectangle 1/2 in. wide by 1/16 in. tall and positioning it in the center of the existing shape.  A composite shape is created by selecting both shapes and choosing the Union command from Shape > Operations.  Note that commands such as Union and Subtract destroy the selected shapes and generate a brand new shape with the composite geometry.  For this reason, you should create the geometry of a shape before moving on to other aspects like formatting or behavior.

     

     

    Next we need to segment the shape into seven pieces with small gaps in between.  We draw lines in the places where we want the gaps to be located.  The lines extend beyond the shape geometry to facilitate the next shape operation.  Getting the lines in exactly the right place may require zooming in very close.  Otherwise Visio’s snapping behavior may prevent you from placing your cursor where you want it.  Once all the lines are drawn they need to be selected.  This is accomplished by selected all the shapes and then Shift+clicking on the digit shape to deselect it.  Then the Offset command is run with a spacing of 0.015 in.

     

     

    The offset lines serve as break points where the underlying digit shape must be segmented.  The segmenting is done using the Fragment command in Shape > Operations.  This command uses all the selected geometry to define simple closed polygons.  We can apply a green fill to the resulting shapes to better see them.  The inside squares are deleted first.  Then the tiny corner polygons are deleted, leaving only the seven segments for our digit.

     

     

    We now have seven individual shapes that make up our digit.  By selecting the shapes and choosing the Combine command in Shape > Operations, the seven shapes are converted into a single shape containing seven geometry sections.  This is a much more compact representation of the digit - decreasing file size and improving performance.  Corner rounding of 0.02 in is applied to the shape as a final touch.

     

     

    While there were several steps to get to the end result, we never had to do any complicated drawing or Shapesheet formula entry to construct this shape.  Two rectangles were drawn for the basic digit outline.  Then eight lines were drawn to define break points for the segments.  Visio’s shape operation commands did the rest of the work.  In the next post, we’ll add some smarts to this digit shape and use it to build up our digital clock.

     

     

  • Visio Insights

    ScreenTips to HTML

    • 5 Comments

    Today is a holiday in the US, so we're republishing this topic from a newsgroup post not too long ago.

    Summary:
    You can add the User.visEquivTitle cell to your shape and provide a string
    that will display as a tooltip in HTML web output.  The shape must also have
    at least one custom property for the tooltip to be visible.

    Steps:
    1) Select the shape in your drawing that you want to add a web tooltip for
    2) Go to Window > Show Shapesheet
    3) Go to Insert > Section, check User-defined cells and click OK
    4) In the newly created section, click on the row name User.Row_1 to select
    the title of the row
    5) Type visEquivTitle and press Enter - you should now see
    User.visEquivTitle for the row
    6) In the Value cell of that row, enter the text you want to display
    surrounded by quotes (e.g. "Hello World")
    7) If you instead want to display the same tooltip as the Shape ScreenTip
    enter  =Comment    (no quotes)
    8) Go to Insert > Section, check Custom properties and click OK
    9) You can fill in the custom property Label and Value if you want this
    information to be visible
    10) If you don't want the custom property to be visible, enter TRUE in the
    Invisible cell
    11) Close the Shapesheet window and repeat for any other shape you like
    12) Choose File > Save as Web Page to create the HTML output

    As you can see this is a bit involved.  The capability was designed more as
    a developer feature than an end user feature.  We recommend tying the Shape
    ScreenTip to the User cell so that you see the same tooltip in both Visio
    and the web output.  It should also be possible to use Macro Recorder to
    automate these steps.  If your shape has a custom property but does not have
    the User.visEquivTitle cell, Visio will display the shape's text in a
    tooltip instead.

     

  • Visio Insights

    Make Your Own Bubble Chart, part 1

    • 1 Comments

    In the previous post we introduced the Bubble Chart diagram and demonstrated a quick way to create one using the BubbleChart.vss stencil.  This stencil was custom-built for the blog, so grab the file attachment from the previous post.  Now we build the stencil from scratch to understand how to integrate Visio 2007's Data Connectivity features with shape design.

     

    Bubble chart 

     

    There are two shapes in the BubbleChart.vss stencil: Bubble Chart and Bubble Data.  Bubble Chart is the background shape that defines all the parameters of the chart.  Bubble Data is the circle shape added for each row of data displayed.  There's a third player that is critical to making the bubble chart work without the need for code - the Page.  In this solution the Bubble Data shapes do not have to know anything about the Bubble Chart shape.  The page acts as the central property store for the chart, avoiding any messy configuration between the chart and the bubbles.

     

    First, we create the stencil.  Launch Visio and create a new blank page.  Then create a new blank stencil.  Right-click in the Shapes window and choose New Master.  Enter Bubble Chart and click OK.  Right-click again to create a new master shape called Bubble Data.  Go ahead and save the stencil to name it BubbleChart.vss.

     

     

     

    Now we flesh out the Bubble Chart master shape.  Double-click the shape in the Shapes window.  We start with the page itself.  The page will store all the parameters needed for the chart.  Any page properties added here will be replicated on the drawing page once the master shape gets dropped.  Go to Window > Show Shapesheet to edit the Pagesheet - the Shapesheet for the page.  Next go to Insert > Section.  Choose User-defined cells then click OK.

     

     

     

    Scroll down to find the newly added section.  We need to store nine property values.  Right-click and choose Insert Row eight times.  Now we can name each property by clicking on the red row heading and typing.  Enter the nine property names and some default values as shown in the picture.

     

     

     

    Let's look at the properties we're defining.  The chart has an X axis and a Y axis.  For each axis there is a minimum value and a maximum value.  The first four properties will be set by the user.  These are the ranges that will correspond to their data.  The second four properties describe the location of the chart on the page.  They are set by the BubbleChart shape.  Note that the values of these properties have a measurement unit.  Both sets of four properties describe the same points - one from the user's perspective and one from Visio's.  The last property is the size factor.  We need to know how big to make each bubble on the chart.  The size factor is a simple way to record a scale.  Using the default value 10 as an example, a bubble with a Size of 10 in the data set will have a diameter of 1 inch in the chart.

     

    Now that the page is set up, let's make the chart shape itself.  Close the Shapesheet window for the page and draw a rectangle.  Then go to Window > Show Shapesheet to open the rectangle's Shapesheet.  There are several things to do here.  We need to capture some chart information from the user.  This will be done through Shape Data.  Other information comes from the shape itself.  We'll use User-defined cells to track this information.  Go to Insert > Section and check the User-defined and Shape Data boxes, then click OK.

     

     

     

    We need four User-defined cells to store the page coordinates related to the chart boundaries.  Add three more rows using right-click > Insert Row.  We'll use the same row names as in the Pagesheet.  Next we need to enter formulas to calculate the values from the shape transform.  The bottom left corner of a shape can be found by taking the shape's Pin and subtracting its LocPin.  This is done for both X and Y.  The upper right corner can then be found by adding the shape's Width or Height the minimum values.  So we know the page coordinates for the chart, but we need these to be stored in the page not the chart shape.  We use the function SETF to push the values to the matching User-defined cells in the Pagesheet.  SETF takes two parameters.  First comes a reference to the target cell, which is retrieved using the GETREF function.  Second is the value to be pushed, which is the chart page coordinates.  Enter the row names and formulas as shown in the picture.

     

     

     

    The remaining properties are stored in seven Shape Data rows.  Right-click in a Shape Data row and choose Insert Row six times.  The first four rows will match the Pagesheet names for the data ranges.  Then we add two new rows for X and Y axis labels.  The final row matches the size factor property from the page.  In the Shape Data section, the Label column stores the friendly text that appears in the Shape Data dialog.  The Type column specifies the data type.  Enter 2 for the numeric properties and 0 for the string properties.  Again we need to push the values to the User-defined cell s in the Pagesheet.  In this case SETATREF is a good choice.  The function essentially forwards any value entered to the cell referenced in the function.  Enter the Shape Data information as shown in the picture.

     

     

     

    To prompt the user to fill in the Shape Data properties when the shape is dropped, we use a little trick involving the SETF function.  Normally you just need to set the Ask property in a Shape Data row to pop up the Shape Data dialog on drop.  However, Ask will display the dialog when the shape is either dropped or copied.  In our case, we would prefer not to see the dialog on a copy because the properties are already set.  An alternate mechanism is to put a formula in the EventDrop cell of the shape.  Scroll down to find the EventDrop cell in the Events section.  DOCMD(1312) is the command code for the Shape Data dialog.  This command will fire when the shape is dropped.  To prevent further events from triggering the dialog, SETF is called.  We set a zero in the EventDrop cell itself.  Thus the formula can wipe itself out.

     

     

     

    At this point we have all the functionality of the Bubble Chart shape defined.  In the next post, we complete the master shape by adding labeling.

     

     

  • Visio Insights

    How It All Began

    • 3 Comments

    We're going to wrap up our look at Visio's essential features with the most significant innovation of all - the SHAPE.

     

    Essential Feature: Shapes

    A central concept in Visio is assembling a diagram from a pre-packaged set of content.  Users do not need to construct drawings from scratch using geometric primitives, nor do they need to be artists to draw great-looking symbols.  You only have to find a shape in one of Visio's stencils and drag it into the drawing.

     

    Visio shapes differ from Clip-Art in three important ways:

     

    ·         Shapes are vector-based graphics meaning that they size and scale well (yes, some Clip-Art is vector-based too).

    ·         Shapes can have behaviors that control their appearance or interactivity with the user. 

    ·         Users can customize shapes or build new ones from scratch to easily create new content. 

     

    We refer to Visio's content as SmartShapes because they react in an intelligent manner when you manipulate them in a diagram.

     

    There are many, many things to say about designing and using shapes in Visio, but for now let's look at one shape in particular.  Looking back at the history of Visio, you could say it all began with a single SmartShape - the block arrow.

     

     

    If you want to see an example of this shape in the current product, open the Basic Shapes template (File > New > Block Diagram > Basic Diagram) and drag out the 45 degree single shape from the Basic Shapes stencil.  There are two special behaviors on this shape.  First, you can stretch the width of the arrow without affecting the size of the arrowhead.  Second, you can control the size of the arrowhead by changing the height of the shape.  These behaviors preserve the 45 degree angle of the arrowhead across a wide range of shape sizes.

     

     

    Compare this resize behavior to a standard symbol.  Every arrowhead has a different angle.

     

     

    How does this work?  Every Visio shape is actually a collection of properties that are defined using parametric expressions.  Unlike many objects that have properties with static values, a Visio shape has properties with either a static value or a dynamic value that is calculated from a formula.  Other shape properties are often used as parameters in the formula, and that gives the shape its behavior.  For example, I can make a rectangle whose Width property is a function of Height.  If I set Width = Height * 2, then I have made a behavior that changes the Width automatically whenever the user adjusts the Height of the shape.

     

    Visio shapes have hundreds of properties, each of which can have a formula.  These properties are organized into a spreadsheet interface called the ShapeSheet.  Just as in a spreadsheet, the properties are called Cells in the ShapeSheet.  Cells are organized into rows, columns and sections.  See for yourself.  Select the arrow shape on the page and choose Window > Show ShapeSheet from the menu.  The ShapeSheet Window opens, showing you the real power behind shapes.

     

     

    If you look at the ShapeSheet for the 45 degree single arrow shape, you can see some of the parametric formulas that give this shape its special behaviors.  The 1-D Endpoints section tracks the current begin and end points of the arrow.  The Shape Transform section has formulas that depend on the endpoints.  For example, the Width of the shape uses the Pythagorean theorem to compute its value from the endpoints.

     

    The Geometry section lists the points that make up the line segments you see on the screen.  If you tile the drawing window and ShapeSheet window together (Window > Tile), you can select a cell in the Geometry section and Visio will highlight that point on the arrow in the drawing window.  Notice that all these points are expressed in terms of Width and Height and also a pair of Scratch cells.  The smarts behind this arrow shape are found in the Scratch.X1 cell.  This cell has a formula that determines the correct size of the arrowhead in order to maintain a 45 degree angle.

     

    One of the best ways to learn how to make shapes is to look at the ShapeSheets of existing Visio shapes.  You can see the formulas those shapes use.  You may just need to customize an existing shape slightly to make the SmartShape you want.  There are thousands of shapes that ship with Visio.  Or you may want to make a shape from scratch incorporating behaviors you discovered in other shapes.  The ShapeSheet is a powerful tool that Visio exposes to all users so that they can create shapes that have the visual appearance users need and behaviors that make diagramming with them easy.

     

  • Visio Insights

    Visio 2007 Service Pack 3 Available

    • 2 Comments

    The Service Pack 3 (SP3) update for Visio 2007 is now available. It includes a variety of new security, stability and performance improvements as well as all previous updates and hotfixes released through August 2011. The SP releases are cumulative, so it is not necessary to apply any earlier service pack releases to get all previous updates.

    A number of issues that have been addressed in previous hotfixes are included in this SP. The most significant of these are:

    • Corrected an issue that caused fonts in to lose formatting in Organizational Charts when text was edited
    • Corrected an issue that caused Visio to crash when opening certain VDX drawings
    • Corrected an issue that caused Visio VBA projects to intermittently save incorrectly in Windows XP.

    A full list of addressed issues can be found at http://support.microsoft.com/kb/2526291.

    Fix for Bluetooth add-in crashes

    This service pack also addresses an issue involving Bluetooth add-ins which could cause recurring crashes in some machines running specific versions of a Bluetooth add-in. These add-ins are commonly installed by default on new laptops and PCs.

    If a Bluetooth “Send to Office” add-in is installed, Visio may crash at the start of a session, during copy/paste, or on exit. This crash is often frequent and persistent on affected computers and may prevent use of Visio.

    In order to correct this problem, Visio 2007 SP3 moves any Bluetooth add-in to the disabled add-ins list, and the add-in is not re-enabled in subsequent sessions. Once a Bluetooth add-in has been moved to the disabled add-ins list, the “Send to Office” functionality is disabled and no longer available. A disabled Bluetooth add-in can be re-enabled manually or manufacturers can override the disabling code during the installation to prevent the Bluetooth add-in from ever being disabled.

    Detailed instructions to re-enable or override this behavior can be found at http://support.microsoft.com/kb/2621762.

    SP3 Downloads

    The Visio SP3 and instructions for installation can be found at http://support.microsoft.com/kb/2526291.

    Thank you for your continued feedback on Visio. If you have additional comments for the product team, please add them below or e-mail us a message.

  • Visio Insights

    Themes and Live Preview in Visio 2010

    • 2 Comments

    In Visio 2007, we introduced the Themes feature to make it easy to apply a professionally designed look to a diagram. In Visio 2010, the Themes feature gets a whole new user interface that takes advantage of the Office Fluent UI. The theme choices are displayed in a gallery on the Design tab in the ribbon.

    Themes

    An improvement over Visio 2007 is that you can apply both theme colors and effects with one click on a thumbnail in the main Themes gallery, instead of having to visit two separate task panes. Each thumbnail is a pairing of a color scheme from the Colors gallery and an effect scheme from the Effects gallery.

    As in Visio 2007, the color schemes include colors for text, fills, lines, connectors, shadows, and backgrounds, as well as a collection of five accent colors. The effect schemes include the font used in text, as well as formatting for the fills, lines, connectors, and shadows.

    If none of the theme pairs in the main gallery are to your liking, you can choose from any of the schemes in the Colors or Effects galleries, which are located next to the main gallery.

    image

    As in Visio 2007, you can also click “Create New Theme Colors” or “Create New Theme Effects” at the bottom of the gallery to create your own custom theme.

    Live Preview

    Themes is one of the features that demonstrate the Live Preview capability of the Office Fluent UI. As you move the cursor over each thumbnail in the gallery, the theme’s formatting is previewed on your diagram. This lets you quickly experiment with various looks without forcing you to commit to the change. If you don’t click on anything, the diagram reverts back to whatever was applied before the preview.

    image 

    Live Preview helps break the repetitive “Undo” cycle of applying formatting to content, deciding against the formatting change, choosing Undo to return to the original formatting, and then starting the cycle all over again.

    Live Preview is available for many other galleries and menus in Visio 2010. Another feature that makes good use of it is the Containers feature discussed in an earlier post. When you move the cursor over the various container designs in the Container gallery on the Insert tab, the container style is previewed on the selected shapes so you can see what it would look like if applied.

    Insert Container

    If you’re running the Visio 2010 Technical Preview, check out the new Themes user interface and Live Preview and let us know what you think via Send a Smile or a comment on the blog.

  • Visio Insights

    Visio 2003 Service Pack 3

    • 2 Comments

    Microsoft has released Service Pack 3 for the Visio 2003 product.  You can download the pack here:

    http://www.microsoft.com/downloads/details.aspx?FamilyId=E6B77D9A-0749-41CE-BD1A-9BF73718593C&displaylang=en

    (If English is not your install language, you can change to another one on the web page.)

     

    Contents

    The set of changes is described here:

    http://support.microsoft.com/kb/938794/ 

    The majority of the changes in this release are security and reliability related as Visio 2003 gets much of the same hardening that has gone into more recent versions.  There are also a number compatibility fixes to help Visio 2003 work with newer products such as IE7, Vista, SQL 2005 and even Visio 2007.

    In particular the hyperlink problem with IE7 as described in this previous post has been corrected.

    This update also applies to those running Visio for Enterprise Architects in Visual Studio 2005.  A number of fixes have been made to the Software / Database functionality that resides in Visio Professional as well as VEA.

    And finally no update to Visio 2003 would be complete without addressing a printing problem.  Visio 2003 has had more than its fair share of printing issues.  SP3 fixes a problem with very long plotter pages.

    This is a beefy download at 48MB but definitely recommended.

     

  • Visio Insights

    Working with ResizeMode

    • 2 Comments
     

      In this post, we take a break from Visio 2007 information and explore a peculiar shape design issue.  If you have worked with Groups in Visio, you have probably encountered a situation where the shapes inside of a group just don't behave properly during resize.  Sometimes you want shapes inside a group to resize with the group.  Sometimes you don't.  Visio provides a setting to control the resize behavior, but you may be surprised how it works.  Enter ResizeMode.

       

      ResizeMode is the name of the Shapesheet cell that controls shape resize within groups.  This is presented as Resize Behavior in the Format > Behavior dialog.  There are three possible settings for the resize behavior: Scale with group, Reposition only and Use group's setting.

       

      Format > Behavior dialog 

       

      A shape inside a group will have one of these three settings.  Really there are just two behaviors (scale & reposition), with the third setting just deferring up to the group for its value.  The default setting is Use group, which in turn defaults to Scale.  So how does Scale and Reposition affect the resizing of shapes inside a group?

       

      Resize behaviors 

       

      Scale allows the shapes inside the group to stretch as the group stretches.  Reposition maintains the original size of the shapes but moves their center as the group stretches.  Sounds straightforward enough, so what's the catch?

       

      The catch is that ResizeMode only works when used BEFORE a shape is grouped.  When a shape is put into a group, Visio uses ResizeMode to determine what formulas get applied to the shape to make it resize with the group.  Changing ResizeMode later on has no effect on the resize behavior.  Thus it is quite likely that users change the setting and then get frustrated when nothing happens.  It's just not a good design.

       

      Here is the Shapesheet view of what is happening.  ResizeMode is a cell in the Shape Transform section.  The default is 0 (Use group's setting).  Reposition only is 1.  Scale with group is 2.  Below is the Shapesheet for a shape before it is grouped.

       

      Shapesheet 

       

      Below is the Shapesheet of a shape with ResizeMode = 1 that is then grouped.  Notice that the Width and Height formulas are untouched, but the PinX and PinY depend on the group.  This is the Reposition behavior.

       

      Shapesheet - Reposition 

       

      Below is the Shapesheet of a shape with ResizeMode = 2 that is then grouped.  Notice that Width and Height now depend on the group.  This is the Scale behavior.

       

      Shapesheet - Resize 

       

      Changing ResizeMode in the Shapesheet and in the Format > Behavior dialog has no effect on these formulas.  The setting only comes into play at the time the shape is added to a group.  Visio has some work to do to clean up both the design and the documentation for ResizeMode.  Hopefully this article explains what is really happening.

       

  • Visio Insights

    The Office Fluent UI in the Visio 2010 Technical Preview

    • 8 Comments

    The Visio 2010 user interface has been completely revamped this release based on the Office Fluent or “Ribbon” UI. The Office Fluent UI represents a dramatic departure from the overloaded menu and toolbar design model of previous Visio releases. Visio’s extensive capabilities are now organized into logical, easy to find groups that help you accomplish tasks efficiently rather than choosing features.

    There are several design elements that comprise the Office Fluent UI.

    The Ribbon replaces menus and toolbars as the place to find functionality organized to help you accomplish tasks. You’ll find the many features that Visio 2010 has in common with other Office applications on Ribbon tabs of the same name.

    Here’s a brief breakdown of each of the core tabs across the Visio 2010 Ribbon.

    The Home tab contains the most common and frequently used drawing tasks and tools: cut/copy/paste from the clipboard, formatting text and shapes, drawing tools, and shape arrangement.

    image

    The Insert tab is where you introduce new elements into a drawing: pages, pictures, clip art, CAD drawings, as well as new Container and Callout shapes.

    image

    The Design tab includes everything you might change for an entire page: page orientation and size, themes, backgrounds, borders and title blocks, layout commands, and connector styles.

    image

    The Data tab provides everything you need for linking external data to drawings and shapes, displaying that data with data graphics, and generating legends to show the meaning of data graphics.

    image

    The Process tab includes functionality focused on the creation of business process diagrams: simplified creation of subprocesses, validation of diagrams based upon defined rules, import and export of SharePoint workflows.

    image

    The Review tab includes proofing and language tools as well as functionality for inserting and managing comments and other markup when reviewing diagrams.

    image

    The View tab is where all drawing and visual aids that assist diagram creation, such as rulers, grid, AutoConnect, and Dynamic Grid are turned on or off.

    image

    At the bottom of the application window is the new Status Bar. The right side of the Status Bar includes convenient controls for quickly adjusting the zoom level of the Visio drawing, switching into Full Screen mode, or switching between open drawings.

    image

    The left side of the Status Bar includes status items related to what you’re working with. Beyond merely showing status, these items help you take actions. For example, if you need to set the width of a shape, simply select it and click on the Width status item. The Size & Position window is opened with the Width value already selected.

    image

    In the upper left corner of the application window is the Quick Access Toolbar, into which you can add the commands you use most frequently, eliminating the need to switch to the Ribbon tab on which they are located while creating diagrams.

    image

    This post is merely an overview of the primary Office Fluent design elements you’ll see in Visio 2010 Technical Preview. Stay tuned for future posts that will explore the new design in greater detail.

    We're interested in your feedback on the new Office Fluent UI design in Visio 2010 Technical Preview, so use the Send a Smile feedback tool or comment on the blog to let us know what you think.

  • Visio Insights

    Update: Visio 2007 Service Pack 2 and Visio Conference 2008

    • 2 Comments

    A few updates…

    XMI Export

    We recently reported the availability of Service Pack 2 (SP2) for Visio 2007.  We received a few questions about how to use the XMI export feature in UML diagrams.  The behavior in SP2 is exactly the same as in previous versions.  Integrating it into the UML solution and retiring the separate download should make life easier for everyone, including us!  The following VBA example demonstrates the interface:

    Application.Addons("UML Background Add-on").Run("/CMD=400 /XMIFILE=""C:\path\file.xmi""")

    The XMI export acts on the active document, so be sure to set that if your application session has multiple documents open.  If you’re not familiar with VBA, the extra quotation marks in the XMIFILE argument are used to escape the quote character – the value passed in must be wrapped in quotes.

    Visio Conference 2008 Videos

    Last year, we posted links to videos from the Visio Conference 2008, where we shared a few glimpses into the next version of Visio.  The links have changed – replace the visioconference2008 part of the URL with visio2008 to get to the video site.  Note that some of the videos are quite large and can take a bit to download.

  • Visio Insights

    User Interface Extensibility in Visio 2010

    • 3 Comments

    When Office 2007 was introduced, a new UI paradigm was adopted, and so was a new UI extensibility model, the RibbonX (Ribbon extensibility) model. RibbonX is a XML markup that allows developers to customize the Office UI. It enables 3rd party developers and solution providers to build custom tabs and groups on top of the Ribbon, and target scenarios unique to and optimized for their customers. As Visio 2010 adopts the Fluent UI, Visio developers now also have the opportunity to utilize this platform to build and customize Fluent UI to offer users a more discoverable and instructive UI experience.

    Existing Visio Solutions

    There are two existing mechanisms for UI extensibility in Visio: CommandBar and UIObject. Both would still work in Visio 2010: Visio 2010 automatically creates a new tab called “Add-Ins” with groups for these existing menu commands and toolbar commands and requires no extra work from developers. Here, as an example, we see a top-level menu item called Process Analysis.

    clip_image001

    In the Ribbon, this menu becomes a drop-down control that opens to show the menu commands. This automatically-generated tab and its controls require zero-effort for your solutions to migrate to the next release of Visio.

    Although the migration to ribbon can be zero-effort, this really is an ideal opportunity for solution developers to re-think their UI from a Ribbon perspective. The Ribbon provides contextually-relevant commands, and presents them in a way that is more results-oriented. Your UI can integrate more seamlessly with the rest of Visio, and look more like Office. Here is an example of how Visio 2010 reconfigured the Gantt Chart UI, allowing users to more easily discover commands and learn about them through controls of varying sizes, big icons and super tooltips:

    clip_image003

    Note, if you are using UIObject in your solution, we especially recommend upgrading to the ribbon. UIObject is a legacy Visio-specific model for defining UI and it may become deprecated in the future.

    RibbonX for Different Types of Add-in Technologies

    Depending on what add-in technology you were using, Visio provides a number of ways to import Fluent UI controls through RibbonX and improve users’ experience. Here is how you achieve that for each type of add-in technology.

    If you’re developing a Visual Studio Tools for Office (VSTO) add-in, you will have access to a visual Ribbon designer that provides a graphical construction environment, similar to other Visual Studio designers. Alternatively, you can specify your UI using RibbonX. Your add-in merely provides an override called CreateRibbonExtensibilityObject that returns an instance of your ribbon object. One-line, very simple to do.

    If you’re writing a shared COM add-in, in your Connect class (the class that implements IDTExtensibility), define an override called GetCustomUI that returns your RibbonX XML as a string. GetCustomUI is the single interface through which the Fluent UI communicates with a COM add-in. Two-to-three lines, still very simple to do.

    VSLs, or legacy Visio add-ons, may also use RibbonX. You add the RibbonX XML to your add-on’s resources. Your add-on defines the GetCustomUI callback and notifies the Visio Application that it has RibbonX XML by calling RegisterRibbonX.

    For VBA, you simply provide the contents of a RibbonX XML as a string directly to Visio through the CustomUI property.

    RibbonX and Visio XML file format

    The Visio XML file format (*.vdx) may also contain RibbonX. The RibbonX markup is stored inside a new element in the Visio XML schema, called, unsurprisingly, RibbonX. The customUI element is the top-level wrapper element in the RibbonX schema.

    clip_image005

    Since you can define custom UI directly in the Visio XML file, you have all the benefits of being able to read and write the file without Visio being present. For example, this enables an entire class of server-side scenarios where the server can not only manipulate diagram content, but can also make changes to custom UI in the document.

    Developing with Visual Studio 2010

    The recommended Visual Studio version to develop for Visio 2010 is Visual Studio 2010, which is currently available as Release Candidate. Visual Studio 2010 offers a friendly design environment with the Ribbon Designer, where developers can easily drag and drop ribbon groups and controls onto a graphical design canvas. Also, a Visio 2010 VSTO template is available for you to easily create a Visio add-in project. Multi-project deployment packages, post-deployment actions, and removing PIA dependencies are all benefits from using VS 2010. For more information on what’s new in VS 2010, see this MSDN article.

    Conclusion

    With Visio 2010 and the UI extensibility model available, you now have the opportunity to utilize our more intuitive attractive drawing surface to broaden your user base. We highly recommend moving existing solutions to the Fluent UI. It is worth the work to get rid of the old menu bars, and help your users realize the full capability of your solution by making it easier to use. For new and old solution developers alike, Visual Studio 2010 allows a great way to easily develop Fluent UI for Visio 2010 as well.

    To get more details about UI extensibility for Office 2010 applications, here are some helpful links:

    Microsoft Office 2010 Engineering blog

    UI Extensibility in Office 2010- Including details on customizing Office Menu and Backstage View

    MSDN documentation

    Office Development in Visual Studio 2010

    How to setup the Ribbon Visual Designer

    Ribbon best practices

    Do try implementing your own Visio ribbon and send us feedback through the Send a Smile feedback tool or comment on this post!

  • Visio Insights

    Visio 2010 Release Dates

    • 0 Comments

    Last week on the Office Engineering Blog, Microsoft confirmed the release dates for Visio 2010, Office 2010, SharePoint 2010, and Project 2010.

    We’re happy to announce that Visio 2010 and the rest of the Office suite will release to manufacturing (RTM) next month.

    • For businesses, Visio 2010 and the rest of the Office 2010 products will be available worldwide on May 12th.
    • For consumers, Office 2010 and Visio 2010 will be available online and on retail shelves this June. Until then, you can get the Visio 2010 Beta here

    Office 2010 Technology Guarantee

    Consumers who purchase and activate Office 2007 or Visio 2007 will be able to download corresponding Office 2010 or Visio 2010 products at no additional cost when they become available in June 2010.

    All you need to be eligible for this program – Office 2010 Technology Guarantee – is the following:

    • Purchase Office 2007 (or Visio 2007), or a new PC with Office 2007, and activate it between March 5, 2010 and September 30, 2010.
    • Have, or create a Windows Live ID.
    • Redeem your Tech Guarantee before October 31, 2010 by visiting www.office.com/techg .

    For more information about the Office 2010 Technology Guarantee, and to sign up for an e-mail reminder when Office 2010 is available, visit www.office.com/techg.

    As always, let us know in the comments if you have any questions or topics you’d like to see us discuss here in the future.

  • Visio Insights

    The World Cup Summarized as a Visio Diagram

    • 0 Comments

    WorldCup Congratulations to Spain for winning the 2010 World Cup! Now that the games are over and we’re all suffering through soccer withdrawal, here’s a recap of the world cup summarized as a Visio diagram. You can use this diagram as a reference to remember who eliminated who, and which group your team was in. You can also see some stats like who the top scorers were, and who received the most yellow cards.

    And as a bonus, you can view this diagram with Visio Services ! (If you don’t have a SharePoint server handy, you can see what Visio Services looks like).

    This diagram highlights one of the many ways you can use Visio to visualize information. We’ve seen people create intricate diagrams for all types of sports, like bracket diagrams for March madness, elaborate baseball diagrams, and classic Xs and Os for drawing up American football playbooks.

    As always, let us know if you have any feedback on Visio 2010, Visio Services, or suggestions for blog posts you would like to see.

  • Visio Insights

    CAD Integration in Visio - Part 1

    • 2 Comments

    Visio has long had the ability to display, import and export CAD drawings stored in the DWG and DXF file formats.  If you are unfamiliar with the ways that Visio can work with CAD drawings, please read through this previous post.

     

    In Visio 2003 the CAD feature set was overhauled to improve performance and reliability plus provide a better mapping of Visio shapes to CAD entities on Export.  There were changes in the CAD Display Properties and Conversion dialogs as well.  Unfortunately there were a number of serious bugs that impacted the functionality of the feature set.  A few items have been fixed in Visio 2003 service packs, but many more were addressed in Visio 2007.

     

    This post describes the problems in Visio 2003 that were corrected in Visio 2007.  The next post will discuss the remaining issues surrounding Visio's CAD integration.

     

     

    Insert CAD Drawing

    There are two ways to display a CAD drawing in a Visio document.  If you go to File > Open, you can point directly at the DWG or DXF file and open it.  Visio creates a new blank drawing, chooses a page scale that will fit the CAD drawing to the Visio page and adds the CAD drawing.  Another method is to start from an existing diagram and go to Insert > CAD Drawing.  Visio shows the CAD Drawing Properties dialog and allows you to specify the scale you want to use.  Unfortunately, there are several issues going this route in Visio 2003:

     

     

     

    ·         Visio defaults to a custom scale that fits the CAD object to the page, but this scale does not match the scale of the Visio page.  If you choose this default, the CAD object will be scaled incorrectly with respect to everything else in the diagram.  When inserting into an existing diagram you should always choose the current page scale.  The custom scale default is really only useful when you want to use the CAD drawing as an unscaled image in your diagram.

     

    ·         Since CAD drawings don't explicitly define what units of measure are used, you must specify the CAD drawing units in the dialog to properly scale the CAD object.  This can be confusing, and in Visio 2003 the setting doesn't work.  The value is ignored, resulting in improper scaling for CAD objects drawn in Metric coordinates.

     

    ·         For those who bravely tried to get the scale settings configured properly, there is one more problem:  The preview pane did not update as you made changes to the settings.  Thus the visual feedback about what you would get was also wrong.

     

    These issues combined to make Insert > CAD Drawing very challenging in Visio 2003.  Settings either didn't work or were configured improperly by default.   This created unnecessary confusion and frustration for customers.  Visio 2007 corrects these problems, although it is still the responsibility of the user to set the CAD drawing units properly to end up with the right scale.

     

    A note of caution for Visio 2007:  The CAD Drawing Properties dialog does not remember settings very well.  Once you close the dialog and reopen it, you will have to reset the Pre-defined scale to Page Scale again.  Also do not manually resize the CAD object using the green shape handles since this just distorts the scale.

     

     

    Export CAD Drawing

    Visio drawings are exported to CAD files using the File > Save As > DWG / DXF command.  If there is no existing CAD object in the drawing, Visio converts the Visio shapes to entities correctly.  If there is a CAD object in the drawing, Visio 2003 fails to use the proper scale to ensure that the converted Visio shapes match up with the existing CAD object's entities.  It also fails to position the converted shapes relative to the existing CAD entities.  Additionally any cropping or rotation of the CAD object is ignored in the exported file.

     

    Visio 2007 corrects most of the scaling and positioning issues.  There are a few cases with dimensions that still are troublesome.  Visio 2007 does not support cropping or CAD object rotation on export.

     

     

    Customer Input

    Many of the fixes in Visio 2007 can be credited to a group of customers that are passionate about Visio and its use with CAD drawings.  At the Visio Conference in 2006 the product team showcased the upcoming Visio 2007 version with its emphasis on data connectivity.  However, a number of partners and customers voiced concerns about the problems with CAD in Visio 2003.  In an ad-hoc meeting, we sat down with all interested parties to understand the issues and hear firsthand how important the feature is for these customers.

     

    Following the conference, the Visio team did an extensive review of the CAD feature set to uncover the bugs that were causing the most customer pain.  These issues were corrected in Visio 2007 and released as part of the Visio 2007 betas to have partners and customers verify the fixes.  The result is a significantly better experience in Visio 2007 over Visio 2003.  We weren't able to address all concerns though.  Next time we will look at the current state of CAD integration in Visio.

     

  • Visio Insights

    Creating Visio Add-ins with VSTO 2005 SE

    • 0 Comments

    There have been several newsgroup postings about using VSTO to create Visio Add-ins.  The deployment of these add-ins can be especially challenging.  There is a new developer article by Chris Castillo detailing how to write VSTO add-ins for Visio.  Chris explains why using VSTO is desirable and aggregates information from a number of sources to walk you through the development and deployment process.

     

    http://blogs.msdn.com/chcast/archive/2007/03/28/creating-visio-add-ins-with-vsto-2005-se.aspx.

     

     

  • Visio Insights

    Shape Conversion in Process Engineering

    • 5 Comments
     

      A recent newsgroup post asks for an explanation of the cells that get added to a shape when it is converted using the Process Engineering add-on. 

       

      The Shape Conversion command in Process Engineering allows you to make any shape work like the built-in Process Engineering shapes.  We recognized that customers who made Piping & Instrumentation diagrams often had custom equipment or valves or instruments that they needed to include in the diagram.  Shape Conversion modifies a custom shape to make it recognizable by the Process Engineering add-on and match the behaviors of built-in shapes.

       

      You can try this by drawing a rectangle and choosing Shape Conversion from the Process Engineering menu.  In the dialog, note that the shape Source is already set to Selected Shapes.  Process Engineering can also bring in shapes from other documents or CAD symbols.  Then comes the challenging part: you can optionally give the shape a Category and Tag Format.  Categories are used to organize the shape in the Component Explorer window.  You can choose an existing category or type in a new string.  Tag formats are used for automatically labeling and numbering shapes.  You must choose from an existing tag format.  Visio only offers you choices for Categories and Tag Formats that already exist in the drawing, so if you want your shape to be a piece of Equipment you should drop a built-in Equipment shape on the drawing before converting your custom shape.

       

       

      After clicking OK, you can open the Shapesheet window to see what changes were made to your shape.  The primary change is the set of User-defined cells added to the shape.  These cells identify the shape and control its behavior in the diagram.

       

       

      Here is a brief explanation of each cell:

      User.SOLSH

      A GUID (unique identifier) that tells Visio what add-on is managing the shape.  All shapes that are used with Process Engineering, need the GUID matching the Process Engineering add-on.

      User.ShapeClass

      The Category that the shape is assigned to.  The shape appears under this name in the Component Explorer.

      User.PEComponentTag

      The current tag name (label & number) for the shape.

      User.PETagFormat

      The Tag Format name and expression for the shape.  Unless the Component Tag has been overwritten, this is the automatically generated label displayed on the shape.

      User.PETagNumber

      The sequence number for the shape.  Visio updates this value when components are renumbered.  This value then feeds into the Component Tag.

      User.PEHideTag

      A Boolean value that determines whether the Component Tag is displayed on the shape.  This is manipulated by an Action in the Actions section.

      User.PEPageHideTags

      A value that references the global page setting for hiding tags.  If tags are hidden at the page level, then the local setting is ignored.

      User.PELayout

      This is a bit flag that controls the layout behavior of the components in the diagram.  Mostly these settings determine how the split and heal features in Process Engineering work.  Here are the bits:

       

      CAUSES SPLIT = 1 (Splits connector when dropped on connector)

      CAUSES HEAL = 2 (Heals connector when deleted)

      ALLOWS SPLIT = 4 (Connector splits when shape dropped)

      ALLOWS HEAL = 8 (Connector heals when shape deleted)

      ALLOWS JUNCTION = 16  (Connector to connector connection)

      JUNCTION IN USE = 32  (Temporary state)

       

      The default setting here is 31, which enables all the split and heal and junction behaviors.

       

      There are a few other changes to connection points, action cells and text to complete the conversion.  These are straightforward changes, and you can inspect the Shapesheet to see the details.

       

  • Visio Insights

    CAD Integration in Visio - Part 2

    • 8 Comments

    In the previous post we reviewed the problems users were encountering with the CAD Integration feature set in Visio 2003 and the fixes that were made in Visio 2007.  In this post we look at the remaining issues with CAD and Visio.

     

     

    Converting CAD drawings to Visio shapes

    Visio 2003 changed the way that CAD drawings are converted to Visio shapes.  Instead of converting each entity and adding it as a Visio shape, the entities are converted in bulk to an intermediate document and then the entire document is merged into the current drawing in one big Paste operation.  This change makes conversion up to 10 times faster – a significant improvement.  However, Visio now requires quite a bit more memory to accomplish the task.  On PCs without sufficient memory, performance degrades because Visio must page memory to disk. 

     

    Additionally we have found that some really large CAD files fail to convert.  There is a limit to the number of entities that can be converted at once, though this limit is not easily expressed as a quantifiable number.  Unfortunately the failure comes near the end of the lengthy operation rather than at the beginning.  Visio 2007 does not remedy this situation.  Your best bet is to divide up the diagram into more layers and then convert the layers individually.  While Visio should handle this situation better, keep in mind that CAD programs are designed to deal with hundreds of thousands of simple entities and Visio is designed to deal with thousands of complex entities.  It's difficult to scale up to support the largest CAD drawings out there.  Simplifying the drawing before bringing it into Visio is recommended.

     

     

    DWG file formats supported by Visio

    A frequent complaint from users is that Visio refuses to open a DWG file because it was saved in a newer format.  Visio 2003 and 2007 do not support the latest file formats used in AutoCAD programs.  That means CAD files must be saved back to a compatible version before they can be used with Visio.  Visio 2003 and 2007 support the R15 version of the DWG format.  This was the default format used by AutoCAD 2000 and AutoCAD 2002.  Newer versions of AutoCAD save to newer versions of the DWG format by default.

     

    Additionally, Visio does not support all the entities defined in the R15 version of the DWG format.  In terms of entity support, Visio handles the entities defined in the R14 version of the DWG format with a few exceptions.  A specific entity list is beyond the scope of this blog post.  The point is that the level of entity support and the version of the file format supported are not identical.

     

    Note that there was a specific problem where files saved out from AutoCAD 2007 would not open in Visio 2007 even when saved back to the R15 format.  This was corrected in Visio 2007 SP1.

     

     

    What's next for CAD integration 

    It's too soon to announce our plans for the next release.  We continue to gather information from customers about their needs for CAD with Visio.  Your input on specific issues or the overall importance of CAD integration to your Visio usage is encouraged.

     

     

  • Visio Insights

    What’s in a (File)Name?

    • 3 Comments

    This is the second topic in a series discussing the essential features that make up the Visio application.

     

    Essential Feature:  Drawings, Stencils and Templates

    In the previous post on Drag and Drop, we mentioned that Stencils were separate documents from the drawing and thus Visio has to make a local copy of a master shape when you drag one onto the page.  So what is the difference between a stencil and a drawing?  And what about templates?

     

    Actually, there is very little difference between these three types of Visio documents.  That's because there is really only one document type in Visio.  Drawings, stencils and templates are the same technically.  The difference is in the “view” of the document information presented to the user.

     

    Try this: make a simple flowchart by starting from the Basic Flowchart template.  Drag some shapes onto the drawing page from the Basic Flowchart Shapes stencil.  Save the drawing as MyDrawing.vsd and exit Visio.  Now rename the file, changing the extension from 'VSD' to 'VSS'.  Reopen the drawing in Visio.  What do you see?  You should see a stencil with just the master shapes you dragged into your drawing.  Close Visio and change the extension to 'VST'.  Now what do you see when the file is reopened?  You should see your drawing but with a generic filename like Drawing1.

     

    What's going on?  Every Visio document has a drawing surface - the page that you drop shapes on.  Every document also has a stencil containing masters, called the Document Stencil.  The file extension tells Visio whether to open a document showing the drawing surface or the stencil.  You can see the Document Stencil for your drawing by choosing File > Shapes > Show Document Stencil.  Templates are just like drawings.  The only difference is that Visio will open a template as a copy of the original document by default.  This explains the change in filename.

     

    Another part of a Visio document is the workspace information.  Whenever you save a drawing, Visio records the names of the stencils that were opened with your drawing.  These stencil documents are automatically reopened the next time your file is reopened.

     

    Those of you who are familiar with Visio's file format history know that there are now two sets of Visio file extensions.  VSD, VSS and VST are the drawing, stencil and template extensions for Visio's binary document format.  There is a companion set of VDX, VSX and VTX extensions for Visio's XML document format.  The XML document format is a full fidelity peer of the binary format that was introduced in Visio 2002.  The XML formats offer an under the hood view of the contents of a Visio document.  They allow developers to write programs that build new drawings from scratch or read the contents of a drawing – all without having to launch the Visio application.

     

    Try saving out a drawing as XML and then opening the file in a text editor.  You can rename the file to give it a .XML extension and view it in Internet Explorer too.  There is a lot of information, but if you dig around you'll find the Masters collection that makes up the Document Stencil and the Pages collection that makes up the drawing.  You may even find the workspace information.

     

  • Visio Insights

    Container, List and Callout API in Visio 2010

    • 4 Comments

    This post examines the programmability features for Containers, Lists and Callouts in Visio 2010.  It supplements an earlier post that describes how these special shapes are constructed and how they can be customized.  Collectively these shapes are known as Structured Diagram elements, and the part of the Visio API that manages these elements is known as the Structured Diagram API.  This API enables developers to use Structured Diagram elements in their solutions.  Developers can identify the relationships between these elements and other shapes, they can add or change the relationships with other shapes, and they can detect when the user makes changes to the relationships with other shapes.

     

    Structured Diagram API Overview

    Here are the key objects, properties and methods in the Structured Diagrams API:

    image

    There are two new objects in the API.  ContainerProperties is an extension of the Shape object.  It encapsulates the special properties and behaviors of containers and lists.  RelatedShapePairEvent is an object used with the Structured Diagram API events, where Visio can describe a relationship being formed or broken between two shapes.  The remaining parts of the API are additions to existing Visio objects.

    Note that lists are just another type of container as far as the API is concerned.  Therefore, lists use all the same objects, properties and methods as containers; and lists have a few additional properties and methods as well (those with “List” in their name).

     

    Enabling Structured Diagram Behaviors in Solutions

    Visio 2010 introduces a new feature called Diagram Services that manages what diagramming behaviors are enabled in the document.  There are diagram services that control the behavior of Auto Size Page and diagram services that control the behaviors of Containers, Lists and Callouts.  These services are turned on and off at the document level.  When a service is off, changes made in the diagram through automation will not trigger the diagramming behaviors related to that service.  (Changes made through the user interface are not subject to the diagram service state.)

    For example, the Auto Size Page feature will normally grow the page size if a shape is placed outside the page boundary.  However, when a shape is placed outside the page via automation, the Auto Size Page feature will only respond if the Auto Size Page diagram service is enabled.  Similarly, dropping a shape on top of a container will normally make it a member of the container and cause the container to resize to fit it.  However, when the shape is dropped via automation, the Containers feature will only respond if the Structured Diagram service is enabled.

    The reason Visio 2010 includes this capability is that solutions may not always want these diagramming behaviors to get triggered while they are manipulating shapes in the diagram.  This may especially be true for existing solutions that have no knowledge of the new Visio 2010 behaviors and have expectations that shapes respond in ways consistent with Visio 2007.  In order for existing solutions to work as originally designed, all diagram services in Visio 2010 are disabled by default.  Solutions must opt the document in to the new diagramming behaviors.  Note that diagram service states apply to automation properties and methods that existed in Visio 2007.  When a new Visio 2010 automation method is explicitly invoked by a solution - such as any of the examples below – the service state is ignored.  The presumption is that the solution wants the Visio 2010 behavior associated with that method.

    Diagram service states are checked or changed using the Document.DiagramServicesEnabled property.  The value of this property is a mask of all the services currently enabled.  Available services and values are listed in the table below.  It is possible for a solution to opt into just one service, all the services supported in Visio 2010, or even all existing and future services.

    VisDiagramServices values:

    Enum Value Description
    visServiceAll -1 All diagram services
    visServiceVersion140 7 Diagram services that exist in Visio 2010
    visServiceNone 0 No diagram services (default)
    visServiceAutoSizePage 1 AutoSize page behaviors
    visServiceStructureBasic 2 Behaviors that maintain existing Structured Diagram relationships but do not create new relationships
    visServiceStructureFull 4 Structured Diagram behaviors that match the behaviors in the user interface

    There are two services for Structured Diagram behaviors.  The StructureBasic service maintains relationships but will not form new ones.  This might be appropriate for a solution that wants to respect the user’s usage of Containers, Lists and Callouts but does not want the solution itself to inadvertently form relationships when shapes are moved around the page.  The StructureFull service maintains relationships and will form new relationships as well.  This matches the behaviors that are triggered in the user interface.  If both services are enabled, then Visio uses the StructureFull set of behaviors.

     

    Common Tasks with the Structured Diagram API

    Let’s look at some typical Structured Diagram tasks to explore the API in greater detail.  For a complete list of the special flags that can be passed into the methods, look at the Object Browser within the VBA editor in Visio.

    Add a container to the page

    Containers can be added to a page by calling the traditional Page.Drop method, which will add the shape at coordinates you specify without affecting the membership of existing shapes on the page.  However, there is a new Page method – Page.DropContainer - that will not only drop the container but will also size it around a set of shapes and make those shapes members of the container.  This is the behavior in the UI when using Insert > Container when a selection exists.  DropContainer needs an object for the container shape.  If you want to use one of the shapes in the Insert Container gallery, you can use the GetBuiltInStencilFile method to retrieve the hidden stencil where these containers are stored.

    Dim vsoDoc1 As Visio.Document
    Set vsoDoc1 = Application.Documents.OpenEx(Application.GetBuiltInStencilFile(visBuiltInStencilContainers, visMSUS), visOpenHidden)
    Application.ActivePage.DropContainer vsoDoc1.Masters.ItemU("Container 1"), Application.ActiveWindow.Selection
    vsoDoc1.Close

    Add a shape to a container

    Shapes are added to a container by moving or dropping them onto the container (if the StructureFull diagram service is enabled).  Shapes can be explicitly added to a container using the AddMember method.  This is useful when the shape already overlaps the container and is not yet a member.  It is also helpful if you want to force the container to expand to encompass the new member.

    vsoContainerShape.ContainerProperties.AddMember vsoShape, visMemberAddExpandContainer

    Find the containers on a page

    To discover what containers exist in a document, Visio provides a direct way to get the set of containers in a selection or on a page.  The GetContainers method returns an array of Shape IDs for the containers.  Containers nested within other containers can be included or excluded using flags.

    For Each containerID In vsoPage.GetContainers(visContainerIncludeNested)
        Set vsoContainerShape = vsoPage.Shapes.ItemFromID(containerID)
        '...
    Next

    Get the shapes in a container

    Solutions can identify the members of a container using the GetMemberShapes method, which returns an array of Shape IDs for the member shapes.  The flags allow certain kinds of member shapes to be filtered out of the array returned.

    For Each memberID In vsoContainerShape.ContainerProperties.GetMemberShapes(visContainerFlagsDefault)
        Set vsoShape = vsoPage.Shapes.ItemFromID(memberID)
        '...
    Next

    Reorder a list

    Every member of a list is placed in a specific position, and that ordinal value can be retrieved with the ContainerProperties.GetListMemberPosition method.  To reorder a member, you can call the ContainerProperties.ReorderListMember method.  Both methods use 1 to indicate the first position in the list.

    vsoListShape.ContainerProperties.ReorderListMember vsoShape, 2

    Add a callout to the page

    Callouts can be added to a page by calling the traditional Page.Drop method, which will add the shape at coordinates you specify.  However, there is a new Page method – Page.DropCallout - that will not only drop the callout but will associate it with a target shape and position it near the target shape.  This is the behavior in the UI when using Insert > Callout when a selection exists.  As with DropContainer, DropCallout needs an object for the callout shape.  If you want to use one of the shapes in the Insert Callout gallery, you can use the GetBuiltInStencilFile method to retrieve the hidden stencil where these containers are stored.

    Dim vsoDoc1 As Visio.Document
    Set vsoDoc1 = Application.Documents.OpenEx(Application.GetBuiltInStencilFile(visBuiltInStencilCallouts, visMSUS), visOpenHidden)
    Application.ActivePage.DropCallout vsoDoc1.Masters.ItemU("Callout 1"), vsoTargetShape
    vsoDoc1.Close

    Get the target shape for a callout

    A shape can have multiple callouts, but a callout can have only one target shape at a time.  The Shape.CalloutsAssociated property returns an array of callout shape IDs.  You can get or set the target shape of a callout using the Shape.CalloutTarget property.

    Set vsoShape = vsoCalloutShape.CalloutTarget

    Structured Diagram Events

    In addition to manipulating the containers, lists and callouts in a document, you can also respond to user actions that relate to these shapes.  Containers, lists and callouts work by establishing relationships with other shapes.  Visio fires an event whenever one of these relationships is formed or broken.  For example, adding a shape to a container forms a new relationship between the shape and the container.

    When a relationship event fires, Visio specifies the details in a RelatedShapePairEvent object.  The FromShapeID property of this object indicates the container, list or callout involved in the relationship.  The ToShapeID property indicates the other shape involved in the relationship.  Thus when adding a shape to a container, the ToShapeID would refer to the new member shape, and when associating a callout with a target shape, the ToShapeID would refer to the target shape.

    The following events are available for Application, Documents, Pages and Page event lists:

    ContainerRelationshipAdded

    ContainerRelationshipDeleted

    CalloutRelationshipAdded

    CalloutRelationshipDeleted

    Also the ShapeChanged event will now fire when members of a list shape are reordered.  The event passes the list shape as an argument and includes the string “/ListReorder” in the EventInfo argument.

     

    Feedback

    The Structured Diagrams feature set – Containers, Lists and Callouts – offers both end users and developers significant new diagramming capabilities in Visio 2010.  We’re interested to hear what developers think of this API functionality, so please use the Send a Smile feedback tool or leave a comment below.

Page 4 of 8 (181 items) «23456»