Skip to main content
added 346 characters in body
Source Link
Tristan Forward
  • 2.2k
  • 3
  • 25
  • 43

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)...

enter image description here

enter image description here

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?

Report

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)...

enter image description here

enter image description here

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"

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)...

enter image description here

enter image description here

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?

Report

Correct code error
Source Link
Get Spatial
  • 13.3k
  • 6
  • 41
  • 68

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)...

enter image description here

enter image description here

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"

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)...

enter image description here

enter image description here

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

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"

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)...

enter image description here

enter image description here

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"

added 624 characters in body
Source Link
Tristan Forward
  • 2.2k
  • 3
  • 25
  • 43

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)...

enter image description here

enter image description here

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

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"

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)...

enter image description here

enter image description here

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?

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)...

enter image description here

enter image description here

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

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"

added 442 characters in body
Source Link
Tristan Forward
  • 2.2k
  • 3
  • 25
  • 43
Loading
Source Link
Tristan Forward
  • 2.2k
  • 3
  • 25
  • 43
Loading