Module: Microstation::ElementTrait

Included in:
Element
Defined in:
lib/microstation/element.rb

Instance Method Summary collapse

Instance Method Details

#cell?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/microstation/element.rb', line 36

def cell?
  ole_obj.Type == ::Microstation::MSD::MsdElementTypeCellHeader
end

#complex?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/microstation/element.rb', line 40

def complex?
  ole_obj.IsComplexElement
end

#graphical?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/microstation/element.rb', line 61

def graphical?
  ole_obj.IsGraphical
end

#has_tags?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/microstation/element.rb', line 28

def has_tags?
  ole_obj.HasAnyTags
end

#id_from_record(id) ⇒ Object



73
74
75
76
77
78
# File 'lib/microstation/element.rb', line 73

def id_from_record(id)
  return unless id.instance_of?(WIN32OLE_RECORD)
  return id.Low if id.Low > id.High

  id.High
end

#line?Boolean

Returns true if ole type is TypeLine.

Returns:

  • (Boolean)

    true if ole type is TypeLine



57
58
59
# File 'lib/microstation/element.rb', line 57

def line?
  ole_obj.Type == ::Microstation::MSD::MsdElementTypeLine
end

#microstation_idObject



49
50
51
52
53
54
# File 'lib/microstation/element.rb', line 49

def microstation_id
  id = ole_obj.Id || ole_obj.ID64
  return nil unless id

  id_from_record(id)
end

#microstation_typeObject

def Type

ole_obj.Type

end



88
89
90
# File 'lib/microstation/element.rb', line 88

def microstation_type
  ole_obj.Type
end

#modelObject



92
93
94
# File 'lib/microstation/element.rb', line 92

def model
  Model.new(app, app.current_drawing, ole_obj.ModelReference)
end

#parentObject



65
66
67
68
69
70
71
# File 'lib/microstation/element.rb', line 65

def parent
  parent_id = ole_obj.ParentID
  return nil unless parent_id

  id = id_from_record(parent_id)
  app.active_design_file.find_by_id(id)
end

#selectObject



80
81
82
# File 'lib/microstation/element.rb', line 80

def select
  app.active_model_reference.select_element(self)
end

#text?Boolean

Returns true if ole type is Text.

Returns:

  • (Boolean)

    true if ole type is Text



19
20
21
# File 'lib/microstation/element.rb', line 19

def text?
  ole_obj.Type == ::Microstation::MSD::MsdElementTypeText
end

#text_node?Boolean

Returns true if ole type is TextNode.

Returns:

  • (Boolean)

    true if ole type is TextNode



24
25
26
# File 'lib/microstation/element.rb', line 24

def text_node?
  ole_obj.Type == ::Microstation::MSD::MsdElementTypeTextNode
end

#textual?Boolean

Returns true if Text or TextNode.

Returns:

  • (Boolean)

    true if Text or TextNode



45
46
47
# File 'lib/microstation/element.rb', line 45

def textual?
  text? || text_node?
end

#to_oleObject



32
33
34
# File 'lib/microstation/element.rb', line 32

def to_ole
  ole_obj
end