johnvisiomvp

Life with Visio and other Microsoft Toys!

Open Shape Surgery for the Visio Developer

leave a comment »

One of the first gotchas for new Visio developers is the UnGroup command.

Visio shapes are simple, they can have one colour and one line type. To make a traffic light, you need to group a red circle, yellow circle and a green circle. When grouped, Visio will take a collection of shapes and create a new shape with a group section and a shape collection of the shapes selected. To  ungroup, the shapes are released from the collection and the group shape is deleted. The process is reversible, some times. Shape developers learned early on, that this new shape was like any other shape and could have other sections added to it. Shape Data, User Data, Connections, Control Handles etc. Unfortunately, when these shapes are ungrouped, these extra sections are not preserved. So knowing this why would you ever want to ungroup one of these these?  You can always subselect or use the Drawing Explorer to get access to one of the sub shapes. Welcome to one of the other gotchas, the bounding box. Sometimes you have to ungroup, and create a group with a more appropriate bounding box. You can go bigger by adding a temporary shape of the desired size, lock the group from recalculating the bounding box and delete the temporary shape, but you can not go smaller without Ungrouping. You would then create a shape of the correct size, group it and before adding the other shapes to the group, lock the group shape from recalculating. The final cleanup would be to add back the component shapes and delete the temporary shape.

Early on Graham Wideman showed me a way to remove VBA projects from a Visio solution. Deleting the VBA only got you part of the way, there was still a Project stub that made Visio think the file contained a VBA solution. His solution was to edit the XML version of the file and delete the stub.

 

 

 

 

Written by johnvisiomvp

April 17, 2016 at 4:22 pm

Posted in Visio, Shapes, VBA

Tagged with , ,

UWP Samples generate hundred of errors?

with one comment

For the past few months I have had problems trying to run any of the Windows 10 UWP samples. Each attempt resulted in hundreds of errors.  Yesterday, thanks to Colin Melia and a little Google spelunking I may have found the issue and the solution.

The Googling turned up https://github.com/Microsoft/Windows-universal-samples/issues/182 which indicates the same issues and that the problem may be with one of the references, Microsoft.NetCore.UniversalWindowsPlatform. Since I have been having issues, I did a clean install and installed the Windows 10 SDK. The issue appears to be that the samples were created with the 5.0 version of that file, but the clean install used 5.1. So when trying to open the samples, the reference could not resolve.

The solution was to open the project, in the Solution Explorer, right click reference and chose Manage NuGet Packages… Select Microsoft.NetCore.UniversalWindowsPlatform and select Update. I was able to do a Clean Project and Run.

No more errors!

Hopefully this will work for others.

Remember, if your solution contains more than one project, you probably will have to do this for each project.

Enjoy.

John Marshall… Visio MVP       Visio.MVPs.org

Written by johnvisiomvp

April 17, 2016 at 4:21 pm

Taming Geometry Sections in Visio

leave a comment »

Ever create a pair of shapes in Visio, butted them together and do a Union operations and find that the joining line between the shapes does not disappear and find that the new shape has two geometry sections? So, before you start to copy rows from one section to the other, place a rectangle shape over the offending line and union that with the original shape. You will now have one Geometry section. The rectangle does not have to be a precise match, just cover part of the line. You can then easily edit the Geometry section and delete the offending rows. Far easier than copying rows between Geometry Sections.

Recently I was creating shapes that basically looked like a stack of trapezoids. Rather than create the trapezoids, I created a stack of rectangles. Each rectangle was the width of the various cross sections and the height was the distance between transitions.  Once Unioned, I edited the shapesheet and deleted the extra rows that the rectangles created.

Next time I will talk about open shape surgery, a lesson learned from an old master.

Enjoy.

John Marshall… Visio MVP       Visio.MVPs.org

Written by johnvisiomvp

November 22, 2015 at 2:29 am

Posted in Shapes, Uncategorized, Visio

