2

I'm trying to add a temporary field to one of the input feature classes in my Python toolbox.

arcpy.AddWarning("Adding field of type " + fieldType.upper() + " to FC " + varFC + " called " + tempField)
arcpy.AddField(varFC, tempField, fieldType.upper())

The first line outputs as I'd expect

("Adding field of type DOUBLE to FC C:\foobar\Test.gdb\inputFC called Population_temp"), but the second line raises an error:

Failed to execute. Parameters are not valid. ERROR 000732: Input Table: Dataset C:\foobar\TEST.gdb\outputFC does not exist or is not supported Failed to execute (AddField).

outputFC is the output parameter in the Python toolbox, and NOT what's stored in varFC (which is an input parameter). I can't figure out why Arc is referencing outputFC at all, unless Python toolboxes will only allow alteration of parameters designated as output?


If anyone is wondering the specific answer to my question, you can alter input parameters. You just have to use valid arcpy commands.

closed as off-topic by PolyGeo Aug 31 '15 at 21:37

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    It's been a while since I used ArcGIS/Python scripting but I would suggest trying a shorter simpler variable name like poptemp just to see if that makes any difference. Also check if it should be DOUBLE or double (you are passing in double on creation. Should it be AddField_management help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//… ? I couldn't find AddField in the docs.... – djq Aug 31 '15 at 18:39
  • I have read your question 3 times and still can't figure out what's the problem is :) can you provide more clear info on the input and output params and the script configuration? Having the full code of the script would be helpful to get the context. – Alex Tereshenkov Aug 31 '15 at 18:46
  • Ahh, man. I totally forgot the _management part of AddField_management(). Not the first time I've done that, and probably won't be the last! Thank you @djq !! Also thanks for trying to decipher my incomprehensible nonsense, @Alex Tereshenkov – user187135 Aug 31 '15 at 19:10
  • You're welcome! I recommend using the debugger ipdb instead of print. Install ipdb and then add import ipdb; ipdb.set_trace() where the problem occurs. This way you can jump into the terminal and interact with code at this breakpoint. – djq Aug 31 '15 at 20:03
  • You can also use the module form, if it helps you remember (ie. arcpy.management.AddField). – Evil Genius Aug 31 '15 at 20:12