Thanks Alex. As a fellow AO vet, I appreciate your insight.
We have numerous Engine and ArcMap applications that rely on the pattern of using the IGraphicsContainer interface associated with the PageLayout. Typically, the apps perform the required analysis and then passes the results along with all of the ancillary layout information (text, text location, map, layout size, symbols etc...) to a method that adds these elements to the layout graphics container. In fact, we have built numerous helper classes that specifically handle adding these elements to a layout graphics collection. Once the layout is 'built', it is exported to whatever format the user specifies.
Here is a bit of code to illustrate:
public void BuildLayout ( IMxDoc pDoc, IActiveView pActiveView, IMap pMap, string strTitle double[] dblEnvArray...)
{
DeleteAllGraphElementsExceptMapFrame(pDoc); //method that removes all graphics
pDoc.ActiveView.Refresh();
pDoc.PageLayout.Page.Orientation = Convert.ToInt16(intOrient);
pDoc.PageLayout.Page.PutCustomSize(dblCustSizeX, dblCustSizeY);
pDoc.PageLayout.RulerSettings.SmallestDivision = 1;
pDoc.PageLayout.ZoomToWhole();
pDoc.ActiveView.Refresh();
pActiveView = pDoc.ActiveView;
// testing calling routine for map to page transformation
IGraphicsContainer pGC;
pGC = (IGraphicsContainer)pDoc.PageLayout;
pGC.Reset();
IElement pElem;
pElem = pGC.Next();
IEnvelope pMapEnvelope;
pActiveView.Refresh();
while (pElem != null)
{
if (pElem is IMapFrame)
{
pMapEnvelope = pElem.Geometry.Envelope;
pMapEnvelope.XMin = dblEnvArray[0];
pMapEnvelope.YMin = dblEnvArray[1];
pMapEnvelope.XMax = dblEnvArray[2];
pMapEnvelope.YMax = dblEnvArray[3];
pElem.Geometry = pMapEnvelope;
IMapFrame pMapFrame = (IMapFrame)pElem;
pMapFrame.MapScale = pMap.MapScale;
}
pElem = pGC.Next();
} //end while
LayoutGeneric.AddTextToLayout(pActiveView, strTitle, 1, 1.5) //calling helper routine to add text
......
Export to PDF.....
}
public void AddTextToLayout(IActiveView pActiveView, string strTitle, double dblX, double dblY, int intFontSize)
{
if(pActiveView is IPageLayout)
{
IGraphicsContainer pGraphicsContainer;
ITextElement pTextElement = new TextElementClass();;
IPageLayout pPageLayout;
ISimpleTextSymbol pTextSym;
pTextSym = new TextSymbolClass();
pPageLayout = (IPageLayout) pActiveView;
pGraphicsContainer = (IGraphicsContainer) pPageLayout;
IElement pElement;
IGroupElement pGroupElement = new GroupElementClass();
IPoint pPoint;
pPoint = new PointClass();
pPoint.PutCoords(dblX, dblY - 0.1);
pTextElement.Text = strTitle;
pTextSym.Font.Name = "Arial";
pTextSym.Size = intFontSize;
pTextSym.HorizontalAlignment = ESRI.ArcGIS.Display.esriTextHorizontalAlignment.esriTHALeft;
pTextSym.VerticalAlignment = ESRI.ArcGIS.Display.esriTextVerticalAlignment.esriTVABaseline;
pTextSym.Font.Bold = true;
pTextElement.Symbol = pTextSym;
pElement = (IElement)pTextElement;
pElement.Geometry = (IGeometry) pPoint;
pGraphicsContainer.AddElement(pElement,0);
pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGraphics,null,null);
}
}
When looking at the Pro version of the Layout class and the LayoutProjectItem, there does not appear to be any way to add elements to the layout. There are examples of Pro code manipulating elements already present. As we have discussed, the elements collection returned from the layout appears to be read only. Presently, in my Pro efforts, I am reading a 'layout file' (.pagx) into the Project. This layout file only contains the layout dimensions. I was hoping to be able to add the elements I needed to the element collection associated with this layout. I hope I don't have to have a 'boiler plate' layout file for each type of layout I will need to produce, with all of the text and symbols present, with my code only swapping the values. If this is the case, I am not sure how I would handle custom graphics I want to add to the layout that could not be part of the boiler plate layout file(.pagx) approach.
Thanks again for your interest.