Unknown Outputs
When using the Extend Python Script workflow component, it is best to declare the outputs ahead of time with the declare_output_connector() function. However this does not work if the outputs are not known when the script is written. Starting in 1.4, the set_output() function will accept outputs that do not correspond to output connectors.
For example, the following script filters out all of the input attributes that are not numeric. Because the outputs are dependent on the inputs, they cannot be defined when the script is written and instead they are defined when the script is run.
from mapteksdk.workflows import WorkflowArgumentParser
if __name__ == "__main__":
parser = WorkflowArgumentParser(
description="Filters out all non-numeric attributes.",
allow_unknown_attributes=True)
# Note that no connectors are declared.
parser.parse_arguments()
for name in parser.unknown_attribute_names:
try:
parser.set_output(name, parser.unknown_attribute(name, float))
except ValueError:
# The attribute was not numeric, skip it.
continue
The following animation demonstrates a simple workflow that uses this script:
Was this page helpful?