Like it says on the tin. I wrote this script because I had thousands of features in a CAD drawing which were supposed to represent points, but were closed boxes made of lines instead.
|# @date 26/06/2015|
|# @author Cindy Williams|
|# Creates centroids from closed lines by creating temporary|
|# For use as as a standalone script.|
|arcpy.env.workspace = r"C:\Some\Arb\Folder\work.gdb"|
|lyr_line = "ftr_line"|
|lyr_point = "ftr_point"|
|fields = ["SHAPE@", "Name"]|
|cursor_ins = arcpy.da.InsertCursor(lyr_point, fields)|
|with arcpy.da.SearchCursor(lyr_line, fields) as cursor:|
|for row in cursor:|
|poly = arcpy.Polygon(row.getPart())|
|centroid = arcpy.PointGeometry(poly.centroid)|
The script builds a polygon from the parts of the line, creates a centroid and inserts it into a point feature class.