microstation 0.8.5 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +26 -29
  3. data/Rakefile +45 -44
  4. data/bin/dgn2pdf +5 -6
  5. data/bin/dgn_template +23 -25
  6. data/bin/pw_print +11 -13
  7. data/cad_files/drawing_no_block.dgn +0 -0
  8. data/cad_files/drawing_with_3_block.dgn +0 -0
  9. data/cad_files/drawing_with_block.dgn +0 -0
  10. data/cad_files/drawing_with_text.dgn +0 -0
  11. data/lib/microstation/app.rb +91 -87
  12. data/lib/microstation/cad_input_queue.rb +10 -20
  13. data/lib/microstation/cell.rb +6 -18
  14. data/lib/microstation/changer.rb +3 -3
  15. data/lib/microstation/configuration.rb +33 -50
  16. data/lib/microstation/criteria_creation_t.rb +4 -8
  17. data/lib/microstation/dir.rb +27 -59
  18. data/lib/microstation/directory.rb +2 -7
  19. data/lib/microstation/drawing.rb +103 -102
  20. data/lib/microstation/element.rb +55 -68
  21. data/lib/microstation/enumerator.rb +4 -9
  22. data/lib/microstation/errors.rb +0 -5
  23. data/lib/microstation/event_handler.rb +1 -5
  24. data/lib/microstation/ext/pathname.rb +12 -14
  25. data/lib/microstation/ext/win32ole.rb +0 -2
  26. data/lib/microstation/extensions/faa.rb +12 -34
  27. data/lib/microstation/file_tests.rb +15 -50
  28. data/lib/microstation/functions.rb +10 -20
  29. data/lib/microstation/graphics.rb +6 -13
  30. data/lib/microstation/line.rb +2 -6
  31. data/lib/microstation/model.rb +11 -20
  32. data/lib/microstation/model_trait.rb +40 -40
  33. data/lib/microstation/ole_cad_input_message.rb +25 -34
  34. data/lib/microstation/ole_helper.rb +58 -66
  35. data/lib/microstation/pdf_support.rb +7 -16
  36. data/lib/microstation/point3d.rb +17 -30
  37. data/lib/microstation/primitive_command_interface.rb +8 -14
  38. data/lib/microstation/properties.rb +29 -17
  39. data/lib/microstation/property_handler.rb +6 -8
  40. data/lib/microstation/scan/color.rb +1 -8
  41. data/lib/microstation/scan/criteria.rb +17 -33
  42. data/lib/microstation/scan/klass.rb +8 -12
  43. data/lib/microstation/scan/level.rb +2 -9
  44. data/lib/microstation/scan/line_style.rb +4 -12
  45. data/lib/microstation/scan/line_weight.rb +1 -3
  46. data/lib/microstation/scan/range.rb +2 -8
  47. data/lib/microstation/scan/scan_trait.rb +48 -51
  48. data/lib/microstation/scan/subtype.rb +0 -10
  49. data/lib/microstation/scan/type.rb +9 -15
  50. data/lib/microstation/scan_trait.rb +13 -20
  51. data/lib/microstation/scanner.rb +1 -11
  52. data/lib/microstation/tag.rb +12 -21
  53. data/lib/microstation/tag_set.rb +52 -71
  54. data/lib/microstation/tag_set_trait.rb +6 -10
  55. data/lib/microstation/tagged_element.rb +16 -28
  56. data/lib/microstation/template.rb +15 -14
  57. data/lib/microstation/template_info.rb +35 -49
  58. data/lib/microstation/template_runner.rb +14 -22
  59. data/lib/microstation/text.rb +15 -19
  60. data/lib/microstation/text_node.rb +17 -26
  61. data/lib/microstation/ts/attribute.rb +16 -20
  62. data/lib/microstation/ts/instance.rb +28 -38
  63. data/lib/microstation/ts/tagset_trait.rb +5 -12
  64. data/lib/microstation/types.rb +0 -3
  65. data/lib/microstation/version.rb +1 -3
  66. data/lib/microstation/wrap.rb +3 -10
  67. data/lib/microstation.rb +57 -72
  68. data/spec/microstation/app_spec.rb +49 -46
  69. data/spec/microstation/configuration_spec.rb +45 -43
  70. data/spec/microstation/drawing_spec.rb +103 -101
  71. data/spec/microstation/functions_spec.rb +18 -12
  72. data/spec/microstation/tag_set_spec.rb +57 -55
  73. data/spec/microstation/template_spec.rb +41 -42
  74. data/spec/microstation/text_node_spec.rb +16 -14
  75. data/spec/microstation/text_spec.rb +10 -8
  76. data/spec/microstation_spec.rb +18 -17
  77. data/spec/spec_helper.rb +18 -18
  78. metadata +36 -22
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'wrap'
4
- require_relative 'point3d'
5
- require_relative 'event_handler'
6
- require_relative 'functions'
7
- require 'pry'
3
+ require_relative "wrap"
4
+ require_relative "point3d"
5
+ require_relative "event_handler"
6
+ require_relative "functions"
7
+ require "pry"
8
8
 
