0

My model iterate through many shapefiles:

First it checks if, the field I want to add (model parameter), already exists in the table (check if the field name is the same).

If it doesn't exist:

  • Great! Just add the field I want.

If exists:

  • Creates a temp field
  • Store the the value from the existing field in the temp field
  • Drop the existing field
  • Create the field I want, the way I want (string, with exactly 137 length)
  • Copy the values from the temp field to the new field
  • Drop the temp field

It works perfectly, always. As many shapefiles I want.

The problem is I want to run it several times, checking for a lot of fields, in a single run in the tool.

If I try to bath it, doesn't work. And if I try to put 'List of Values' in the first parameter 'Multiple Value' it gets error, because model builder doesn't allow both 'model iterator' and 'list of values' working together.

Can you guys help me?

download model - wetransfer

enter image description here

6
  • Can you create a second model with a different iterator (ex: multiple values) that would iterate through a list of each field you want to check, and that this model be a step/tool within the new model. So the new model would iterate and for each field value, it would run this model checking all of the input feature classes for that field. The trick there is just making sure you have input values correctly defined in this model so you can include it correctly in the a wrapper model. Just a thought.... not sure if sub-modeling like that would accomplish your goal.
    – John
    Apr 19, 2017 at 17:24
  • I think it can work, but i still dont know exactly how to proceed. Reading, it make sense, but i coudnt figure it, doing the second model. Can you please try to explain more your idea?
    – raphael
    Apr 19, 2017 at 17:29
  • Take the current model (pictured above) and save it as a model in a custom toolbox. Then, open a new model. In the new model, add an iterator that will iterate over all of the fields you want to run the original model on. Then add the original model to the new model just as you would add any geoprocessing tool. Then you can set the output of the new iterator's value as the input for the field parameter in your original model. Does that clarify?
    – John
    Apr 19, 2017 at 17:31
  • im going to try it, promess... thanks. i updated the original post, put a link to download the toolbox, if anybody wants it...
    – raphael
    Apr 19, 2017 at 17:38
  • I dont know what is wrong, but it only iterated with the last field in the list of the new iterator... it didnt run for all...
    – raphael
    Apr 19, 2017 at 18:16

1 Answer 1

1

Create a second model with your current model as a submodel. Put an iterator in the parent model to iterate through the field names and then feed those field names into your current model in sequence. Have a table of the field names as the inputs to an Iterate Field Values in the main model, then call the submodel using the resultant field name as one of the parameters

Batch execution won't work because batch executions of models runs in parallel, rather than in series. There should be a way to force serial execution, but ESRI, Lords of All GIS™, have not deigned to grant us that ability.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.