arcpy.ListSubtypes is not working

1218
2
Jump to solution
05-12-2013 05:22 AM
MoizIshfaq
New Contributor II
Hello,
I am following ESRI Documentation link 'http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000021000000' to print the details of subtype associated with a feature class but for some reason am always getting an error message complaining arcpy doesn't contain a definition for ListSubtypes(table_name) method.

Here is the code snippet,
          subtypes = arcpy.ListSubtypes(table_name)           for stcode, stdict in subtypes.iteritems():             print('Code: {0}'.format(stcode))             for stkey in stdict.iterkeys():                 if stkey == 'FieldValues':                     print('Fields:')                     fields = stdict[stkey]                     for field, fieldvals in fields.iteritems():                                         print(' --Field name: {0}'.format(field))                         print(' --Field default value: {0}'.format(fieldvals[0]))                         if not fieldvals[1] is None:                             print(' --Domain name: {0}'.format(fieldvals[1].name))                 else:                                         print('{0}: {1}'.format(stkey, stdict[stkey]))


Here is the error message,

[HTML]PYTHON ERRORS:
Error Info:
'module' object has no attribute 'ListSubtypes'
Exception Type is: <type 'exceptions.AttributeError'>
Traceback info:
  File "\\machine_name\published_folder\GPT\listAllDataObjFieldsNamesTypes.py", line 72, in <module>
    subtypes = arcpy.ListSubtypes(schemaObject)
[/HTML]

Secondly, I was wondering if there is anyway we can get a subtype values instead of codes. I know I can use a search cursor to get the distinct values from a featureclass for the subtype field but that won't give me the actual values associated with these codes. Kindly share your thought on it.

I am using ArcGIS Desktop 10.1 with ArcSDE 10 (64bit Oracle 11g).

In advance I thank you all for your time and support.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Esteemed Contributor
I am following ESRI Documentation link (ListSubtypes) to print the details of subtype associated with a feature class but for some reason am always getting an error message complaining arcpy doesn't contain a definition for ListSubtypes(table_name) method.

subtypes = arcpy.ListSubtypes(table_name)


Britt, this method is within the arcpy.da module. The code example is a bit weak in the help; I complained in the feedback - and I suggest you do too!

Have you tried:

subtypes = arcpy.da.ListSubtypes(table_name)


Secondly, I was wondering if there is anyway we can get a subtype values instead of codes.


I'm pretty sure the most direct approach would be to examine the associated domain with arcpy.da.ListDomains.

View solution in original post

0 Kudos
2 Replies
curtvprice
MVP Esteemed Contributor
I am following ESRI Documentation link (ListSubtypes) to print the details of subtype associated with a feature class but for some reason am always getting an error message complaining arcpy doesn't contain a definition for ListSubtypes(table_name) method.

subtypes = arcpy.ListSubtypes(table_name)


Britt, this method is within the arcpy.da module. The code example is a bit weak in the help; I complained in the feedback - and I suggest you do too!

Have you tried:

subtypes = arcpy.da.ListSubtypes(table_name)


Secondly, I was wondering if there is anyway we can get a subtype values instead of codes.


I'm pretty sure the most direct approach would be to examine the associated domain with arcpy.da.ListDomains.
0 Kudos
MoizIshfaq
New Contributor II
Thanks Curtis for your quick reply and help. It indeed answered both of my questions like a charm.



Britt, this method is within the arcpy.da module. The code example is a bit weak in the help; I complained in the feedback - and I suggest you do too!

Have you tried:

subtypes = arcpy.da.ListSubtypes(table_name)




I'm pretty sure the most direct approach would be to examine the associated domain with arcpy.da.ListDomains.
0 Kudos