Solved

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

Posted on 2014-03-21
3
2,008 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 52

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

The ability to add structure to Visio diagrams using containers, lists and callouts is one of my favorite features in Visio 2010. In this article we’ll examine lists. We’ll explore containers and callouts in separate articles. Prior to reading th…
Book Review: Using Microsoft Visio 2010 by Chris Roth   Disclaimer: The author of Using Visio 2010 is a friend and fellow Visio MVP. Whether you’re new to Visio or are upgrading to Visio 2010 from a previous version, you will find a lot to like…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

617 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