Wednesday 5 June 2019

arcpy - Stop ArcGIS model until all values are collected and then merge?


This is similar to Using If precondition is false, continue iterating next input in ModelBuilder? but I want the iterate tool to run to collect all the values and only then continue to the merge. Any ideas? Currently it just runs the whole process for each file (which works but takes much longer than if the merge is done only once) or I have to manually break the collect-merge link, run the iterate, reconnect the collect-merge link and then continue running the model which is a pain as it is a lot of towers that need processing and this collect values-finish getting all values and then continue will be required in other models as well.



enter image description here


I tried the "Select Data" tool as well but this doesn't allow for wildcard searches like the Iterate does -my Iterate has the "_Graded*" as the search param as the gdb included many other files related to each tower chunk.


My STOP is set to "True" (tried false as well). I also tried to connect the Stop to the Iterate instead of Collect values but same result.


=== SCRIPT ADDED


I just created a python tool for this and it collects all the values but it passes them back to the model as a long list -how can I get it to output in a proper format?


    import sys, os, arcpy

GDB=arcpy.GetParameterAsText(0)
Search=arcpy.GetParameterAsText(1)
Type=arcpy.GetParameterAsText(2)


##GDB=r'P:\2012\044_DM_Radio_Propogation\Working\Propogation\Propogation_28355.gdb'
##Search='_m'
##Type='Polygon'

path=os.path.dirname(GDB)
arcpy.env.workspace = GDB
List=[]
for item in arcpy.ListFeatureClasses('*'+Search+'*',Type):
List.append(path+"\\"+item)

#arcpy.SetParameterAsText(3, item)

arcpy.SetParameterAsText(3, List)
arcpy.AddMessage("List: "+str(List))

enter image description here


enter image description here




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...