ModelBuilder Get Count

4082
5
06-22-2012 10:19 AM
JoseSanchez
Occasional Contributor III
Hi all

I am using ArcGIS 9.3.

I need to add a condition after a ModelBuilder GetCount.   When the number of records counted is bigger that 1000 the model stops running.

Questions:
- how to retrieve Get Count in a model
- how to stop a model when the value read is bigger that 1000 for example

thanks
0 Kudos
5 Replies
NobbirAhmed
Esri Regular Contributor
You need to create a Python script tool and chain the tool with the GetCount's output. The script tool will intercept the output of GetCount return true or false based on your condition.
0 Kudos
curtvprice
MVP Esteemed Contributor
You need to create a Python script tool and chain the tool with the GetCount's output. The script tool will intercept the output of GetCount return true or false based on your condition.


I think you could also do this using Calculate Value to convert the output of Get Count into True or False.

* Use the Count Rows tool - name the output element from it "Row Count".
* Set that as a precondition to Calculate Value
* Calculate Value would look something like this:

Expression: check(%Row Count%)
def check(rowcount):
  return float(rowcount) < 1000

Data Type: Boolean

* Rename the output of Calculate Value to "Rows greater than 1000"
* Use this element as an iterator condition for your model.
0 Kudos
NobbirAhmed
Esri Regular Contributor
Hi Curtis, the model-only tools (such as Calculate Value) were not available in 9.3 or 9.3.1. The only option available was to use a script tool. Here is an example:

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Branching:_Implementing_if-then-else_l...
0 Kudos
curtvprice
MVP Esteemed Contributor
Hi Curtis, the model-only tools (such as Calculate Value) were not available in 9.3 or 9.3.1.


Thanks Nobbir - it's possible this option isn't available to Jose.

Calculate Value is available in 9.3,  but you do a) need to go get it from the Toolbox - no fancy right-click model-only tools function and b) you need an ArcInfo or Spatial Analyst or 3D Analyst license to use it.
0 Kudos
NobbirAhmed
Esri Regular Contributor
Curtis, sorry for my mistake. You are right - calculate Value IS available in 9.3.

Hi Jose, the tool is under Data Management Tools > General toolset. Click on the link if the message of Curtis to get to tool help.
0 Kudos