Solved

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

Posted on 2014-03-21
3
1,734 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 50

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Scott A. Helmers Partner, Harvard Computing Group Microsoft Visio MVP Background Microsoft has added more enhancements and new features to Visio 2010 than to any release since they purchased the Visio product line in 2000. In addition, the com…
David Parker’s latest book, Microsoft Visio 2010: Business Process Diagramming and Validation, will give you the tools to turn flowcharts and other business diagrams into valuable, data-driven corporate assets. Armed with the knowledge you’ll gain f…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 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