9
9
  class WIN32OLE
10
10
  def ole_obj
@@ -19,14 +19,16 @@ module Windows
19
19
  obj.windows_path(path)
20
20
  end
21
21
 
22
- def fs_object
23
- @fs_object ||= WIN32OLE.new('Scripting.FileSystemObject')
24
- end
25
-
22
+ # Convert path to windows path
23
+ # @param path [String, Pathname] the path you want to convert
26
24
  def windows_path(path)
27
25
  path = path.to_path if path.respond_to? :to_path
28
26
  fs_object.GetAbsolutePathName(path.to_str)
29
27
  end
28
+
29
+ def fs_object
30
+ @fs_object ||= WIN32OLE.new("Scripting.FileSystemObject")
31
+ end
30
32
  end
31
33
  end
32
34
 
@@ -41,11 +43,9 @@ module Microstation
41
43
  class App
42
44
  include Functions
43
45
 
44
-
45
- @default_app_options = { visible: false }
46
+ @default_app_options = {visible: false}
46
47
 
47
48
  class << self
48
-
49
49
  attr_accessor :default_app_options
50
50
 
51
51
  # include Wrap
@@ -66,12 +66,12 @@ module Microstation
66
66
  # @yield [App] the_app yields the instanciated app
67
67
  # @return [void]
68
68
  def run(options = {})
69
- opts = self.default_app_options.merge(options)
69
+ opts = default_app_options.merge(options)
70
70
  begin
71
71
  the_app = new(**opts)
72
72
  binding.pry if the_app.nil?
73
73
  yield the_app
74
- rescue StandardError
74
+ rescue
75
75
  binding.pry
76
76
  ensure
77
77
  the_app.quit if the_app.respond_to? :quit
@@ -86,8 +86,9 @@ module Microstation
86
86
  # (see #open_drawing)
87
87
  # @yield Drawing
88
88
  # @return [void]
89
- def open_drawing(drawing, app_options: {}, options: {}, &block)
90
- run(**app_options) do |app|
89
+ def open_drawing(drawing, **options, &block)
90
+ opt_visible = options.delete(:visible) || false
91
+ run(visible: opt_visible) do |app|
91
92
  app.open_drawing(drawing, **options, &block)
92
93
  end
93
94
  end
@@ -111,23 +112,27 @@ module Microstation
111
112
  # @param error_proc [Proc]
112
113
  # @yield [Drawing]
113
114
  # @return [void]
114
- def with_drawings(*files, visible: true, readonly: false, error_proc: ::Microstation.default_error_proc, &block)
115
+ def with_drawings(*files, **options, &block)
115
116
  # drawing_options = default_drawing_options.merge(options)
116
117
  # app_options = default_app_options
117
118
  errors = []
118
119
  files = files[0] if files[0].is_a? Array
