News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Rotate a group of Shapes

Started by mmulvenna, May 08, 2008, 02:23:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mmulvenna

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

Visio Guy

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:


  • ANGLETOLOC
  • ANGLETOPAR
  • LOCTOLOC
  • LOCTOPAR
  • PAR
  • PNT

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
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

mmulvenna

#2
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.

Visio Guy

Do you have a formula in the Angle cells as well? You won't get any rotation from PinX/PinY :)
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

mmulvenna

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

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 246 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1077KB.
Tokens: post-login.
Cache hits: 14: 0.00417s for 26,742 bytes (show)
Cache misses: 4: (show)
Queries used: 18.

[Show Queries]