Class: Microstation::Drawing

Inherits:
Object
  • Object
show all
Includes:
Properties
Defined in:
lib/microstation/dir.rb,
lib/microstation/drawing.rb

Defined Under Namespace

Classes: File

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Properties

#author=, #comments=, #keywords=, #subject=, #title=

Constructor Details

#initialize(app, ole) ⇒ Drawing

Returns a new instance of Drawing.



11
12
13
14
# File 'lib/microstation/drawing.rb', line 11

def initialize(app, ole)
  @app = app
  @ole_obj = ole
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



9
10
11
# File 'lib/microstation/drawing.rb', line 9

def app
  @app
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/microstation/drawing.rb', line 16

def active?
  @ole_obj.IsActive
end

#basenameObject



99
100
101
# File 'lib/microstation/drawing.rb', line 99

def basename
  Pathname(name)
end

#cad_input_queue(&block) ⇒ Object



20
21
22
# File 'lib/microstation/drawing.rb', line 20

def cad_input_queue(&block)
  @app.cad_input_queue(&block)
end

#closeObject



119
120
121
# File 'lib/microstation/drawing.rb', line 119

def close
  @ole_obj.Close
end

#create_scanner(&block) ⇒ Object

alias_method :title, :title=



46
47
48
# File 'lib/microstation/drawing.rb', line 46

def create_scanner(&block)
  app.create_scanner(&block)
end

#create_tagset(name, &block) ⇒ Object



146
147
148
149
150
# File 'lib/microstation/drawing.rb', line 146

def create_tagset(name,&block)
  ts = tagsets.create(name)
  block.call ts if block
  ts
end

#create_tagset!(name, &block) ⇒ Object



152
153
154
155
# File 'lib/microstation/drawing.rb', line 152

def create_tagset!(name,&block)
  remove_tagset(name)
  create_tagset(name,&block)
end

#dimensionsObject

alias_method :keywords , :keywords=x



79
80
81
# File 'lib/microstation/drawing.rb', line 79

def dimensions
  eval_cexpression("tcb->ndices")
end

#dirnameObject



103
104
105
# File 'lib/microstation/drawing.rb', line 103

def dirname
  Pathname(@ole_obj.Path).expand_path
end

#eval_cexpression(string) ⇒ Object



115
116
117
# File 'lib/microstation/drawing.rb', line 115

def eval_cexpression(string)
  app.eval_cexpression(string)
end

#find_tagset(name) ⇒ Object



161
162
163
164
# File 'lib/microstation/drawing.rb', line 161

def find_tagset(name)
  ts = tagsets[name]
  ts.create_instances(scan_tags)
end

#modified_dateObject



74
75
76
# File 'lib/microstation/drawing.rb', line 74

def modified_date
  @ole_obj.DateLastSaved
end

#nameObject



95
96
97
# File 'lib/microstation/drawing.rb', line 95

def name
  @ole_obj.Name
end

#ole_objObject



123
124
125
# File 'lib/microstation/drawing.rb', line 123

def ole_obj
  @ole_obj
end

#pathObject



107
108
109
# File 'lib/microstation/drawing.rb', line 107

def path
  dirname + basename
end

#pdf_driverObject



134
135
136
# File 'lib/microstation/drawing.rb', line 134

def pdf_driver
  app.windows_path( (Microstation.plot_driver_directory + "pdf-bw.plt").to_s)
end

#pdf_name(lname = nil, dir = nil) ⇒ Object



127
128
129
130
131
132
# File 'lib/microstation/drawing.rb', line 127

def pdf_name(lname = nil,dir=nil)
  dname = lname ? Pathname(lname) : Pathname(self.basename)
  pdfname = dname.ext('.pdf')
  dirname = dir ? Pathname(dir) : Pathname(self.dirname)
  pdfname = (dirname + pdfname).expand_path
end

#pdf_name_from_options(options = {}) ⇒ Object



38
39
40
41
42
# File 'lib/microstation/drawing.rb', line 38

def pdf_name_from_options(options = {})
  name = options.fetch(:name){ basename.ext('.pdf')}
  dir = options.fetch(:dir){ dirname}
  (dir + name).expand_path
end

#remove_tagset(name) ⇒ Object



157
158
159
# File 'lib/microstation/drawing.rb', line 157

def remove_tagset(name)
  tagsets.remove(name)
end

#revision_countObject



111
112
113
# File 'lib/microstation/drawing.rb', line 111

def revision_count
  @ole_obj.DesignRevisionCount
end

#save_as_pdf(name = nil, dir = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/microstation/drawing.rb', line 24

def save_as_pdf(name = nil, dir = nil)
  out_name = pdf_name(name,dir)
  windows_name = app.windows_path(out_name)
  cad_input_queue do |q|
    q << "Print Driver #{pdf_driver}"
    q << "Print Papername ANSI D"
    q << "Print BOUNDARY FIT ALL"
    q << "Print ATTRIBUTES BORDER OUTLINE OFF"
    q << "Print Attributes Fenceboundary Off"
    q << "Print Execute #{windows_name}"
  end
  puts "saved #{windows_name}"
end

#scan(scanner = nil, &block) ⇒ Object



50
51
52
# File 'lib/microstation/drawing.rb', line 50

def scan(scanner = nil,&block)
  app.scan(scanner,&block)
end

#scan_graphical(&block) ⇒ Object



54
55
56
57
58
# File 'lib/microstation/drawing.rb', line 54

def scan_graphical(&block)
  sc = create_scanner
  sc.ExcludeNonGraphical
  app.scan(sc,&block)
end

#scan_tags(&block) ⇒ Object



67
68
69
70
71
72
# File 'lib/microstation/drawing.rb', line 67

def scan_tags(&block)
  sc = create_scanner do
    include_tags
  end
  app.scan(sc,&block)
end

#scan_text(&block) ⇒ Object



60
61
62
63
64
65
# File 'lib/microstation/drawing.rb', line 60

def scan_text(&block)
  sc = create_scanner do
    include_textual
  end
  app.scan(sc,&block)
end

#tagset_namesObject



138
139
140
# File 'lib/microstation/drawing.rb', line 138

def tagset_names
  tagsets.map{|ts| ts.name}
end

#tagsetsObject



142
143
144
# File 'lib/microstation/drawing.rb', line 142

def tagsets
  @tagsets = TagSets.new(ole_obj_tagsets)
end

#three_d?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/microstation/drawing.rb', line 91

def three_d?
  dimensions == 3
end

#two_d?Boolean

def fullname

@ole_obj.FullName

end

Returns:

  • (Boolean)


87
88
89
# File 'lib/microstation/drawing.rb', line 87

def two_d?
  dimensions == 2
end