120
+ opt_visible = options.delete(:visible) || false
121
+ error_proc = options.delete(:error_proc)
119
122
  begin
120
- the_app = new(visible: visible)
123
+ the_app = new(visible: opt_visible)
121
124
  files_enum = files.each
122
125
  loop do
123
126
  file = files_enum.next
124
127
  puts "opening #{file}.."
125
128
  begin
126
- the_app.open_drawing(file, readonly: readonly, error_proc: error_proc, &block)
129
+ the_app.open_drawing(file, **options, &block)
127
130
  the_app.ole_obj.ole_methods # check if server still open
128
- rescue StandardError => e
131
+ rescue => e
132
+ raise e unless error_proc
133
+
129
134
  error_proc.call(e, file)
130
- the_app = new(app_options)
135
+ the_app = new(visible: opt_visible)
131
136
  end
132
137
  end
133
138
  ensure
@@ -135,7 +140,7 @@ module Microstation
135
140
  the_app = nil
136
141
  end
137
142
  end
138
- end
143
+ end
139
144
 
140
145
  attr_reader :scanners, :visible, :app_event, :project_dir
141
146
 
@@ -146,12 +151,12 @@ module Microstation
146
151
  @visible = visible
147
152
  @event_handler = event_handler
148
153
  @ole_obj, @app_event = init_ole_and_app_event(visible: @visible, event_handler: @event_handler, tries: 5,
149
- sleep_duration: 0.5)
154
+ sleep_duration: 0.5)
150
155
  @run_loop = true
151
156
  @windows = Windows::FileSystem.new
152
157
  # make_visible(visible)
153
158
  @scanners = {}
154
- rescue StandardError => e
159
+ rescue => e
155
160
  binding.pry
156
161
  end
157
162
 
@@ -179,13 +184,13 @@ module Microstation
179
184
  #
180
185
  def default_event_handler
181
186
  event_handler = EventHandler.new
182
- event_handler.add_handler('OnDesignFileOpened') do |*_args|
183
- puts 'drawing opened'
187
+ event_handler.add_handler("OnDesignFileOpened") do |*_args|
188
+ puts "drawing opened"
184
189
  @drawing_opened = true
185
190
  end
186
- event_handler.add_handler('OnDesignFileClosed') do |*_args|
191
+ event_handler.add_handler("OnDesignFileClosed") do |*_args|
187
192
  @drawing_opened = false
188
- puts 'drawing closed'
193
+ puts "drawing closed"
189
194
  end
190
195
  event_handler
191
196
  end
@@ -199,7 +204,7 @@ module Microstation
199
204
  # @return [<Type>] <description>
200
205
  #
201
206
  def register_handler(event, &block)
202
- @event_handler.add_handler(event, &block) unless event == 'OnQuit'
207
+ @event_handler.add_handler(event, &block) unless event == "OnQuit"
203
208
  end
204
209
 
205
210
  #
@@ -214,7 +219,7 @@ module Microstation
214
219
  end
215
220
 
216
221
  def exit_message_looop
217
- puts 'Microstation exiting...'
222
+ puts "Microstation exiting..."
218
223
  @run_loop = false
219
224
  end
220
225
 
@@ -228,7 +233,7 @@ module Microstation
228
233
  end
229
234
 
230
235
  def init_ole_and_app_event(visible: @visible, event_handler: @event_handler, tries: 5, sleep_duration: 1)
231
- ole = WIN32OLE.new('MicrostationDGN.Application')
236
+ ole = WIN32OLE.new("MicrostationDGN.Application")
232
237
  sleep(sleep_duration)
233
238
  ole.Visible = visible
234
239
  ole.IsProcessLocked = true
@@ -236,12 +241,12 @@ module Microstation
236
241
  app_event = WIN32OLE_EVENT.new(ole)
237
242
  app_event.handler = event_handler
238
243
  [ole, app_event]
