Class: Autocad::Plot

Inherits:
Element show all
Defined in:
lib/autocad/plot.rb

Instance Attribute Summary

Attributes inherited from Element

#acad_type, #app, #ole_obj, #original

Instance Method Summary collapse

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

#plot_previewObject

Display full plot preview window



19
20
21
# File 'lib/autocad/plot.rb', line 19

def plot_preview
  ole_obj.DisplayPlotPreview(1) # 1 = acFullPreview
end

#plot_to_deviceObject

Execute plot using configured device

Raises:



26
27
28
29
30
# File 'lib/autocad/plot.rb', line 26

def plot_to_device
  ole_obj.PlotToDevice
rescue => e
  raise Autocad::Error.new("Device plot failed: #{e.message}")
end

#plot_to_file(filename, plot_config: nil) ⇒ Object

Plot to file with specified configuration

Raises:



37
38
39
40
41
42
43
# File 'lib/autocad/plot.rb', line 37

def plot_to_file(filename, plot_config: nil)
  path = app.windows_path(filename)
  config_name = plot_config.respond_to?(:name) ? plot_config.name : plot_config
  ole_obj.PlotToFile(path, config_name)
rescue => e
  raise Autocad::Error.new("File plot failed: #{e.message}\nPath: #{path}")
end

#set_layouts_to_plot(*layouts) ⇒ Object

Configure which layouts to include in the plot



6
7
8
9
10
11
12
13
14
15
# File 'lib/autocad/plot.rb', line 6

def set_layouts_to_plot(*layouts)
  layouts = layouts.first if layouts.size == 1 && layouts.first.is_a?(Array)
  ole_layouts = layouts.map { |l| l.is_a?(Autocad::Layout) ? l.name : l.to_s }
  
  ole_layout_values = WIN32OLE::Variant.new(
    ole_layouts,
    WIN32OLE::VARIANT::VT_ARRAY | WIN32OLE::VARIANT::VT_BSTR
  )
  ole_obj.SetLayoutsToPlot(ole_layout_values)
end