# Filename: pl_coordinates.py
# Purpose: Used for polygon coordinates.

from maptek import vulcan_gui

# use dynamic selection to select correct object
sel = vulcan_gui.selection("Select closed polygon.")
sel.criteria = ["LINE", "POLYGON"]  # limit selection to a polyline object
sel.single_object = True  # prevents selection prompt from asking more than once

for obj in sel:
    obj_name = obj.get_name()  # get name of object
    
    # get coordinates of selected object
    coord_list = obj.coordinates   
    print(f"{obj_name}: {coord_list}")

    # set coordinates of selected object
    coord_list = [[74000.0, 4400.0, 0.0], 
                  [73300.0, 3600.0, 0.0], 
                  [73300.0, 5300.0, 0.0]]

    obj.coordinates = coord_list  # assign new coordinates to line

    # connect points in line
    num_points = obj.num_points() # get the number of points
    obj.set_connected(0,num_points,True)  # (start pt, end pt, connection on or off)
    sel.replace(obj)  # replaces the old object and preserves changes