239
- rescue StandardError => e
244
+ rescue => e
240
245
  tries -= 1
241
246
  sleep_duration += 1.5
242
247
  puts "Error: #{e}. #{tries} tries left."
243
248
  retry if tries.positive?
244
- raise e, 'unable to init ole app'
249
+ raise e, "unable to init ole app"
245
250
  end
246
251
 
247
252
  # @return [Boolean] whether the app is visible
@@ -274,7 +279,7 @@ module Microstation
274
279
 
275
280
  def normalize_name(name)
276
281
  name = Pathname.new(name) unless name.is_a? Pathname
277
- name = name.ext('.dgn') unless name.extname.to_s == /\.(dgn|dwg)$/
282
+ name = name.ext(".dgn") unless name.extname.to_s == /\.(dgn|dwg)$/
278
283
  (base_dir + name).expand_path
279
284
  end
280
285
 
@@ -292,7 +297,7 @@ module Microstation
292
297
  is_ok = true
293
298
  begin
294
299
  @ole_obj.Visible
295
- rescue StandardError => e
300
+ rescue => e
296
301
  is_ok = false
297
302
  end
298
303
 
@@ -327,14 +332,12 @@ module Microstation
327
332
 
328
333
  begin
329
334
  ole = ole_open_drawing(windows_path(filename), readonly: readonly, wait_time: wait_time,
330
- wait_interval: wait_interval)
331
- rescue StandardError => e
332
- if error_proc
333
- error_proc.call(filename)
334
- return
335
- else
336
- raise e
337
- end
335
+ wait_interval: wait_interval)
336
+ rescue => e
337
+ raise e unless error_proc
338
+
339
+ error_proc.call(filename)
340
+ return
338
341
  end
339
342
  drawing = drawing_from_ole(ole)
340
343
  return drawing unless block_given?
@@ -365,7 +368,7 @@ module Microstation
365
368
 
366
369
  # @return [String] the configuration variable USERNAME
367
370
  def username
368
- configuration['USERNAME']
371
+ configuration["USERNAME"]
369
372
  end
370
373
 
371
374
  # create a new drawing
@@ -388,12 +391,12 @@ module Microstation
388
391
  windows_name = windows_path(filename)
389
392
  ole = new_ole_drawing(seedfile, windows_name, open: open, wait_time: wait_time, wait_interval: wait_interval)
390
393
  drawing = drawing_from_ole(ole)
391
- return drawing unless block_given?
394
+ return drawing unless block
392
395
 
393
396
  begin
394
397
  yield drawing
395
- rescue StandardError => e
396
- 'puts error in new drawing'
398
+ rescue => e
399
+ "puts error in new drawing"
397
400
  raise e
398
401
  ensure
399
402
  drawing.close
@@ -406,7 +409,7 @@ module Microstation
406
409
  raise "drawing not opened in #{wait_time}" unless drawing_opened?
407
410
 
408
411
  ole
409
- rescue StandardError => e
412
+ rescue => e
410
413
  raise e
411
414
  end
412
415
 
@@ -417,7 +420,7 @@ module Microstation
417
420
  # prepend a dir to the MS_SEEDFILES configuration
418
421
  # @param dir [String,Pathname]
419
422
  def prepend_seed_path(dir)
420
- configuration.prepend('MS_SEEDFILES', windows_path(dir))
423
+ configuration.prepend("MS_SEEDFILES", windows_path(dir))
421
424
  end
422
425
 
423
426
  def drawing_from_ole(ole)
@@ -425,7 +428,7 @@ module Microstation
425
428
  end
426
429
 
427
430
  def determine_seed(seedfile)
428
- return configuration['MS_DESIGNSEED'] unless seedfile
431
+ return configuration["MS_DESIGNSEED"] unless seedfile
429
432
 
430
433
  seed = find_seed(seedfile)
431
434
  return seed.to_s if seed
@@ -435,7 +438,7 @@ module Microstation
435
438
 
436
439
  # @return [String] the configuration variable MS_SEEDFILES