Tagged with , ,

Shape Developers need Love too!

leave a comment »

It has been a while since the demise of ShapeStudio. It was not the greatest, but it did help developers create series of shapes. Using the Shapesheet is not for the faint of heart. The shapesheet is a powerful tool for creating shapes and adding functionality, but, but it is labour intensive. What is needed is some enhancements.

Sorting? Not necessarily sorting, but the developer should be able to change the order of the rows in the shape data, user data and connection sections. Rather than using a menu item, an up/down toggle button would be preferred. Using a menu item, is not a big deal, but do it a hundred times and it becomes tedious.

In addition to rows, Geometry sections should also be able to be reordered.

If the order of the Geometry sections can be changed, joining adjacent Geometry sections should be relatively easy. Each Geometry section has a start and end point, so joining would mean there would be an end and start row in the middle of the section.

Of course, not all Geometry sections have a convenient start and end point. So it would be useful to reverse a Geometry Section so the one section ends here the adjacent section starts.

A few versions back, Visio added relative positioning in the Geometry section. Another useful feature would be a toggle bottom to switch between absolute to relative
A toggle button to switch a Geometry row from absolute to relative. Sometimes it is easier to enter absolute positions, other times it is easier to use relative. Currently you can use a menu item, but that involves selecting the Change Item type and remembering the appropriate alternate type.

When you are working on a Geometry section, the row you are working on is highlighted in the drawing to let the designer where that point is. Also for reference, if the PinX or PinY cells are selected, a cross should be placed over that point so the designer can see where the point is.

One of the first things that bites first time shape developers is the ungroup command. For some applications Group and Ungroup are complements and you can ungroup and then group to get back to where you were. In most cases this is true, but with Visio, grouping creates a new shape to control the other shapes and ungroup deletes that shape. This group shape, like any other shape can be enhanced, but ungrouping will also remove these enhancements. So, if you add user data, shape data, actions or connection points, these will be lost. Another nicety for shape developers would be the ability to copy these sections from other shapes. So, never ungroup should be the rule? No, during shape development, grouping and ungrouping is a very useful tool. You can align a set of shapes on their centers, group them and then align or distribute this group with other shapes/groups without destroying the group on center the shapes have in the original group.

Outside the Shapsheet
Of course, before even getting into the shapesheet, the ability to sort the shapes in the stencil would be very useful. Yes, this can be done with VBA, but this should be a standard feature.

An alternate to the bounding box is needed. Rather than a box, the shape involved should change color. The bounding box just shows that something in that area was selected. A bonus would be to use gradient colors that show the direction of lines.

If the shapesheet is like a spreadsheet, why can we not copy and paste cells, rows and sections between shapesheets like Excel? What about copying from a shapesheet to Excel and back.

Enjoy.

John Marshall… Visio MVP       Visio.MVPs.org

Written by johnvisiomvp

October 17, 2015 at 4:00 am

Posted in Uncategorized

Dual Outlets

leave a comment »

The VBA code to stack shapes was used to create a series of shapes that represented inserts into the cap of a bottle that allowed hoses to be connected. For the single connections, the shapes making up the stack were horizontally symmetrical, so after stacking the shapes it was a simple matter of aligning all the shapes around their centers. The dual connections were only slightly more complex. All the shapes were aligned around the same center, but the shape through the cap was offset from the rest. So, it was just a matter of adding a horizontal guide to align to the edge of the bottom shape above the cap and then horizontally move the part within the cap to align to the guide. The next step was to use the Size & Position window to add the horizontal offset to that shape.

So, now I had a single outlet shape with the proper offset. The next step was to group the shape, duplicate the group and align the two grouped shapes horizontally and vertically. The result is a dual version of the shape. Cleanup involved deleting the duplicated section through the cap, ungrouping and doing a Join operation to simplify the shape. Since I had to do a number of shapes of various cap sizes, outlet sizes and offsets, I kept a master of the single outlet version (the one with the offset), so I could earebuild the shapes.

