Layout and PDF automatically (C++)


I would like to automate the export of some 2D drawings…create the layout (frame, stamp, etc…) and export it as PDF. I haven’t done any of those things before - haven’t programmed anything related to the layout or exported drawings as PDFs…

So, I would like some general advice for starters. What classes to use? For Layout? For PDF export (print)? Of course some code examples would be perfect.

Thanks a lot!


Hi Milos,

A layout (or page) view is represented by a CRhinoPageView object, which is derived from CRhinoView.

To retrieve all of the page views in a document, you can do something like this:

ON_SimpleArray<CRhinoView*> view_list;
context.m_doc.GetViewList(view_list, false, true);

To determine whether or not a view is really a page view, you can do this:

CRhinoView* view = ...;
bool bPageView = (view->RhinoViewType() == CRhinoView::page_view_type);

To cast a CRhinoView to a CRhinoPageView, you can do this:

CRhinoView* view = ...;
if (view->IsKindOf(RUNTIME_CLASS(CRhinoPageView)))
  CRhinoPageView* page_view = static_cast<CRhinoPageView*>(view);
  if (page_view)

A page view can contain one or more detail view, which represented by CRhinoDetailViewObject.

To get all of the details from a page you, you can do this:

ON_SimpleArray<CRhinoDetailViewObject*> detail_list;

This should make you dangerous. :wink:

– Dale

1 Like

Hi Dale,

thanks! I will look into it this week. As I understood with this class I can set all the parameters I need (paper size, frame, etc…). And how do I actually automate the export? Printing to PDF? What classes/functions are used for that?


P.S. Additionally to printing automatically to PDF (howdo I set printer properties of the layout? ), can I automatically set all the variables that open in a print dialog( View and Output Scale, Margins and Positions, Linetypes and Line Widths, …)?