Select to view content in your preferred language

Can we use "IF ELSE" condition in Arcmap without using python script

858
5
11-18-2017 12:35 AM
AkhilChhibber1
Emerging Contributor

I am new to GIS models. I was preparing a very basic model which does the following task:
1.) Inputs 2 shapefiles
2.) Projects their co-ordinate system
3.) Repair Geometry
4.) Add Field(ID_no)
5.) Field Calculate for the field "ID_no."

Actually i want to apply if condition that if there is already a field named "ID_no" in the shapefile, don't add field else if there is not a field named "ID_no" in the shapefile then add the field.

Please help me out regarding how should I do this in GIS modelling as I am unaware of python.

0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus

I suppose that you have the rest of the model put together already, but are just looking for help with

..... branching.. if-else logic ...

curtvprice
MVP Esteemed Contributor

Dan, good link, but the example in the help requires creation of a Python script tool. So does the example in the https://community.esri.com/docs/DOC-8931-if-you-are-stuck-at-if?sr=search&searchId=7fe48a5d-7146-451...‌ blog posts.

To answer the OP: If the field already exists, Add Field will not throw an error, the tool it will throw a warning and the model will continue to run. I don't think you need an if branch.

AkhilChhibber1
Emerging Contributor

Actually what exactly I wanted as a result of my model is that:

After the Add field, the next step is "Calculate Field" in which I copy the numbers same as FID. 

This step i.e. "Calculate Field" is not working in case the field "ID_no" already exist. 

What should I do in this scenario???????

0 Kudos
curtvprice
MVP Esteemed Contributor

This should work if the field exists or not if you connect the output of Add Field to Calculate Field.

0 Kudos
MarcoBoeringa
MVP Regular Contributor

Akhil,

For the specific case of the "Add Field" tool, you don't need an If..Else construct. The tool has been written to automatically skip adding a new field, and allow the model to continue, when there is an existing field with the same name as needs to be added, it will just emit a warning in the geoprocessing log, but continue.

0 Kudos