437
440
  def configured_seed_paths
438
- configuration['MS_SEEDFILES']
441
+ configuration["MS_SEEDFILES"]
439
442
  end
440
443
 
441
444
  # find the seedfile
@@ -446,7 +449,7 @@ module Microstation
446
449
  # * If the seed file is not found search MS_SEEDFILES
447
450
  # @return [Pathname] seedfile the found seedfile
448
451
  def find_seed(seedfile)
449
- seed = Pathname(seedfile).expand_path.sub_ext('.dgn')
452
+ seed = Pathname(seedfile).expand_path.sub_ext(".dgn")
450
453
  return seed if seed.file?
451
454
 
452
455
  find_seed_in_seed_dirs(seed.basename)
@@ -459,7 +462,7 @@ module Microstation
459
462
 
460
463
  # @return [Array] returns the MS_SEEDFILES as Pathnames Array
461
464
  def seed_paths
462
- configured_seed_paths.split(';').map { |d| Pathname(d) }
465
+ configured_seed_paths.split(";").map { |d| Pathname(d) }
463
466
  end
464
467
 
465
468
  def eval_cexpression(string)
@@ -476,7 +479,7 @@ module Microstation
476
479
  @scanners.each { |_name, sc| sc.close }
477
480
  begin
478
481
  ole_obj.Quit
479
- rescue StandardError
482
+ rescue
480
483
  nil
481
484
  end
482
485
  end
@@ -484,14 +487,14 @@ module Microstation
484
487
  # the active design file
485
488
  # @return [Drawing]
486
489
  def active_design_file
487
- if active_design_file?
488
- ole = ole_obj.ActiveDesignFile
489
- drawing_from_ole(ole)
490
- end
490
+ return unless active_design_file?
491
+
492
+ ole = ole_obj.ActiveDesignFile
493
+ drawing_from_ole(ole)
491
494
  end
492
495
 
493
- alias active_drawing active_design_file
494
- alias current_drawing active_design_file
496
+ alias_method :active_drawing, :active_design_file
497
+ alias_method :current_drawing, :active_design_file
495
498
 
496
499
  #
497
500
  # close the active_design_file
@@ -502,7 +505,7 @@ module Microstation
502
505
  active_design_file.close if active_design_file?
503
506
  end
504
507
 
505
- alias close_current_drawing close_active_drawing
508
+ alias_method :close_current_drawing, :close_active_drawing
506
509
 
507
510
  #
508
511
  #
@@ -513,7 +516,7 @@ module Microstation
513
516
  ole_obj.HasActiveDesignFile
514
517
  end
515
518
 
516
- alias current_design_file? active_design_file?
519
+ alias_method :current_design_file?, :active_design_file?
517
520
 
518
521
  #
519
522
  # <Description>
@@ -535,7 +538,7 @@ module Microstation
535
538
  end
536
539
 
537
540
  def tags_criteria
538
- sc = scanners[:tags] || create_scanner(:tags) { include_tags }
541
+ scanners[:tags] || create_scanner(:tags) { include_tags }
539
542
  end
540
543
 
541
544
  def create_scan_criteria(name = nil, &block)
@@ -569,7 +572,7 @@ module Microstation
569
572
 
570
573
  begin
571
574
  yield queue
572
- rescue StandardError
575
+ rescue
573
576
  ensure
574
577
  queue.close
575
578
  queue = nil
@@ -598,43 +601,43 @@ module Microstation
598
601
  #
599
602
  def show_temp_message(text, location: nil)
600
603
  loc = case location
601
- when :left
602
- MSD::MsdStatusBarAreaLeft
603
- when :middle
604
- MSD::MsdStatusBarAreaMiddle
605
- else
606
- MSD::MsdStatusBarAreaLeft
607
- end
604
+ when :left
605
+ MSD::MsdStatusBarAreaLeft
606
+ when :middle
607
+ MSD::MsdStatusBarAreaMiddle
608
+ else
609
+ MSD::MsdStatusBarAreaLeft
610
+ end
608
611
  ole_obj.ShowTempMessage(loc, text)