Enjoy.

John Marshall… Visio MVP       Visio.MVPs.org

Written by johnvisiomvp

August 21, 2015 at 7:49 am

Posted in Shapes, Visio

Tagged with ,

Are Visio Shapes Stacked against you?

leave a comment »

Recently I have been working on some Visio shapes that were basically a stack of rectangles. Though Visio has tools for aligning and distributing shapes, it does not have an easy way of stacking shapes. If you are lucky enough to have shapes that are multiples of the grid size, it is a piece of cake. If not, the guides can be used to connect a shape, above or below the guide. If you want to do more than two it gets tricky. First, you have to determine the top of the shape to determine where to place the next guide. Then use the Size / Position dialog to set the position of the guide. You can then add the next shape to the guide.

This of course would be tedious, but long before Visio was acquired by Microsoft, it was the first non Microsoft company to fully implement VBA. So, now the problem is trivial, turn on developer mode and write some VBA. So, this routine will take the selected shapes and stack them.

Public Sub StackVertical()
Dim vsoSelect As Visio.Selection
Dim vsoShape As Visio.Shape
Dim ShapeH As Double
Dim OldShapeH As Double
Dim pin As Double

Set vsoSelect = Visio.ActiveWindow.Selection
If vsoSelect.Count > 0 Then
Set vsoShape = ActiveWindow.Selection.Item(1)
pin = vsoShape.Cells(“piny”).Result(“inches”) + vsoShape.Cells(“LocPinY”).Result(“inches”)

For Each vsoShape In vsoSelect
ShapeH = vsoShape.Cells(“Height”).Result(“inches”)
vsoShape.Cells(“piny”) = pin – (OldShapeH + ShapeH) / 2
pin = pin – (OldShapeH + ShapeH) / 2
OldShapeH = ShapeH
Next vsoShape
Else
MsgBox “You Must Have Something Selected”
End If

End Sub

… and the following code will stack the shapes horizontally.

Public Sub StackHorizontal()
Dim vsoSelect As Visio.Selection
Dim vsoShape As Visio.Shape
Dim ShapeW As Double
Dim OldShapeW As Double
Dim pin As Double

Set vsoSelect = Visio.ActiveWindow.Selection
If vsoSelect.Count > 0 Then
Set vsoShape = ActiveWindow.Selection.Item(1)
pin = vsoShape.Cells(“pinx”).Result(“inches”) – vsoShape.Cells(“LocPinx”).Result(“inches”)

For Each vsoShape In vsoSelect
ShapeW = vsoShape.Cells(“Width”).Result(“inches”)
vsoShape.Cells(“pinx”) = pin + (OldShapeW + ShapeW) / 2
pin = pin + (OldShapeW + ShapeW) / 2
OldShapeW = ShapeW
Next vsoShape
Else
MsgBox “You Must Have Something Selected”
End If

End Sub
Though you could do a select area, it may be safer to use the Ctrl key to select the shapes in the stacking order you want.

Enjoy.

John Marshall… Visio MVP       Visio.MVPs.org

Written by johnvisiomvp

August 14, 2015 at 1:05 pm

Posted in Shapes, Visio

Tagged with ,

Future of Visio?

with one comment

Visio was introduced 22 years ago and has unfortunately become complacent. The Visio wannabees have become established and use half-truths to promote their products. What was Visio’s last oh wow feature, something to make the market pay attention?

In its’ life time, most under the Microsoft brand, Visio has come out with some interesting innovations, Data Graphics, Containers, Rules, the shapesheet and a programmable model. Before joining Microsoft, Visio was the first non-Microsoft company to fully embrace VBA.

