Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-03-21
3
Medium Priority
?
2,310 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 668 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 53

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 668 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 31

Assisted Solution

by:Scott Helmers
Scott Helmers earned 664 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
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 I’ll describe a mashup of containers and lists that meet a real-world need. Prior to reading this ar…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

876 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