609
612
  end
610
613
 
611
614
  def can_open?(filename)
612
615
  ext = File.extname(filename)
613
- (ext == '.dwg') || (ext == '.dgn')
616
+ (ext == ".dwg") || (ext == ".dgn")
614
617
  end
615
618
 
616
619
  def active_model_reference
617
620
  DefaultModel.new(self, ole_obj.ActiveModelReference)
618
- rescue StandardError
621
+ rescue
619
622
  nil
620
623
  end
621
624
 
622
625
  def default_model
623
626
  DefaultModel.new(self, ole_obj.DefaultModelReference)
624
- rescue StandardError
627
+ rescue
625
628
  nil
626
629
  end
627
630
 
628
631
  def ole_point
629
- ::WIN32OLE_RECORD.new('Point3d', ole_obj)
632
+ ::WIN32OLE_RECORD.new("Point3d", ole_obj)
630
633
  end
631
634
 
632
635
  def ole_rotation
633
- ::WIN32OLE_RECORD.new('Rotation', ole_obj)
636
+ ::WIN32OLE_RECORD.new("Rotation", ole_obj)
634
637
  end
635
638
 
636
639
  def ole_matrix
637
- ::WIN32OLE_RECORD.new('Matrix', ole_obj)
640
+ ::WIN32OLE_RECORD.new("Matrix", ole_obj)
638
641
  end
639
642
 
640
643
  #
@@ -655,7 +658,7 @@ module Microstation
655
658
  end
656
659
 
657
660
  def to_ole_matrix3d(vec)
658
- if vec.instance_of?(WIN32OLE_RECORD) && vec.typename == 'Matrix3d'
661
+ if vec.instance_of?(WIN32OLE_RECORD) && vec.typename == "Matrix3d"
659
662
  vec
660
663
  else
661
664
  binding.pry
@@ -690,14 +693,14 @@ module Microstation
690
693
  # @return [Boolean] true if pt is WIN32OLE_RECORD of 'Point3d'
691
694
  #
692
695
  def ole_point3d?(pt)
693
- pt.instance_of?(WIN32OLE_RECORD) && pt.typename == 'Point3d'
696
+ pt.instance_of?(WIN32OLE_RECORD) && pt.typename == "Point3d"
694
697
  end
695
698
 
696
699
  def create_text_node(origin, rotation, temp = nil)
697
700
  ole_origin = to_ole_point3d(origin)
698
701
  ole_rotation = to_ole_matrix3d(rotation)
699
702
  temp ||= WIN32OLE_VARIANT::Nothing
700
- ole = ole_obj.CreateTextNodeElement1(temp, ole_origin, ole_rotation)
703
+ ole_obj.CreateTextNodeElement1(temp, ole_origin, ole_rotation)
701
704
  rescue Exception => e
702
705
  puts e.message
703
706
  nil
@@ -720,7 +723,7 @@ module Microstation
720
723
  when Point3d
721
724
  pt
722
725
  when WIN32OLE_RECORD
723
- Point3d.from_ole(pt) if pt.typename == 'Point3d'
726
+ Point3d.from_ole(pt) if pt.typename == "Point3d"
724
727
  end
725
728
  end
726
729
 
@@ -733,30 +736,31 @@ module Microstation
733
736
  end
734
737
 
735
738
  def my_place_line
736
- require_relative 'primitive_command_interface'
739
+ require_relative "primitive_command_interface"
737
740
  start_primitive LineCreation
738
741
  end
739
742
 
740
743
  def method_missing(meth, *args, &block)
741
- if meth.to_s =~ /^[A-Z]/
742
- require 'pry'; binding.pry
744
+ if /^[A-Z]/.match?(meth.to_s)
745
+ require "pry"
746
+ binding.pry
743
747
  result = ole_obj.send(meth, *args, &block)
