Class: Microstation::App
- Inherits:
-
Object
show all
- Includes:
- Functions
- Defined in:
- lib/microstation/app.rb,
lib/microstation/element.rb,
lib/microstation/functions.rb,
lib/microstation/functions.rb,
lib/microstation/configuration.rb,
lib/microstation/configuration.rb,
lib/microstation/scan/criteria.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#active_design_file ⇒ Drawing
(also: #active_drawing, #current_drawing)
-
#active_design_file? ⇒ Boolean
(also: #current_design_file?)
True if app has an active design file open.
-
#active_model_reference ⇒ Object
-
#active_workspace ⇒ Object
-
#base_dir ⇒ Object
-
#cad_input_queue {|CadInputQueue| ... } ⇒ void
lets you interact with the cad_input_queue.
-
#can_open?(filename) ⇒ Boolean
-
#capabilities(mode = :all) ⇒ Object
-
#change_drawing(dgn, output_dir: nil, name: nil, options: {}, &block) ⇒ Object
-
#close_active_drawing ⇒ void
(also: #close_current_drawing)
close the active_design_file.
-
#configuration ⇒ Object
-
#configured_seed_paths ⇒ String
The configuration variable MS_SEEDFILES.
-
#create_ole_point(x, y, z = 0) ⇒ WIN32OLE_RECORD
Create an WIN32OLE_RECORD of type Point3d.
-
#create_ole_scan_criteria ⇒ Object
-
#create_scan_criteria(name = nil, &block) ⇒ Object
-
#create_scanner(name = nil, &block) ⇒ Object
-
#create_text_node(origin, rotation, temp = nil) ⇒ Object
-
#default_event_handler ⇒ EventHandler
the default EventHandler.
-
#default_model ⇒ Object
-
#determine_seed(seedfile) ⇒ Object
-
#drawing_from_ole(ole) ⇒ Object
-
#drawing_opened? ⇒ Boolean
-
#eval_cexpression(string) ⇒ Object
-
#exit_message_looop ⇒ Object
-
#file_exists?(file) ⇒ Boolean
-
#find_seed(seedfile) ⇒ Pathname
find the seedfile * If the seed file is absolute and found the return the seedfile.
-
#find_seed_in_seed_dirs(seedfile) ⇒ Object
-
#get_handler(event) ⇒ Proc
-
#get_ole_element_enumerator(model:, criteria: nil) ⇒ Object
-
#has_current_drawing? ⇒ Boolean
-
#init_ole_and_app_event(visible: @visible, event_handler: @event_handler, tries: 5, sleep_duration: 1) ⇒ Object
-
#initialize(visible: false, event_handler: default_event_handler) ⇒ App
constructor
-
#make_visible(visible) ⇒ Object
-
#method_missing(meth, *args, &block) ⇒ Object
-
#my_place_line ⇒ Object
-
#new_drawing(filename, seedfile: nil, open: true, wait_time: 500, wait_interval: 1, &block) ⇒ Drawing
-
#new_ole_drawing(seedfile, new_design_file_name, open: true, wait_time: 500, wait_interval: 0.5) ⇒ Object
-
#normalize_name(name) ⇒ Object
-
#ole_matrix ⇒ Object
-
#ole_obj ⇒ Object
-
#ole_point ⇒ Object
-
#ole_point3d?(pt) ⇒ Boolean
-
#ole_rotation ⇒ Object
-
#ole_to_ruby(ole) ⇒ Object
-
#open_drawing(filename, readonly: false, error_proc: nil, wait_time: 500, wait_interval: 0.5) {|Drawing| ... } ⇒ void
-
#prepend_seed_path(dir) ⇒ Object
prepend a dir to the MS_SEEDFILES configuration.
-
#quit ⇒ void
-
#register_handler(event, &block) ⇒ <Type>
-
#render_template(drawing, output_dir: nil, locals: {}, name: nil) ⇒ Object
-
#run_templates_in_dir(dir, options = {}) ⇒ Object
-
#scan_model(criteria = nil, model = nil) ⇒ Object
def find_by_id(id) active_design_file.find_by_id(id) wrap(model) if el end.
-
#seed_paths ⇒ Array
Returns the MS_SEEDFILES as Pathnames Array.
-
#show_command(text) ⇒ Object
-
#show_message(text) ⇒ Object
-
#show_prompt(text) ⇒ Object
-
#show_temp_message(text, location: nil) ⇒ void
-
#start_primitive(klass) ⇒ Object
-
#tags_criteria ⇒ Object
-
#text_criteria ⇒ Object
-
#to_ole_matrix3d(vec) ⇒ Object
-
#to_ole_point3d(pt) ⇒ WIN32OLE_RECORD
Conversion to WIN32OLE_RECORD of type Point3d.
-
#to_point(pt) ⇒ Object
-
#to_point3d(pt) ⇒ Point3d
-
#username ⇒ String
The configuration variable USERNAME.
-
#visible? ⇒ Boolean
Whether the app is visible.
-
#wait_drawing_opened(secs, interval = 1) ⇒ Object
-
#windows_path(path) ⇒ Object
-
#with_config ⇒ Object
-
#with_drawing(drawing) ⇒ Object
-
#with_template(template) {|template| ... } ⇒ Object
-
#wrap(item, cell = nil) ⇒ Object
Methods included from Functions
#clear_ui, #get_point, #get_points_by_line, #get_points_by_rectangle
Constructor Details
#initialize(visible: false, event_handler: default_event_handler) ⇒ App
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/microstation/app.rb', line 150
def initialize(visible: false, event_handler: default_event_handler)
@visible = visible
@event_handler = event_handler
@ole_obj, @app_event = init_ole_and_app_event(visible: @visible, event_handler: @event_handler, tries: 5,
sleep_duration: 0.5)
@run_loop = true
@windows = Windows::FileSystem.new
@scanners = {}
rescue => e
binding.pry
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
743
744
745
746
747
748
749
750
751
752
753
|
# File 'lib/microstation/app.rb', line 743
def method_missing(meth, *args, &block)
if /^[A-Z]/.match?(meth.to_s)
require "pry"
binding.pry
result = ole_obj.send(meth, *args, &block)
else
super(meth, *args, &block)
end
rescue => e
binding.pry
end
|
Class Attribute Details
.default_app_options ⇒ Object
Returns the value of attribute default_app_options.
49
50
51
|
# File 'lib/microstation/app.rb', line 49
def default_app_options
@default_app_options
end
|
Instance Attribute Details
#app_event ⇒ Object
Returns the value of attribute app_event.
145
146
147
|
# File 'lib/microstation/app.rb', line 145
def app_event
@app_event
end
|
#project_dir ⇒ Object
Returns the value of attribute project_dir.
145
146
147
|
# File 'lib/microstation/app.rb', line 145
def project_dir
@project_dir
end
|
#scanners ⇒ Object
Returns the value of attribute scanners.
145
146
147
|
# File 'lib/microstation/app.rb', line 145
def scanners
@scanners
end
|
#visible ⇒ Object
Returns the value of attribute visible.
145
146
147
|
# File 'lib/microstation/app.rb', line 145
def visible
@visible
end
|
Class Method Details
.open_drawing(drawing, **options) { ... } ⇒ void
This method returns an undefined value.
Calls #run to get an app instance then call open drawing with that app (see #open_drawing)
89
90
91
92
93
94
|
# File 'lib/microstation/app.rb', line 89
def open_drawing(drawing, **options, &block)
opt_visible = options.delete(:visible) || false
run(visible: opt_visible) do |app|
app.open_drawing(drawing, **options, &block)
end
end
|
.run(options = {}) {|App| ... } ⇒ void
This method returns an undefined value.
Initialize an instance of app with the options
- source
App.run do |app|
drawing = app.open_drawing('test.dgn')
drawing.scan_all_text do |model,text|
puts "#{model} #{text}"
end
end
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/microstation/app.rb', line 68
def run(options = {})
opts = default_app_options.merge(options)
begin
the_app = new(**opts)
binding.pry if the_app.nil?
yield the_app
rescue
binding.pry
ensure
the_app.quit if the_app.respond_to? :quit
the_app = nil
GC.start
nil
end
end
|
.with_drawings(*files, **options) {|Drawing| ... } ⇒ void
This method returns an undefined value.
Runs the app, opening the filenames and yielding each open drawing to the supplied block it automatically closes the drawing and the app when done
- source
-
dir = Pathname(‘C:/templates’) drawings = Pathname.glob(dir + ‘/*/.dgn’) App.with_drawings(drawings) do |drawing|
drawing.save_as_pdf(dir: 'c:/output/')
end
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/microstation/app.rb', line 115
def with_drawings(*files, **options, &block)
errors = []
files = files[0] if files[0].is_a? Array
opt_visible = options.delete(:visible) || false
error_proc = options.delete(:error_proc)
begin
the_app = new(visible: opt_visible)
files_enum = files.each
loop do
file = files_enum.next
puts "opening #{file}.."
begin
the_app.open_drawing(file, **options, &block)
the_app.ole_obj.ole_methods
rescue => e
raise e unless error_proc
error_proc.call(e, file)
the_app = new(visible: opt_visible)
end
end
ensure
the_app&.quit
the_app = nil
end
end
|
Instance Method Details
#active_design_file ⇒ Drawing
Also known as:
active_drawing, current_drawing
489
490
491
492
493
494
|
# File 'lib/microstation/app.rb', line 489
def active_design_file
return unless active_design_file?
ole = ole_obj.ActiveDesignFile
drawing_from_ole(ole)
end
|
#active_design_file? ⇒ Boolean
Also known as:
current_design_file?
515
516
517
|
# File 'lib/microstation/app.rb', line 515
def active_design_file?
ole_obj.HasActiveDesignFile
end
|
#active_model_reference ⇒ Object
619
620
621
622
623
|
# File 'lib/microstation/app.rb', line 619
def active_model_reference
DefaultModel.new(self, ole_obj.ActiveModelReference)
rescue
nil
end
|
#active_workspace ⇒ Object
360
361
362
|
# File 'lib/microstation/app.rb', line 360
def active_workspace
ole_obj.ActiveWorkspace
end
|
#base_dir ⇒ Object
272
273
274
|
# File 'lib/microstation/app.rb', line 272
def base_dir
project_dir || Pathname.getwd
end
|
This method returns an undefined value.
lets you interact with the cad_input_queue
569
570
571
572
573
574
575
576
577
578
579
580
581
|
# File 'lib/microstation/app.rb', line 569
def cad_input_queue
queue = init_cad_input_queue
return queue unless block_given?
begin
yield queue
rescue
ensure
queue.close
queue = nil
@cad_input_queue = nil
end
end
|
#can_open?(filename) ⇒ Boolean
614
615
616
617
|
# File 'lib/microstation/app.rb', line 614
def can_open?(filename)
ext = File.extname(filename)
(ext == ".dwg") || (ext == ".dgn")
end
|
#capabilities(mode = :all) ⇒ Object
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/microstation/configuration.rb', line 163
def capabilities(mode = :all)
case mode
when :all
configuration.capabilities_all
when :dwg
configuration.capabilites_dwg
when :v7
configuration.capabilities_v7
else
configuration_capabilities_all
end
end
|
#change_drawing(dgn, output_dir: nil, name: nil, options: {}, &block) ⇒ Object
170
171
172
173
|
# File 'lib/microstation/app.rb', line 170
def change_drawing(dgn, output_dir: nil, name: nil, options: {}, &block)
changer = Changer.new(dgn, name: name, output_dir: output_dir, app: self)
changer.run(&block)
end
|
#close_active_drawing ⇒ void
Also known as:
close_current_drawing
This method returns an undefined value.
close the active_design_file
504
505
506
|
# File 'lib/microstation/app.rb', line 504
def close_active_drawing
active_design_file.close if active_design_file?
end
|
#configuration ⇒ Object
365
366
367
|
# File 'lib/microstation/app.rb', line 365
def configuration
@config ||= ::Microstation::Configuration.new(self)
end
|
440
441
442
|
# File 'lib/microstation/app.rb', line 440
def configured_seed_paths
configuration["MS_SEEDFILES"]
end
|
#create_ole_point(x, y, z = 0) ⇒ WIN32OLE_RECORD
Create an WIN32OLE_RECORD of type Point3d
652
653
654
655
656
657
658
|
# File 'lib/microstation/app.rb', line 652
def create_ole_point(x, y, z = 0)
ole = ole_point
ole.X = x
ole.Y = y
ole.Z = z
ole
end
|
#create_ole_scan_criteria ⇒ Object
12
13
14
|
# File 'lib/microstation/scan/criteria.rb', line 12
def create_ole_scan_criteria
ole_obj.CreateObjectInMicroStation("MicroStationDGN.ElementScanCriteria")
end
|
#create_scan_criteria(name = nil, &block) ⇒ Object
544
545
546
|
# File 'lib/microstation/app.rb', line 544
def create_scan_criteria(name = nil, &block)
::Microstation::Scan::Criteria.create_scanner(name, self, &block)
end
|
#create_scanner(name = nil, &block) ⇒ Object
532
533
534
|
# File 'lib/microstation/app.rb', line 532
def create_scanner(name = nil, &block)
::Microstation::Scan::Criteria.create_scanner(name, self, &block)
end
|
#create_text_node(origin, rotation, temp = nil) ⇒ Object
699
700
701
702
703
704
705
706
707
|
# File 'lib/microstation/app.rb', line 699
def create_text_node(origin, rotation, temp = nil)
ole_origin = to_ole_point3d(origin)
ole_rotation = to_ole_matrix3d(rotation)
temp ||= WIN32OLE_VARIANT::Nothing
ole_obj.CreateTextNodeElement1(temp, ole_origin, ole_rotation)
rescue Exception => e
puts e.message
nil
end
|
#default_event_handler ⇒ EventHandler
185
186
187
188
189
190
191
192
193
194
195
196
|
# File 'lib/microstation/app.rb', line 185
def default_event_handler
event_handler = EventHandler.new
event_handler.add_handler("OnDesignFileOpened") do |*_args|
puts "drawing opened"
@drawing_opened = true
end
event_handler.add_handler("OnDesignFileClosed") do |*_args|
@drawing_opened = false
puts "drawing closed"
end
event_handler
end
|
#default_model ⇒ Object
625
626
627
628
629
|
# File 'lib/microstation/app.rb', line 625
def default_model
DefaultModel.new(self, ole_obj.DefaultModelReference)
rescue
nil
end
|
#determine_seed(seedfile) ⇒ Object
430
431
432
433
434
435
436
437
|
# File 'lib/microstation/app.rb', line 430
def determine_seed(seedfile)
return configuration["MS_DESIGNSEED"] unless seedfile
seed = find_seed(seedfile)
return seed.to_s if seed
raise "Seedfile #{seedfile} not found in #{configured_seed_paths}"
end
|
#drawing_from_ole(ole) ⇒ Object
426
427
428
|
# File 'lib/microstation/app.rb', line 426
def drawing_from_ole(ole)
Drawing.new(self, ole)
end
|
#drawing_opened? ⇒ Boolean
352
353
354
|
# File 'lib/microstation/app.rb', line 352
def drawing_opened?
@drawing_opened
end
|
#eval_cexpression(string) ⇒ Object
468
469
470
|
# File 'lib/microstation/app.rb', line 468
def eval_cexpression(string)
ole_obj.GetCExpressionValue(string)
end
|
#exit_message_looop ⇒ Object
221
222
223
224
|
# File 'lib/microstation/app.rb', line 221
def exit_message_looop
puts "Microstation exiting..."
@run_loop = false
end
|
#file_exists?(file) ⇒ Boolean
528
529
530
|
# File 'lib/microstation/app.rb', line 528
def file_exists?(file)
Pathname(file).expand_path.file?
end
|
#find_seed(seedfile) ⇒ Pathname
find the seedfile
seedfile.
451
452
453
454
455
456
|
# File 'lib/microstation/app.rb', line 451
def find_seed(seedfile)
seed = Pathname(seedfile).expand_path.sub_ext(".dgn")
return seed if seed.file?
find_seed_in_seed_dirs(seed.basename)
end
|
#find_seed_in_seed_dirs(seedfile) ⇒ Object
458
459
460
461
|
# File 'lib/microstation/app.rb', line 458
def find_seed_in_seed_dirs(seedfile)
seed_dir = seed_paths.find { |p| (p + seedfile).file? }
return (seed_dir + seedfile) if seed_dir
end
|
#get_handler(event) ⇒ Proc
217
218
219
|
# File 'lib/microstation/app.rb', line 217
def get_handler(event)
@event_handler.get_handler(event)
end
|
#get_ole_element_enumerator(model:, criteria: nil) ⇒ Object
558
559
560
561
562
563
564
|
# File 'lib/microstation/app.rb', line 558
def get_ole_element_enumerator(model:, criteria: nil)
criteria ||= create_scan_criteria
criteria.resolve
model.scan(criteria.ole_obj)
rescue Exception
end
|
#has_current_drawing? ⇒ Boolean
416
417
418
|
# File 'lib/microstation/app.rb', line 416
def has_current_drawing?
ole_obj.HasActiveDesignFile
end
|
#init_ole_and_app_event(visible: @visible, event_handler: @event_handler, tries: 5, sleep_duration: 1) ⇒ Object
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
# File 'lib/microstation/app.rb', line 235
def init_ole_and_app_event(visible: @visible, event_handler: @event_handler, tries: 5, sleep_duration: 1)
ole = WIN32OLE.new("MicrostationDGN.Application")
sleep(sleep_duration)
ole.Visible = visible
ole.IsProcessLocked = true
load_constants(ole)
app_event = WIN32OLE_EVENT.new(ole)
app_event.handler = event_handler
[ole, app_event]
rescue => e
tries -= 1
sleep_duration += 1.5
puts "Error: #{e}. #{tries} tries left."
retry if tries.positive?
raise e, "unable to init ole app"
end
|
#make_visible(visible) ⇒ Object
286
287
288
289
290
291
292
293
294
|
# File 'lib/microstation/app.rb', line 286
def make_visible(visible)
@visible = visible
begin
ole_obj.Visible = @visible
true
rescue Exception => e
false
end
end
|
#my_place_line ⇒ Object
738
739
740
741
|
# File 'lib/microstation/app.rb', line 738
def my_place_line
require_relative "primitive_command_interface"
start_primitive LineCreation
end
|
#new_drawing(filename, seedfile: nil, open: true, wait_time: 500, wait_interval: 1, &block) ⇒ Drawing
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
|
# File 'lib/microstation/app.rb', line 384
def new_drawing(filename, seedfile: nil, open: true, wait_time: 500, wait_interval: 1, &block)
file_path = Pathname(filename).expand_path
raise ExistingFile, file_path if file_path.exist?
seedfile = determine_seed(seedfile)
binding.pry unless seedfile
windows_name = windows_path(filename)
ole = new_ole_drawing(seedfile, windows_name, open: open, wait_time: wait_time, wait_interval: wait_interval)
drawing = drawing_from_ole(ole)
return drawing unless block
begin
yield drawing
rescue => e
"puts error in new drawing"
raise e
ensure
drawing.close
end
end
|
#new_ole_drawing(seedfile, new_design_file_name, open: true, wait_time: 500, wait_interval: 0.5) ⇒ Object
406
407
408
409
410
411
412
413
414
|
# File 'lib/microstation/app.rb', line 406
def new_ole_drawing(seedfile, new_design_file_name, open: true, wait_time: 500, wait_interval: 0.5)
ole = ole_obj.CreateDesignFile(seedfile, new_design_file_name, open)
wait_drawing_opened(wait_time, wait_interval)
raise "drawing not opened in #{wait_time}" unless drawing_opened?
ole
rescue => e
raise e
end
|
#normalize_name(name) ⇒ Object
280
281
282
283
284
|
# File 'lib/microstation/app.rb', line 280
def normalize_name(name)
name = Pathname.new(name) unless name.is_a? Pathname
name = name.ext(".dgn") unless name.extname.to_s == /\.(dgn|dwg)$/
(base_dir + name).expand_path
end
|
#ole_matrix ⇒ Object
639
640
641
|
# File 'lib/microstation/app.rb', line 639
def ole_matrix
::WIN32OLE_RECORD.new("Matrix", ole_obj)
end
|
#ole_obj ⇒ Object
296
297
298
299
300
301
302
303
304
305
306
307
|
# File 'lib/microstation/app.rb', line 296
def ole_obj
is_ok = true
begin
@ole_obj.Visible
rescue => e
is_ok = false
end
@ole_obj, @app_event = init_ole_and_app_event(tries: 3) unless is_ok
@ole_obj
end
|
#ole_point ⇒ Object
631
632
633
|
# File 'lib/microstation/app.rb', line 631
def ole_point
::WIN32OLE_RECORD.new("Point3d", ole_obj)
end
|
#ole_point3d?(pt) ⇒ Boolean
695
696
697
|
# File 'lib/microstation/app.rb', line 695
def ole_point3d?(pt)
pt.instance_of?(WIN32OLE_RECORD) && pt.typename == "Point3d"
end
|
#ole_rotation ⇒ Object
635
636
637
|
# File 'lib/microstation/app.rb', line 635
def ole_rotation
::WIN32OLE_RECORD.new("Rotation", ole_obj)
end
|
#ole_to_ruby(ole) ⇒ Object
274
275
276
|
# File 'lib/microstation/element.rb', line 274
def ole_to_ruby(ole)
Element.convert_item(ole, self)
end
|
#open_drawing(filename, readonly: false, error_proc: nil, wait_time: 500, wait_interval: 0.5) {|Drawing| ... } ⇒ void
This method returns an undefined value.
open the drawing
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
|
# File 'lib/microstation/app.rb', line 329
def open_drawing(filename, readonly: false, error_proc: nil, wait_time: 500, wait_interval: 0.5)
filename = Pathname(filename)
raise FileNotFound unless filename.file?
begin
ole = ole_open_drawing(windows_path(filename), readonly: readonly, wait_time: wait_time,
wait_interval: wait_interval)
rescue => e
raise e unless error_proc
error_proc.call(filename)
return
end
drawing = drawing_from_ole(ole)
return drawing unless block_given?
begin
yield drawing
ensure
drawing.close
end
end
|
#prepend_seed_path(dir) ⇒ Object
prepend a dir to the MS_SEEDFILES configuration
422
423
424
|
# File 'lib/microstation/app.rb', line 422
def prepend_seed_path(dir)
configuration.prepend("MS_SEEDFILES", windows_path(dir))
end
|
#quit ⇒ void
This method returns an undefined value.
quit the app
477
478
479
480
481
482
483
484
485
|
# File 'lib/microstation/app.rb', line 477
def quit
close_active_drawing
@scanners.each { |_name, sc| sc.close }
begin
ole_obj.Quit
rescue
nil
end
end
|
#register_handler(event, &block) ⇒ <Type>
206
207
208
|
# File 'lib/microstation/app.rb', line 206
def register_handler(event, &block)
@event_handler.add_handler(event, &block) unless event == "OnQuit"
end
|
#render_template(drawing, output_dir: nil, locals: {}, name: nil) ⇒ Object
175
176
177
178
|
# File 'lib/microstation/app.rb', line 175
def render_template(drawing, output_dir: nil, locals: {}, name: nil)
temp = Template.new(drawing, output_dir: output_dir, app: self, name: name)
temp.render(output_dir: output_dir, locals: locals)
end
|
#run_templates_in_dir(dir, options = {}) ⇒ Object
163
164
165
166
167
168
|
# File 'lib/microstation/app.rb', line 163
def run_templates_in_dir(dir, options = {})
yaml_files = Pathname.glob("#{Pathname(dir).expand_path}*.yaml")
yaml_files.each do |f|
TemplateRunner.new(f).run_with_app(self, options)
end
end
|
#scan_model(criteria = nil, model = nil) ⇒ Object
def find_by_id(id)
active_design_file.find_by_id(id)
wrap(model) if el
end
553
554
555
556
|
# File 'lib/microstation/app.rb', line 553
def scan_model(criteria = nil, model = nil)
model ||= active_model_reference
model.scan(criteria)
end
|
#seed_paths ⇒ Array
464
465
466
|
# File 'lib/microstation/app.rb', line 464
def seed_paths
configured_seed_paths.split(";").map { |d| Pathname(d) }
end
|
#show_command(text) ⇒ Object
583
584
585
|
# File 'lib/microstation/app.rb', line 583
def show_command(text)
ole_obj.ShowCommand(text)
end
|
#show_message(text) ⇒ Object
591
592
593
|
# File 'lib/microstation/app.rb', line 591
def show_message(text)
ole_obj.ShowMessage(text)
end
|
#show_prompt(text) ⇒ Object
587
588
589
|
# File 'lib/microstation/app.rb', line 587
def show_prompt(text)
ole_obj.ShowPrompt(text)
end
|
#show_temp_message(text, location: nil) ⇒ void
602
603
604
605
606
607
608
609
610
611
612
|
# File 'lib/microstation/app.rb', line 602
def show_temp_message(text, location: nil)
loc = case location
when :left
MSD::MsdStatusBarAreaLeft
when :middle
MSD::MsdStatusBarAreaMiddle
else
MSD::MsdStatusBarAreaLeft
end
ole_obj.ShowTempMessage(loc, text)
end
|
#start_primitive(klass) ⇒ Object
734
735
736
|
# File 'lib/microstation/app.rb', line 734
def start_primitive(klass)
ole_obj.CommandState.StartPrimitive klass.new(self)
end
|
540
541
542
|
# File 'lib/microstation/app.rb', line 540
def tags_criteria
scanners[:tags] || create_scanner(:tags) { include_tags }
end
|
#text_criteria ⇒ Object
536
537
538
|
# File 'lib/microstation/app.rb', line 536
def text_criteria
scanners[:textual] || create_scanner(:textual) { include_textual }
end
|
#to_ole_matrix3d(vec) ⇒ Object
660
661
662
663
664
665
666
|
# File 'lib/microstation/app.rb', line 660
def to_ole_matrix3d(vec)
if vec.instance_of?(WIN32OLE_RECORD) && vec.typename == "Matrix3d"
vec
else
binding.pry
end
end
|
#to_ole_point3d(pt) ⇒ WIN32OLE_RECORD
Conversion to WIN32OLE_RECORD of type Point3d
674
675
676
677
678
679
680
681
682
683
684
685
686
|
# File 'lib/microstation/app.rb', line 674
def to_ole_point3d(pt)
case pt
when ole_point3d?(pt)
pt
when Point3d
create_ole_point(pt.x, pt.y, pt.z)
when Array
pt1 = pt.map(&:to_f)
x, y, z = pt1
z ||= 0.0
create_ole_point(x, y, z)
end
end
|
#to_point(pt) ⇒ Object
730
731
732
|
# File 'lib/microstation/app.rb', line 730
def to_point(pt)
to_point3d(pt)
end
|
#to_point3d(pt) ⇒ Point3d
716
717
718
719
720
721
722
723
724
725
726
727
728
|
# File 'lib/microstation/app.rb', line 716
def to_point3d(pt)
case pt
when Array
pt_a = pt.map(&:to_f)
x, y, z = pt_a
z ||= 0.0
Point3d.new(x, y, z)
when Point3d
pt
when WIN32OLE_RECORD
Point3d.from_ole(pt) if pt.typename == "Point3d"
end
end
|
#username ⇒ String
370
371
372
|
# File 'lib/microstation/app.rb', line 370
def username
configuration["USERNAME"]
end
|
#visible? ⇒ Boolean
253
254
255
|
# File 'lib/microstation/app.rb', line 253
def visible?
@visible
end
|
#wait_drawing_opened(secs, interval = 1) ⇒ Object
226
227
228
229
230
231
232
233
|
# File 'lib/microstation/app.rb', line 226
def wait_drawing_opened(secs, interval = 1)
elapsed = 0
while !drawing_opened? && elapsed <= secs
elapsed += interval
sleep(interval)
WIN32OLE_EVENT.message_loop
end
end
|
#windows_path(path) ⇒ Object
356
357
358
|
# File 'lib/microstation/app.rb', line 356
def windows_path(path)
@windows.windows_path(path)
end
|
#with_config ⇒ Object
78
79
|
# File 'lib/microstation/configuration.rb', line 78
def with_config
end
|
#with_drawing(drawing) ⇒ Object
309
310
311
312
313
|
# File 'lib/microstation/app.rb', line 309
def with_drawing(drawing)
yield drawing
ensure
drawing.close
end
|
#with_template(template) {|template| ... } ⇒ Object
315
316
317
318
319
|
# File 'lib/microstation/app.rb', line 315
def with_template(template)
template = Template.new(template, self)
yield template
template = nil
end
|
#wrap(item, cell = nil) ⇒ Object
276
277
278
|
# File 'lib/microstation/app.rb', line 276
def wrap(item, cell = nil)
Element.convert_item(item, self, cell)
end
|