3

I have a script that takes in a line, and creates a certain polygon based on this.

My code obtaining the input information is as follows:

inFC = arcpy.GetParameterAsText(0)
hasClearway = arcpy.GetParameterAsText(1) 
hasHighDivergence = arcpy.GetParameterAsText(2)
outFC = arcpy.GetParameterAsText(3)
fcName = outFC.rpartition("\\")[2]
fcPath = outFC.rpartition("\\")[0]
outFC = arcpy.CreateFeatureclass_management(fcPath, fcName, "POLYGON", inFC, "DISABLED", "DISABLED", inFC)

The polygon is finally created from an array and inserted into outFC

runwaypolygon = arcpy.Polygon(polygon_array)
cursor = arcpy.da.InsertCursor(outFC, ['SHAPE@'])
cursor.insertRow([runwaypolygon])

However I am getting the error 20469, "An Error Occured trying to save the object named X", when trying to set the output FC, see below screenshot:

enter image description here

I have looked into this http://support.esri.com/de/knowledgebase/techarticles/detail/20469 but this has not shed any light on the issue. Two further points:

(1) I have successfully used this method with an object of exactly the same type (a polygon produced in the same way).

(2) The script works fine when I ask the user to specify output file location and name separately, as here:

inFC = arcpy.GetParameterAsText(0)
hasClearway = arcpy.GetParameterAsText(1)
hasHighDivergence = arcpy.GetParameterAsText(2)
outFC_location = arcpy.GetParameterAsText(3)
fcName = (arcpy.GetParameterAsText(4))
outFC = arcpy.CreateFeatureclass_management(outFC_location, fcName, "POLYGON")

What is the error in my code or my approach?

  • maybe try fcPath, fcName = os.path.split(outFC)? – crmackey Dec 31 '15 at 15:39
  • Same result sadly, worth a try though. – branches Dec 31 '15 at 16:01
  • 2
    It must be something with the pathing that is being input. Run a test and print out what's being input for the path and the name right before you try creating your feature class to make sure the inputs are valid. – Emil Brundage Dec 31 '15 at 16:30
  • 1
    As it stands your question seems to show a few lines from here and there and then part of an error message. Would you be able to include a code snippet that works up to where you are stuck and the complete error message seen when that code snippet is run, please? – PolyGeo Jan 1 '16 at 9:27
  • Re-reading my question I realise that I had missed an important piece of explanation, apologies, this is now edited. The issue I am having is when trying to use the tool in Arcmap. – branches Jan 6 '16 at 9:50
1

Regardless of where the error occurs, it seems that the data type of your outFC parameter is wrong, you've probably chosen 'Workspace' instead of 'Feature Class'. In the script tool's interface, choose 'Feature Class' as data type:

enter image description here

| improve this answer | |
  • I had it set to "Workspace or feature class", however setting explicitly to "feature class" has worked. Many thanks. – branches Jan 6 '16 at 10:07
  • @branches - I don't have that option with 10.3.1, only 'Workspace', 'Workspace or feature dataset' and 'Workspace or Raster Catalog'. Maybe you could have changed the 'Save as data type' option from 'Geodatabases' to 'Feature classes' in the parameter's browse window. 'Feature classes' is a safer choice anyway if it's the only valid option for your script! – GISGe Jan 6 '16 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.