744
748
  else
745
749
  super(meth, *args, &block)
746
750
  end
747
- rescue StandardError => e
751
+ rescue => e
748
752
  binding.pry
749
753
  end
750
754
 
751
755
  protected
752
756
 
753
757
  def ole_open_drawing(path, readonly: false, wait_time: 500, wait_interval: 0.5)
754
- ole = ole_obj.OpenDesignFile(windows_path(path), 'ReadOnly' => readonly)
758
+ ole = ole_obj.OpenDesignFile(windows_path(path), "ReadOnly" => readonly)
755
759
  wait_drawing_opened(wait_time, wait_interval)
756
760
  raise "drawing not opened in #{wait_time}" unless drawing_opened?
757
761
 
758
762
  ole
759
- rescue StandardError => e
763
+ rescue => e
760
764
  raise e
761
765
  end
762
766
 
@@ -1,14 +1,12 @@
1
- require_relative 'ole_cad_input_message'
2
- require 'dry/monads'
1
+ require_relative "ole_cad_input_message"
2
+ require "dry/monads"
3
3
  module Microstation
4
-
5
4
  class CadInputQueue
6
-
7
5
  include Dry::Monads[:result]
8
6
 
9
- attr_reader :app,:ole_obj
7
+ attr_reader :app, :ole_obj
10
8
 
11
- def initialize(ole_obj,app)
9
+ def initialize(ole_obj, app)
12
10
  @ole_obj = ole_obj
13
11
  @app = app
14
12
  @input_procs = []
@@ -42,29 +40,27 @@ module Microstation
42
40
  @ole_obj.SendTentativePoint(pt)
43
41
  end
44
42
 
45
- def send_drag_points(down_pt, up_point, view_specifier:nil, qualifier:nil)
46
- @ole_obj.SendDragPoints(down_pt,up_point)
43
+ def send_drag_points(down_pt, up_point, view_specifier: nil, qualifier: nil)
44
+ @ole_obj.SendDragPoints(down_pt, up_point)
47
45
  end
48
46
 
49
47
  def get_input(*args)
50
48
  com = @ole_obj.GetInput(*args)
51
- OLE_CadInputMessage.new(com,app)
49
+ OLE_CadInputMessage.new(com, app)
52
50
  end
53
51
 
54
-
55
52
  def get_point(prompt: "Enter vertex")
56
53
  show_prompt(prompt)
57
54
  mycim = get_input(InputType::DataPoint, InputType::Reset)
58
55
  if mycim.reset?
59
56
  clear_ui
60
- return Failure(:reset_pressed)
57
+ Failure(:reset_pressed)
61
58
  elsif mycim.data_point?
62
59
  clear_ui
63
60
  Success(mycim.get_point)
64
61
  end
65
62
  end
66
63
 
67
-
68
64
  def show_command(text)
69
65
  app.show_command(text)
70
66
  end
@@ -77,24 +73,18 @@ module Microstation
77
73
  app.show_status(text)
78
74
  end
79
75
 
80
-
81
76
  def clear_ui
82
77
  app.show_prompt("")
83
78
  app.show_status("")
84
79
  app.show_command("")
85
80
  end
86
81
 
87
-
88
- def method_missing(name,*args,&block)
89
- @ole_obj.send(name,*args,&block)
82
+ def method_missing(name, *args, &block)
83
+ @ole_obj.send(name, *args, &block)
90
84
  end
91
85
 
92
86
  def start_default_command
93
87
  @app.ole_obj.CommandState.StartDefaultCommand
94
88
  end
95
-
96
-
97
-
98
89
  end
99
-
100
90
  end
@@ -1,7 +1,5 @@
1
1
  module Microstation
2
-
3
2
  class Cell < Element
4
-
5
3
  def initialize(*args)
6
4
  super(*args)
7
5
  @should_replace = false
@@ -16,19 +14,16 @@ module Microstation
16
14
  ole_obj.Name
