Solved

Visio 2013 - How to find the exact center of a shape.

Posted on 2014-03-21
3
1,606 Views
1 Endorsement
Last Modified: 2014-04-08
I have a odd shaped polygon which I would like to create a connection point in the center of.  I'm looking for any tips and tricks for quickly finding the center of the shape.
1
Comment
Question by:brothertruffle880
3 Comments
 
LVL 7

Accepted Solution

by:
XGIS earned 167 total points
ID: 39947108
Hello brothertruffle880,
Please find attached a sample of achieving the goal using some different techniques.  The centre you are referring to is generally predefined for "regular" shapes. Irregular shapes may not have a "centre", but rather a centroid.  By using the "Text Block" on the ribbon bar under HOME | TOOLS you can identify the centroid which will either be IN or OUT of the free-form polygon.   The feature is also a line and not a proper polygon although it can appear to be a fully closed polygon.

The workaround here is to create some very small ellipse features exactly where you want the centre to be represented.  Join your features with 2 or more connectors.  Straight connectors can often be less confusing than angled ones. Then just set the line of the ellipses (fake centres) to "No Colour".  

You may also find some settings under "File | Options | Advanced" that will help with Free-Form construction.    You can also modify "Snap and Glue" settings under the "View | Visual Aids" ribbon.

Hope this helps. No magic but it will achieve your goal.  I would "group" the items after the task is complete to prevent separation.     Cheers Aaron
VisioSnapNGlueSettings.PNG
Visio2013FreeformConnectorSample.txt
0
 
LVL 49

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 167 total points
ID: 39947147
Hi,

to find the centroid of the selected polygon pls try

Sub Macro()
Dim ArrCoord() As Variant
Set s = Selection
CoordCount = s.ShapeRange.Nodes.Count
ReDim ArrCoord(1, CoordCount - 1)
For Each Nde In s.ShapeRange.Nodes
    pts = Nde.Points
    ArrCoord(0, Idx) = pts(1, 1)
    ArrCoord(1, Idx) = pts(1, 2)
    Idx = Idx + 1
Next

For Idx = 0 To UBound(ArrCoord, 2) - 1
            area = area + _
            (ArrCoord(0, Idx + 1) - ArrCoord(0, Idx)) * _
            (ArrCoord(1, Idx + 1) + ArrCoord(1, Idx)) / 2
Next

area = Abs(area)
X = 0
Y = 0
For Idx = 0 To UBound(ArrCoord, 2) - 1
    second_factor = _
        ArrCoord(0, Idx) * ArrCoord(1, Idx + 1) - _
        ArrCoord(0, Idx + 1) * ArrCoord(1, Idx)
    X = X + (ArrCoord(0, Idx) + ArrCoord(0, Idx + 1)) * _
        second_factor
    Y = Y + (ArrCoord(1, Idx) + ArrCoord(1, Idx + 1)) * _
        second_factor
Next

X = X / 6 / area
Y = Y / 6 / area
If X < 0 Then
    X = Abs(X)
    Y = Abs(Y)
End If
MsgBox "Coordinates of the barycenter are X: " & X & "and Y: " & Y
End Sub

Open in new window

Regards
0
 
LVL 30

Assisted Solution

by:Scott Helmers
Scott Helmers earned 166 total points
ID: 39953201
The explanations above are great for finding the mathematical center of a shape. There is a simpler approach if you want to use the default location that Visio uses as the center of rotation for a shape: it's at width*0.5 and height*0.5 for the rectangle that contains the shape.

Consequently, the "center" of your irregular polygon is at that location and Visio stores these coordinates in two cells in the Shape Transform section of the shapesheet: LocPinX and LocPinY. If you look at them you will probably see values of Width*0.5 and Height*0.5, respectively.

To create a connection point at that location:

If your shape already has a Connection Points section, add a new row; if not right-click in the shapesheet, select Insert Section, select Connection Points, and then click OK.

In the desired Connection Points row, set X to LocPinX and set Y to LocPinY.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever created a custom Visio stencil – a collection of your own unique master shapes – and then created a drawing by dragging masters onto the drawing page? Have you then made changes to the stencil master and wondered why the shapes on the …
A recent Visio zone question asked how to use the data in an Excel file to create a Visio Gantt chart -- and then to dynamically update the Gantt chart. The good news is that the Viso Gantt Chart wizard can be automated. The bad news is that the…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now