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.

  • 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. – Baltok Nov 5 '14 at 17:51
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.

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.