Maintain aspect ratio and relative position in a Visio group

Kevin Meiresonne picture Kevin Meiresonne · Jun 19, 2013 · Viewed 12.2k times · Source

I'm currently creating a custom container shape in Visio 2010 but having some trouble getting the correct resizing behavior. My container consists of a main rectangle and a small triangular shape at the top right (see image). Both these shape are grouped.

Custom container consisting of rectangle and triangle

When resizing this group, I want the rectangle to resize, but the triangle should keep its original size ans aspect ratio and remain "attached" to the side of the rectangle.

When I set the triangle's resize behavior to "Use group setting" (default), it gets deformed when resizing:

triangle deformed

When I set the triangle's resize behavior to "Reposition only", it does not maintain attached to the rectangle:

triangle detached

Is there any way I can get the desired behavior?

Answer

Jon Fournier picture Jon Fournier · Jun 19, 2013

If you want to keep the triangle in the same relative position, and at the same absolute size, you'll need to use the shapesheet.

The formulae you're interested in will be the PinX, PinY, Width, and Height for the rectangle. The Width and Height should stay the same, so the formula should just be =GUARD(0.25 in.), where you replace 0.25 with whatever the width or height should be.

When you grouped the shapes, Visio automatically set up formulas to stretch the sub shapes, and move them as a proportion of the size of the group shape. So if you look at the PinX formula for the Triangle, it might be something like: =Sheet.1!Width*0.95 . That just means the triangle's X location will always be at 95% of the width of the parent shape.

But that's not what you want. What you want is for the triangle always to sit on the right edge of the rectangle. So to do that your formula just has to calculate to be the right edge of the rectangle (its width) plus half the width of your triangle (the Pin location default is the midpoint of your shape).

So to make your formula you need the ID of the rectangle sub shape, which you can find by accessing the Format->Special dialog for the rectangle. Once you get that number, the PinX formula for the triangle should just be =GUARD(Sheet.RectangleID!Width+(Width/2))

I think the PinY for the triangle should be all set as it is, as long as the width and height are guarded.