0
我的程序的目的是查看給定目錄中的每個.mxd文件,刪除其舊的和損壞的註記圖層,並添加新的特定要素類。地理數據庫中的舊註釋源按每個要素類類型組合爲一個註記文件。 (所以不要使用bAnno1,bAnno2 ...它會成爲bAnnos,這樣可以節省空間並減少ArcGIS的編輯時間。)添加現有的註釋層
我的問題是創建新的註記圖層。我原來的代碼是沿着這些線路(創建第一個五個變量只有一次外循環):
IMapDocument mapdoc = new MapDocumentClass();
IWorkspaceFactory iwf = new FileGDBWorkspaceFactoryClass();
IFeatureWorkspace workspace = (IFeatureWorkspace)iwf.OpenFromFile(path, 0);
IFeatureDataset dataset = workspace.OpenFeatureDataset(datasetName);
IFeatureClassContainer container = (IFeatureClassContainer)dataset;
// Here is where it enters the loop for .mxd files
IMap pMap = mapdoc.get_Map(0);
// Here it removes old annotation layers first
IFeatureLayer newlayer = new FeatureLayerClass();
newlayer.DataSourceType = "File Geodatabase Feature Class";
newlayer.Name = "Anno Name";
newlayer.FeatureClass = container.get_ClassByName(annoName);
pMap.AddLayer((ILayer)newlayer);
的添加層中的一切,但符號原來的註釋層相匹配。換句話說,ArcGIS將這些添加的文件視爲多邊形的要素類,而不是帶有單詞的註記類。看着我的代碼,我可以看到爲什麼。
那麼,我該如何獨佔一個註釋層?或者,如何使用地理數據庫中的數據集中的現有源創建註記圖層?
失敗的嘗試包括使用:
AnnotationFeatureClass tempLayer = new AnnotationFeatureClass();
IAnnoClass newlayer = (IAnnoClass)tempLayer;
和
IAnnotationLayerFactory annofactory = new FDOGraphicsLayerFactoryClass();
IAnnotationLayer annoLayer = annofactory.CreateAnnotationLayer(...);
之一上述方法實際上可能是答案;我可能會錯誤地做事。
其他細節:使用ArcGIS 10,與和從ArcGIS 9.3製成的.mxd文件10