5

I'm trying to create a model wherein one of the parameters is a compound variable, that is made of multiple variables joined together. How can this be done?

For example: create an insider buffer using Buffer(analysis) and name the output feature class from the distance parameter.

Variables:

BufferDistance = 1000
InputFC = d:\test.gdb\boundaries

Buffer tool parameters:

Input Features = %InputFC%
Output Feature Class = %InputFC%_%BufferDistance%
Distance = -%BufferDistance% Meters

A negative buffer distance is needed to create an inside buffer, but that means the %BufferDistance% variable can't be used in the output FC name. Thus the need for a compound variable.

6

I suspect the easiest way to do it would be through Python (or VBA).

  1. Start by putting your model together, including parameters for the input and output variables.
  2. Then from the model menu export the model to a Python script
  3. Open the script in an editor of your choice (I use Eclipse with the Pydev extension, but Notepad++ works, as does IDLE).
  4. Simply set the output parameter equal to the buffer distance etc. eg:
OUPUT_NAME = ''.join(INPUT_NAME, "_", str(-BUFFER_DISTANCE), OUTPUT_SUFFIX)
  1. Run the script
  • 2
    soo, it appears that actual answer is "you can't" :) This works, and I'll use it, but I might as well just skip model builder altogether and do everything in python. Thanks. – matt wilkie Aug 31 '10 at 21:56
  • doesn't look like it I'm afraid. However you can add discrete pieces of script to model builder, and use those answers (not tried it myself, but see the adding a boolean example (webhelp.esri.com/arcgisdesktop/9.3/…) on the ArcGIS help). Good luck! – om_henners Sep 1 '10 at 5:41
2

I've since learned it is also possible to do this using the Calculate Value tool, see Adding arbitrary code to ArcGIS ModelBuilder?. It's not as involved as creating a script and adding to a toolbox.

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.