Initially, Visio was a simple way of making connected diagrams. Drop a predefined shape and add a connection line. If the shape moves, the lines remained connected. Unlike other packages at the time, which did not have the connection feature, you were not limited to the eight shapes they supplied. The Visio team had added some magic behind the shapes, called the shapesheet. My handwriting is atrocious and I can not draw, but with the shapesheet I am able to create some fantastic shapes. Nothing compared to the mastery of one of the original shape miesters like Chris Roth, but adequate. The shapesheet contains formulas that react to the shapes surroundings. So, you could start a shape from scratch or build on an existing shape. Chris Roth’s site is the place to be if you want to be a shape developer.

Then custom properties were added so the shapes could contain more than a picture of the object. The information could surface in reports or be used to alter the shapes appearance. A critically low value could change the shape colour to red. Along the way, it was possible to interrogate a Visio drawing or modify it under the control of a program. Data Graphics added the ability to add KPIs to a shape without cluttering a drawing. Since one use of Visio drawings was to illustrate processes, rules were added (I am willing to bet most people are not aware that there were Visio Rules (Check out David Parker’s books, he is our Rules wizard)). So, with rules you could check a drawing for compliance and is with most things Visio, you were not limited to the rules in the box. As I said, David Parker wrote the book on it.

So, what happened? When Visio was on its’ own, it had full control of the marketing and training, but as part of Microsoft, Visio is just a small piece of the puzzle. Now marketing has a plethora of products to promote and sales can make their quota on other products. Unfortunately, a lot of people are unaware of Visio’s capabilities. Most consider it just a diagramming tool using clipart. On the Microsoft site, there are a number of “Visio” stencils which are no more than clipart encapsulated in a Visio shape, with none of the smarts of a true Visio shape.

Visio 2013 was a great product, but it was released more than three years ago. So far, there have been no hints of what is to come, or if there will be a new version.

So what needs to happen? There needs to be a stronger marketing campaign to promote Visio both inside and outside Microsoft. Has anybody heard of an ad for Visio? The sales force needs to aggressively promote Visio features, especially to the regions. By the time information reaches the regions, the gung ho attitude has been watered down and Visio has become just a clipart diagramming tool.

There should be a Visio-lite to get more on board. A web version would take of the Visio wannabees who complain that there is no a Mac version.

The programming of Visio should be simplified. In the old days I use to use VB until Visio spoiled me with VBA. I have tried to return, but the various methods, like VSTO have too much overhead or the process of including shapes is convoluted and keeps changing. There should also be training. At one point there was certification for Visio, but that has lapsed. And when I talk about programming Visio, I also include those who want to master the shapesheet.

Price

I have owned almost all versions of Visio, except Visio Maps, but I am probably not the best person to comment on the price. I have never paid for a version. What got me interested in Visio was a Visio 1 sampler that was on a Windows 3.1 upgraded evaluator floppy from Microsoft Canada. I started answering questions on the ShapeWare forum on CompuServe and as Visio improved, was given beta versions and then the final releases. Having said that, I do find the price high. This is software, not a physical object, so dropping the price just means you have to sell more for the same revenue. A lower price would increase demand and destroy the main reason used by the wannabees.

MSO shapes – (MSO – MicroSoft Office) For a long time, the other Office products, Word, Excel, PowerPoint and Publisher have had Visio like capabilities. The problem is that these drawings can not be copied into Visio and the experience continued. What you get is a single grouped shape. Ungroup it and it falls apart. A simple red text box becomes a shape for the fill colour, a shape for the outline, a shape for the text. So you end up redrawing using real Visio shapes. At some point the MSO shapes need to merge into Visio.

As part of the learning curve, anyone who wants to appreciate the power of Visio should visit the websites of my fellow Visio MVPs: David Parker, John Goldsmith and especially Chris Roth.

Enjoy.

John Marshall… Visio MVP       Visio.MVPs.org

Written by johnvisiomvp

January 27, 2015 at 3:46 am

Posted in Visio

Follow

Get every new post delivered to your Inbox.

Join 428 other followers