tamerali

Python script exported from ModelBuilder won't run

Discussion created by tamerali on Mar 6, 2014
Latest reply on Jul 14, 2014 by rfairhur24
hi to all

i exported mode builder to python but it is not work , plz any ideas , it work will in arcgis

thank you

# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# test.py
# Created on: 2014-03-07 03:11:40.00000
#   (generated by ArcGIS/ModelBuilder)
# Description:
# ---------------------------------------------------------------------------

# Set the necessary product code
# import arcinfo


# Import arcpy module
import arcpy
arcpy.env.overwriteOutput = True
# Load required toolboxes
arcpy.ImportToolbox("Model Functions")


# Local variables:
cad_distace_DWG = "E:\\country\\cad_distace.DWG"
acad1_gdb = "E:\\country\\acad1.gdb"
Polyline = "E:\\country\\acad1.gdb\\cad\\Polyline"
point = "E:\\country\\acad1.gdb\\point"
cad = "E:\\country\\acad1.gdb\\cad"
south1 = "E:\\country\\acad1.gdb\\south1"
west = "E:\\country\\acad1.gdb\\west"
east = "E:\\country\\acad1.gdb\\east"
north = "E:\\country\\acad1.gdb\\north"
south = "E:\\country\\acad1.gdb\\south"
north1 = "E:\\country\\acad1.gdb\\north1"
east1 = "E:\\country\\acad1.gdb\\east1"
west1 = "E:\\country\\acad1.gdb\\west1"
west_dis = "E:\\country\\acad1.gdb\\west_dis"
east_dis = "E:\\country\\acad1.gdb\\east_dis"
south_dis = "E:\\country\\acad1.gdb\\south_dis"
north_dis = "E:\\country\\acad1.gdb\\north_dis"
final_distance = "E:\\country\\acad1.gdb\\final_distance"

# Process: CAD to Geodatabase
arcpy.CADToGeodatabase_conversion("E:\\country\\cad_distace.DWG", acad1_gdb, "cad", "25000000", "PROJCS['WGS_1984_UTM_Zone_38N',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',45.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]];-5120900 -9998100 10000;-100000 10000;-100000 10000;0.001;0.001;0.001;IsHighPrecision")

# Process: Iterate Feature Classes
arcpy.IterateFeatureClasses_mb(cad, "", "LINE", "NOT_RECURSIVE")

# Process: Feature Vertices To Points
arcpy.FeatureVerticesToPoints_management(Polyline, point, "ALL")

# Process: Select (8)
arcpy.Select_analysis(point, west1, "Layer ='?'")

# Process: Select (2)
arcpy.Select_analysis(Polyline, west, "Layer ='???'")

# Process: Spatial Join
arcpy.SpatialJoin_analysis(west1, west, west_dis, "JOIN_ONE_TO_ONE", "KEEP_ALL", "Layer \"Layer\" true true false 255 Text 0 0 ,First,#,E:\\country\\acad1.gdb\\west1,Layer,-1,-1", "CLOSEST", "", "distance")

# Process: Select (7)
arcpy.Select_analysis(point, east1, "Layer ='?'")

# Process: Select (3)
arcpy.Select_analysis(Polyline, east, "Layer ='????'")

# Process: Spatial Join (2)
arcpy.SpatialJoin_analysis(east1, east, east_dis, "JOIN_ONE_TO_ONE", "KEEP_ALL", "Layer \"Layer\" true true false 255 Text 0 0 ,First,#,E:\\country\\acad1.gdb\\east1,Layer,-1,-1", "CLOSEST", "", "distance")

# Process: Select
arcpy.Select_analysis(point, south1, "Layer ='?'")

# Process: Select (5)
arcpy.Select_analysis(Polyline, south, "Layer ='??????'")

# Process: Spatial Join (3)
arcpy.SpatialJoin_analysis(south1, south, south_dis, "JOIN_ONE_TO_ONE", "KEEP_ALL", "Layer \"Layer\" true true false 255 Text 0 0 ,First,#,E:\\country\\acad1.gdb\\south1,Layer,-1,-1", "CLOSEST", "", "distance")

# Process: Select (6)
arcpy.Select_analysis(point, north1, "Layer ='????'")

# Process: Select (4)
arcpy.Select_analysis(Polyline, north, "Layer ='??????'")

# Process: Spatial Join (4)
arcpy.SpatialJoin_analysis(north1, north, north_dis, "JOIN_ONE_TO_ONE", "KEEP_ALL", "Layer \"Layer\" true true false 255 Text 0 0 ,First,#,E:\\country\\acad1.gdb\\north1,Layer,-1,-1", "CLOSEST", "", "distance")

# Process: Merge
arcpy.Merge_management("E:\\country\\acad1.gdb\\west_dis;E:\\country\\acad1.gdb\\east_dis;E:\\country\\acad1.gdb\\south_dis;E:\\country\\acad1.gdb\\north_dis", final_distance, "Join_Count \"Join_Count\" true true false 0 Long 0 0 ,First,#,E:\\country\\acad1.gdb\\west_dis,Join_Count,-1,-1,E:\\country\\acad1.gdb\\east_dis,Join_Count,-1,-1,E:\\country\\acad1.gdb\\south_dis,Join_Count,-1,-1,E:\\country\\acad1.gdb\\north_dis,Join_Count,-1,-1;distance \"distance\" true true false 0 Double 0 0 ,First,#,E:\\country\\acad1.gdb\\west_dis,distance,-1,-1,E:\\country\\acad1.gdb\\east_dis,distance,-1,-1,E:\\country\\acad1.gdb\\south_dis,distance,-1,-1,E:\\country\\acad1.gdb\\north_dis,distance,-1,-1;TARGET_FID \"TARGET_FID\" true true false 0 Long 0 0 ,First,#,E:\\country\\acad1.gdb\\west_dis,TARGET_FID,-1,-1,E:\\country\\acad1.gdb\\east_dis,TARGET_FID,-1,-1,E:\\country\\acad1.gdb\\south_dis,TARGET_FID,-1,-1,E:\\country\\acad1.gdb\\north_dis,TARGET_FID,-1,-1;Layer \"Layer\" true true false 255 Text 0 0 ,First,#,E:\\country\\acad1.gdb\\west_dis,Layer,-1,-1,E:\\country\\acad1.gdb\\east_dis,Layer,-1,-1,E:\\country\\acad1.gdb\\south_dis,Layer,-1,-1,E:\\country\\acad1.gdb\\north_dis,Layer,-1,-1")

Outcomes