0

I have a modelbuilder model setup that, in short, takes all selected features from ArcMap and exports it to a dwg. I need to add two things to this model which I'm not sure can be done in modelbuilder. The ArcMap document has several feature classes which don't necessarily overlap so first I need the model to run only on the feature classes that HAVE selected features and ignore the rest of the feature classes. Second, I need the model to NOT run if more than 10000 features are selected from any of the feature classes in ArcMap. This can probably be easily done in Python but I have no experience in Python hence I'd like to confirm if it can be done in modelbuilder. If not, I'll have to explore Python.

Edit: I need a statement where if the number of features are greater than 0 and less than 10000 then it should be true and proceed. I think the "Get Count" and "Calculate Value" tools can be used to do this in modelbuilder, just not sure how.

2

Well, what I would do, if you are serious about wanting to do this in Model Builder, is use some python snippets within model builder as you state in your edit. What you can do is, for example with the not running if more than 10,000 features are selected, use the Get Count geoprocessing tool on that layer. It will output the number of features selected if there is a selection, or the total number of features if there is no selection or the selection returned 0 features thus resulting in no selection (because of this 0 will never be returned by Get Count tool unless run against an empty feature class, and if there are less than 10000 features total in your feature class when you run this, it will run even if there is no selection, though not if there is a selection of less than 10000). In model builder you can specify the name of the resulting value, for example call the output of the Get Count tool RowCount. Then you can use the model builder only tool called "Calculate Value" (find it under the insert menu > model only tools > Calculate Value within model builder).

Within that you could put in the Expression:

ifSelected(%RowCount%)

Within the code block:

def ifSelected(e):
  if e < 10000:
    return "TRUE"
  else:
    return "FALSE"

Data Type:

Boolean

Then, in the model, set the output of calculate value as a precondition to the operation you want to only run if true.

Also, if you regularly have feature classes with less than 10000 total features that you want to run this against, you could run two get count tools, one before a selection is made and one after and do something like the following in the calculate value tool instead

ifSelected(%TotalCount%,%SelectedCount%), 

def ifSelected(Total,Selected):
    if Selected < 10000 and Selected < Total:
        return "TRUE"
    else:
        return "FALSE"

Hope that helps.

20
  • Thanks for the response! There are no feature classes with less than 10000 total features so I can skip the second part for now. Couple questions on the get count and calculate value tools. Does the get count tool need to be connected to the collect values tool as a precondition? The collect value tool would connect to the copy features tool. How do I set the output of calculate value as a precondition (if true) to copy features precondition. Heres a screenshot of what I have: sites.google.com/site/shobuddy/misc Click on "export graphic.jpg – Steve Feb 11 '14 at 19:59
  • It looks from that image like you have it set up correctly as far as those two tools are concerned. You would have the layer file input to the get count, count output precondition to calc value, calc value output precondition to copy features (if calc value type is Boolean, it will use the returned True or False as the precondition) and the original layer input to copy features. If original input is a raw shapefile/feature class input to get count it will of course only return the total number of features, but if it is a layer it will return selected features if available. That make sense? – John Feb 11 '14 at 20:56
  • The original input is a feature class that should only return selected features. With the model configured as shown in screenshot, the copy features tool does not run. I'm not sure whats missing to get it to run. The output for the calculate value tool is set to true. – Steve Feb 11 '14 at 21:09
  • Well you would probably need to connect the original feature class or layer to the copy features as the copy features tool needs some input for it to know what to copy. – John Feb 11 '14 at 21:33
  • 1
    Since the export to cad tool was not working when it didn't receive features, I'm using a geodatabase as the input. The gdb has feature classes, some have features and some don't and this is fine with the export to cad tool. Previously the export to cad tool was not working because it was not seeing a feature class at all, vs an empty feature class. – Steve Feb 16 '14 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.