How Do I add an Object to Layout Space


In Rhino Common, I add an Object (Curve, Text etc.) to the Model Space by:


What’s the Equivalent to adding something to the Layout Space? Inserting a 2D Line, A Text, Dimensions and Block instances?


The document takes into account the active view when adding geometry. If you have a layout active, the geometry will be added to that specific layout.

As an alternative, you can create ObjectAttributes and set the ViewportId to that of the layout’s main viewport. Pass this ObjectAttributes to the Add functions.


Is the second method working properly in Rhino 6?
For example, if I try to add a line on the “Page 1” layout using the code below inside a grasshopper C# component, this line always appears on the active layout.

Rhino.DocObjects.ObjectAttributes att = new Rhino.DocObjects.ObjectAttributes();
var view = RhinoDocument.Views.Find("Page 1", false);
att.ViewportId = view.MainViewport.Id;
RhinoDocument.Objects.AddLine(new Point3d(0, 0, 0), new Point3d(100, 100, 0), att);


Hi @atai,

I am not finding the second method working. I’ve logged a bug for that.

This, however, does work (from a plug-in command):

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
  var page_views = doc.Views.GetPageViews();
  if (null == page_views || 0 == page_views.Length)
    return Result.Nothing;

  const string page_name = "Page 1";
  var page_view = page_views.FirstOrDefault(pg => pg.PageName.Equals(page_name, StringComparison.OrdinalIgnoreCase));
  if (null == page_view)
    RhinoApp.WriteLine("{0} page view not found.", page_name);
    return Result.Nothing;

  var plane = Plane.WorldXY;
  var circle = new Circle(plane, 5.0);

  doc.Views.RedrawEnabled = false;
  var old_view = doc.Views.ActiveView;
  doc.Views.ActiveView = page_view;

  doc.Objects.AddCircle(circle/*, attributes*/);

  doc.Views.ActiveView = old_view;
  doc.Views.RedrawEnabled = true;

  return Result.Success;

– Dale


Thanks. Switching between active layout works.


Hi everyone, if you are working with detail in pageview then you should set pageview as active in order to add objects to page layout instead of the document in detail view. For example :

detail.DetailGeometry.IsProjectionLocked = true;
doc.Views.ActiveView = pageview;
RhinoDoc.ActiveDoc.Objects.AddCurve(new Line(new Point3d(20, 20, 0), new Point3d(200, 20, 0)).ToNurbsCurve());