Class: Autocad::PaperSpace

Inherits:
Element
  • Object
show all
Includes:
ModelTrait
Defined in:
lib/autocad/model.rb

Overview

Paper space container class

Instance Attribute Summary

Attributes inherited from Element

#acad_type, #app, #ole_obj, #original

Instance Method Summary collapse

Methods included from ModelTrait

#add_arc, #add_circle, #add_ellipse, #add_line, #add_rectangle, #add_spline, #attach_external_reference, #drawing, #each, #layout, #xref?

Methods inherited from Element

#[], #app_ole_obj, #clone, convert_item, #delete, #do_update, #each_complex, #get_property_handler, #in_cell?, #initialize, #method_missing, #move, #move_ole, #move_x, #move_y, #ole_cell, ole_object?, #property_handler, #read_ole, #redraw, #update, #updated?, #write_ole

Methods included from ElementTrait

#autocad_type, #block_reference?, #bounds, #cell?, #def, #drawing, #explode, #graphical?, #has_tags?, #highlight, #id_from_record, #inspect, #line?, #model, #parent, #pviewport?, #select, #text?, #to_ole, #visible?

Constructor Details

This class inherits a constructor from Autocad::Element

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Autocad::Element

Instance Method Details

#add_pv_viewport(center, width:, height:) ⇒ Object

Add a paper space viewport

Raises:

  • (StandardError)

    If viewport creation fails



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/autocad/model.rb', line 181

def add_pv_viewport(center, width:, height:)
  center = Point3d(center)
  ole = ole_obj.AddPViewport(center.to_ole, width.to_f, height.to_f)
  if ole
    ole.Display(true)
    ole.ViewportOn = true
    layer = drawing.create_layer('Vport', 9)
    layer.Plottable = false
    ole.Layer = layer.name
    ole.StandardScale = ACAD::AcVpScaleToFit
    app.wrap(ole)
  else
    nil
  end
rescue StandardError => e
  nil
end

#clear_pviewportsObject

Delete all paper space viewports



207
208
209
# File 'lib/autocad/model.rb', line 207

def clear_pviewports
  pviewports.each(&:delete)
end

#pviewportsObject

Get all paper space viewports



201
202
203
# File 'lib/autocad/model.rb', line 201

def pviewports
  each.select { it.pviewport? }
end