Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: mmulvenna on May 08, 2008, 02:23:50 PM

Title: Rotate a group of Shapes
Post by: mmulvenna on May 08, 2008, 02:23:50 PM
I have a group of shapes that I have formulas for PINX and PINY. When i size or move the group my formulas work just fine.
When I rotate the group however, some of the formulas do not work.
Is there a way to calculate a new x and y coordinates based on the original coordinates using a formula for the angle of rotation?

Thanks
Mike
Title: Re: Rotate a group of Shapes
Post by: Visio Guy on May 08, 2008, 06:06:05 PM
Hi Mike,

What kind of formulas? Maybe post a few here so we can help.

But 'til then, I'll take a whack...

A typical formula to get a sub-shape to remain level when the group is rotated looks like this:

     Angle = -Sheet.5!Angle

where "Sheet.5" is the group.

More advanced, to handle horizontal and vertical flips of the group looks like this:

     Angle = IF( BITXOR( Sheet.5!FlipX, Sheet.5!FlipY ), Angle, -Angle )

Its not really obvious why, but it works, even when the group gets flipped!

Other functions related to transforming one shape's coordinates to another, which can be useful for shapes inside of groups include:


You can read more about these functions in the Developer Help or in the really nice help file that ships with the Visio 2007 SDK (http://www.microsoft.com/downloads/details.aspx?FamilyID=772ccdd1-7d06-4cc4-8ecd-de5864428c26&displaylang=en)
Title: Re: Rotate a group of Shapes
Post by: mmulvenna on May 08, 2008, 06:16:29 PM
Thanks for the reply.
I do want all the shapes to rotate.
Here is a formula in the pinx cell of a shape.
=GUARD(Sheet.1!PinX-Sheet.1!LocPinX+LocPinX+Sheet.1!Width)

Also this one in the piny cell
=GUARD(Sheet.1!PinY+Sheet.1!LocPinY+LocPinY-(Height*2))

This works great when the selected group of shapes is moved or resized but does not correctly calculate when it is rotated.

The values appear to be off by some calculation of the angle.
Title: Re: Rotate a group of Shapes
Post by: Visio Guy on May 22, 2008, 06:16:12 PM
Do you have a formula in the Angle cells as well? You won't get any rotation from PinX/PinY :)
Title: Re: Rotate a group of Shapes
Post by: mmulvenna on May 23, 2008, 12:21:49 AM
I selected all the shapes and then grouped them. This automatically fixed most of the rotation issues because of group inheritance.

After the group is  rotated and I insert shapes and then add them to the group thru the code in the CALLTHIS function, I had to set the angle of the inserted shape to =guard(0) and the rotation using group handles work just fine. Also the flip functions from the menu work fine on the group.

Hope that makes sense ???

Thanks
Mike