ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / LayoutProjectItem Class / GetLayout Method
Example

In This Topic
    GetLayout Method
    In This Topic
    Loads and returns the Layout associated with the LayoutPrjectItem. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function GetLayout() As Layout
    public Layout GetLayout()

    Return Value

    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Open a layout project item in a new view
    {
      //Open a layout project item in a new view.
      //A layout project item may exist but it may not be open in a view. 
    
      //Reference a layout project item by name
      LayoutProjectItem layoutItemByName = Project.Current.GetItems<LayoutProjectItem>()
                                .FirstOrDefault(item => item.Name.Equals("MyLayoutItem"));
    
      //Get the layout associated with the layout project item
      //Note: Needs QueuedTask to run
      Layout layoutFromItem = layoutItemByName.GetLayout();  //Worker thread
    
      //Create the new pane - call on UI
      ILayoutPane iNewLayoutPane = await ProApp.Panes.CreateLayoutPaneAsync(layout); //GUI thread
    }
    Change the layout page size
    {
      //Change the layout page size.
      //Reference the layout project item
      LayoutProjectItem lytItem = Project.Current.GetItems<LayoutProjectItem>()
                             .FirstOrDefault(item => item.Name.Equals("MyLayoutItem"));
      if (layoutItem != null)
      {
        //Note: Needs QueuedTask to run
        //Get the layout
        Layout lyt = lytItem.GetLayout();
        if (lyt != null)
        {
          //Change properties
          CIMPage page = lyt.GetPage();
          page.Width = 8.5;
          page.Height = 11;
    
          //Apply the changes to the layout
          lyt.SetPage(page);
        }
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also