# Import arcpy module import arcpy # Script arguments Selecting_Features = arcpy.GetParameterAsText(0) if Selecting_Features == '#' or not Selecting_Features: Selecting_Features = "in_memory\\{1CFDCCDD-5D8D-42F8-AEB2-E66ED4A51A44}" # provide a default value if unspecified value = arcpy.GetParameterAsText(1) # Local variables: Input_Points = "D:\\ArcGISData\\ESRI_GEO_EX\\GDB.gdb\\SamplePoints" Final_Output = value Input_Points_Layer = "SamplePoints_Layer" # Process: Make Feature Layer arcpy.MakeFeatureLayer_management(Input_Points, Input_Points_Layer, "", "", "OBJECTID OBJECTID VISIBLE NONE;SymbologyField SymbologyField VISIBLE NONE;DomainField DomainField VISIBLE NONE;Shape Shape VISIBLE NONE;Subtype Subtype VISIBLE NONE;EditField EditField VISIBLE NONE") # Process: Select Layer By Location arcpy.SelectLayerByLocation_management(Input_Points_Layer, "INTERSECT", Selecting_Features, "", "NEW_SELECTION") Selected_Features = Input_Points_Layer # Process: Calculate Field arcpy.CalculateField_management(Selected_Features, "EditField", "'%value%'", "PYTHON_9.3", "")
Solved! Go to Solution.
arcpy.CalculateField_management(Selected_Features, "EditField", '"' + value + '"', "PYTHON_9.3")
# -*- coding: utf-8 -*- # --------------------------------------------------------------------------- # calcfeatures_script.py # Created on: 2013-09-30 15:22:46.00000 # (generated by ArcGIS/ModelBuilder) # Usage: calcfeatures_script <Selecting_Features> <value> # Description: # test # --------------------------------------------------------------------------- # Import arcpy module import os, sys, arcpy, traceback, arcgisscripting # Script arguments Selecting_Features = arcpy.GetParameterAsText(0) value = arcpy.GetParameterAsText(1) arcpy.AddMessage("TEST") arcpy.AddMessage(value) if Selecting_Features == '#' or not Selecting_Features: Selecting_Features = "in_memory\\{1CFDCCDD-5D8D-42F8-AEB2-E66ED4A51A44}" # provide a default value if unspecified # Local variables: Input_Points = "D:\\ArcGISData\\ESRI_GEO_EX\\GDB.gdb\\SamplePoints" #Final_Output = value Input_Points_Layer = "SamplePoints_Layer" # Process: Make Feature Layer arcpy.MakeFeatureLayer_management(Input_Points, Input_Points_Layer, "", "", "OBJECTID OBJECTID VISIBLE NONE;SymbologyField SymbologyField VISIBLE NONE;DomainField DomainField VISIBLE NONE;Shape Shape VISIBLE NONE;Subtype Subtype VISIBLE NONE;EditField EditField VISIBLE NONE") # Process: Select Layer By Location arcpy.SelectLayerByLocation_management(Input_Points_Layer, "INTERSECT", Selecting_Features, "", "NEW_SELECTION") Selected_Features = Input_Points_Layer # Process: Calculate Field with arcpy.da.UpdateCursor(Selected_Features, ("EditField")) as rows: # row comes back as a tuple in the order specified here, so Office is row[0], Forester is row[1] for row in rows: row[0] = value rows.updateRow(row)