2

My model requires field1 to be added to fc1 and fc2, and then calculated according to a Python expression calc1. field2 is then added to fc2, and calculated using calc1. How do I add the multiple feature classes as the input to Add Field and Calculate Field? I have tried creating an input table variable as a list of values, and while it accepts fc1 and fc2 when I type it in, the model does not run ("dataset does not exist").

edit I'm adding these fields so that I can join the tables on a common pre-existing field and populate fc2.field1 with the values from fc1.field1.

model screenshot

3
  • Can you add a picture of your model please? It is perfectly possible to add a list of feature classes to the functions you describe, so I think something else is going on. May 15, 2012 at 10:00
  • 1
    Iterators or Python loops are a must for repetative tasks (I prefer the programming method for reusablility with other projects).
    – Roy
    May 15, 2012 at 11:22
  • @SylvesterSneekly I've added an image. May 15, 2012 at 12:42

2 Answers 2

1

Have you tried to use Add Field twice? First for fc1 and then another block for fc2. Add Field tool accepts only single table/feature class as input.

It will look similar to: Add Field example

If you have many feature classes and want to add field to each of them then you can use iterators in ModelBuilder (take a look at "Iterate Datasets" section) or convert to python script and use loops if you are convenient with python.

5
  • Yes I did have Add Field three times, but it seemed a bit ridiculous to have three copies of the exactly the same process. Was hoping there was a way to make the model more streamlined. I'll take a look at the iterators, though for only two feature classes I'm not sure if it is worth it for this exercise. Would be useful for the future though. Thanks May 15, 2012 at 9:56
  • You should only need two add fields (one for field1 and one for field2). The first takes a list and the second (as you describe it) takes just fc2. You then need two calculate fields (one for Field1 and one for Field2). I don't think an iterator will help you a great deal here May 15, 2012 at 10:05
  • Sorry I didn't make that clear, there are two Add Field processes to add field1 to fc1 and fc2, and a third Add Field to add field2 to fc2. Calculate Field is then run on fc1.field1 and fc2.field2. May 15, 2012 at 12:32
  • Yes - you can do the first one using a list (or ought to be able to) May 15, 2012 at 14:55
  • After consulting with a colleague, he confirmed that for each Add Field operation, I would have to copy and paste the block for each input. Thanks for bringing iterators to my attention! Jun 6, 2012 at 6:28
0

In order to add a field to multiple FeatureClasses, you are still going to have to add the "Add Field" tool into both FC "chains". However, if you want to simply define the characteristics of the field once and apply it to multiple "Add Field" tools, you can call things like Field Name, Field Type, and Field Length out as model Parameters and apply them to multiple Add Field tools, as shown below.

Right-click on Add Field-->Make Variable-->From Parameter-->choose a model characteristic to expose. In this example, the parameter will not be exposed through the user dialog, just to setting through modelbuilder and re-using in multiple tools.

Re-using model parameters for multiple tools

1
  • I did have the characteristics exposed initially, which is how I got to this question as I had three copies of each process (and therefore four properties were exposed in triplicate). I do like this concept though, as it would allow me to change the name of the field to be added to each table once only, rather than having to change it in each copy of the process. May 16, 2012 at 5:06

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.