①数据源修复
IMapDocument mapDoc = new MapDocumentClass(); mapDoc.Open(mxdPath); IDataSourceHelperMapDocument helpler = new DataSourceHelperClass(); helpler.FindAndReplaceWorkspaceNamePath(mapDoc, oldpath, mdbPath, true); //oldpath为打开的mxd模板中加载的层的路径(任意一个) //mdbPath为新的对应数据的路径
②修改出图过程中的IElement
IMapDocument pDoc = new MapDocumentClass(); pDoc.Open("D:/Desktop/EXPT.mxd"); IPageLayout pageLayout = pDoc.PageLayout; IGraphicsContainer container = pageLayout as IGraphicsContainer; container.Reset(); IElement ele = null; while ((ele=container.Next())!=null) { IElementProperties eleProp = ele as IElementProperties; if (ele is ITextElement) { switch (eleProp.Name) { case "TITLE": (ele as ITextElement).Text = "Element_TITLE内容更换测试"; break; case "LABEL": (ele as ITextElement).Text = "Element_LABEL内容更换测试"; break; case "DATE": (ele as ITextElement).Text = "二零二二年四月"; break; default: break; } } else if (ele is IGraphicElement) { } }
③添加辅助图层,并至于对应位置
IMapDocument pDoc = new MapDocumentClass(); pDoc.Open("D:/Desktop/EXPT.mxd"); IWorkspaceFactory pWSF = new ShapefileWorkspaceFactoryClass(); IFeatureWorkspace pFW = pWSF.OpenFromFile(@"F:\0505\1矢量数据", 0) as IFeatureWorkspace; IFeatureLayer pFLayer = new FeatureLayerClass(); pFLayer.FeatureClass = pFW.OpenFeatureClass("610330JSYDGZQ"); pDoc.ActiveView.FocusMap.AddLayer(pFLayer); pDoc.ActiveView.FocusMap.MoveLayer(pFLayer, 1);
标签:ITextElement,代码,pFLayer,ele,break,出图,new,pDoc,ArcEngine From: https://www.cnblogs.com/clgis/p/17374046.html