Back to all posts

Script 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.

This script is provided as-is, please see the disclaimer below for more information.

Download script

# 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

Disclaimer

All scripts are provided as-is, and no warranty is made as to the script's accuracy, completeness, or suitability for any particular purpose. This script may contain errors and require correction or modification by the modeler before its use.

The modeler is obligated to review the script code in its entirety and determine its suitability for its intended usage.

This script may also be updated from time to time to fix issues or provide enhanced functionality. If you have suggestions for improvement, please create a support ticket to let us know.