Select to view content in your preferred language

how to pass a variable to a python script in model builder

2529
1
02-14-2011 09:50 AM
by Anonymous User
Not applicable
Original User: frankv3

how do you send the results of geoprocessing tools in model builder to a python script that has been added to the model?
The model fails for some reason, but it doesn't say why in the results

this is the script:


# Import arcpy module
import arcpy
import sys
import os
import types

# Load required toolboxes
arcpy.ImportToolbox("Model Functions")

# Script arguments
AltNum = arcpy.GetParameterAsText(0)
DXFWorkspace = arcpy.GetParameterAsText(1)



# Process: Get Field Value
SX = arcpy.GetFieldValue_mb(Parcel_XY_View, "X_COORD", "Double", "0")

# Process: Get Field Value (2)
SY = arcpy.GetFieldValue_mb(Parcel_XY_View, "Y_COORD", "Double", "0")

X1 = SX - 1000
Y1 = SY - 1000
X2 = SX + 1000
Y2 = SY + 1000

coord = ('-1000.000000,-1000.00000 %s,%s' + '\n' + '1000.00000,1000.00000 %s,%s')%(X1,Y1,X2,Y2)

Afile = r"%s\%s.wld"%(DXFWorkspace,AltNum)
Wfile =  file(Afile, 'w')
Wfile.write(coord)
Wfile.close()
0 Kudos
1 Reply
by Anonymous User
Not applicable
Original User: frankv3

it didn't like these lines:
arcpy.ImportToolbox("Model Functions")
SX = arcpy.GetFieldValue_mb(Parcel_XY_View, "X_COORD", "Double", "0")
SY = arcpy.GetFieldValue_mb(Parcel_XY_View, "Y_COORD", "Double", "0")

thiose were removed and the Script arguments was changed to include
SX = arcpy.GetParameter(2)
SY = arcpy.GetParameter(3)
and it runs fine
0 Kudos