Class: Autocad::PViewport

Inherits:
Element
  • Object
show all
Defined in:
lib/autocad/pviewport.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, #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

#custom_scale=(scale) ⇒ Object

set a custom scale for model objects



109
110
111
# File 'lib/autocad/pviewport.rb', line 109

def custom_scale=(scale)
  @ole_obj.CustomScale = scale
end

#display_locked?Boolean

specifies the lock stat fo the viewports display. When locked, cant change view

Returns:

  • (Boolean)


120
121
122
# File 'lib/autocad/pviewport.rb', line 120

def display_locked?
  @ole_obj.DisplayLocked
end

#eachObject



128
129
130
131
132
133
134
# File 'lib/autocad/pviewport.rb', line 128

def each
  return enum_for(:each) unless block_given?

  @ole_obj.each do |ole|
    yield app.wrap(ole)
  end
end

#front_viewObject

change the viewport to front_view direction



24
25
26
27
# File 'lib/autocad/pviewport.rb', line 24

def front_view
  view_direction = Point3d(0, -1, 0)
  ole_obj.Direction = view_direction.to_ole
end

#heightObject

the viewport height



46
47
48
# File 'lib/autocad/pviewport.rb', line 46

def height
  @ole_obj.Height
end

#height_inchesObject



15
16
17
# File 'lib/autocad/pviewport.rb', line 15

def height_inches
  height / 25.4
end

#isometric_viewObject



39
40
41
42
# File 'lib/autocad/pviewport.rb', line 39

def isometric_view
  view_direction = Point3d(1, 1, 1)
  ole_obj.Direction = view_direction.to_ole
end

#lock_displayObject



113
114
115
# File 'lib/autocad/pviewport.rb', line 113

def lock_display
  @ole_obj.DisplayLocked = true
end

#offObject

turn of the display of viewport



63
64
65
# File 'lib/autocad/pviewport.rb', line 63

def off
  @ole_obj.Display(false)
end

#onObject

turn on the view



57
58
59
# File 'lib/autocad/pviewport.rb', line 57

def on
  @ole_obj.Display(true)
end

#on?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/autocad/pviewport.rb', line 51

def on?
  @ole_obj.ViewPortOn
end

#pviewport?Boolean

Returns:

  • (Boolean)


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

def pviewport?
  true
end

#right_viewObject



34
35
36
37
# File 'lib/autocad/pviewport.rb', line 34

def right_view
  view_direction = Point3d(1, 0, 0)
  ole_obj.Direction = view_direction.to_ole
end

#standard_scaleObject

the standard scale from Autocad AcViewportScale enum converted to symbol



69
70
71
72
# File 'lib/autocad/pviewport.rb', line 69

def standard_scale
  ole = @ole_obj.StandardScale
  standard_scale_ole_to_symbol(ole)
end

#standard_scale=(scale) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/autocad/pviewport.rb', line 74

def standard_scale=(scale)
  if scale.is_a?(Symbol)
    ole = standard_scale_symbol_to_ole(scale)
    @ole_obj.StandardScale = ole
  else
    @ole_obj.StandardScale = scale
  end
end

#standard_scale_ole_to_symbol(scale) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/autocad/pviewport.rb', line 83

def standard_scale_ole_to_symbol(scale)
  case scale
  when ACAD::AcVpScaleToFit then :scale_to_fit
  when ACAD::AcVpCustomScale then :custom
  when ACAD::AcVp1_128in_1ft then :"128_to_1"
  when ACAD::AcVp1_64in_1ft then :"64_to_1"
  when ACAD::AcVp1_32in_1ft then :"32_to_1"
  when ACAD::AcVp1_16in_1ft then :"16_to_1"
  when ACAD::AcVp1_8in_1ft then :"8_to_1"
  end
end

#standard_scale_symbol_to_ole(scale) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/autocad/pviewport.rb', line 95

def standard_scale_symbol_to_ole(scale)
  case scale
  when :scale_to_fit then ACAD::AcVpScaleToFit
  when :custom then ACAD::AcVpCustomScale
  when :"128_to_1" then ACAD::AcVp1_128in_1ft
  when :"64_to_1" then ACAD::AcVp1_64in_1ft
  when :"32_to_1" then ACAD::AcVp1_32in_1ft
  when :"16_to_1" then ACAD::AcVp1_16in_1ft
  when :"8_to_1" then ACAD::AcVp1_8in_1ft
  end
end

#top_viewObject



29
30
31
32
# File 'lib/autocad/pviewport.rb', line 29

def top_view
  view_direction = Point3d(0, 0, 1)
  ole_obj.Direction = view_direction.to_ole
end

#unlock_displayObject



124
125
126
# File 'lib/autocad/pviewport.rb', line 124

def unlock_display
  @ole_obj.DisplayLocked = false
end

#widthObject

the viewport width



7
8
9
# File 'lib/autocad/pviewport.rb', line 7

def width
  @ole_obj.Width
end

#width_inchesObject



11
12
13
# File 'lib/autocad/pviewport.rb', line 11

def width_inches
  width / 25.4
end