Select to view content in your preferred language

How to add Annotation Layer to ArcMap from CAD file

1077
2
03-11-2013 07:08 AM
AntonPerlov1
Deactivated User
I need to add Annotation Layers from .dwg and .dgn CAD files to arcmap

At first I used Block of code like this

ESRI.ArcGIS.Geodatabase.IWorkspaceFactory pWorkspaceFact = new
                 ESRI.ArcGIS.DataSourcesFile.CadWorkspaceFactory();
                //Open the workspace.
                ESRI.ArcGIS.Geodatabase.IWorkspace pWorkspace = pWorkspaceFact.OpenFromFile
                    (workspace_path, 0);

                ESRI.ArcGIS.Geodatabase.IFeatureWorkspace pFeatureWorkspace =
    (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)pWorkspace;
 IGroupLayer cl = new GroupLayerClass();
            cl.Name = fc_name;


                IAnnotationLayerFactory lf = new FDOGraphicsLayerFactory() as IAnnotationLayerFactory;
                IAnnotationLayer al= lf.OpenAnnotationLayer(pFeatureWorkspace, null, System.String.Concat(fc_name,":Annotation"));

                cl.Add(al as ILayer);


but this code generates Annotation Layer with broken emty datasource. And datasource cannot be set from CAD manually.

There also is interface
EngineCadAnnotationLayerFactory and CoClass EngineCadAnnotationLayerFactoryClass, but they only implement ILayerFactory interface, not the IAnnotationLayerFacory interface. This trouble makes unreachable OpenAnnotationLayer() method.

Can anyone help me to find solution?
0 Kudos
2 Replies
LeoDonahue
Deactivated User
hang on... posted the wrong thing, looking it up again..
0 Kudos
AntonPerlov1
Deactivated User
The solution is finally found


                CadAnnotationLayerClass newlayer = new CadAnnotationLayerClass();
                newlayer.DataSourceType = "CAD Annotation Feature Class";
                newlayer.Name = "Аnnotations";

                newlayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass(System.String.Concat(fc_name, ":Annotation")); ;
0 Kudos