I am trying to get LisfFields from AutoCad DWG, to arcpy Add-In, i have tried
mxd = arcpy.mapping.MapDocument("CURRENT")
Layers = arcpy.mapping.ListLayers(mxd)
for Layers in Layers:
if Layers.name==Target_Layer:
fieldList = arcpy.ListFields(Target_Layer)
for field in fieldList:
fieldName=str(field.name)
It works for Feature Class Layers but not for DWG.
Is there other way to do this?
I have also tried MakeFeatureLayer before LisfFields and it did not work.
-
1I think you may have to convert your DWG to a Feature Class in order to access that information. ArcMap has limited functionality with DWGs.Baltok– Baltok2014年11月05日 17:51:48 +00:00Commented Nov 5, 2014 at 17:51
1 Answer 1
As indicated in the help for ListFields (arcpy) that ArcPy function:
Lists the fields in a feature class, shapefile, or table in a specified dataset. The returned list can be limited with search criteria for name and field type and will contain field objects.
Consequently, as commented by @Baltok, I think you will need to convert your CAD drawing to a feature class before using ListFields on it.
One tool that should be able to do this is CAD to Geodatabase (Conversion) which:
Reads a CAD dataset and creates feature classes of the drawing. The feature classes are written to a geodatabase feature dataset.
Explore related questions
See similar questions with these tags.