4

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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Nov 2, 2014 at 14:52
1
  • 1
    I think you may have to convert your DWG to a Feature Class in order to access that information. ArcMap has limited functionality with DWGs. Commented Nov 5, 2014 at 17:51

1 Answer 1

1
+50

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.

answered Nov 6, 2014 at 9:25

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.