Class: Autocad::BlockReference

Inherits:
Element
  • Object
show all
Defined in:
lib/autocad/block_reference.rb

Direct Known Subclasses

ExternalReference

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, #bounds, #cell?, #def, #drawing, #graphical?, #has_tags?, #highlight, #id_from_record, #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

#attribute_hashObject



91
92
93
94
95
# File 'lib/autocad/block_reference.rb', line 91

def attribute_hash
  attributes.each.with_object({}) do |a, h|
    h[a.key] = a.value
  end
end

#attributesObject



101
102
103
104
105
106
107
108
# File 'lib/autocad/block_reference.rb', line 101

def attributes
  return to_enum(__callee__) unless block_given?

  els = @ole_obj.GetAttributes
  return [] if els.empty?

  els.each { |e| yield app.wrap(e) }
end

#block_reference?Boolean



5
6
7
# File 'lib/autocad/block_reference.rb', line 5

def block_reference?
  true
end

#dynamic?Boolean



44
45
46
# File 'lib/autocad/block_reference.rb', line 44

def dynamic?
  @ole_obj.IsDynamicBlock
end

#eachObject



20
21
22
23
24
25
26
# File 'lib/autocad/block_reference.rb', line 20

def each
  return enum_for(:each) unless block_given?

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

#explodeObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/autocad/block_reference.rb', line 9

def explode
  return enum_for(__callee__) unless block_given?

  ole = ole_obj.explode
  ole.each do |ole|
    yield app.wrap(ole)
  end
rescue => e
  binding.irb
end

#external?Boolean



28
29
30
# File 'lib/autocad/block_reference.rb', line 28

def external?
  false
end

#get_block_extentsObject



32
33
34
35
36
# File 'lib/autocad/block_reference.rb', line 32

def get_block_extents
  min_point = ole_obj.GeometricExtents.MinPoint
  max_point = ole_obj.GeometricExtents.MaxPoint
  BoundingBox.from_min_max(min_point, max_point)
end

#has_attributes?Boolean



48
49
50
# File 'lib/autocad/block_reference.rb', line 48

def has_attributes?
  @ole_obj.HasAttributes
end

#insertion_pointObject



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

def insertion_point
  Point3d(ole_obj.InsertionPoint)
rescue
  Autocad::Error.new("error getting insertion point of block #{name}")
end

#inspectObject



97
98
99
# File 'lib/autocad/block_reference.rb', line 97

def inspect
  "<BlockReference: name:#{name}>"
end

#layout?Boolean



85
86
87
88
89
# File 'lib/autocad/block_reference.rb', line 85

def layout?
  @ole_obj.IsLayout
rescue
  false
end

#nameObject



52
53
54
# File 'lib/autocad/block_reference.rb', line 52

def name
  @ole_obj.Name
end

#scale_by(amt) ⇒ Object



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

def scale_by(amt)
  @ole_obj.XScaleFactor = amt
  @ole_obj.YScaleFactor = amt
end

#x_effective_scale_factorObject



65
66
67
# File 'lib/autocad/block_reference.rb', line 65

def x_effective_scale_factor
  @ole_obj.XEffectiveScaleFactor
end

#x_scale_factorObject



61
62
63
# File 'lib/autocad/block_reference.rb', line 61

def x_scale_factor
  @ole_obj.XScaleFactor
end

#y_effective_scale_factorObject



73
74
75
# File 'lib/autocad/block_reference.rb', line 73

def y_effective_scale_factor
  @ole_obj.YEffectiveScaleFactor
end

#y_scale_factorObject



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

def y_scale_factor
  @ole_obj.YScaleFactor
end

#z_effective_scale_factorObject



81
82
83
# File 'lib/autocad/block_reference.rb', line 81

def z_effective_scale_factor
  @ole_obj.ZEffectiveScaleFactor
end

#z_scale_factorObject



77
78
79
# File 'lib/autocad/block_reference.rb', line 77

def z_scale_factor
  @ole_obj.ZScaleFactor
end