I want to export a feature class to a geodatabase using arcpy and strip out any subtypes. But they keep hanging around in the new feature class. How do I get rid of them? This doesn't work:

subtypes = arcpy.da.ListSubtypes(featureClass)
arcpy.RemoveSubtype_management(featureClass, subtypes)

The above throws this error:

Traceback (most recent call last):
File "E:\SCAT\Scripts\test.py", line 112, in <module>
arcpy.RemoveSubtype_management(featureClass, subtypes)
File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\management.py", line 17276, in RemoveSubtype
raise e
RuntimeError: Object: Error in executing tool

The arcpy.da.ListSubtypes() function returns a dictionary.

The keys of the dictionary are the subtype codes, and the values of the dictionary are the subtype properties.

subtypes = arcpy.da.ListSubtypes(r'C:\temp\data.gdb\Water\Fittings')

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]

The Remove Subtype GP tool can accept a list of subtypes codes. You can choose what codes you would like to remove

subtype_code=[code for code in subtypes.keys() if code in [0,1,2]])

or just delete all the codes:

  • I tried your suggestion to delete all the codes, but this error was thrown:Traceback (most recent call last): File "E:\SCAT\Scripts\CreateShorelineFromSelectedPolylines.py", line 114, in <module> arcpy.RemoveSubtype_management(shoreline, subtype_code = subtypes.keys()) File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\management.py", line 17276, in RemoveSubtype raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000192: Invalid value for Subtype Code Failed to execute (RemoveSubtype).
    – spaine
    Mar 20 '18 at 14:52
  • @spaine, can you please print out the subtypes.keys()? Mar 20 '18 at 15:12
  • Hi Alex, I think I solved the problem - I was iterating this through 2 datasets. It worked correctly on the first one that had subtypes, but the 2nd one did not. So the value for subtypes.keys() was [0], which apparently is not a valid parameter for RemoveSubtype
    – spaine
    Mar 20 '18 at 15:45

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.