MBoucher21

Model Builder Export Puzzelment

Discussion created by MBoucher21 on May 1, 2012
Latest reply on May 1, 2012 by mzcoyle
I'm attempting to create an arcpy script starting from a Model that comes from the ArcHydro Tools.tbx. I copied the Model to a toolbox in my project folder, edited it and exported it to Python Script.

The script has some puzzling stuff in it.

For example, in the code below under "# Local variables:" it sets Fdr = Fil, Fdr = Fda, etc. Is this right?
Is this just a way to set the layers as local variables?

# ---------------------------------------------------------------------------# Basic Dendritic Terrain Processing2.py
# Created on: 2012-05-01 07:28:57.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: Basic Dendritic Terrain Processing2 <Fil> <Number_of_cells_to_define_stream> 
# Description: 
# ---------------------------------------------------------------------------


# Import arcpy module
import arcpy


# Script arguments
Fil = arcpy.GetParameterAsText(0)
if Fil == '#' or not Fil:
    Fil = "Fil" # provide a default value if unspecified


Number_of_cells_to_define_stream = arcpy.GetParameterAsText(1)
if Number_of_cells_to_define_stream == '#' or not Number_of_cells_to_define_stream:
    Number_of_cells_to_define_stream = "5000" # provide a default value if unspecified


# Local variables:
Fdr = Fil
Fac = Fdr
str = Fac
StrLnk = str
cat = StrLnk
Catchment = cat
DrainagePoint = Catchment
AdjointCatchment = Catchment
DrainageLine = StrLnk


# Process: Flow Direction
arcpy.FlowDirection_archydro(Fil, Fdr, "")


# Process: Flow Accumulation
arcpy.FlowAccumulation_archydro(Fdr, Fac)


# Process: Stream Definition
arcpy.StreamDefinition_archydro(Fac, Number_of_cells_to_define_stream, str, "0.046452")


# Process: Stream Segmentation
arcpy.StreamSegmentation_archydro(str, Fdr, StrLnk, "", "")


# Process: Catchment Grid Delineation
arcpy.CatchmentGridDelineation_archydro(Fdr, StrLnk, cat)


# Process: Catchment Polygon Processing
arcpy.CatchmentPolyProcessing_archydro(cat, Catchment)


# Process: Drainage Point Processing
arcpy.DrainagePointProcessing_archydro(Fac, cat, Catchment, DrainagePoint)


# Process: Drainage Line Processing
arcpy.DrainageLineProcessing_archydro(StrLnk, Fdr, DrainageLine)


# Process: Adjoint Catchment Processing
arcpy.AdjointCatchment_archydro(DrainageLine, Catchment, AdjointCatchment)


Outcomes