17
15
  end
18
16
 
19
-
20
17
  def text_elements
21
18
  return to_enum(:text_elements) unless block_given?
19
+
22
20
  each do |el|
23
21
  yield el if el.textual?
24
22
  end
25
23
  end
26
-
27
24
  end
28
-
29
25
  end
30
26
 
31
-
32
27
  # def each
33
28
  # return enum_for(:each) unless block_given?
34
29
  # ole_enum = @ole_obj.GetSubElements
@@ -36,11 +31,10 @@ end
36
31
  # item = ole_enum.Currentq
37
32
  # wrapped = Microstation::Wrap.wrap(item,app)
38
33
 
39
- # yield
34
+ # yield
40
35
  # end
41
36
  # end
42
37
 
43
-
44
38
  # def each_ole(ole)
45
39
  # ole_enum = ole.GetSubElements
46
40
  # while ole_enum.MoveNext
@@ -49,14 +43,12 @@ end
49
43
  # each_ole(item)
50
44
  # else
51
45
 
52
-
53
46
  # wrapped = Microstation::Wrap.wrap(item,app)
54
47
 
55
- # yield
56
- # end
48
+ # yield
49
+ # end
57
50
  # end
58
51
 
59
-
60
52
  # def each_ole(ole)
61
53
  # ole_enum = ole.GetSubElements
62
54
  # end
@@ -74,8 +66,6 @@ end
74
66
  # ole_obj.ReplaceCurrentElement this_var
75
67
  # end
76
68
 
77
-
78
-
79
69
  # Dim search_text As String
80
70
  # Dim replace_text As String
81
71
 
@@ -104,7 +94,6 @@ end
104
94
 
105
95
  # Public Sub ReplaceAllTextsInModel()
106
96
 
107
-
108
97
  # 'USE THIS TO SET THE REPLACEMENT BY CONFIGURATION VARIABLE
109
98
  # 'search_text = ActiveWorkspace.ExpandConfigurationVariable("SEARCH_TEXT")
110
99
  # 'replace_text = ActiveWorkspace.ExpandConfigurationVariable("REPLACE_TEXT")
@@ -126,7 +115,6 @@ end
126
115
  # Loop
127
116
  # End Sub
128
117
 
129
-
130
118
  # Option Explicit
131
119
  # ' Searches in text strings and nested cells
132
120
 
@@ -148,7 +136,7 @@ end
148
136
  # End If
149
137
 
150
138
  # sToFind = Trim(CmdLine(0)) '1. Parameter for search text
151
- # sToReplace = Trim(CmdLine(1)) '2. Parameter for new text
139
+ # sToReplace = Trim(CmdLine(1)) '2. Parameter for new text
152
140
  # ' Check if optional parameter = yes complex was given
153
141
  # isComplex = False
154
142
  # If UBound(CmdLine) > 1 Then
@@ -188,4 +176,4 @@ end
188
176
  # End If
189
177
  # End If
190
178
  # End If
191
- # # End Sub
179
+ # # End Sub
@@ -29,15 +29,15 @@ module Microstation
29
29
  tmp_dgn = the_app ? change_in_tempfile(the_app, &block) : change_once_in_tempfile(&block)
30
30
  FileUtils.mv(tmp_dgn.to_s, newname.to_s)
31
31
  puts "Saved drawing #{newname}"
32
- rescue StandardError => e
33
- puts 'error in changing file'
32
+ rescue => e
33
+ puts "error in changing file"
34
34
  raise e
35
35
  end
36
36
 
37
37
  def change_in_tempfile(app, &block)
38
38
  path = Pathname(File.join(::Dir.tmpdir, "#{template_filename}_#{Time.now.to_i}_#{rand(1000)}"))
39
39
  app.new_drawing(path, seedfile: @template) do |drawing|
40
- if block_given?
40
+ if block
41
41
  block.call(drawing)
42
42
  else
43
43
  default_block.call(drawing)