Examples:
Create a sheet and place a scene view on it
doc = ModraUp.active_model.layout_document
page = doc.pages.add("Floor plan")
scene = ModraUp.active_model.pages.add("Ground floor")
view = Layout::SketchUpModel.new(scene, Geom::Bounds2d.new(20.mm, 20.mm, 250.mm, 180.mm))
view.scale = 1.0 / 100
doc.add_entity(view, doc.layers.active, page)
Drawing sheet and title block
doc = ModraUp.active_model.layout_document
doc.pages.add("Floor plan")
info = doc.page_info # document-wide settings
info.width = 420.mm
info.height = 297.mm
info.left_margin = 10.mm # apply to all four sides
doc.title_block["project"] = "Example residence"
Create an elevation and an associated overall dimension for a component in one undo step
model = ModraUp.active_model
doc = model.layout_document
page = doc.pages.add
cabinet = model.entities.add_group
cabinet.entities.add_face([0, 0, 0], [600.mm, 0, 0], [600.mm, 400.mm, 0], [0, 400.mm, 0]).pushpull(-800.mm)
model.start_operation("Cabinet elevation", true)
front = Layout::SketchUpModel.new(cabinet, Geom::Bounds2d.new(290.mm, 20.mm, 110.mm, 90.mm))
front.view = Layout::SketchUpModel::FRONT_VIEW
front.scale = 1.0 / 20
doc.add_entity(front, doc.layers.active, page)
bb = cabinet.bounds
p1, p2 = bb.corner(0), bb.corner(1)
dim = Layout::LinearDimension.new(front.model_to_paper_point(p1), front.model_to_paper_point(p2), -8.mm)
dim.connect(Layout::ConnectionPoint.new(front, p1), Layout::ConnectionPoint.new(front, p2))
dim.set_attribute("auto_dim", "source", cabinet.persistent_id)
doc.add_entity(dim, doc.layers.active, page)
model.commit_operation
Section View (with the top as an independent viewport added to the document)
# bb = cabinet.bounds; c = bb.center
# section = top.create_section(Geom::Point3d.new(bb.min.x - 20.mm, c.y, c.z),
# Geom::Point3d.new(bb.max.x + 20.mm, c.y, c.z),
# Geom::Vector3d.new(0, 1, 0), depth: bb.height / 2 + 20.mm)
# section.scale = 1.0 / 20
Text and Line Styles (Styles are copies, modify at your own risk; revert changes when done)
doc = ModraUp.active_model.layout_document
page = doc.pages.add
title = Layout::FormattedText.new("Ground-floor plan 1:100", Geom::Point2d.new(20.mm, 205.mm),
Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)
s = title.style
s.font_size = 14
title.style = s
doc.add_entity(title, doc.layers.active, page)
frame = Layout::Rectangle.new(Geom::Bounds2d.new(5.mm, 5.mm, 410.mm, 287.mm))
s = frame.style
s.stroke_width = 2.0
s.stroke_pattern = Layout::Style::STROKE_PATTERN_DASH
frame.style = s
doc.add_entity(frame, doc.layers.active, page)