If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
auto aligning shapes in a circle
I'm doing up a couple of network diagrams, and one of our networks is
a hub/spoke topology. Is it possible to select a bunch of shapes, and automatically lay them out in a circle? I can do it manually, but getting the spacing right is killing me... there's 150+ shapes to layout! |
#2
|
|||
|
|||
auto aligning shapes in a circle
It has to be done with code. John Marshall has some code on his site
(visio.mvps.org) for polar arrays. al "Mighty" wrote in message ... I'm doing up a couple of network diagrams, and one of our networks is a hub/spoke topology. Is it possible to select a bunch of shapes, and automatically lay them out in a circle? I can do it manually, but getting the spacing right is killing me... there's 150+ shapes to layout! |
#3
|
|||
|
|||
auto aligning shapes in a circle
Beautiful, that does the trick nicely.
For anyone who comes across this thread in their own desperate hour (Visio 2007, but shouldn't be too different in 2003): 1) Open a Visio document. Select the shape (abovementioned code doesn't arrange existing ones, it takes a sample shape, copies it x times and arranges it around the circle you specify the dimensions of). 2) http://visio.mvps.org/VBA.htm, scroll down to Polar Array. Select the code and ctrl+c to the clipboard. Go to Tools -- Macro -- Visual Basic Editor. Double click on the "ThisDocument" object for your Visio Drawing. Paste code from your clipboard. Close the editor. 3) In the Visio window (with your sample shape selected), go to Tools -- Macro -- ThisDocument -- Polar Array. Answer the prompts (# of items to place, size of circle, angle of first item on circle), and you're done. On Aug 3, 1:16*pm, "AlEdlund" wrote: It has to be done with code. John Marshall has some code on his site (visio.mvps.org) for polar arrays. al "Mighty" wrote in message ... I'm doing up a couple of network diagrams, and one of our networks is a hub/spoke topology. * Is it possible to select a bunch of shapes, and automatically lay them out in a circle? * I can do it manually, but getting the spacing right is killing me... *there's 150+ shapes to layout! |
#4
|
|||
|
|||
auto aligning shapes in a circle
Thanks for pointing that out. I have added a request to my to-do list to add
some code to use the selection rather than repeatedly dropping a specific shape. (Or it is another excuse to dust off the blog. ;-) ) John... "Mighty" wrote in message ... Beautiful, that does the trick nicely. For anyone who comes across this thread in their own desperate hour (Visio 2007, but shouldn't be too different in 2003): 1) Open a Visio document. Select the shape (abovementioned code doesn't arrange existing ones, it takes a sample shape, copies it x times and arranges it around the circle you specify the dimensions of). 2) http://visio.mvps.org/VBA.htm, scroll down to Polar Array. Select the code and ctrl+c to the clipboard. Go to Tools -- Macro -- Visual Basic Editor. Double click on the "ThisDocument" object for your Visio Drawing. Paste code from your clipboard. Close the editor. 3) In the Visio window (with your sample shape selected), go to Tools -- Macro -- ThisDocument -- Polar Array. Answer the prompts (# of items to place, size of circle, angle of first item on circle), and you're done. On Aug 3, 1:16 pm, "AlEdlund" wrote: It has to be done with code. John Marshall has some code on his site (visio.mvps.org) for polar arrays. al "Mighty" wrote in message ... I'm doing up a couple of network diagrams, and one of our networks is a hub/spoke topology. Is it possible to select a bunch of shapes, and automatically lay them out in a circle? I can do it manually, but getting the spacing right is killing me... there's 150+ shapes to layout! |
#5
|
|||
|
|||
auto aligning shapes in a circle
Hey John,
Judy and I'll be in the neighborhood in about two weeks. We'll wave on the way... :-) al "John... Visio MVP" wrote in message ... Thanks for pointing that out. I have added a request to my to-do list to add some code to use the selection rather than repeatedly dropping a specific shape. (Or it is another excuse to dust off the blog. ;-) ) John... "Mighty" wrote in message ... Beautiful, that does the trick nicely. For anyone who comes across this thread in their own desperate hour (Visio 2007, but shouldn't be too different in 2003): 1) Open a Visio document. Select the shape (abovementioned code doesn't arrange existing ones, it takes a sample shape, copies it x times and arranges it around the circle you specify the dimensions of). 2) http://visio.mvps.org/VBA.htm, scroll down to Polar Array. Select the code and ctrl+c to the clipboard. Go to Tools -- Macro -- Visual Basic Editor. Double click on the "ThisDocument" object for your Visio Drawing. Paste code from your clipboard. Close the editor. 3) In the Visio window (with your sample shape selected), go to Tools -- Macro -- ThisDocument -- Polar Array. Answer the prompts (# of items to place, size of circle, angle of first item on circle), and you're done. On Aug 3, 1:16 pm, "AlEdlund" wrote: It has to be done with code. John Marshall has some code on his site (visio.mvps.org) for polar arrays. al "Mighty" wrote in message ... I'm doing up a couple of network diagrams, and one of our networks is a hub/spoke topology. Is it possible to select a bunch of shapes, and automatically lay them out in a circle? I can do it manually, but getting the spacing right is killing me... there's 150+ shapes to layout! |
#6
|
|||
|
|||
auto aligning shapes in a circle
Some of my forum readers (most credit to "wapperdude"!) have been
dinking around with this, starting with John's code, I think. Have a look at this thread: Circle up the wagons, the arc is here! href="http://visguy.com/vgforum/index.php?topic=566.msg2396#msg2396 And on a related note for those who stumble upon this thread: Circular Text Generator (version 2) http://www.visguy.com/2008/01/05/cir...tor-version-2/ -- Hope this helps, Chris Roth Visio MVP Visio Guy: Smart Graphics for Visual People Articles: http://www.visguy.com Shapes: http://www.visguy.com/shapes Dev: http://www.visguy.com/category/development/ Forum: http://www.viguy.com/vgforum John... Visio MVP wrote: Thanks for pointing that out. I have added a request to my to-do list to add some code to use the selection rather than repeatedly dropping a specific shape. (Or it is another excuse to dust off the blog. ;-) ) John... "Mighty" wrote in message ... Beautiful, that does the trick nicely. For anyone who comes across this thread in their own desperate hour (Visio 2007, but shouldn't be too different in 2003): 1) Open a Visio document. Select the shape (abovementioned code doesn't arrange existing ones, it takes a sample shape, copies it x times and arranges it around the circle you specify the dimensions of). 2) http://visio.mvps.org/VBA.htm, scroll down to Polar Array. Select the code and ctrl+c to the clipboard. Go to Tools -- Macro -- Visual Basic Editor. Double click on the "ThisDocument" object for your Visio Drawing. Paste code from your clipboard. Close the editor. 3) In the Visio window (with your sample shape selected), go to Tools -- Macro -- ThisDocument -- Polar Array. Answer the prompts (# of items to place, size of circle, angle of first item on circle), and you're done. On Aug 3, 1:16 pm, "AlEdlund" wrote: It has to be done with code. John Marshall has some code on his site (visio.mvps.org) for polar arrays. al "Mighty" wrote in message ... I'm doing up a couple of network diagrams, and one of our networks is a hub/spoke topology. Is it possible to select a bunch of shapes, and automatically lay them out in a circle? I can do it manually, but getting the spacing right is killing me... there's 150+ shapes to layout! |
#7
|
|||
|
|||
auto aligning shapes in a circle
Rather than wait for the blog, here is the bare code. It still needs some
error checking and other refinements. If nothing is selected, it runs the old code. if something is selected, then it arranges them in a circle. I have disabled the code that rotates the shapes and have left them vertical. If this was to be used for something like a set of chairs around a table, then the shape rotation should be used. Option Explicit Sub PolarArray() ' by Chris Roth Dim shp As Visio.Shape, shpObj As Visio.Shape, celObj As Visio.Cell Dim iNum As Integer, i As Integer Dim dRad As Double, dAngStart As Double, dAng As Double Dim x As Double, y As Double Dim VsoSelect As Visio.Selection Dim VsoShape As Visio.Shape ' obtain the shape to be distributed Set shp = Visio.ActiveWindow.Selection(1) Const PI = 3.14159265358 Set VsoSelect = Visio.ActiveWindow.Selection If VsoSelect.Count 0 Then iNum = VsoSelect.Count dRad = InputBox("Enter the radius for the polar array in inches:", "Polar Array") dAngStart = InputBox("Enter the first angle in degrees (0 deg = 3 o'clock):", "Polar Array") dAngStart = dAngStart * PI / 180 'Convert to radians dAng = 2 * PI / iNum For Each VsoShape In VsoSelect For i = 1 To iNum x = dRad * Cos(dAngStart + dAng * (i - 1)) + 4.25 y = dRad * Sin(dAngStart + dAng * (i - 1)) + 5.5 Set VsoShape = VsoSelect(i) ' Set shpObj = Visio.ActivePage.Drop(shp, x, y) VsoShape.Cells("Pinx").Formula = x VsoShape.Cells("piny").Formula = y ' rotate the shape ' Set celObj = VsoShape.Cells("Angle") ' celObj.Formula = Str(Int((i - 1) * 360 / iNum)) + "deg." Next i Next VsoShape Else iNum = InputBox("Enter the number of items in the array:", "Polar Array") dRad = InputBox("Enter the radius for the polar array in inches:", "Polar Array") dAngStart = InputBox("Enter the first angle in degrees (0 deg = 3 o'clock):", "Polar Array") dAngStart = dAngStart * PI / 180 'Convert to radians dAng = 2 * PI / iNum For i = 1 To iNum x = dRad * Cos(dAngStart + dAng * (i - 1)) + 4.25 y = dRad * Sin(dAngStart + dAng * (i - 1)) + 5.5 Set shpObj = Visio.ActivePage.Drop(shp, x, y) shpObj.Text = i ' rotate the shape Set celObj = shpObj.Cells("Angle") celObj.Formula = Str(Int((i - 1) * 360 / iNum)) + "deg." Next i End If End Sub John... Visio MVP "Mighty" wrote in message ... Beautiful, that does the trick nicely. For anyone who comes across this thread in their own desperate hour (Visio 2007, but shouldn't be too different in 2003): 1) Open a Visio document. Select the shape (abovementioned code doesn't arrange existing ones, it takes a sample shape, copies it x times and arranges it around the circle you specify the dimensions of). 2) http://visio.mvps.org/VBA.htm, scroll down to Polar Array. Select the code and ctrl+c to the clipboard. Go to Tools -- Macro -- Visual Basic Editor. Double click on the "ThisDocument" object for your Visio Drawing. Paste code from your clipboard. Close the editor. 3) In the Visio window (with your sample shape selected), go to Tools -- Macro -- ThisDocument -- Polar Array. Answer the prompts (# of items to place, size of circle, angle of first item on circle), and you're done. On Aug 3, 1:16 pm, "AlEdlund" wrote: It has to be done with code. John Marshall has some code on his site (visio.mvps.org) for polar arrays. al "Mighty" wrote in message ... I'm doing up a couple of network diagrams, and one of our networks is a hub/spoke topology. Is it possible to select a bunch of shapes, and automatically lay them out in a circle? I can do it manually, but getting the spacing right is killing me... there's 150+ shapes to layout! |
#8
|
|||
|
|||
auto aligning shapes in a circle
Love your work mate (and Chris and everyone else that has done work on
this). The below code works perfectly. Wish I'd saved my earlier document with all the correctly-named shapes now Cheers, Brett On Aug 4, 1:52*am, "John... Visio MVP" wrote: Rather than wait for the blog, here is the bare code. It still needs some error checking and other refinements. If nothing is selected, it runs the old code. if something is selected, then it arranges them in a circle. I have disabled the code that rotates the shapes and have left them vertical. If this was to be used for something like a set of chairs around a table, then the shape rotation should be used. Option Explicit Sub PolarArray() ' by Chris Roth Dim shp As Visio.Shape, shpObj As Visio.Shape, celObj As Visio.Cell Dim iNum As Integer, i As Integer Dim dRad As Double, dAngStart As Double, dAng As Double Dim x As Double, y As Double Dim VsoSelect As Visio.Selection Dim VsoShape As Visio.Shape ' obtain the shape to be distributed Set shp = Visio.ActiveWindow.Selection(1) Const PI = 3.14159265358 Set VsoSelect = Visio.ActiveWindow.Selection If VsoSelect.Count 0 Then * * iNum = VsoSelect.Count * * dRad = InputBox("Enter the radius for the polar array in inches:", "Polar Array") * * dAngStart = InputBox("Enter the first angle in degrees (0 deg = 3 o'clock):", "Polar Array") * * dAngStart = dAngStart * PI / 180 'Convert to radians * * dAng = 2 * PI / iNum * * For Each VsoShape In VsoSelect * * For i = 1 To iNum * * x = dRad * Cos(dAngStart + dAng * (i - 1)) + 4.25 * * y = dRad * Sin(dAngStart + dAng * (i - 1)) + 5.5 * * Set VsoShape = VsoSelect(i) ' * *Set shpObj = Visio.ActivePage.Drop(shp, x, y) * * VsoShape.Cells("Pinx").Formula = x * * VsoShape.Cells("piny").Formula = y * * ' rotate the shape ' * *Set celObj = VsoShape.Cells("Angle") ' * *celObj.Formula = Str(Int((i - 1) * 360 / iNum)) + "deg." * * Next i * * Next VsoShape Else * * iNum = InputBox("Enter the number of items in the array:", "Polar Array") * * dRad = InputBox("Enter the radius for the polar array in inches:", "Polar Array") * * dAngStart = InputBox("Enter the first angle in degrees (0 deg = 3 o'clock):", "Polar Array") * * dAngStart = dAngStart * PI / 180 'Convert to radians * * dAng = 2 * PI / iNum * * For i = 1 To iNum * * x = dRad * Cos(dAngStart + dAng * (i - 1)) + 4.25 * * y = dRad * Sin(dAngStart + dAng * (i - 1)) + 5.5 * * Set shpObj = Visio.ActivePage.Drop(shp, x, y) * * shpObj.Text = i * * ' rotate the shape * * Set celObj = shpObj.Cells("Angle") * * celObj.Formula = Str(Int((i - 1) * 360 / iNum)) + "deg." * * Next i End If End Sub John... Visio MVP"Mighty" wrote in message ... Beautiful, that does the trick nicely. For anyone who comes across this thread in their own desperate hour (Visio 2007, but shouldn't be too different in 2003): 1) Open a Visio document. *Select the shape (abovementioned code doesn't arrange existing ones, it takes a sample shape, copies it x times and arranges it around the circle you specify the dimensions of). 2)http://visio.mvps.org/VBA.htm, scroll down to Polar Array. * Select the code and ctrl+c to the clipboard. *Go to Tools -- Macro -- Visual Basic Editor. *Double click on the "ThisDocument" object for your Visio Drawing. *Paste code from your clipboard. *Close the editor. 3) In the Visio window (with your sample shape selected), go to Tools -- Macro -- *ThisDocument -- Polar Array. * Answer the prompts (# of items to place, size of circle, angle of first item on circle), and you're done. On Aug 3, 1:16 pm, "AlEdlund" wrote: It has to be done with code. John Marshall has some code on his site (visio.mvps.org) for polar arrays. al "Mighty" wrote in message .... I'm doing up a couple of network diagrams, and one of our networks is a hub/spoke topology. Is it possible to select a bunch of shapes, and automatically lay them out in a circle? I can do it manually, but getting the spacing right is killing me... there's 150+ shapes to layout! |
#9
|
|||
|
|||
auto aligning shapes in a circle
Oh good. google groups remembered one of my test gmail account logins
instead. below thanks were from original poster. Cheers, Brett On Aug 6, 3:11*pm, Moisture Meter wrote: Love your work mate (and Chris and everyone else that has done work on this). *The below code works perfectly. * Wish I'd saved my earlier document with all the correctly-named shapes now Cheers, Brett On Aug 4, 1:52*am, "John... Visio MVP" wrote: Rather than wait for the blog, here is the bare code. It still needs some error checking and other refinements. If nothing is selected, it runs the old code. if something is selected, then it arranges them in a circle. I have disabled the code that rotates the shapes and have left them vertical. If this was to be used for something like a set of chairs around a table, then the shape rotation should be used. Option Explicit Sub PolarArray() ' by Chris Roth Dim shp As Visio.Shape, shpObj As Visio.Shape, celObj As Visio.Cell Dim iNum As Integer, i As Integer Dim dRad As Double, dAngStart As Double, dAng As Double Dim x As Double, y As Double Dim VsoSelect As Visio.Selection Dim VsoShape As Visio.Shape ' obtain the shape to be distributed Set shp = Visio.ActiveWindow.Selection(1) Const PI = 3.14159265358 Set VsoSelect = Visio.ActiveWindow.Selection If VsoSelect.Count 0 Then * * iNum = VsoSelect.Count * * dRad = InputBox("Enter the radius for the polar array in inches:", "Polar Array") * * dAngStart = InputBox("Enter the first angle in degrees (0 deg = 3 o'clock):", "Polar Array") * * dAngStart = dAngStart * PI / 180 'Convert to radians * * dAng = 2 * PI / iNum * * For Each VsoShape In VsoSelect * * For i = 1 To iNum * * x = dRad * Cos(dAngStart + dAng * (i - 1)) + 4.25 * * y = dRad * Sin(dAngStart + dAng * (i - 1)) + 5.5 * * Set VsoShape = VsoSelect(i) ' * *Set shpObj = Visio.ActivePage.Drop(shp, x, y) * * VsoShape.Cells("Pinx").Formula = x * * VsoShape.Cells("piny").Formula = y * * ' rotate the shape ' * *Set celObj = VsoShape.Cells("Angle") ' * *celObj.Formula = Str(Int((i - 1) * 360 / iNum)) + "deg." * * Next i * * Next VsoShape Else * * iNum = InputBox("Enter the number of items in the array:", "Polar Array") * * dRad = InputBox("Enter the radius for the polar array in inches:", "Polar Array") * * dAngStart = InputBox("Enter the first angle in degrees (0 deg = 3 o'clock):", "Polar Array") * * dAngStart = dAngStart * PI / 180 'Convert to radians * * dAng = 2 * PI / iNum * * For i = 1 To iNum * * x = dRad * Cos(dAngStart + dAng * (i - 1)) + 4.25 * * y = dRad * Sin(dAngStart + dAng * (i - 1)) + 5.5 * * Set shpObj = Visio.ActivePage.Drop(shp, x, y) * * shpObj.Text = i * * ' rotate the shape * * Set celObj = shpObj.Cells("Angle") * * celObj.Formula = Str(Int((i - 1) * 360 / iNum)) + "deg." * * Next i End If End Sub John... Visio MVP"Mighty" wrote in message .... Beautiful, that does the trick nicely. For anyone who comes across this thread in their own desperate hour (Visio 2007, but shouldn't be too different in 2003): 1) Open a Visio document. *Select the shape (abovementioned code doesn't arrange existing ones, it takes a sample shape, copies it x times and arranges it around the circle you specify the dimensions of). 2)http://visio.mvps.org/VBA.htm, scroll down to Polar Array. * Select the code and ctrl+c to the clipboard. *Go to Tools -- Macro -- Visual Basic Editor. *Double click on the "ThisDocument" object for your Visio Drawing. *Paste code from your clipboard. *Close the editor. 3) In the Visio window (with your sample shape selected), go to Tools -- Macro -- *ThisDocument -- Polar Array. * Answer the prompts (# of items to place, size of circle, angle of first item on circle), and you're done. On Aug 3, 1:16 pm, "AlEdlund" wrote: It has to be done with code. John Marshall has some code on his site (visio.mvps.org) for polar arrays. al "Mighty" wrote in message .... I'm doing up a couple of network diagrams, and one of our networks is a hub/spoke topology. Is it possible to select a bunch of shapes, and automatically lay them out in a circle? I can do it manually, but getting the spacing right is killing me... there's 150+ shapes to layout! |
#10
|
|||
|
|||
auto aligning shapes in a circle
The macro associated with the Circle the Wagons post will place a selected
shape in either a circle or in an arc. The latest incarnation adds rainbow color option. John's code? Chris' code? I think the history of the polar array macro is the original written by Chris and posted on John's site. It is the basis for the arc array macro, which has added error checking, options, and is posted on Chris' site. Funny world, eh? For the present application, either the Polar or Arc macros should work fine. Wapperdude "Chris Roth [Visio MVP]" wrote: Some of my forum readers (most credit to "wapperdude"!) have been dinking around with this, starting with John's code, I think. Have a look at this thread: Circle up the wagons, the arc is here! href="http://visguy.com/vgforum/index.php?topic=566.msg2396#msg2396 And on a related note for those who stumble upon this thread: Circular Text Generator (version 2) http://www.visguy.com/2008/01/05/cir...tor-version-2/ -- Hope this helps, Chris Roth Visio MVP Visio Guy: Smart Graphics for Visual People Articles: http://www.visguy.com Shapes: http://www.visguy.com/shapes Dev: http://www.visguy.com/category/development/ Forum: http://www.viguy.com/vgforum John... Visio MVP wrote: Thanks for pointing that out. I have added a request to my to-do list to add some code to use the selection rather than repeatedly dropping a specific shape. (Or it is another excuse to dust off the blog. ;-) ) John... "Mighty" wrote in message ... Beautiful, that does the trick nicely. For anyone who comes across this thread in their own desperate hour (Visio 2007, but shouldn't be too different in 2003): 1) Open a Visio document. Select the shape (abovementioned code doesn't arrange existing ones, it takes a sample shape, copies it x times and arranges it around the circle you specify the dimensions of). 2) http://visio.mvps.org/VBA.htm, scroll down to Polar Array. Select the code and ctrl+c to the clipboard. Go to Tools -- Macro -- Visual Basic Editor. Double click on the "ThisDocument" object for your Visio Drawing. Paste code from your clipboard. Close the editor. 3) In the Visio window (with your sample shape selected), go to Tools -- Macro -- ThisDocument -- Polar Array. Answer the prompts (# of items to place, size of circle, angle of first item on circle), and you're done. On Aug 3, 1:16 pm, "AlEdlund" wrote: It has to be done with code. John Marshall has some code on his site (visio.mvps.org) for polar arrays. al "Mighty" wrote in message ... I'm doing up a couple of network diagrams, and one of our networks is a hub/spoke topology. Is it possible to select a bunch of shapes, and automatically lay them out in a circle? I can do it manually, but getting the spacing right is killing me... there's 150+ shapes to layout! |
|
Thread Tools | |
Display Modes | |
|
|