Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

python script in modelbuilder get field value return boolean expressions

$
0
0
I have problems integrating a python script in a modelbuilder tool. I'm a absolute beginner with python, any help is much appreciated. Maybe there's also an easier way to solve this problem in modelbuilder, but I haven't found it yet

so here's my problem:

my modelbuilder tool's flow of control needs to evaluate a situation and decide on one of two courses of action: If the value in the field "Building" in my feature class is 1, it should follow one path, if the value is greater than one it should follow another path.

Here's my python code that I tried so far

Code:

# Load the arcpy module
import sys, os, arcpy

# Get the input feature class from the model
InputFC = arcpy.GetParameterAsText(0)
field = "Building"
cursor = arcpy.SearchCursor(InputFC)

# check if one or more than one building footprint exist
for row in cursor:
    Building =(row.getValue(field))
    if Building == 1:
        arcpy.SetParameterAsText(1, "True")
        arcpy.SetParameterAsText(1, "False")
    else:
        arcpy.SetParameterAsText(1, "False")
        arcpy.SetParameterAsText(2, "True")

regards
nicolas

Viewing all articles
Browse latest Browse all 2485

Trending Articles