Back to all posts

Example: Select the conduits with three or more vertices

This script example selects the conduits with three or more vertices on the Map panel and prints the conduit name and number of vertices in the script log. The total count is printed at the end.

Example

# select the conduits with 3 or more vertices
conduits = pcpy.Map.Layer['Conduits'].get_entities()
m = 0
for cond in conduits:
  name = cond["Name"]  #record the name
  n = len(cond.Geometry.Vertices) #determine how many vertices
  if n >= 3: # if there are more than 2 vertices, print the name and number of vertices
    m = m + 1
    cond.Selected = True
    print '{0}\t{1}'.format(name, n)    
print 'Count = ', m