Generating a centroid for a polygon

Discussion created by yousafhassan on Oct 13, 2011
Latest reply on Oct 14, 2011 by hzhu
I posted this question in a generic thread earlier, but was wondering if it can be done in python.

I am trying to help my colleague who wants to select a polygon and then click a button (or a custom tool), which would generate a centroid for that polygon. Ideally, he wants a pop-up to appear which would display a copy&pasteable X and Y. He wants this automation as he wants X and Y to be generated for all polygons using the same algorithm.

I was thinking of building a custom tool for him using a model. Could anyone please point me to the tools I need in order to achieve this? If you have already written a tool, would you like share it with me? I am quite comfortable in python and VBA but am not so familiar with Arc tools. I would actually prefer to do this in python as the support for VBA won't be there in future.

I am looking at the CalculateField example: Calculate centroids on this link:

I was wondering how I can adapt this python script in to doing the above, i.e. the input is the selected polygon and the output is a pop-up displaying X and Y.

Any help would be extremely appreciated.