Having trouble in book "Getting to Know ArcGIS ModelBuilder"

1055
8
Jump to solution
02-11-2013 06:47 PM
LeighHolcombe
New Contributor
Hello,
I'm not sure if this is the best place to ask about this, but... Recently I have been working through the exercises in the ESRI Press book Getting to Know ArcGIS ModelBuilder by David W. Allen, and I have found what I believe may be a mistake in exercise 3D (exercise D, chapter 3). It would be pointless and possibly a breach of copyright to reproduce all the steps and processes of the exercise here, so I will assume you have a copy of this book available.

In this exercise, the user creates a Python script to check a geodatabase workspace for the existence of a feature class, and creates one if none exists. However, I believe this script only checks for feature classes in the root of the geodatabase, without checking for feature classes inside a feature dataset. Since this exercise creates its feature classes within a feature dataset, the check will never resolve to True. If a feature class with the same name already exists in the workspace, the model itself won't run - ArcGIS will flag the feature class name as inappropriate during the parameter input stage. The model asks for a feature dataset as a parameter where the feature class will be stored, and checks for the pre-existence of the feature dataset, but it doesn't check for feature classes that already exist within the feature dataset. And the "Empty FC to Store Schema" template appears to remove any feature classes that exist within the feature dataset, so the model never even notices whether a feature class of that name already exists.

Am I missing something here? I'm just getting started with this stuff, so it's possible that I am not understanding this correctly. If anyone has access to this book, and experience with Python and modeling, I'd appreciate some insight.

Thank you.
0 Kudos
1 Solution

Accepted Solutions
DaleHoneycutt
Regular Contributor
Feature class and table names within a geodatabase must be unique, even if they reside in a feature dataset.  This is unlike folders on the file system.  I just did a test and arcpy.Exists does return true whether or not the feature class resides in a feature dataset. (I like using the python window to quickly test how something works).

Here's what I did.
In my geodatabase "Test.gdb", I created a Feature Dataset named "TestFD".  Within TestFD, I created a feature class named "Fred".

In python:
>>> print arcpy.Exists(r'E:\StreetIntersectionList\ToolData\Test.gdb\Fred') True >>> 

View solution in original post

0 Kudos
8 Replies
DaleHoneycutt
Regular Contributor
Feature class and table names within a geodatabase must be unique, even if they reside in a feature dataset.  This is unlike folders on the file system.  I just did a test and arcpy.Exists does return true whether or not the feature class resides in a feature dataset. (I like using the python window to quickly test how something works).

Here's what I did.
In my geodatabase "Test.gdb", I created a Feature Dataset named "TestFD".  Within TestFD, I created a feature class named "Fred".

In python:
>>> print arcpy.Exists(r'E:\StreetIntersectionList\ToolData\Test.gdb\Fred') True >>> 
0 Kudos
LeighHolcombe
New Contributor
Thanks for your response, Dale. Based on what you've said, the model and script in question should work. So if the model always evaluates to false, then there must be some other part of the script that is misbehaving. Ponder this further I must.
0 Kudos
LeighHolcombe
New Contributor
I've figured out the problem. Somehow a typo was introduced into the CheckExists.py script that checks for the existence of the feature dataset. There was a space in the path of the workspace variable. I don't think I ever edited that script, but I must have, because the typo doesn't exist in the Sample Models.
0 Kudos
curtvprice
MVP Esteemed Contributor

I am following the steps in the book and replacing PD_Buffer with PD_%Incident%_Buffer and i keep getting an error that tells me
"The name contain invalid character" and it executes no further.


If the element "Incident" does not exist in your model, no substitution takes place and the tool gets a path with a "%" character in it, which will generate the error you mention.

I'd carefully check your spelling of the model element against where you entered it in the tool.
0 Kudos
MarthaSnyderwine
New Contributor
Hello! Trying to work thru chapter 3c exercises in "Getting to Know ArcGIS Modelbuilder".  I'm running ArcGIS 10.1, Build 3035.  The goal is to incorporate error checking.  I get the same results regardless of what I name the feature data set or the feature class, meaning, it keeps overwriting.  I have tried checking and unchecking Geoprocessing General Options> Overwrite the outputs of geoprocessing operations.  This only effects the warning display (yellow triangle w/!).  The other problem is running the practice model check and unchecks this box. 

At this point I'm ready to give up on this chapter but figured I'd ask for help first, since I need some kind of error checking to prevent overwriting and for proper naming.  The model builder users won't know how to avoid this.

Any suggestions?
Thanks in adavnce!
0 Kudos
DaleHoneycutt
Regular Contributor
When running a model within ModelBuilder (using the Run button), output is always overwritten regardless of the overwrite output setting.  This is by design and is a good thing.

However, if you run the model as a tool -- that is, you expand the toolbox and its models in the Catalog window, then double-click the model to open its dialog box,  overwrite outputs does take effect; if you enter an existing dataset for an output parameter, it'll have a red X if it exists.
0 Kudos
MarthaSnyderwine
New Contributor
When running a model within ModelBuilder (using the Run button), output is always overwritten regardless of the overwrite output setting.  This is by design and is a good thing.

However, if you run the model as a tool -- that is, you expand the toolbox and its models in the Catalog window, then double-click the model to open its dialog box,  overwrite outputs does take effect; if you enter an existing dataset for an output parameter, it'll have a red X if it exists.


Hello!  I am running the tool from the catalog.  But from what you are saying are all this script does is warn, it does not "prevent" or
"stop" overwriting, correct?  Also, it still seems odd that the overwrite is switching on and off. Or were you implying that this is part of running model builder?

Thank you!
0 Kudos
PaulDavidson1
Regular Contributor
Trying to install the sample data for the book, the install keeps failing with
"Macromedia Projector" has stopped working...

Win 7 64 bit machine, 16GB, etc... I assume the problem is a Win7 compatability?
I tried running Esri.exe directly off the CD with Admin permissions but no difference.

I was able to install the samples by running the msi directly
(Getting to Know ArcGIS ModelBuilder - Data and Maps.msi)

I assume this is adequate.
Does anyone know if the Esri.exe startup code does anything other than just install the msi file?

Thanks
0 Kudos