Model converted to Script - No editing mode?

2107
6
Jump to solution
09-30-2013 10:31 AM
by Anonymous User
Not applicable
Original User: ionara_wilson

I have a model that an ESRI associate sent me as an example. When I run the model everything is great. I click on the model and because the seleting features is a parameter, it automatically starts an edit session for me to digitize the selecting features. However when I convert this model to a script and try to run as a script, when I run it, the selecting feature parameter is not in edit mode, a polygon does not pop up in the table of contents as a feature class to be digitized like it was with the model. Is there a way to change the model so that the selecting features can be digitized ? Thanks

The first picture shows the model, the second shows the model when I run it, and the third shows the scrip when I run it. [ATTACH=CONFIG]27884[/ATTACH][ATTACH=CONFIG]27885[/ATTACH][ATTACH=CONFIG]27886[/ATTACH]


 # -*- coding: utf-8 -*- # --------------------------------------------------------------------------- # toolbox_scrip3t.py # Created on: 2013-09-30 13:13:52.00000 #   (generated by ArcGIS/ModelBuilder) # Usage: toolbox_scrip3t <Selecting_Features> <value>  # Description:  # test # ---------------------------------------------------------------------------  # Import arcpy module import arcpy  # Script arguments Selecting_Features = arcpy.GetParameterAsText(0) if Selecting_Features == '#' or not Selecting_Features:     Selecting_Features = "in_memory\\{44DC94EF-CABC-4233-A4AF-CEFD34618B2E}" # provide a default value if unspecified  value = arcpy.GetParameterAsText(1)  # Local variables: Input_Points = "FirePerimeter" Final_Output = value Selected_Features = Selecting_Features 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")  # Process: Calculate Field arcpy.CalculateField_management(Selected_Features, "EditField", "'%value%'", "PYTHON_9.3", "")
0 Kudos
1 Solution

Accepted Solutions
DaveBarrett
Occasional Contributor
Hi,

Had a similar issue recently, the data type for the input feature needs to be a feature set and you need to specify a template schema for the feature. This can be a basic polygon feature class with no extra fields or you can have a number of fields that the user can also edit and you can then use within the script.

I think I might have an example at work that I will grab and post

Cheers

Dave

View solution in original post

0 Kudos
6 Replies
DaveBarrett
Occasional Contributor
Hi,

Had a similar issue recently, the data type for the input feature needs to be a feature set and you need to specify a template schema for the feature. This can be a basic polygon feature class with no extra fields or you can have a number of fields that the user can also edit and you can then use within the script.

I think I might have an example at work that I will grab and post

Cheers

Dave
0 Kudos
by Anonymous User
Not applicable
Original User: ionara_wilson

Awesome Dave, Thank you! How do I specify the schema?
0 Kudos
DaveBarrett
Occasional Contributor
You should be able to specify it in the properties dialog when attaching the script to a tool. It is one of the options in the additional information box just need to make sure you have the parameter selected.

Cheers

Dave
0 Kudos
by Anonymous User
Not applicable
Original User: ionara_wilson

Now it starts in edit mode, but the script shows an error because it says the filed FireName does not exist. Why would it be looking for FireName in the polygon if it is going to calculate the value for FirePerimeter? I am really puzzled. The polygon feature that came with the example also does not have a field FireName and it works great when I run the model, but the script has this problem that is looking for FireName. Can  you please take a look at the script and tell me why it complains about FireName not being found when it is in FirePerimeter? Thank you so much!
0 Kudos
DaveBarrett
Occasional Contributor
Hi,

Like you I cannot see any direct reference to the Field called FireName, the only thing I can think of at the moment is that a field that was present in the make feature layer tool before you exported the model. Might be worth rewriting that line and only specify the minimum parameters you need.

Dave
0 Kudos
by Anonymous User
Not applicable
Original User: ionara_wilson

I tried rewriting that line and also using the original data and converting the original model directly to a script. The script still throws an error looking for the EditField, very strange. I will start a new thread with this question! Thank you so much for your help!
0 Kudos