Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I created some model builder for some customization to reduce time in our routine process. I exported my model builder to python script by availability of export options. It doesn't work if i bring to tool bar. any one suggest me clearly how to access the script in tool bar with some standard clear steps to follow? as well as whether i need to do any modification on my exported python script?

share|improve this question
    
perhaps gis.stackexchange.com/questions/1697/… will help –  matt wilkie Oct 18 '11 at 8:38
    
@Poovallnga Ganesh, If the model runs successfully then the script by it self should not error. Can you provide a copy of the script and the error message? Also, are you trying to create a UI tool or script within ArcToolbox? –  artwork21 Oct 18 '11 at 11:56

2 Answers 2

Typically users run Python scripts from ArcToolbox, just like you would typically run a ModelBuilder process from ArcToolbox.

Take a look at this nice tutorial that will walk you through the steps of adding your python script to a tool in ArcToolbox. Or read the ArcGIS Online Help for how to add a script tool.

NOTE: The process is not the same for adding a UI button to a toobar. See the link in the comment from @matt wilkie for that process.

share|improve this answer

Here is a list of things to consider before exporting models to Python:

  • If your model uses an iterator, the iteration logic will not be exported and will have to be replaced with looping statements in Python.
  • If your model used a Model only tool such as Merge Branch, Collect Values, or Calculate Value, these tools will not run properly in Python; they may execute without error, but nothing happens and your script doesn't work as expected. In some cases, the Python script will fail at a later point. You need to implement the equivalent Python functionality these Model only tools provide.
  • If your model used inline variable substitution such as %workspace%, %scratchworkspace%, %n%, %i%, or %variable name%, you will have to replace these with the correct value in the Python script.
  • If your model used layers or table views from ArcMap or ArcGlobe, those layers or table views will have to be created or the data will need to be fully referenced in the script.
  • If your model used layers or table views that are not created within the original model, those layers or table views will have to be created in the script using tools such as MakeFeatureLayer and MakeTableView.
  • If your model included sub-models, the contents within those sub-models will not be exported. Instead, the toolbox will have to be referenced and the model tool will need to be called inside the script.
  • If you expect to be overwriting data, set the overwriteOutput property to True. arcpy.env.overwriteOutput = True

  • Variables in your model are converted directly into Python variables in the exported script. You need to avoid naming your model variables the same as Python's reserved keywords (for example, class, global, return). For a full list of reserved keywords, use Python's keyword module.

  • If your model has an input variable type that is a FeatureSet or RecordSet, it will be exported as an in-memory feature class such as "in_memory\{E83BC42B-3578-4D20-A817-5F2AF3F5D05E}". You need to update this variable in Python with a path to a valid dataset or create a script tool where the input data type is a feature set.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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