import os, sys, random, arcgisscripting
import os, sys, random, arcgisscripting as gp
ah, it seems the python script you included in the model is probably from arcgis 9.3 or prior, which used different syntax for certain tools then what is being used for 10.0 to current. the gp you see is the older version syntax they used. If you could post the python script that was included in the model, we could probably help you debug or update it so it can run for 10.0 - 10.2
import os, sys, random, arcgisscripting try: gp = arcgisscripting.create() gp.overwriteoutput = 1 # Specify input featureclass, output *.lyr file and the percentage of # random points to return. Set these parameters in ArcToolbox as shown. inputFC = sys.argv[1] # Feature Class or Feature Layer outputLyr = sys.argv[2] # Layer File inpct = sys.argv[3] # Long # Ensure that the input percentage is between 1 and 100% inpct = min(int(inpct),100) inpct = max(int(inpct),1) # Work out how many features to select inputDirname = os.path.dirname(inputFC) inputBasename = os.path.basename(inputFC) gp.workspace = inputDirname desc = gp.describe(inputFC) totpnts = gp.getcount(inputFC) numValues = int(round(totpnts * float(inpct) / 100.0)) gp.addmessage("Selecting " + str(numValues) + " random features") # Generate a list of all features, and select randomly from this inList = [] randomList = [] fldname = desc.OIDFieldName rows = gp.SearchCursor(inputFC) row = rows.next() gp.addmessage ("Loading all IDs into a list") while row: id = row.GetValue(fldname) inList.append(id) row = rows.next() selpnts = 0 gp.addmessage("Creating the list of randomly selected features") while len(randomList) < numValues: selpnts += 1 selItem = random.choice(inList) randomList.append(selItem) inList.remove(selItem) # Select features whose OID value occurs in the random list, generate # a *.lyr file from this selection. (Leading and trailing [ and ] marks # need to be removed from the list object) theLen = len(str(randomList)) sqlexp = '"' + fldname + '"' + " in " + "(" + str(randomList)[1:theLen - 1] + ")" selectionLyr = inputBasename + " selection" gp.MakeFeatureLayer_management(inputFC, selectionLyr, sqlexp) gp.SaveToLayerFile_management(selectionLyr, outputLyr) gp.addmessage("\nOutput layer " + outputLyr + " contains features randomly selected from " + inputBasename + "\n") except: gp.adderror("Error running script. Try specifying the full path to the input layer") # END OF FILE
You should just be able to convert the entire model to a python script which can be run outside of ArcGIS (you would still have to run it on a computer with ArcGIS licensing).In the model you simply need to go to Model>export>to python script.From there you probably could integrate it into whatever you need to make it an .exe file.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.