Visio Insights
The official blog of the Microsoft Visio product team

  • Visio Insights

    The Visio Services JavaScript Mashup API

    • 11 Comments

    Last week, we took a look at how to create interactive mashups with Visio diagrams without writing any code. If you need more flexibility in creating rich diagram mashups than offered out of the box by web part connections, you can use the Visio Services JavaScript Mashup API.

    In this post we'll review the breadth of possibilities by the Visio Services Mashup API and show you how to get started coding with a few simple examples.

    Overview of the Visio Services JavaScript Mashup API

    In a nutshell, the Visio Services JavaScript Mashup API enables developers to access and manipulate the Visio web drawing, its pages and shapes. Some key scenarios enabled by the Mashup API are:

    • Interacting with web page elements that don’t expose web part connections.
    • Creating visual markup on the Visio drawing canvas.
    • Writing custom handlers for mouse events within the drawing.
    • Exposing diagram data, such as shape name and shape data, to your solution.
    • Combining data from inside and outside a diagram to build dynamic composite mashups.

    Objects

    The class diagram below summarizes the available objects in the API. Notice that related class members are collected into functional groups – each group is discussed in more detail in the API in the appendix of this article.

    image 

    Events

    Like many JavaScript APIs, it's important to note that the Visio Services JavaScript API is event-based. To program against the Visio Web Access web part, you must catch the events it exposes by writing event handler functions. The diagram below is the state chart of VwaControl events:

    image

    Typically, when the onApplicationLoad event fires you'll want to get a reference to the vwaControl object and set-up handlers for ondiagramcomplete. Note that vwaControl is the only valid object in the object model until ondiagramcomplete fires. Then, when the ondiagramcomplete event fires you'll want to get a reference to the currently loaded page and set-up handlers for the various mouse events.

    Getting Started

    Now that you understand the object and event model of the API, let's get started coding. Before you can interact programmatically with a Visio Web drawing you must add a Visio Web Access web part to a web part page, load a VDW file into it and add a Content Editor Web part to the page to contain your JavaScript.

    To do so, assuming you have "Contribute", "Design" or "Full Control" permissions to a page in SharePoint Server 2010, you should:

    1. Create a drawing in Visio and publish it to SharePoint document library as a VDW file.
    2. Create a .JS file in any JavaScript editor and copy paste the following contents into it. Once you're done save it to the same document library as the drawing in step #1.
         1: <script language="javascript">
         2: // A hook into AJAX's Sys.Application.load event, raised after all scripts 
         3: // have been loaded and the objects in the application have been created 
         4: // and initialized.
         5: Sys.Application.add_load(onApplicationLoad)
         6:  
         7: // Global variables for the application
         8: var webPartElementID = "WebPartWPQ3"; //Change this to the appropriate web part ID. 
         9: var vwaControl;
        10: var vwaPage;
        11: var vwaShapes;
        12:  
        13: // Function Name:   onApplicationLoad()
        14: // Parameters:      None
        15: // Description:     This function handles the AJAX's Sys.Application.load event 
        16: //                  When this event fires the function captures references to 
        17: //                  the Visio Web Access web part object and registers 
        18: //                  the following Visio Web Access specific event handlers: 
        19: //
        20: //                  1. diagramcomplete: raised when the request for a web
        21: //                                      drawing page finishes.
        22: function onApplicationLoad() {
        23:     try{
        24:         vwaControl= new Vwa.VwaControl(webPartElementID)
        25:         vwaControl.addHandler("diagramcomplete", onDiagramComplete);
        26:     }
        27:     catch(err){
        28:     }
        29: }
        30:     
        31: // Function Name:   onDiagramComplete
        32: // Parameters:      None
        33: // Description:     This function handles the onDiagramComplete event which is
        34: //                  raised when a request for a web drawing page completes.
        35: //                  When the event fires, this function captures references
        36: //                  to script's global variables such as the current page, the
        37: //                  collection of shapes on the page. It also sets the page zoom to 
        38: //                  "fit page to view" to give a full view of the page to 
        39: //                  users and registers the following Visio Web Access specific 
        40: //                  event handlers:
        41: //
        42: //                  1. shapemouseleave: raised when the mouse enters a shape.
        43: //                  
        44: //                  2. shapemouseenter: raised when the mouse leaves a shape.
        45: //
        46: //                  3. shapeselectionchanged:   raised when the active selection
        47: //                                              is changed from one shape 
        48: //                                              to another.
        49: function onDiagramComplete() {
        50:     try {
        51:         vwaPage = vwaControl.getActivePage();
        52:         vwaPage.setZoom(-1);
        53:         vwaShapes = vwaPage.getShapes();
        54:         vwaControl.addHandler(“shapeselectionchanged”, onShapeSelectionChanged);
        55:         vwaControl.addHandler(“shapemouseenter” , onShapeMouseEnter);
        56:         vwaControl.addHandler(“shapemouseleave”, onShapeMouseLeave);    
        57:     }    
        58:     catch(err) {
        59:     }
        60: }
        61:  
        62: // Put the sample code discussed later in the blog below...
        63: </script>
    3. Edit the SharePoint page that will host the mash-up and add a Visio Web Access web part and configure it to load the web drawing published in step #1.
    4. On the same page, add a Content Editor Web Part and configure it to load the .JS file you created in step #2. This process is similar to step 3, however the Content Editor web part is in the Media and Content category of SharePoint web part picker and you need to set the "URL" property of the web part.
    5. Get out of page edit mode. Check the bottom left corner of your browser. If there is no JavaScript error, move to step 8. If there is however, you need to update the second line of the code snippet above which reads “var webPartElementID = "WebPartWPQ3";” with the ID that SharePoint gave to the Visio Web Access web part.
    6. Open the SharePoint web part page in source mode (in IE, right click and “View Source”) and search for class="VisioWebAccess",then back track to the immediate parent <div> tag and look for an attribute of the form id="WebPartWPQ?".
    7. Once you have this ID, replace it in the JS file and save it back to the document library
    8. Reload your mash-up page.

    Tada! You have the basics of a mash-up. That said, it doesn't do much except get references to a few basic objects and setup some event handlers. The next section gives you a few useful examples that build on this base.

    Example #1: Overlays on hover

    In this example we will explore how to create an overlay that appears when a user hovers over a shape. In this scenario, the manager of a grocery store visualizes sales data on a floor plan of his store: sales figures are represented as colors on a store shelf. Now, let’s say we want to show a picture of the best-selling product of the day on each shelf as a user hovers his mouse over a shelf. This product changes daily and is calculated at night by running database queries; this data is then exposed through shape data when the drawing is refreshed.

    image

    Key JavaScript API Capabilities Used in this Solution

    Capability In this example…
    Creating dynamic visual markup on the Visio drawing canvas. Product pictures take up a lot of screen real-estate -- you can't show all of them on the drawing without hiding the floor plan. Using overlays let you "fade them in" and "fade them out" as needed.
    Writing custom handlers for mouse events within the drawing. The fade-in and fade-out feature discussed above requires you to handle the onmouseenter and onmouseleave events.
    Combining data from inside and outside a diagram to build dynamic composite mashups The best-selling product on a shelf changes daily and is stored in the document. The product is stored outside the diagram. The mash-up must be able to pull these two sources of visual data into one diagram.

    Code

    To solve this problem, you'll want to draw an overlay on the shape when the mouse enters the shape, and remove the overlay when the mouse leaves the shape. Let's take a look at one possible implementation:

       1: // Function Name: shapeMouseEnter
       2: // Parameters:         
       3: //    source -- a reference to the base HTML element of the vwaControl.
       4: //    args -- the shape ID of the shape the mouse entered.
       5: // Description:        
       6: //    On entering a shelf shape (a shape that contains a "Best Seller" shape 
       7: //    data), this function extracts that shape data then overlays the 
       8: //    corresponding image on the shape.
       9: shapeMouseEnter = function(source, args)
      10: {
      11:     //Get the name of the shape that was just entered
      12:     var shape = vwaShapes.getItemById(args);
      13:  
      14:     //Determine the best seller for that shelf. This information is stored in a shape data     //named “Best Seller” item that updates over time.
      15:     var bestSeller; 
      16:     var shapeData = shape.getShapeData();
      17:     for (var j=0; j<shapeData.length; j++) {              
      18:         if (shapeData[j].label = "Best Seller") {
      19:         bestSeller = shapeData[j].value;
      20:         }
      21:     }
      22:  
      23:     //Depending on which shape this is, draw the correct overlay.
      24:     switch(bestSeller)
      25:     {
      26:         case "productA":
      27:             shape.addOverlay(
      28:                 "myOverlay" ,
      29:                 "<Image Source=\"productA.jpg\" Width=\"50\" Height=\"70\"><\/Image>",        
      30:                 vwaVerticalAlignment.Top, 
      31:                 vwaHorizontalAlignment.Left, 
      32:                 shape.getBounds().width,
      33:                 shape.getBounds().height);
      34:         break;
      35:  
      36:         //If the best seller is product B, then display an overlay with product B.
      37:         case "productB":
      38:             shape.addOverlay(
      39:                 "myOverlay" ,
      40:                 "<Image Source=\"productB.jpg\" Width=\"50\" Height=\"70\"><\/Image>",        
      41:                 vwaVerticalAlignment.Top, 
      42:                 vwaHorizontalAlignment.Left, 
      43:                 shape.getBounds().width,
      44:                 shape.getBounds().height);
      45:         break;
      46:         
      47:         //You can add more cases below as needed for different shelves.
      48:  
      49:         default:
      50:     }
      51: }
      52:  
      53: // Function Name: shapeMouseLeave
      54: // Parameters:        
      55: //    source -- a reference to the base HTML element of the vwaControl.
      56: //    args -- the shape ID of the shape the mouse just left.
      57: // Description:
      58: //    On leaving a shelf shape (a shape that contains a "Best Seller" shape 
      59: //    data), this function removes the existing overlay on that shape.
      60: shapeMouseLeave = function(source, args)
      61: {
      62:     //Get the name of the shape that was just entered
      63:     var shape = vwaShapes.getItemById(args)
      64:  
      65:     //And remove the overlay
      66:     shape.removeOverlay("myOverlay");
      67: }

    Getting this to work

    To add this to your solution, copy/paste the above code presented in the earlier “Getting Started”. Note that this code makes the following assumptions:

    1. There are shapes in the drawing with the shape data whose label is "Best Seller" and whose value is "product?" (where ? is A, B etc...).
    2. You have bitmap images of these products, named productA.jpg etc... stored in the same directory as the .JS file. They should be 50 pixels wide and 70 pixels high.

    Example Scenario #2: Search and Highlighting...

    In this second example, the scenario is a network diagram mashup that allows a network administrator to find computers in a network diagram that have a particular string and to highlight them; this is useful when looking at a computer topology to quickly spot computers that meet a particular spec, or contain a particular set of characters in their name. We are effectively “scraping” the diagram to find shapes that contain a particular piece of text in either shape text or shape data.

    clip_image002

    Key JavaScript API Capabilities Used in this Solution

    Capability In this example…
    Interacting with web page elements that don’t expose web part connections. The search text box in this solution is not a SharePoint web part.
    Exposing diagram data, such as shape name and shape data to your solutions. The solution searches on data within the drawing.
    Combining data form inside and outside a diagram to build dynamic composite mashups Search text (data from outside the document) changes throughout a session, diagram markup must do so at the same rate.

    Code

    To solve this problem, the algorithm iterates through all the shapes on the page and does a string compare against the name/shape data of that shape and highlight the shapes that contain that string. One implementation of this scenario is detailed below:

       1: // Creates the user interface for this code sample which consists of a
       2: // text box to enter the find-text and a button to trigger the 
       3: // find operation.
       4: document.write("Find text:");
       5: document.write("<BR><input type=\"text\" id=\"findText\"><\/input>");
       6: document.write("<BR><Button id=\"findButton\" type=\"button\""+
       7:     "onClick=\"find()\">Find<\/Button>");
       8:    
       9: // Function Name:  find
      10: // Parameters:     None
      11: // Description:    This function iterates through vwaShapes and highlights 
      12: //                 the shapes who's name, shape data or shape hyperlinks 
      13: //                 contains the find-text. The search is case insensitive.
      14: function find() {
      15:     // Iterate through the collection of shapes on the page, if either the
      16:     // shape name, shape data or shape hyperlinks contain the find-text, 
      17:     // highlight it and jump back to the "shapeContainsFindText:" label
      18:     // to process the next shape.
      19:  
      20:     shapeContainsFindText:
      21:     for (var i=0; i<vwaShapes.getCount(); i++) {
      22:         //  Extract the find-text from the text box and covert it to lower case.
      23:         var findText = document.getElementById('findText').value.toLowerCase();
      24:         
      25:         //  Get a reference to the shape at index "i" of the shape collection 
      26:         // and remove existing highlights. 
      27:         var shape = vwaShapes.getItemAtIndex(i);
      28:         shape.removeHighlight();
      29:         
      30:         // Get a reference to the shape name, shape data and shape hyperlinks
      31:         // collections.
      32:         var shapeName = shape.getName();
      33:         var shapeData = shape.getShapeData();
      34:         var shapeHyperlinks = shape.getHyperlinks();    
      35:         
      36:         // Highlight the shape if the find text is found within the shape name 
      37:         // and return to the top of the loop to process the next shape.
      38:         if(shapeName.toLowerCase().indexOf(findText) != -1) {
      39:             shape.addHighlight(2,"#00FF00");
      40:             continue shapeContainsFindText;
      41:         }
      42:         
      43:         // If the shape name did not contain the find-text, search through the 
      44:         // the shape's shape data values for the find-text. If the find-text 
      45:         // is found highlight the shape and return to the top of the loop to 
      46:         // process the next shape.
      47:         for (var j=0; j<shapeData.length; j++) {              
      48:             if (shapeData[j].value.toLowerCase().indexOf(findText) !=-1) {
      49:                 shape.addHighlight(2,"#00FF00");
      50:                 continue shapeContainsFindText;
      51:             }
      52:         }
      53:         
      54:         // If the shape name or shape data did not contain the find-text, 
      55:         // search through the shape's hyperlinks for the find-text. If the
      56:         // find-text is found, highlight the shape and return to the top of
      57:         // the loop to process the next shape.
      58:         for (var j=0; j<shapeHyperlinks.length; j++) {
      59:             if (shapeHyperLinks[j].value.toLowerCase().indexOf(findText) !=-1) {
      60:                 shape.addHighlight(2,"#00FF00");
      61:                 continue shapeContainsFindText;
      62:             }
      63:         }
      64:     
      65:         // If the text hasn't been found in the web drawing, then warn the user.
      66:         alert("Text not found in this web drawing!");
      67:     }
      68: }

    Getting this to work

    To add this to your solution, copy/paste the above code presented in the earlier “Getting Started” section. Note that using the code above, the find text box and button will appear in the place of the Content Editor web part.

    Example #3: Workflow Visualization

    For our third example, we’d like to highlight an in-house use of the Visio Services JavaScript OM, namely the new SharePoint workflow visualization feature in SharePoint 2010. In a nutshell, using this feature, you can now create a workflow using Visio/SharePoint Designer and visualize the progress of an instance of that workflow in SharePoint.

    The progress visualization is in fact an example of using the Visio mash-up to overlay data on an existing diagram. The SharePoint workflow team used the JavaScript API to overlay workflow instance data in the context of the workflow diagram. Taking a look at the picture below, all the visuals and the text highlighted in the green box are not actually part of the published diagram but are actually drawn over the workflow shape at run-time using the mash-up API. As the data changes during the lifetime of a workflow, so will the overlay.

    image

    As you can see, the integration between the Visio published diagram and the overlays is pretty seamless!

    More information to come…

    We’re in the process of developing a full MSDN reference for the JavaScript Mashup API, including samples and an overview document. We’ll make sure to announce this on the blog when it’s made publicly available. Please note that the contents of this blog entry are preliminary and may change by the time Visio Services 2010 is officially released.

    Try it out

    We hope this blog post has given you enough to get started building your own JavaScript solutions. Feel free to share your thoughts either through send-a-smile or by commenting on this blog post.

    Appendix – API Reference

    Object

    Description

    Vwa.VwaControl

     

     

    The VwaControl object represents an instance of the Visio Web Access (VWA) web part. It has the following functional groups: 

     

    ·         Web part properties: using getVersion() and getDisplayMode() you can access web part properties such as the web part's version and its rendering technology (Silverlight or raster).

     

    ·         Drawing-level: using getDiagramUrl()/setDiagramUrl(string diagramUrl) in tandem with openDiagram()*  you can assign which diagram to display in the web part and then load it. External data connections in a drawing can be refreshed using refreshDiagram()*.

     

    ·         Page-level: using getAllPageIds() in tandem with setActivePage(string pageId)* you can iterate through all the pages in a drawing. You can retrieve a reference to a particular page by using getActivePage().

     

    ·         Events: using addHandler(string eventName, function functionName), removeHandler(string eventName, function functionName), clearHandlers() you can manage user interaction with the drawing by adding and removing event handlers to events such as:

    o    diagramcomplete – fired when a drawing finishes loading.

    o    shapeselectionchange – fired when a new shape is selected.

    o    shapemouseenter – fired when the mouse enters a shape's outline.

    o    shapemouseleave – fired when the mouse exits a shape's outline.

    More details about the API's event model seciton.

     

    ·         Errors: using displayCustomMessage(string HTML)and hideCustomMessage() you can show and hide and your applications' custom HTML error message pages.

     

    * These methods are asynchronous which means that they trigger a non-blocking call back to Visio Services to replace the page currently displayed with another one. These operations have the side effect of making the current VwaControl object invalid which effectively stops you from coding against the OM after these statements. The best way to follow-up such calls is to create a handler for diagramcomplete, which fires when the VwaControl has finished loading the new page, and to put your code in that event handler. More details about the API's event model section.

     

    Page

     

     

    The Page object represents the active Web drawing page currently displayed in the web part. It has the following functional groups:

     

    ·         Page: using getId() and getSize() you can access properties of the currently displayed page such as its page id and its size in pixels

     

    ·         View: using getPosition()/setPosition(int x, int y) and getZoom()/setZoom(double zoom%) you can change the zoom center and zoom percentage of the web part's viewport. You can also use centerViewonShape(string shapeID) to focus the view on a particular shape and isShapeInView(string shapeID) to determine if a shape is in the current view.

     

    ·         Shapes: using getSelectedShape() and setSelectedShape(string shapeID) you can change the currently selected shape. You can also get a reference to the collection of shapes in the currently displayed page by using getShapes().

     

    ShapeCollection

     

     

    The ShapeCollection object represents the collection of shape objects on the currently displayed page. It has the following functional groups:

     

    ·         Shapes: using getCount() in tandem with getItemAtIndex(int index) you can easily iterate through all the shapes on a page; the array is 0 based. You can also use getItemByName(string shapeName), getItemById(string shapeId) or getItemByGuid(string shapeGuid) to index into the page’s shape collection using different Visio shape identifiers.

     

    Shape

     

     

    The Shape object represents a single shape on the active Web drawing page. It has the following functional groups:

     

    ·         Shape Properties: using getName(), getId() & getGuid() you can access the shape's various Visio identifiers such as shape name, Id and Guid. You can also access a shape's meta-data by using getHyperlinks(), getShapeData() and getBounds().

     

    ·         Markup: using addHighlight(integer width, string color), removeHighlight(), addOverlay(string overlayID, string content, Vwa.VerticalAlignment vPos, Vwa.HorizontalAlignment hPos, integer overlayHeight, integer overlayWidth), addPredefinedOverlay(Vwa.OverlayType overlayType, string overlayID, string content, [Vwa.VerticalAlignment vPos], [Vwa.HorizontalAlignment hPos], [integer overlayHeight], [integer overlayWidth]) and removeOverlay(string overlayID) you can manage shape markup.

     

    Highlighting a shape draws a colored rectangle around the bounding box of the Shape as seen below:

     

    image

     

    A shape overlay is a way of adorning a particular shape with a developer visual. An example of this concept is a pushpin icon that is placed on top of a map in an online mapping application. With this set of functions, you can tag a Visio shape with your own overlay to bring attention to it:

    image

    Using the various arguments of addOverlay() and addPredefined() overlay you can configure the contents, size of the overlay as well as its alignment relative to the bounding box of the shape. Each shape may have more than one overlay; these overlays cannot however have the same developer-defined overlayID.

     

    Note that when the underlying drawing is rendered in PNG, overlays be either HTML or an image. If the diagram is rendered in Silverlight, the overlay can be XAML or an image.

  • 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

    Gluing It All Together

    • 11 Comments

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

     

    Essential Feature:  Connectors

    The fundamental drawing type in Visio is the flowchart - a collection of boxes connected together by lines.  When Visio was first introduced, drawing programs mostly worked with geometric primitives.  Boxes and connectors were just sets of lines, with no intelligent behavior.  If you wanted to move a box to a new location, you also had to redraw the connecting line to make it reach the box again.

     

    To avoid the tediousness of fixing up drawings, Visio introduced a pair of diagramming innovations: connectors and glue.  A connector is a one-dimensional shape consisting of line segments.  Each endpoint is attached to a two-dimensional shape (the box) using glue.  When the box is moved to a new location, the connector stays attached and stretches as needed to maintain the connectivity between boxes.  Visio chooses the route the connector will take between its endpoints.

     

     

    Connectors have intelligent routing behavior.  They will avoid other shapes on the page where possible.  They will even show line jumps (or line breaks) where they cross over each other.  When you do choose to override Visio, you can easily control the connector path using green handles found on the shape.

     

    The default connector in Visio is the Dynamic Connector, which is the shape created by the Connector Tool.  However, any 1-D shape can be used as a connector.  You can turn an ordinary line into a connector by changing the ObjType cell in the Shapesheet from 0 to 2.  You can also make your own connector master shape.  If you name your master "Dynamic Connector", Visio will use it when you draw with the Connector Tool.

     

    There are some other interesting behaviors when using the Connector Tool in conjunction with masters in the Shapes window.  Try this:  Select an existing shape on the page.  Then switch to the Connector Tool and drag a master shape out onto the page.  Not only is the shape added, a connector is created and glued between the existing shape and the new shape.  You can also make Visio use a different connector shape with the Connector Tool.  Switch to the Connector Tool, then select a 1-D master in the Shapes window.  Now draw a connector on the page.  Visio uses the selected master instead of the Dynamic Connector.

     

    The Dynamic Connector is itself a master.  It's built into Visio.  The first time you draw with the Connector Tool, Visio looks for a master named "Dynamic Connector" in the Document Stencil.  If no master is found, Visio puts a copy of its built-in Dynamic Connector master in the Document Stencil (File > Shapes > Show Document Stencil).  You can edit this master to change the appearance of all connectors in the diagram.

     

    There's a lot more that can be said about connectors and also glue, but those are the basics.  Connectors streamline the diagramming process by maintaining their connections with shapes and managing their routing automatically.

  • Visio Insights

    Smarter Paste between Pages

    • 10 Comments

    The Visio Product Team uses Visio for a number of tasks.  A common task is creating storyboards to show how a user might construct a diagram.  If you’ve ever seen one of those “behind the scenes” documentaries for a movie, you’ve seen the storyboarding process.  Each step the user takes is captured on a separate page in a Visio drawing.  Then the entire document is shown as a presentation to replay the construction of the diagram.

    It seems that quite a few people use Visio for this sort of task.  Visio is a pretty good tool for mocking up application or web interfaces.  One common request is to make copying between pages work better.  In these types of documents, each page is almost identical to the one before it.  One of the nicer touches in PowerPoint is that objects copied from one page (slide) to another are pasted in exactly the same position.  In Visio objects are pasted to the center of the screen making repositioning a chore.  Visio needs a smarter paste behavior.

    A little bit of code can solve the problem for Visio.  Actually, there are two ways to solve the problem.  You could write your own procedures to perform copy and paste with better logic for positioning.  Alternatively, you could handle the event notifications from Visio when copy and paste occur and fix up the positioning after the fact.  The attached Visio document has VBA code to illustrate both methods.

    Create your own copy / paste commands

    When invoking Visio’s Copy and Paste command through automation, Visio allows you to specify whether the position of the selection on the page should be preserved using the visCopyPasteNoTranslate flag.  Thus you can create your own macros that do copy and paste:

    Public Sub CopyNoTranslate()

       

        Application.ActiveWindow.Selection.Copy (visCopyPasteNoTranslate)

     

    End Sub

     

    Public Sub PasteNoTranslate()

       

        Application.ActivePage.Paste (visCopyPasteNoTranslate)

     

    End Sub

    In fact you can assign Ctrl-C and Ctrl-V as the accelerator keys for these macros to override Visio’s copy / paste.  If the real goal is to support copying to a new page, this macro will perform the necessary steps:

    Public Sub CopyToNewPage()

       

        Dim vsoSelection As Visio.Selection

       

        'Make sure we are in a drawing window

        If Application.ActiveWindow.Type = Visio.VisWinTypes.visDrawing Then

       

            'If there is no selection, select all shapes on the page

            Set vsoSelection = Application.ActiveWindow.Selection

            vsoSelection.IterationMode = 0

            If vsoSelection.Count = 0 Then

                vsoSelection.SelectAll

            End If

           

            'Copy selection to new page

            vsoSelection.Copy Visio.visCopyPasteNoTranslate

            Application.ActiveDocument.Pages.Add

            Application.ActivePage.Paste Visio.visCopyPasteNoTranslate

           

        End If

       

    End Sub

    Respond to Visio’s copy / paste events

    This method uses an event handler to detect copy and paste actions.  The position of the selection is read during the copy action.  The new position of the selection (which will be placed in the center of the window) is read during the paste action.  The current page is recorded during each action as well.  If the copy and paste actions occur on different pages, the code moves the selection back to its previous coordinates following the paste action.

    Private Sub vsoApp_EnterScope(ByVal app As IVApplication, ByVal nScopeID As Long, ByVal bstrDescription As String)

     

        'Check for Copy action in a drawing window

        If nScopeID = 1021 And app.ActiveWindow.Type = Visio.VisWinTypes.visDrawing Then

       

            Dim vsoSelection As Visio.Selection

            Set vsoSelection = app.ActiveWindow.Selection

           

            If vsoSelection.Count > 0 Then

           

                'Find the shape in the selection at the bottom of the z-order

                Dim bottomShape As Integer

                bottomShape = GetBottomShape(vsoSelection)

               

                'Record scope ID and selection information

                nCopyScopeID = nScopeID

                gCopyPageID = app.ActivePage.PageSheet.UniqueID(Visio.visGetOrMakeGUID)

                dShapePosX = vsoSelection(bottomShape).CellsU("PinX").ResultIU

                dShapePosY = vsoSelection(bottomShape).CellsU("PinY").ResultIU

               

            End If

       

        End If

       

    End Sub

     

    Private Sub vsoApp_ExitScope(ByVal app As IVApplication, ByVal nScopeID As Long, ByVal bstrDescription As String, ByVal bErrOrCancelled As Boolean)

     

        'Check for Paste action in a drawing window

        If nScopeID = 1022 And app.ActiveWindow.Type = Visio.VisWinTypes.visDrawing Then

       

            If nCopyScopeID <> 0 Then

           

                Dim vsoSelection As Visio.Selection

                Set vsoSelection = app.ActiveWindow.Selection

               

                Dim activePageID As String

                activePageID = app.ActivePage.PageSheet.UniqueID(Visio.visGetOrMakeGUID)

               

                If vsoSelection.Count > 0 And gCopyPageID <> activePageID Then

               

                    'Find the shape in the selection at the bottom of the z-order

                    Dim bottomShape As Integer

                    bottomShape = GetBottomShape(vsoSelection)

               

                    'Fix up position of selection by offsetting from the bottom shape

                    Dim posX As Double, posY As Double

                    posX = vsoSelection(bottomShape).CellsU("PinX").ResultIU

                    posY = vsoSelection(bottomShape).CellsU("PinY").ResultIU

                   

                    vsoSelection.Move dShapePosX - posX, dShapePosY - posY

                   

                End If

           

            End If

           

        End If

           

    End Sub

    The full code for this method is found in the attached document.  We use the EnterScope and ExitScope events to detect the copy and paste actions.  The key problem to solve is recording the current position of the selected shapes.  Visio selections do not have coordinates associated with them, so the coordinates of one of the shapes within the selection must be used.  The trick is to make sure that the same shape is scanned in both the copy and paste actions.  Visio does not necessarily preserve the order of shapes in the selection during paste.  This code finds the bottommost shape in the z-order (layering order) to ensure that the same shape is scanned each time.

    To use this method, open the SmartPaste.vsd file in Visio along with the other documents you are working on.  Once you enable macros for the file, SmartPaste will work with your regular Copy  and Paste actions.

    If you find this type of behavior useful or find it counter-productive, please let us know.

  • Visio Insights

    Inserting and Deleting Shapes in Visio 2010

    • 10 Comments

    Diagram maintenance is a task that everyone performs, and many users spend much of their time in Visio maintaining existing diagrams.  We realize that a fair amount of the time you spend maintaining your diagrams is spent in the mechanics of the task, rather than achieving the goals of updating the concept the diagram represents.  There are some clear gains we can effect to make your life easier as you go about editing your diagrams.

    Consider a typical flowchart.  You documented an internal process and now need to add some steps to the process diagram.  Prior to Visio 2010, this meant facing what could be a tedious task of ungluing connectors, selecting and dragging shapes to make room for the new ones, adding the new ones, positioning them neatly, re-gluing connectors, adding new connectors and moving the other shapes into position to leave you with a nice, neat diagram.

    In Visio 2010, as part of our focus on ease of use and improving core process diagramming, we have simplified this basic, repeated task dramatically.  Now, all you need to do is drag your new shape out and drop it on the connector you wish to split.  Visio highlights the endpoints of the connector to make it clear which connector will split.  When you drop, Visio moves all the “downstream” shapes over just enough to make room for the new shape.  Visio takes care of positioning the new shape so that it is aligned with and evenly spaced from the shape upstream from it.

    Before: image
    Hover: image
    After: image

    Visio identifies which shapes are “downstream” from the insertion point, moves them in the right direction the right amount and places the new shape in just the right spot.  The lower left rectangle is connected downstream from the inserted shape, but is to its left, so did not need to move.

    At some point you may need to remove a few steps from your diagram.  Prior to Visio 2010, this meant deleting shapes, deleting excess connectors, re-gluing the remaining connectors to the remaining shapes and moving those shapes to align and space evenly with the rest of the diagram.

    In Visio 2010, we take care of the connector healing for you.  When you delete a connected shape, Visio checks how many connectors go into and out of the shape, and which ones have text.  If it is clear how to re-glue the connectors without changing the diagram and which connectors can be removed without losing text, Visio deletes the extraneous connectors and re-glues the remainder.

    image

    We made an explicit decision not to move the remaining shapes to fill in the empty space, as that could easily lead to all those downstream shapes – which could be numerous – overlapping another part of the diagram.  Fortunately, you can simply select which shapes should tighten up and use Auto Align or Auto Space to help you neaten up the diagram.  As you can see above, we also preserve connectors that have text, even when that means not healing.  Text on connectors is important, so better safe than sorry.

    As mentioned, we enabled this behavior for cases where we can make a safe conclusion about how the connectors should heal.  Other than to prevent losing text, when else don’t we try to heal?  If there is more than one connector coming into and going out of the shape being deleted, then it is ambiguous how all the shapes should be re-connected together.  Typical examples of this are shown below.

    image

    Our hope is that these additions, while seemingly small, will have a big impact on reducing your workload as you maintain the millions of Visio diagrams you have all created.  Let us know how this works for you using Send a Smile or through a comment on the blog.

  • Visio Insights

    Introducing the Microsoft Visio 2010 Beta SDK

    • 10 Comments

    A Beta release of the Microsoft Visio 2010 SDK is now available for download! Due to high demand for an early version of the SDK, we have released a Beta version of the SDK with a partial set of supported features. Additional features and functionality will be available in the RTM version of the Visio SDK.

    There are two versions available depending on whether you are running the 32-bit or 64-bit version of Visio. It is important to install the right version of the SDK to ensure that all the SDK tools function correctly.

    The Microsoft Visio 2010 SDK contains the following items:

    1. Tools
    2. Sample applications
    3. Visual Studio Add-on Wizards
    4. Documentation
    5. Visio Type Libraries and C++ Library Files

    We explain these items in more detail below. Features listed with an asterisk (*) are not supported in the Beta version of the Visio SDK.

    Tools

    Once you install the Visio SDK, you will see SDK Tools available on the Developer tab in Visio.

    SDK tools

    The Event Monitor tool watches for events that are raised in Visio and it can help you debug your solution when handling events.

    The Persistent Events tool provides a user interface that lets you add and modify persisted events.

    The Print ShapeSheet tool provides a user interface that lets you print the contents of a ShapeSheet.

    The Visio SDK also includes the Microsoft Visio Solution Publishing Tool*, which is an executable that you can run from outside Visio. This tool works with Windows Installer to add Visio-specific entries, such as Visio add-ons (.vsl and .exe files), stencils (.vss and .vsx files), templates (.vst and .vtx files), and Help files (.chm files), to the PublishComponent table of the .msi file that you create to install your solution on your users' computers.

    Sample applications

    The Visio SDK also includes a number of sample applications written in either Microsoft Visual Basic .NET, Microsoft Visual C#, or Microsoft Visual C++. You can experiment with these samples as you develop your own custom solutions for Microsoft Visio 2010. By default, the sample applications target the 32-bit version of Visio 2010.

    After installing the Visio SDK, you will see a new category of template on the New tab of the Backstage View.

    clip_image003

    The samples are not functional, however, until after they are built in Visual Studio and then installed using the generated setup.exe or .msi file. Once a sample application is installed, the application can be launched by opening the corresponding template in the SDK folder shown above. The only exception is the Office Plan Sample, which uses the Microsoft Visio 2010 Drawing Control inside a Microsoft Windows Form and is launched from outside Visio. The available sample applications are shown below.

    The Flowchart Chart Sample (available in C#, VB.NET and C++*):

    clip_image005

    The TreeView Sample* (available in VB.NET):

    TreeView

    The Office Plan Sample (available in C#):

    clip_image007

    Add-on Wizards

    The Visio SDK installs wizards for creating Visio add-on projects in Microsoft Visual Studio 2005 and Microsoft Visual Studio 2008. These Wizards let you set up new Visio add-on projects in Microsoft Visual Basic .NET, Microsoft Visual C#, and Microsoft Visual C++, and create corresponding setup programs to install add-ons. Once you have used the wizard to create a Visio project, you can explore the project code and settings to learn more about how Visio add-ons should work.

    VisualStudioWizard

    Microsoft Visual Studio 2010 also includes wizards to generate Visio 2010 VSTO add-in projects. The Visio SDK is not required to use these wizards.

    clip_image009

    Documentation*

    The Visio SDK includes documentation like the Visio Automation Reference, the Visio ShapeSheet Reference, the Visio Save As Web Reference, the Visio Viewer Reference and the Visio XML Reference. In addition, it includes the Code Sample Library—a library of interesting code samples. Note that the documentation included with the Beta SDK is Visio 2007 documentation.

    Libraries

    We also include a number of support files in the SDK. We provide type libraries for three application programming interfaces (APIs) that Microsoft Visio 2010 exposes: the Visio type library, the Save as Web type library, and the Microsoft Office Visio Drawing Control type library. In addition, we provide support files to help C++ developers automate Visio. The Beta versions of these support files are in this release of the SDK.

    Things to expect at RTM

    Along with the content described above, we are working on some new features for the RTM version of the SDK. We are currently planning to release the following additions at RTM:

    1. A new VSTO Add-in Sample Application that uses a "ClickOnce" post-deployment action to install Visio template and stencil files,
    2. Guidance for reconfiguring the SDK sample applications to target the 64-bit version of Visio 2010,
    3. New code samples in the Code Sample Library for API functionality added in Visio 2010, and
    4. Documentation for new Visio 2010 API and ShapeSheet functionality.

    Feedback welcome!

    As you explore the SDK and use the tools provided, we encourage you to provide feedback about your experience. You can use the Office 2010 Send a Smile functionality to send us feedback about the SDK, or you can comment on the blog.

  • Visio Insights

    Subprocesses and Hyperlinks

    • 9 Comments

    You may recall that simplifying Process Management is one of the core areas we focused on in Visio 2010.  Many Visio users build large process diagrams and a common tactic is to segment them into manageable, reusable pieces.  Typically, processes are broken down into parts on different pages within the same document, or in some cases into separate documents.  These subprocesses may be organized around ownership of the process, the people and groups who are related to them, or simply around the size of the diagram.  Visio 2010 adds explicit support to create new subprocesses and reference existing ones.

    1b

    When the diagram authors are building their diagrams, we found that they may take different approaches depending on the circumstances of what they are designing or documenting.  Some build out from a higher level and know where subprocesses need to be referenced or created, adding subprocess shapes that act as placeholders for the subprocess that will be filled in later.  Others build out full detail and then go back to move parts of the diagram into subprocesses.  To reference each of these subprocesses, a hyperlink is typically added to a shape that refers to the entire subprocess.  Visio 2010 builds on these common characteristics and provides ways to automate much of the manual work around creating subprocesses.

    The Create New command is designed to help you build out a brand new subprocess represented by the selected shape.  This will insert a new blank page and add the page name and a hyperlink pointing to the new page to the selected shape.

    2

    The Link to Existing command allows you to create a hyperlink on the selected shape that points either to a page in the current document or to an external document, such as one stored in a Visio Process Repository.

    3

    The Create from Selection command is used when you want to move a number of shapes from your current page onto a new subprocess page.  Visio adds a new page, moves the selected shapes to the new page and adds a subprocess shape to the current page.  The new shape represents the new subprocess and contains the name of the new page as well as a hyperlink pointing to it.

    Selection moved to a new subprocess 4
    New subprocess shape in higher-level process 5
    Subprocess page 6

    Hyperlinks are used to jump to and from the various subprocesses, so we looked toward our Ease of Use goals and made a few changes to how hyperlinks, in general, are managed.  We improved hyperlink navigation in Visio 2010 by allowing you to Ctrl+Click on a shape to follow a hyperlink, which is common elsewhere in Office.  The hyperlink still exists in the context (right-click) menu, and we added an entry point to the hyperlink dialog to make it easier to manage the links on your shape.  Some of you are probably thinking, “Hey, Ctrl+Click is already used to select multiple shapes!”  Not to worry – if you click to select a shape and then use Ctrl+Click to add more shapes to your selection, that still works.

    7 8

    You can add your own hyperlinks to shapes using the Hyperlink command on the Insert menu, which should be familiar from the other Office programs.

    9b

    You may notice that the Hyperlink button is disabled if no shapes are selected.  When rethinking the interface for Visio 2010, we found that many users accidentally added a hyperlink to the page rather than a shape because they didn’t have a shape selected.  We also found that page hyperlinks are used mainly in custom templates or solutions and infrequently enough otherwise that we felt it was better to help users avoid accidents in the common case.  Page hyperlinks can still be added via the API or PageSheet.  And what about document hyperlinks?  Developers can add those through the API or DocumentSheet and end users can do it in the Backstage View.  Click the File tab, and go to the right side of the Info tab, where document properties are listed.

    10 11

    As usual, feel free to drop us a line about this using Send a Smile, or here on the blog.

  • Visio Insights

    The Developer tab in Visio 2010

    • 9 Comments

    Visio has long had a setting called “developer mode” that developers and shape designers can enable in order to surface extra functionality. In previous versions of Visio, enabling developer mode made new items appear in couple of different menus (Chris Roth has a good overview here). With Visio 2010, we have taken advantage of our new Fluent user interface by grouping this extra functionality into one Ribbon tab named “Developer”. The result is one central location for working with code and designing shapes in Visio:

    image

    Enabling the Developer Tab

    The developer tab does not appear by default, since we want to provide a streamlined interface for users who do not need it. To surface the Developer tab, click on the Backstage Button, and click on Options. This brings up the Visio Options dialog. Click on the Customize Ribbon section. On the right-hand side, check the box that says “Developer” and press OK.

    Visio Options Beta1

    (Note: an alternate method is to go to the Advanced section in Visio Options and check the box at the bottom that says, “Run in developer mode”.)

     

    Organization of the Developer tab

    Here is an overview of how the Developer tab is organized, group by group.

     

    Code & Controls

    image

    These two leftmost groups are common across many Office applications. Use them to work with Visual Basic code and ActiveX controls. Note that the Macros button is also available in the Ribbon’s View tab, so users who do not have developer mode turned on can still access this button.

    Shape Design

    image

    This group contains functions used when designing shapes.

    Clicking on the top part of the Show ShapeSheet button opens the selected shape’s ShapeSheet. (You can read more about the ShapeSheet in a previous post.) Clicking on the bottom part of this button lets you choose to instead view the ShapeSheet for the active page or the active document. This makes these ShapeSheets easier to access than they were in previous versions of Visio.

    image

    The geometry tool is a split button that contains different drawing tools. Note that although a similar button is available on the Home tab, that button only contains the Rectangle, Ellipse, and Line tools, and not the Freeform, Arc, and Pencil tools.

    image

    Clicking on the Shape Name button will open up the dialog that in previous versions of Visio was available under “Format > Special” (this dialog box has been renamed “Shape Name” to better reflect its purpose):

    Shape Name

    The Behavior and Protection dialogs that were previously in the Format menu are in the Shape Design group now:

    Shape Design Group

    Stencil

    image

    This group lets you create a new metric or US stencil.

    Show/Hide

    image

    This group lets you toggle the view of the document stencil, drawing explorer window, and master explorer window.

    Conclusion

    We hope the Developer tab makes your development and shape design tasks more convenient. We’re interested to hear your feedback, so use the Send a Smile feedback tool or comment on this post to let us know what you think.

  • Visio Insights

    Layout Improvements in Visio 2010

    • 9 Comments

    A challenge many users face when building diagrams is getting them to look neat and organized. Visio has included a number of features to help with the placement of shapes for many releases. Some of these are manual and only help when dragging a single shape. Others are automated but often a bit too rigid in forcing a layout style on shapes with no regard to how the user initially placed them.

    What if you could clean up a diagram with a few clicks, maybe just one, and preserve the work you have already put into it? In support of the Ease of Use and Process Management initiatives discussed in our introductory Visio 2010 post, we have added new layout features that make best-effort attempts to clean up a diagram while maintaining the general layout that already exists among the shapes. Rather than tell you how shapes ought to be organized, Visio assumes you have the placement pretty close and simply neatens things up a bit. After all, you know what kind of diagram you’re building and where your shapes belong!

    clip_image002

    This can be accomplished using Auto Align & Space in the Arrange group on the Home tab.

    clip_image004

    Auto Align & Space looks at the selected shapes and determines how two shapes that are connected together should be aligned and spaced from one another. It assumes that the shapes are close to the “right” position relative to the rest of the diagram and makes small adjustments to align and space them evenly, giving you a neat and orderly diagram. It acts on the selected shapes or, if no shapes are selected, on the entire page.

    For example, the selected shape below is connected to, close to and almost aligned with the shape on the left. Auto Align & Space examines the connectors and determines that the selected shape is downstream from – or a child of – the shape on the left. The selected shape is moved to align with the left shape and space from it using the default page spacing distance. Everything else connected downstream from the selected shape doesn’t get left behind – it follows along, but does not align or space. Of course, you could also select more shapes to clean up, or have no selection and clean up everything.

     

    clip_image002[6]

    image

    clip_image004[5]

         

    clip_image006

    image

    clip_image008

     

    In addition to the big Auto Align & Space button, we have broken out Auto Align and Auto Space as separate actions in the Position dropdown button. One of the big benefits the Ribbon enables is the ability to preview these actions so you can see the effects before committing to the change. We’ll talk more about previewing Ribbon actions in a future post.

    clip_image010

    Spacing Options lets you choose a non-default spacing distance between shapes for the automatic spacing actions.

    We kept the existing Align and Distribute features from previous versions of Visio and enhanced them by enabling preview. The Distribute actions are less frequently used and are located in the Space Shapes flyout menu.

    The existing rotate and flip shapes behaviors are in the Rotate Shapes flyout menu.

    Rotate Diagram is a new feature that allows you to change the direction a diagram flows by rotating or flipping it, but without rotating or flipping the individual shapes

     

    Rotate (and Flip) Diagram is handy when you want part of a diagram to rotate around a parent shape to extend in a different direction, or when you want an entire diagram to be vertical rather than horizontal. For example, selecting the shapes shown below and using Rotate Left makes the diagram more compact.

    clip_image012

    clip_image014

     

    Finally, we have also maintained the existing layout feature from previous versions of Visio. You can find Re-Layout Page in the Layout group on the Design tab. This is useful when you want Visio to completely revise the layout of the diagram. We pulled the most common layout configurations into a gallery so you can preview them to see how different layout choices will affect your diagram. More Layout Options takes you to the traditional dialog with full layout options.

    clip_image016

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

  • Visio Insights

    Annotating Diagrams with Callouts in Visio 2010

    • 9 Comments

    One of the guiding principles for the Visio 2010 user interface is that commonly used shapes should be easily accessible.  We showed how the Quick Shapes view in the Shapes Window aggregates the shapes from multiple stencils together.  There are also common shapes that are useful in many different kinds of diagrams.  These are exposed directly in the Ribbon through shape galleries.  We looked at Containers and Backgrounds and Borders previously.  In this post we examine Callouts.

    image

    A callout is an annotation on a diagram that provides more information about a shape.  Callouts are Visio shapes themselves, which differentiates them from other forms of annotation such as comments.  Callouts are part of the visible drawing and can be edited and formatted like any other shape.  A callout points at or references another shape, which we call the “target” of the callout.  It is placed in proximity its target and may have a line connecting to it.  The connecting line is called a “leader”.

    To add a callout shape in Visio 2010, select the target shape on the page and then click on the Callout dropdown in the Insert tab.  You will see the Callout gallery with many different styles of callouts.  Hover over a style to see it applied as a Live Preview and then click the style to add the callout.  The callout appears slightly above and right of the target shape.  (Note in the Technical Preview build the callout is placed a little too close by default and overlaps the target.  This will be corrected in the next beta release.)

    image

    Callout shapes are not new to Visio 2010, but Visio 2010 gives callout shapes special behaviors.  When a target shape is moved, copied or deleted, any callouts attached to the shape will be moved, copied or deleted too.  Thus callouts stay with their target shapes, though you can reposition the callout to any offset from its target.  Callout shapes are also designed to be displayed in front of other shapes.  Even if you add new shapes to a page and overlap them with callouts, the callouts will appear in front.

    There are additional options for the visual style of callout shapes, which you can access by right-clicking on a callout.  The Callout Style flyout menu allows you to switch to a different geometric style and has the same choices as the Insert Callout gallery in the ribbon.  The Orientation flyout menu lets you control which side the callout’s leader attaches to.  Callout Line controls the visibility and placement of the leader line.  Finally you can choose whether the callout shape resizes to fit the amount of text in the shape.

    image

    We hope you find the improved callout behaviors and convenient access from the ribbon a welcome addition to Visio 2010.  Feel free to tell us what you think through the Send a Smile feedback tool or by commenting on this post.

  • Visio Insights

    Where's my text control handle?

    • 9 Comments

    A Visio user posted a question in the newsgroups about the yellow text control handle on connector shapes.  Some connectors have a yellow handle and some don't.  What's going on?

    Starting in Visio 2003, the built-in connector shape used by the Connector Tool was modified to include a text control handle.  If you start a blank drawing and click on the Connector Tool you should get this version of the shape.  Note that you must enter text on the shape before you see the text control handle.  This shape is named the Dynamic Connector. 

    There are also a number of Visio stencils with a Dynamic Connector shape such as the one in the Basic Flowchart Shapes.  Unfortunately, many of these shapes were not updated with the new text control handle.  Diagrams created in previous versions of Visio would have connectors that did not have the text control handle either.  Furthermore, once you have any shape named Dynamic Connector in the document, Visio will use that shape for the Connector Tool.

    All is not lost!  The text control handle behavior is relatively simple and can be added to any existing shape or master.  Here are the steps.  Go to File > Shapes > Show Document Stencil and double-click on the Dynamic Connector master shape.  Select the connector in the edit window and go to Window > Show Shapesheet.  Then go to Insert > Section and choose the Controls and Text Transform sections if they are enabled.  Click OK.  Now enter formulas in the cells as shown in the screenshot.  The downside of this is that connectors already on the page won't pick up all the behavior because they have some local formulas.

    But there is an even better solution.  Download the attached Visio document to get a macro that will fix up your masters and shapes automatically.  The macro is designed to work on the active document.  Load the macro document, enable macros if you get a security warning, then switch back to your document and go to Tools > Macro > TextControlHandle > ThisDocument > AddTextControlHandle.  The macro looks for connectors that do not yet have a text control handle and sets one up.  The macro doesn't quite fix everything.  It doesn't dive into groups looking for connectors to fix.  You should now be able to draw with the Connector Tool and get text control handles.  Note that dragging out a Dynamic Connector shape from a stencil will give you the old connector not the new connector, so stick with the Connector Tool.

    Thanks for the great newsgroup question!

     

     

  • Visio Insights

    Visio 2007 Standard and Professional

    • 9 Comments

    The most common set of questions in the newsgroups asks about the difference between Visio Standard and Visio Professional.  For Visio 2007, Microsoft has published a handy guide detailing the differences between the two editions.  There are breakdowns by feature and by diagram type.

    http://office.microsoft.com/en-us/visio/FX101757911033.aspx

    There are a couple points worth making here.  First, for those using the Visio that ships with Visual Studio for Enterprise Architects or Visual Studio Team System, there is no Visio 2007-based version as of yet.  The latest Visual Studio offering includes Visio 2003.

    Second, this is the first release where some features of the Visio engine are only available in Visio Professional.  For those unfamiliar with Visio's archictecture, the product consists of a drawing engine plus lots of content (shapes and templates and add-ons) that work with the drawing engine.  Historically, the drawing engine is the same in every edition and only the content varies by edition.  In Visio 2007, the features related to data connectivity (Data Link, Data Graphics, Data Refresh) are only supported in the Professional edition.  As in previous versions the Professional edition also has additional content.

    Visio 2007 Standard can open files created in Visio 2007 Professional, but the data features are disabled.  This delineation extends to Visio's programming interface.  Automation related to the new data features will not function on Visio 2007 Standard.  This behavior is somewhat akin to opening files in Visio 2003.  While Visio 2003 and Visio 2007 share the same file format, Visio 2003 does not have the new data connectivity features.  For example, in Visio 2003 you can work with a 2007 diagram that contains Data Graphics, but you cannot apply a data graphic to another shape or manipulate the existing data graphics.

    Thanks to all our MVPs and newsgroup responders who answer questions about Visio's product editions.  Now you can point them to the new Office Online link.

     

     

  • Visio Insights

    DXF, DWG & Visio

    • 8 Comments

    Hi Everyone,

    Do you ever open, save or use AutoCAD files (DXF/DWG) with Visio? If so, the Visio product team would like to talk to you. Please contact us, and we’ll be in touch.

    Visio Team

  • Visio Insights

    No More Template Help

    • 8 Comments

    A common newsgroup question is how to prevent the Template Help task pane from appearing every time a document is opened.  Not only do we see lots of newsgroup posts about this, it turns out that one of the more common pieces of feedback we receive through Rate this Template is “Let me disable this task pane”.

     

     

    Here are the steps to disable automatically showing the task pane:

     

    1)      Go to Tools > Options in the menu

    2)      Click on the General tab and choose Service Options at the bottom

    3)      Select the Online Content category and uncheck “Show Template Help automatically…”

     

     

    The task pane is intended to help people learn more about various diagram types.  Unfortunately the design tends to focus on the initial usage experience (having the template help in your face) at the expense of ongoing productivity (having lots of drawing space).  Perhaps the biggest problem is that there is no place on the task pane itself to disable the automatic behavior.

     

    The good news is that there is no Template Help task pane in Visio 2007.  There is a link to template help at the bottom of the Getting Started screen.  It is grouped with all the other content available from Office Online.  Hopefully this is a better location both for those that want to find template help and those that do not want to be bothered by template help.

     

     

     

  • 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

    Diagram Validation in Visio 2010

    • 8 Comments

    Are all the shapes in my diagram labeled? Do I have any loose connectors that are not attached to other shapes? We have heard from customers that it is often hard to answer these types of questions, especially in large diagrams. As a result, they spend a lot of time manually checking diagrams for errors. At the same time, they have to manually ensure that the different diagrams they create are visually consistent.

    We have also heard from companies that they want to enforce certain diagramming standards or rules within their organization. It’s much easier for different people to understand a diagram if it uses standardized notation. As an example, many companies are adopting BPMN as a standard for business process modeling.

    To help address these needs, we added support for diagram validation in Visio 2010. This allows users to check their diagrams for common errors and allows companies to ensure that employees are following certain diagramming standards. With Visio 2010, we provide diagram validation support for Basic Flowchart, Cross Functional Flowchart, Microsoft SharePoint Workflow and Business Process Modeling Notation diagrams. Companies can also develop custom rules for their own needs.

    You can access the diagram validation functionality from the Process tab. Once you start working on a diagram with a supported set of rules, you can click the Check Diagram button to see whether the diagram has any issues.

    ProcessTab

    Visio will either tell you that there are no issues in the document, or it will list the issues in the Issues Window. In the diagram below, a connector is not attached to the next shape in the flowchart. When the Check Diagram button is clicked, Visio displays two issues to fix. To easily find shapes with issues, you can click on an issue and the corresponding shape will be selected.

    IssuesWindow

    Once you fix the listed issues, you can click Check Diagram to check that there are no longer any issues with the diagram.

    Sometimes you might find that an issue does not apply to a certain shape in your diagram. When this happens, you can ignore the issue and Visio will not display it in the Issues Window. If a rule does not apply to the entire diagram, you can also ignore the rule so that no issues associated with that rule are displayed. You do this by right-clicking an issue in the Issues Window, and selecting the appropriate option.

    IgnoreThisIssue

    Using the same menu, you can also choose to display the ignored issues and to rearrange issues in the Issues Window so that issues with the same rule, category or page are next to each other.

    Validation rules are grouped into logical sets of rules, such as BPMN and flowchart rule sets. When you create a new Basic Flowchart, Cross Functional Flowchart, Microsoft SharePoint Workflow or Business Process Modeling Notation diagram in Visio 2010, the appropriate rule set is automatically available in your document. It is also easy to import the flowchart rule set into flowchart diagrams made with previous versions of Visio. Simply open your legacy diagram in Visio 2010 and, on the Process tab, click the Check Diagram pull-down menu and then click Import Rules From.

    ImportRules

    The flowchart rule set is always available to import into a diagram. You can also import rules from other Visio diagrams. Any open diagrams with rules sets will be listed as possible sources to import rules from. This makes it easy to add new validation rule sets to any diagram.

    In our next post, we’ll talk more about how validation rules are stored in a diagram, and how a developer can write new validation rules.

    We are interested in your feedback on diagram validation, so use the Send a Smile feedback tool or comment on the blog to let us know what you think.

  • 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

    Visio 2010 Beta Released

    • 8 Comments

    This morning Microsoft announced that the Beta versions of Microsoft Office 2010, SharePoint Server 2010, Project 2010 and Microsoft Visio 2010 are now available!  You can download Visio 2010 Beta here.  This is a public Beta, so anyone can install and use it.

    Changes in the Beta

    Visio 2010 Beta has numerous refinements based on customer feedback from the Technical Preview.  The most visible changes can be found in the Backstage View.  This area has been redesigned to feel more integrated with the rest of the Ribbon, as is explained in the Office 2010 Engineering blog.  Also there are several visual updates.  In the screenshot below, you can see the new look of the Backstage View found under the File tab.

    image 

    Saving files to SharePoint is also different in Visio 2010 Beta.  Now saving to a SharePoint location, saving to a Visio Process Repository and publishing to Visio Services have been combined into a single place.  You simply choose a location and then select whether to save out a standard Visio Drawing or a Visio Web Drawing.

    image

    In the other ribbon tabs, you will find visual updates to Themes and a more functional set of Callouts.  For improved ease of use, we’ve refined the behaviors of several diagramming features including adjusting the sensitivity of AutoConnect.

    image

    image

    You will also find functional and visual updates to Containers, Cross-functional Flowchart shapes, BPMN shapes, Data Graphics Legends and Wireframe shapes.  If you created diagrams with these shapes in the Technical Preview, please be aware that your existing diagrams will have the Technical Preview version of the shapes while new diagrams created in the Beta will have the new versions of these shapes.  Also for Cross-functional Flowchart diagrams, significant shape and functionality changes mean that Technical Preview diagrams will open in the Beta but will not be editable.

    More information about the features of Visio 2010 can be found on this blog.  End user help is also available on the Microsoft Office Beta site.

    Visio Services Beta and Visio SDK Beta

    Coinciding with the release of Visio 2010 Beta, we are releasing the Beta version of Visio Services as part of Microsoft SharePoint 2010 Beta.  You can download SharePoint 2010 Beta from MSDN here.   In addition we are releasing a Beta version of the Visio Software Development Kit, a download for solution developers.  We will provide more information about the Visio SDK Beta in an upcoming post.

    Send Us Your Feedback

    We encourage you to download the Beta and give us your feedback.  We’re rapidly approaching the end of the Visio 2010 development cycle, and your feedback is essential to ensure a high quality final product.  You can comment on the posts on the blog or use the Send a Smile tool to let us know what you think.

    Send A Smile in Windows Taskbar

  • Visio Insights

    Updates Regarding the Visio Viewer

    • 8 Comments

    Some of you have recently noticed that your install of the Visio Viewer isn’t working – this is by design and can easily be fixed. Microsoft has recently released Security Bulletin MS09-55 through Windows Update which deactivates Visio Viewers 2002, 2003 and 2007 because of a security issue. With this fix we are retiring Visio Viewer 2002 as well as Visio Viewer 2003. To get your viewer installation back into a working state you have 2 options:

    1. If you can, we recommend that you install the Visio 2010 (Beta) viewer; this version of the viewer has all the functionality of the previous viewers, includes all the required security fixes, and has a product quality that is very close to ship. This build of the viewer can then easily be upgraded to the RTM build of the Viewer when it’s released.
    2. If you can’t or don’t want to download the Visio 2010 (Beta) viewer, you must update your existing viewer by following the steps in the order described below:
      1. If you’re using Viewer 2002 or Viewer 2003, uninstall it and install Visio 2007 Viewer.
      2. Install Visio Viewer 2007 SP1
      3. Install Visio Viewer 2007 SP2
      4. Install the security update KB973709

    The patching discussed in method #2 can also be done through Windows Update but may involve multiples runs of Windows Updates to download the relevant patches – downloading these patches directly is the most efficient way of getting the Viewer back into action.

    If you have more questions about patching your viewer installation, feel free to leave a comment on our blog.

  • Visio Insights

    Visio 2010 is Available Today!

    • 8 Comments

    image

    If you’ve been reading the blog over the past few months, you’ve seen how excited our team is about Visio 2010. Today we are happy to announce that Visio 2010 (and the rest of Office 2010) is available in retail stores and online today. Thanks to everyone who participated in the Technical Preview program, downloaded the Beta, and gave us feedback through the blog or send-a-smile tool. You can get a free trial of Visio 2010 or Office 2010 and purchase them at www.office.com today!

    The Visio Team can answer any questions you have about Visio 2010—just post them in the comments.

  • Visio Insights

    Volume Activation for Visio 2010 Explained

    • 8 Comments

    If you’re an IT administrator managing multiple copies of Visio and Office 2010, this post explains some changes and improvements we’ve made to the deployment experience for Visio 2010. Visio 2010 deployment is a little different than Office 2010 deployment, and this article will illustrate all those differences.

    Volume Activation Methods

    There are two supported volume activation methods for Visio and Office 2010:

    • Key Management Service (KMS). KMS uses a host computer to establish an activation service on your local company network. With a KMS host you can activate thousands of computers at the same time when they regularly connect to the company network. If you use a KMS host to activate Office 2010 or Visio 2010, you can use the same host to activate Windows.

    • Multiple Activation Key (MAK). With MAK, each computer activates Office 2010 and Visio 2010 with the Microsoft hosted activation servers over the Internet or by phone. MAK is recommended when you have fewer than 50 computers to activate, and for computers that are not regularly connected to the company network.

    For more information about those activation methods, see this article on TechNet. There’s also a great blog post on the Office Engineering blog that talks about the differences between these methods.

    Visio Single Image

    Visio 2010 comes in one single-image SKU. This means that the edition of Visio installed is determined by the key that is used to install it. There are three different Visio 2010 editions: Standard, Professional, and Premium. (For more info on the three editions, see this previous post).

    Before you deploy Visio 2010 to your users, you need to decide which edition(s) of Visio you want to deploy.

    The Visio 2010 Single Image SKU is prepopulated with a Visio Premium 2010 KMS client key. This means that if you deploy the Visio 2010 Single Image SKU without making any changes, you will be deploying Visio Premium 2010. If you want to deploy different editions, you need to take additional steps.

    Benefits of Single Image Architecture

    Visio 2010’s new single image architecture was designed to make it easier for organizations to manage multiple editions of Visio 2010. Some of the benefits of single image include:

    • Only one set of bits to download and mange for multiple editions
    • Ability to change editions without having to reinstall Visio
    • Support for upgrading and downgrading editions

    Changing Editions of Visio

    If you’re planning on deploying a different edition of Visio (other than Premium), or deploying multiple editions of Visio, you will need to install the correct product key based on the edition you want. This section is targeted towards those who are using KMS as the activation method, though you can use the same tools to install the correct MAK key. Here are some different options to help you manage this easily:

      1. Pre-deployment

      By default, the KMS client key in the Visio 2010 Single Image SKU is the Visio Premium 2010 key. You may use the “Enter another product key” under the “Licensing and user interface” section in the Office Customization Tool (OCT) to enter the correct KMS client key:

      SKU

      Key

      Visio Premium 2010

      D9DWC-HPYVV-JGF4P-BTWQB-WX8BJ

      Visio Professional 2010

      7MCW8-VRQVK-G677T-PDJCM-Q8TCP

      Visio Standard 2010

      767HD-QGMWX-8QTDB-9G3R2-KHFGJ

      If you don’t enter the key in the OCT, then you can also enter the key in the config.xml file.

      2. Post-deployment: Use VAMT 2.0

      If you’ve already deployed and installed Visio Premium 2010 and want to change editions, it’s easy to do so, and you don’t need to reinstall Visio. Using the Volume Activation Management Tool, you can change the key for every installation of Visio client installed.

      After you change the product key for an installation of Visio 2010, you will need to restart Visio twice for the changes to take effect. From then on Visio will update and run as the edition specified by the new key.

      You can download and get more information about VAMT 2.0 here.

      There’s also a great video here that shows how to use VAMT.

      3. Post-deployment: Ospp.vbs script

      The Office Software Protection Platform script (ospp.vbs script) enables you to configure volume editions of Office 2010 client products. With this script, you can change which keys are used for specific Visio 2010 installations. This is the command you can use to change the key:

      cscript ospp.vbs /inpkey:<Visio key>

      For more information on how to use this script, see this article on TechNet.

    Deploying Multiple Editions of Visio

    The above section talked about how you can change the edition of Visio before installing the single image SKU, and even after you’ve already installed Visio 2010.

    If you’re planning on deploying multiple editions of Visio 2010 in your organization, we recommend you do one of the following:

    1. Keep multiple copies of the Visio 2010 Single Image SKU

      Follow the steps above to customize the single image SKU for each edition of Visio 2010 you are planning on deploying, and keep them around.
    2. Use VAMT or the ospp.vbs script to monitor and change editions of Visio in your organization. VAMT and ospp.vbs make it easy to manage multiple editions of Visio, and you have the option of either a graphical interface or a command line script.

    While we recognize that Visio 2010’s single image SKU requires a little bit of planning before deployment, we hope the benefits of it will save you time in the long run.

    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

    Need help finding commands in the new Visio 2010 ribbon?

    • 7 Comments

    In Visio 2010, we completely revamped the Visio user interface and adopted the Office Fluent UI or the “Ribbon”. With the Office Fluent UI, Visio’s extensive capabilities are organized into logical, easy to find groups that help you accomplish tasks efficiently. The breakdown of each of the core tabs in the Visio 2010 Ribbon was explained in a previous post.

    image

    Although the Office Fluent UI was designed to help make the Office applications easier to work with, we realize that there is a learning curve for the new Office Fluent UI.

    Did you know that there are tools available to help you learn the new Visio 2010 Ribbon?

    Office 2010 menu to ribbon reference workbooks

    Looking for a list of the 2007 menu and toolbar commands and their new 2010 locations? You’re in luck! Each Office application has an Excel workbook that lists the old menu commands and their new locations in the Office Fluent UI. You can find these workbooks here.

    image

    Interactive guides to find commands

    Would you prefer an interactive program that shows you the new location of a command? Interactive guides for each Office application can be found here. Just click the Visio 2007 command or button that you want to find and the guide will show you its location in Visio 2010. These guides are available as online tools or can be installed on your own computer for use any time (even when you’re not connected to the Internet).

    image

    We are enjoying the new look and feel of Visio 2010, and hope you feel the same way! If you have questions or comments about the Visio 2010 Ribbon, please comment on our blog and let us know.

  • Visio Insights

    Custom Containers, Lists and Callouts in Visio 2010

    • 7 Comments

    In previous posts we introduced you to Containers and some of their special capabilities.  We also introduced Lists through their use in Cross-functional Flowchart, Data Graphic Legends and Wireframe shapes.  Finally we introduced Callouts as annotations on Visio diagrams.  Containers, Lists and Callouts can be used in a wide variety of diagram types.  This article explains how shape designers can go beyond the built-in shapes and create their own custom content.

    SD Content examples

     

    Structured Diagrams

    Collectively Containers, Lists and Callouts are referred to as Structured Diagram elements.  They establish relationships with other shapes and those relationships define special behaviors.  For example, shapes placed into a list are automatically arranged adjacent to one another; a callout shape moves whenever its target shape is moved. Structured Diagram elements are shapes themselves, and thus the special behaviors are defined through their ShapeSheet cells and values.

    To designate any shape as a Container, List or Callout you only need to add one User-defined cell called User.msvStructureType.  For the value enter “Container”, “List” or “Callout” as desired.  This setting tells Visio that the shape is a Structured Diagram element and adds many of the Structured Diagrams behaviors to the shape.  In the image below, a rectangle shape is transformed into a container shape by adding the User.msvStructureType cell and setting it to “Container”.  However, there are additional settings available to customize the appearance and behavior of your shape, described in the rest of the article.

    msvStructureType

     

    Container Shape Details

    Any shape with User.msvStructureType = “Container” is treated by Visio as a Container.  The following ShapeSheet cells define additional container properties, several of which can be configured in the Container Tools contextual tab in the Ribbon.

    Cell Name Description
    User.msvSDContainerMargin Distance between container boundary and member shapes
    User.msvSDContainerResize Automatic resize behavior for shape (0 = No automatic resize; 1 = Expand as needed; 2 = Always fit to contents)
    User.msvSDContainerStyle 1-based index value for the current visual style of the container
    User.msvSDContainerStyleCount Total number of visual styles supported by the container
    User.msvSDHeadingStyle 1-based index value for the current visual style of the container heading
    User.msvSDHeadingStyleCount Total number of visual styles supported by the container heading
    User.msvSDContainerLocked Boolean value that prevents membership changes in the container
    User.msvSDContainerRequiredCategories Semi-colon delimited list of category names. Other shapes must have at least one matching name to be allowed as container members.
    User.msvSDContainerExcludedCategories Semi-colon delimited list of category names. Other shapes with at least one matching name are disallowed as container members.
    User.msvSDContainerNoHighlight Boolean value that suppresses the container highlighting when member shapes are selected or added to container
    User.msvSDContainerNoRibbon Boolean value that hides the Container Tools contextual tab in the Ribbon for this container
    User.msvSDContainerHeadingEdge String designating where the interior of the container is from the perspective of the container heading. Must be either “Left”, “Right”, “Top” or “Bottom”.
    User.msvSDMembersOnHiddenLayer Boolean value that determines whether Visio severs container relationships when the container or member is placed on a hidden layer.  If True, Visio allows relationships to exist on the hidden layer.  If False, Visio severs the relationships.

    Creating a visual style

    If you are creating a container shape from scratch, you will notice that by default the container does not have any Container Style or Heading Style available in the Container Tools tab.  Styles are a way to offer different looks for your container through some combination of geometry and formatting changes.  The container shape can define multiple visual styles using the User.msvSDContainerStyle, User.msvSDContainerStyleCount, User.msvSDHeadingStyle and User.msvSDHeadingStyleCount cells (in short, the “Style” cells and the “Count” cells).  Use the Count cells to tell Visio how many styles your shape supports for the overall container or for the heading.  Then determine what ShapeSheet cells should be set for each style.  Put formulas in each of these cells that depend on the value of the Style cells. Visio will check the style count and populate the ribbon galleries with each style defined by the container shape.  When the user chooses a new style from the gallery, Visio puts that style index back into the Style cells to update the look of the container.

    msvSDContainerStyle

    The container shapes in Visio 2010 vary in complexity.  The containers in the Insert Container gallery have many visual styles and lots of formulas to change the appearance of the shapes.  There are some simpler examples in the Wireframe shapes, which define just a few styles each.

    Controlling container membership

    Visio 2010 introduces the concept of Shape Categories to refine the membership behaviors of containers.  This is the mechanism used by features such as Cross-functional Flowchart and Data Graphic Legends to ensure that only the right kinds of shapes participate in the list and container behaviors.  A container shape can restrict membership by defining a required or excluded shape category.  For this to work, a prospective member shape must have a User-defined cell User.msvShapeCategories in its ShapeSheet.  The prospective shape lists one or more category names in a semi-colon delimited string.  To only allow a specific category of member shape, a container can set that name in its User.msvSDContainerRequiredCategories cell.  To allow most shapes as members but specifically exclude a category, a container can set that name in its User.msvSDContainerExcludedCategories cell.  (Prospective shapes with no categories defined will not be allowed in a container with required categories, and they will always be allowed in a container with excluded categories.)

    Creating a heading sub-shape

    The heading of a container is simply the container shape’s text for basic containers.  However, it is possible to achieve more sophisticated visual styles if the heading becomes its own shape.  For this construction the container becomes a group and the heading is added as a sub-shape of the group.  The primary benefit is that Visio can account for the heading sub-shape in sizing and layout operations to avoid putting member shapes on top of the heading.  To designate a sub-shape as a heading for the container, add the cell User.msvStructureType to the sub-shape and give it the value “Heading”.  Also you should properly set the User.msvSDContainerHeadingEdge cell in the sub-shape.  These cells helps Visio understand how the heading is positioned relative to the interior of the container.  For example, if the heading is near the left edge of the container then the correct value for the cell is “Right” (regardless of the heading’s angle).  The interior of the container is on the right side of the heading.

    Showing custom shapes in the Insert Container gallery

    Visio provides several built-in container shapes in the Insert Container gallery located on the Insert tab of the ribbon.  It is possible to override this set of shapes by creating a specially named stencil with other container shapes.  Create a stencil named _CONTAIN.vss and place it in the user’s My Shapes folder.

     

    List Shape Details

    Any shape with User.msvStructureType = “List” is treated by Visio as a List.  Note that Lists are also considered to be Containers.  They simply have the additional capability of ordering and arranging their member shapes.  All of the previously mentioned Container cells apply to list shapes.  The following ShapeSheet cells define additional list properties.

    Cell Name Description
    User.msvSDListAlignment Determines how member shapes are aligned in list (0 = Left; 1 = Center; 2 = Right for vertical lists.  0 = Top; 1 = Middle; 2 = Bottom for horizontal lists.)
    User.msvSDListDirection Direction that list arranges member shapes (0 = Left to Right; 1 = Right to Left; 2 = Top to Bottom; 3 = Bottom to Top)
    User.msvSDListSpacing Distance between list members
    User.msvSDListItemMaster Name or UniqueID of master shape to instance on Insert commands.  Value must be placed inside a USE() function.
    User.msvSDListNoReorder Boolean value that prevents reordering of members.  The list must also be locked via User.msvSDContainerLocked = True for setting to have any effect.
    User.msvSDListRequiredCategories Semi-colon delimited list of category names. Other shapes must have at least one matching name to be allowed as list members.
    User.msvSDListExcludedCategories Semi-colon delimited list of category names. Other shapes with at least one matching name are disallowed as list members.

    Specifying a shape to insert into lists

    There are several ways to add a shape to a list: dragging and dropping the shape, clicking the blue insertion arrow that appears near the list edge or right-clicking an existing member and inserting a shape.  Clicking the insertion arrow and right-clicking to insert both use the User.msvSDListItemMaster cell to determine what shape to add to the list.  The name of the shape is placed in quotes inside a USE() function, such as USE(“Member shape”).  It is also possible to automatically populate the list with some member shapes when the list is first dropped on the page.  To do this put the following formula in the EventDrop cell of the list, repeating the DOCMD(2270) once for each member to be added:

    IF(LISTMEMBERCOUNT()=0,DOCMD(2270)+DOCMD(2270)+DOCMD(2270),0)

    Controlling list membership

    Lists have their own cells to govern list membership.  Use the User.msvSDListRequiredCategories and User.msvSDListExcludedCategories cells to restrict what shapes can become list members.  Because lists are also containers, it is possible for shapes to become container members of the list.  The standard  User.msvSDContainerRequiredCategories  and User.msvSDContainerExcludedCategories cells determine this behavior.  By default Visio will attempt to add a shape to a list as a list member, but if that fails it may try to add it as a container member.  You should manage both sets of cells to ensure the right results.

     

    Callout Shape Details

    Any shape with User.msvStructureType = “Callout” is treated by Visio as a Callout.  Callout shapes must also have a control handle with the Controls row named Controls.Association.  Visio manages the relationship with the callout’s target shape through this row in the ShapeSheet.  The following ShapeSheet cells define additional callout properties.

    Cell Name Description
    User.msvSDCalloutNoHighlight Boolean value that suppresses the highlighting on the callout target shape
    User.msvSDTargetIntersection Location in page coordinates of the intersection between the geometric boundary of the target shape and a virtual line drawn from the center of the callout to the center of the target shape. This is a read-only cell set by Visio.

    Showing custom callout shapes in the Insert Callout gallery

    Visio provides several built-in callout shapes in the Insert Callout gallery located on the Insert tab of the ribbon.  It is possible to override this set of shapes by creating a specially named stencil with other callout shapes.  Create a stencil named _CALLOUT.vss and place it in the user’s My Shapes folder.

     

    Summary

    This post gives shape designers the detailed information needed to create their own Containers, Lists and Callouts.  Please tell us what you think by using the Send a Smile feedback tool or by commenting on this post.

  • Visio Insights

    CAD Integration Announcement for Visio &quot;vNext&quot;

    • 7 Comments

    This morning at Day 2 of Visio Conference 2008, we announced that the next version of Visio will add support for AutoCAD 2007 DWG and DXF file formats.  As mentioned in previous blog posts, this was a major request from Visio customers and partners.

    General Manager Richard Wolf explained in his keynote address how Visio prioritizes feature investments that improve the entire Visio platform over changes that enhance just a single vertical market.  CAD integration is valuable to a broad set of customers spanning the Engineering, Facilities Management and Information Technology markets.  Richard then demonstrated an example of inserting an AutoCAD 2007 floorplan of a data center, overlaying Visio server shapes, adding Data Graphics to show cabinet temperatures and then publishing the diagram to Visio Services for display in a web dashboard.  Thus, while CAD integration does not fall under the three investment areas described on Day 1, it was high on the team's priority list for Visio "vNext" given the applicability to data visualization scenarios across several diagram types.

     

     

    Day 2 also featured demonstrations of new capabilities for developers and shape designers:

    RibbonX

    Visio "vNext" adds support for RibbonX, the API for the Office Fluent user interface.  Existing Visio solutions with custom UI will work unmodified in the Ribbon, but solutions can use RibbonX for a much richer integration into the Ribbon.

    Structured Diagrams

    Visio "vNext" allows solution developers to work with Visio diagrams at a logical level instead of at the physical level.  Visio exposes relationships between shapes that can be discovered and traversed to simplify the understanding of the diagram structure.  Three common relationships are defined: connectivity, containment and callouts.

    Visio Services API

    Visio "vNext" provides a JavaScript API for accessing and enhancing diagrams rendered by Visio Services.  Web page scripts can extract information about the shapes displayed in the diagram for use in another frame.  Scripts can also highlight shapes, place overlays on shapes and manipulate the diagram's viewport for pan and zoom.

     

    The feedback received over the last two days at the Visio Conference has been tremendous.  We're happy to see people so enthusiastic about our Visio "vNext" plans.  There is still much work to be done, and we hope that the Visio community will continue providing feedback as we disclose more over time.

     

  • Visio Insights

    CAD Integration in Visio

    • 7 Comments

    While Visio began mainly as a diagramming package for business, the product has always been capable of making technical drawings.  Visio supports measured and scaled drawings.  It has features such as layers, guides and dimensions to help users create complex and precise drawings.  Not surprisingly then, some of the earliest adopters of Visio were engineers and technical drawers.  This group loved the combination of power and simplicity that Visio provides.

     

    In the engineering software marketplace, one of the most ubiquitous applications is Autodesk’s AutoCAD.  Because AutoCAD is so broadly used, it was essential for Visio to offer the ability to work with AutoCAD drawings.  By integrating with CAD software, Visio connects into engineering and design processes, and it extends technical drawing to people in the organization that either don’t have the training to use CAD software or don’t have the resources to afford CAD software.

     

    Before describing the CAD integration features in Visio, we need to point out which CAD drawings Visio can work with.  Visio 2003 can work with DWG and DXF files saved in the AutoCAD 2000 format (R15) or earlier.  Users working with newer versions of AutoCAD must be sure to save their drawings in a format that Visio will read.

     

    The basic CAD integration features in Visio are import, conversion and export.  Import is the ability to open or insert a CAD drawing into a Visio document and display the drawing on a Visio page.  A drawing is opened using the File > Open menu command and changing the file type to AutoCAD drawing.  A drawing is inserted using Insert > CAD Drawing from the menu.

     

     

    The CAD drawing remains in its native form inside an ActiveX control, but users can choose the insertion scale and layer visibility for the drawing contents.  These properties are accessed by right-clicking on the CAD drawing object and choosing CAD Drawing Object  > Properties.

     

     

    Conversion is the process where some or all of the contents of a CAD drawing are changed into Visio shapes and placed directly on the page.  The conversion command is accessed by right-clicking on the CAD drawing object and choosing CAD Drawing Object  > Convert.

     

     

    Export is the ability to save a Visio drawing out as a CAD drawing.  Visio shapes are converted to CAD entities, and any inserted CAD drawings are written back out as is.  A drawing is exported using the File > Save As menu command and changing the file type to AutoCAD drawing.

     

    Visio and AutoCAD use very different ways to describe a drawing.  Thus translation between a Visio document and a CAD document is not perfect.  There are many differences between Visio shapes and CAD entities such as with text or dimensions or fills / hatches.  Also Visio shapes are large and complex while CAD entities are numerous and simple.  It would be fairly common for a CAD drawing to contain 20,000 entities, but Visio does not normally handle 20,000 shapes at a time.  Expect performance and memory issues if you convert such a drawing.

     

    Because of the challenges converting between AutoCAD and Visio, the most common integration scenario is to import a CAD drawing into Visio but leave it in CAD form.  Then you draw on top of the CAD entities using Visio shapes.  Consider a floor plan imported from CAD that has Visio furniture shapes or electrical wiring drawn on top.  If you want to save everything back to AutoCAD, there are some gotchas to be aware of.  In order for Visio to correctly export both Visio shapes and CAD drawing entities, the CAD drawing must have been imported into Visio using File > Open (not Insert > CAD drawing).  Opening a CAD drawing directly from a file causes Visio to properly set up the page scale and page origin to match the contents of the CAD drawing.

     

    Visio has made improvements in its CAD integration feature set every release, but there are still some issues with Visio 2003 that make conversion and export problematic at times.  Visio 2007 remedies many of these issues.  If you work with CAD drawings, please tell us how you use them with Visio.  If you are having trouble using Visio with your CAD drawings, we’d like to hear about that too.  In a future post we’ll talk about some specific issues in Visio 2003 and changes in Visio 2007.

     

     

Page 2 of 8 (181 items) 12345»