I would like to add an AutoCad .dwg file to Arcmap using python the same way that the +ADD Data button does.
I can add an Annotation layer with python but only as a feature layer not as an annotation layer... even thought in the properties it says it's a CAD Annotation Feature Class
targetGroupLayer = arcpy.mapping.ListLayers(mxd, "ACAD", df)[0]
addLayer = arcpy.mapping.Layer(PlanPath)
arcpy.mapping.AddLayerToGroup(df, targetGroupLayer, addLayer, "BOTTOM")
The files share the same properties, but are different types (Feature, Annotation)...
NOTE: I realize in my screencaps the files have different R1, R2 numbers ignore this.
The documentation for layer says:
"There are essentially three categories of layers in a map document: feature layers, group layers, and raster layers. There are a few specialized layers and datasets that don't fall into one of these three categories: annotation subclasses Group layers and other sublayers (e.g., annotation classes) are treated just like ordinary layers."
Is there any way to add it as an Annotation layer? The same way the +Add Data button works?
EDIT:
This is what I tried doing.
targetGroupLayer = arcpy.mapping.ListLayers(mxd, "ACAD", df)[0]
arcpy.MakeFeatureLayer_management(PlanPath,"CAD")
for lyr in arcpy.mapping.ListLayers(mxd,"CAD",df):
lyr2 = lyr
#Include the Add Layer to Group code as part of the For Loop
arcpy.mapping.AddLayerToGroup(df,targetGroupLayer,lyr2)
From what I could tell from your code (Get Spatial). The annotation layer is added to a temp feature layer. You then search for that temp feature layer "cadname" and then add it to the target grouplayer.I tried to recreate this but using and for loop to loop through each layer and find the one called "CAD"
@GetSpatial I ran the new code and looks like it made the feature layer yet did not correctly add it to the map.
In the report below is the "CAD" after "\Annotation" part of the file name it is trying to find, or is it simply the name of the Layer and has no effect on the file path?