Accessing Items

Use the items property of the WorkflowArgumentParser to access the built-in items list. This allows for the items list to be read, for items to be removed and for items to be added. When the items list is passed into a Python Script, all the items in the list are converted into strings. You can only access the items list via the top connector of the workflow component which can make it difficult to use side connectors and the items list at the same time.

The script below demonstrates how to remove all non-alphabetic items from the items list.

from mapteksdk.workflows import (WorkflowArgumentParser, WorkflowSelection,
                                 Point3DConnectorType, DoubleConnectorType,
                                 CSVStringConnectorType)
 
parser = WorkflowArgumentParser()
 
parser.parse_arguments()
 
# Removes all items which do not entirely contain alphabetical characters.
parser.items = [x for x in parser.items if x.isalpha()]

Here is an example of how the above script can be used in a workflow.

In the above workflow, the Data Editor component provides an items list containing three items: “Sally”, “Fred” and 1. The Extend Script component then filters out the “1”, as it is not an alphabetical character. Therefore, you end up with two items: “Sally” and “Fred”.