# Filename: pl_set_pattern.py
# Purpose: Sets the pattern index of a line.
# Returns: Void.

from maptek import vulcan_gui

# select layer from the screen
sel = vulcan_gui.selection("Select objects to set pattern.")  # prompt for selection
sel.criteria = ["LINE", "POLYGON"]  # limit selection to a line

# get all polyline objects in the layer as an indexed list
for obj in sel:
    if obj.is_closed(): # checks that the object is a closed polygon, not a line
        obj_name = obj.get_name()  # get name of object
        pattern = obj.set_pattern(20)  # set the fill pattern index of the polygon
        sel.replace(obj)  # replaces the old object and preserves changes