ArcGIS Pro 2.7 API Reference Guide
CreateLayout(Double,Double,LinearUnit,Boolean,Double) Method
Example 

ArcGIS.Desktop.Layouts Namespace > LayoutFactory Class > CreateLayout Method : CreateLayout(Double,Double,LinearUnit,Boolean,Double) Method
The width of the page layout in page units.
The height of the page layout in page units.
Specify the linear units.
An optional boolean to show rulers on the layout.
An optional double to specify smallest ruler division.
Creates a layout using a simple set of parameters. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
Public Overloads Function CreateLayout( _
   ByVal width As Double, _
   ByVal height As Double, _
   ByVal units As LinearUnit, _
   Optional ByVal showRulers As Boolean, _
   Optional ByVal smallestRulerDivision As Double _
) As Layout

Parameters

width
The width of the page layout in page units.
height
The height of the page layout in page units.
units
Specify the linear units.
showRulers
An optional boolean to show rulers on the layout.
smallestRulerDivision
An optional double to specify smallest ruler division.

Return Value

Returns Layout or a null.
Exceptions
ExceptionDescription
This method must be called within the lambda passed to QueuedTask.Run.
Example
//This example creates a new layout using a CIM page definion with rulers and guides included.

//Added references
using ArcGIS.Desktop.Layouts;                      
using ArcGIS.Desktop.Framework.Threading.Tasks;    
using ArcGIS.Desktop.Core;
using ArcGIS.Core.CIM;

public class CreateLayoutEx2
{
  async public static Task<Layout> CreateCIMLayout(double width, double height, LinearUnit units, string LayoutName)
  {
    Layout CIMlayout = null;
    await QueuedTask.Run(() =>
    {
      //Set up a page
      CIMPage newPage = new CIMPage();

      //required
      newPage.Width = width;
      newPage.Height = height;
      newPage.Units = units;

      //optional rulers
      newPage.ShowRulers = true;
      newPage.SmallestRulerDivision = 5;

      //optional guides
      newPage.ShowGuides = true;
      CIMGuide guide1 = new CIMGuide();
      guide1.Position = 25;
      guide1.Orientation = Orientation.Vertical;
      CIMGuide guide2 = new CIMGuide();
      guide2.Position = 185;
      guide2.Orientation = Orientation.Vertical;
      CIMGuide guide3 = new CIMGuide();
      guide3.Position = 25;
      guide3.Orientation = Orientation.Horizontal;
      CIMGuide guide4 = new CIMGuide();
      guide4.Position = 272;
      guide4.Orientation = Orientation.Horizontal;

      List<CIMGuide> guideList = new List<CIMGuide>();
      guideList.Add(guide1);
      guideList.Add(guide2);
      guideList.Add(guide3);
      guideList.Add(guide4);
      newPage.Guides = guideList.ToArray();

      Layout layout = LayoutFactory.Instance.CreateLayout(newPage);

      layout.SetName(LayoutName);
    });

    //Open the layout in a pane
    await ProApp.Panes.CreateLayoutPaneAsync(CIMlayout);
    return CIMlayout;
  }
}
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

LayoutFactory Class
LayoutFactory Members
Overload List