# Filename: pl_pattern.py
# Purpose: Polyline pattern.

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 pattern property from selected object
    patt = obj.pattern   
    print(f"{obj_name}: {patt}")

    # assign pattern property to selected object
    assert obj.is_closed(), 'Error: Object is not closed polygon.'
    if obj.is_closed(): 
        obj.pattern = 40  # pattern index
        sel.replace(obj)  # replaces the old object and preserves changes