microstation 0.4.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. checksums.yaml +7 -0
  2. data/.autotest +23 -23
  3. data/.rspec +2 -2
  4. data/Gemfile +28 -10
  5. data/History.txt +6 -6
  6. data/LICENSE.adoc +22 -0
  7. data/Manifest.txt +81 -60
  8. data/README.adoc +131 -0
  9. data/Rakefile +71 -30
  10. data/bin/dgn2pdf +36 -37
  11. data/bin/dgn_template +107 -0
  12. data/bin/microstation +231 -0
  13. data/bin/pw_print +35 -0
  14. data/cad_files/drawing_faatitle_in_non_default_model.dgn +0 -0
  15. data/cad_files/drawing_no_block.dgn +0 -0
  16. data/cad_files/drawing_with_3_block.dgn +0 -0
  17. data/cad_files/drawing_with_block.dgn +0 -0
  18. data/cad_files/seed2d.dgn +0 -0
  19. data/cad_files/test.dgn +0 -0
  20. data/lib/microstation.rb +252 -88
  21. data/lib/microstation/app.rb +781 -286
  22. data/lib/microstation/cad_input_queue.rb +100 -25
  23. data/lib/microstation/cell.rb +191 -0
  24. data/lib/microstation/changer.rb +70 -0
  25. data/lib/microstation/configuration.rb +193 -57
  26. data/lib/microstation/criteria_creation_t.rb +23 -0
  27. data/lib/microstation/dir.rb +252 -252
  28. data/lib/microstation/directory.rb +46 -0
  29. data/lib/microstation/drawing.rb +690 -189
  30. data/lib/microstation/element.rb +311 -0
  31. data/lib/microstation/enumerator.rb +32 -29
  32. data/lib/microstation/errors.rb +17 -0
  33. data/lib/microstation/event_handler.rb +28 -0
  34. data/lib/microstation/ext/pathname.rb +23 -25
  35. data/lib/microstation/ext/win32ole.rb +7 -0
  36. data/lib/microstation/extensions/faa.rb +124 -0
  37. data/lib/microstation/file_tests.rb +68 -0
  38. data/lib/microstation/functions.rb +60 -0
  39. data/lib/microstation/graphics.rb +35 -0
  40. data/lib/microstation/line.rb +19 -0
  41. data/lib/microstation/model.rb +45 -0
  42. data/lib/microstation/model_trait.rb +189 -0
  43. data/lib/microstation/ole_cad_input_message.rb +101 -0
  44. data/lib/microstation/ole_helper.rb +152 -0
  45. data/lib/microstation/pdf_support.rb +40 -40
  46. data/lib/microstation/point3d.rb +71 -0
  47. data/lib/microstation/primitive_command_interface.rb +66 -0
  48. data/lib/microstation/properties.rb +61 -57
  49. data/lib/microstation/property_handler.rb +48 -0
  50. data/lib/microstation/scan/color.rb +38 -38
  51. data/lib/microstation/scan/criteria.rb +89 -85
  52. data/lib/microstation/scan/klass.rb +43 -43
  53. data/lib/microstation/scan/level.rb +38 -38
  54. data/lib/microstation/scan/line_style.rb +45 -45
  55. data/lib/microstation/scan/line_weight.rb +33 -33
  56. data/lib/microstation/scan/range.rb +19 -0
  57. data/lib/microstation/scan/scan_trait.rb +51 -0
  58. data/lib/microstation/scan/subtype.rb +40 -40
  59. data/lib/microstation/scan/type.rb +134 -109
  60. data/lib/microstation/scan_trait.rb +62 -0
  61. data/lib/microstation/scanner.rb +24 -24
  62. data/lib/microstation/tag.rb +87 -58
  63. data/lib/microstation/tag_set.rb +385 -280
  64. data/lib/microstation/tag_set_trait.rb +51 -0
  65. data/lib/microstation/tagged_element.rb +105 -0
  66. data/lib/microstation/template.rb +90 -84
  67. data/lib/microstation/template_info.rb +172 -0
  68. data/lib/microstation/template_runner.rb +65 -0
  69. data/lib/microstation/text.rb +79 -54
  70. data/lib/microstation/text_node.rb +124 -74
  71. data/lib/microstation/ts/attribute.rb +140 -139
  72. data/lib/microstation/ts/instance.rb +146 -112
  73. data/lib/microstation/ts/tagset_trait.rb +49 -0
  74. data/lib/microstation/types.rb +91 -91
  75. data/lib/microstation/version.rb +5 -0
  76. data/lib/microstation/wrap.rb +28 -214
  77. data/plot/pdf-bw.plt +164 -164
  78. data/plot/pdf.plt +163 -163
  79. data/plot/png.plt +383 -383
  80. data/plot/tiff.plt +384 -384
  81. data/plot/wmbw.tbl +324 -66
  82. data/plot/wmcolor.tbl +62 -62
  83. metadata +301 -86
  84. data/.gemtest +0 -0
  85. data/README.txt +0 -75
  86. data/lib/microstation/attributes.rb +0 -35
  87. data/lib/microstation/extensions/hash.rb +0 -27
  88. data/spec/app_spec.rb +0 -267
  89. data/spec/configuration_spec.rb +0 -122
  90. data/spec/drawing_spec.rb +0 -247
  91. data/spec/drawings/new_drawing.dgn +0 -0
  92. data/spec/drawings/test.dgn +0 -0
  93. data/spec/drawings/test1.dgn +0 -0
  94. data/spec/drawings/testfile.pdf +0 -0
  95. data/spec/enumerator_spec.rb +0 -60
  96. data/spec/microstation_spec.rb +0 -36
  97. data/spec/scanner_spec.rb +0 -155
  98. data/spec/spec_app.rb +0 -11
  99. data/spec/spec_helper.rb +0 -31
  100. data/spec/tag_set_spec.rb +0 -123
  101. data/spec/text_node_spec.rb +0 -92
  102. data/spec/text_spec.rb +0 -62
data/bin/dgn2pdf CHANGED
@@ -1,37 +1,36 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'optparse'
4
- require 'methadone'
5
- require 'microstation'
6
-
7
- class App
8
- include Methadone::Main
9
- include Methadone::CLILogging
10
-
11
- main do |directory, output_dir|
12
-
13
- directory_path = Pathname.new(directory).expand_path
14
- exit_now! "arg directory: #{directory_path} doesn't exist" unless directory_path.directory?
15
-
16
- Microstation.dgn2pdf(directory_path, output_dir)
17
- # your program code here
18
- # You can access CLI options via
19
- # the options Hash
20
- end
21
-
22
- # supplemental methods here
23
-
24
- # Declare command-line interface here
25
-
26
- description "Convert a directory of Microstation files (*.dgn) to pdf"
27
-
28
- on("-o","--output_dir","Output Dir")
29
-
30
-
31
- arg :directory
32
- arg :output_dir, :optional
33
-
34
- use_log_level_option
35
-
36
- go!
37
- end
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift('../lib')
3
+ require 'optparse'
4
+ require 'methadone'
5
+ require 'microstation'
6
+
7
+ class App
8
+ include Methadone::Main
9
+ include Methadone::CLILogging
10
+
11
+ main do |directory, output_dir|
12
+
13
+ directory_path = Pathname.new(directory).expand_path
14
+ exit_now! "arg directory: #{directory_path} doesn't exist" unless directory_path.directory?
15
+ Microstation.dgn2pdf(directory_path, output_dir)
16
+ # your program code here
17
+ # You can access CLI options via
18
+ # the options Hash
19
+ end
20
+
21
+ # supplemental methods here
22
+
23
+ # Declare command-line interface here
24
+
25
+ description "Convert a directory of Microstation files (*.dgn) to pdf"
26
+
27
+ on("-o","--output_dir","Output Dir")
28
+
29
+
30
+ arg :directory
31
+ arg :output_dir, :optional
32
+
33
+ use_log_level_option
34
+
35
+ go!
36
+ end
data/bin/dgn_template ADDED
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gli'
3
+ $LOAD_PATH.unshift(File.join(__dir__, 'lib'))
4
+
5
+ begin # XXX: Remove this begin/rescue before distributing your app
6
+ require 'microstation'
7
+ rescue LoadError
8
+ STDERR.puts "In development, you need to use `bundle exec ruby -I lib bin/dgn_template` to run your app"
9
+ STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"
10
+ STDERR.puts "Feel free to remove this message from bin/dgn_template now"
11
+ exit 64
12
+ end
13
+
14
+
15
+ module Cli
16
+ include GLI::App
17
+
18
+ extend self
19
+
20
+ program_desc "Create drawings from dgn templates and yaml files describing changes"
21
+
22
+ version Microstation::VERSION
23
+
24
+ subcommand_option_handling :normal
25
+ arguments :strict
26
+
27
+ # desc 'Describe some switch here'
28
+ # switch [:s,:switch]
29
+
30
+ # desc 'Describe some flag here'
31
+ # default_value 'the default'
32
+ # arg_name 'The name of the argument'
33
+ # flag [:f,:flagname]
34
+
35
+ desc 'create template description files to fill out'
36
+ long_desc "
37
+ Given a directory, this will generate yaml files describing
38
+ the fields and tagsets of dgn files in the directory
39
+ "
40
+
41
+ arg 'dir'
42
+ command :dump do |c|
43
+ # c.desc ''
44
+ # c.switch :s
45
+
46
+ c.desc 'file to run dump on'
47
+ # c.default_value 'default'
48
+ c.flag [:f, :filename]
49
+ c.action do |global_options,options,args|
50
+
51
+ # Your command logic here
52
+
53
+ # If you have any errors, just raise them
54
+ # raise "that command made no sense"
55
+ if file=options[:f]
56
+ puts "file dump ran with file option #{options[:f]}"
57
+
58
+ Microstation.dump_template_info(file, visible: true)
59
+ else
60
+ help_now!('dir is required') if args.empty?
61
+ Microstation.dump_template_info_for_dir args.first
62
+ end
63
+ end
64
+ end
65
+
66
+ desc 'Run the template description files'
67
+ arg :dir, :optional
68
+ command :run do |c|
69
+
70
+ c.desc 'file to run'
71
+ c.flag [:f, :filename]
72
+ c.action do |global_options,options,args|
73
+ if options[:f]
74
+ puts "Running run on file #{options[:f]}"
75
+
76
+ else
77
+ dir = args.shift
78
+ help_now!('arg "dir" is required if no :filename flag set') unless dir
79
+ Microstation.run_templates_in_dir(dir)
80
+ end
81
+ end
82
+ end
83
+
84
+ pre do |global,command,options,args|
85
+ # Pre logic here
86
+ # Return true to proceed; false to abort and not call the
87
+ # chosen command
88
+ # Use skips_pre before a command to skip this block
89
+ # on that command only
90
+ true
91
+ end
92
+
93
+ post do |global,command,options,args|
94
+ # Post logic here
95
+ # Use skips_post before a command to skip this
96
+ # block on that command only
97
+ end
98
+
99
+ on_error do |exception|
100
+ # Error logic here
101
+ # return false to skip default error handling
102
+ true
103
+ end
104
+
105
+ exit run(ARGV)
106
+
107
+ end
data/bin/microstation ADDED
@@ -0,0 +1,231 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/microstation'
3
+
4
+ # app = Microstation::App.new
5
+ # drawing = app.current_drawing if app.has_current_drawing?
6
+ # drawing.scan_text do |t|
7
+ # puts t if t.to_s =~ /{/
8
+ # end
9
+
10
+ module Faa
11
+
12
+ module Templates
13
+
14
+ :0
15
+ class App
16
+
17
+ attr_reader :racks, :lid, :factype
18
+
19
+ def initialize(lid: nil, factype:nil)
20
+ @lid = lid || 'LID'
21
+ @factype = factype || 'FACTYPE'
22
+ @racks = []
23
+ end
24
+
25
+ def add_rco_rack(name: nil)
26
+ rack = Rco::Rack.new(name):
27
+ yield rack if block_given?
28
+ racks << rack
29
+ rack
30
+ end
31
+
32
+ def dry_run(lid: @lid, factype: @factype, starting_number: 1,dir: nil)
33
+ accum = { result: [], next_number: nil}
34
+ result =racks.each_with_object(accum) do |r, o|
35
+ result, next_number = r.dry_run(lid: lid, factype: factype,ending_number: o[:next_number], starting_number: starting_number )
36
+ o[:result].concat(result)
37
+ o[:next_number] = next_number
38
+ o
39
+ end
40
+ result[:result]
41
+ end
42
+
43
+ def run_bak(lid: @lid, factype: @factype, starting_number: 1, dir: Pathname.getwd)
44
+ changes = dry_run(lid: lid, factype: factype, starting_number: starting_number, dir: dir)
45
+ return if changes.size == 0
46
+ Microstation.run do |app|
47
+ changes.each do |change|
48
+ app.change_drawing(change[:template], change[:new_name]) do |drawing|
49
+ drawing.change_template_text(change[:updates])
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ def run2(lid: @lid, factype: @factype, starting_number: 1, dir: Pathname.getwd)
56
+ changes = dry_run(lid: lid, factype: factype, starting_number: starting_number, dir: dir)
57
+ return if changes.size == 0
58
+ require 'pry'; binding.pry
59
+ Microstation.run(visible: true) do |app|
60
+ changes.each do |change|
61
+ app.change_drawing(change[:template], name: change[:new_name], output_dir: dir ) do |drawing|
62
+ drawing.change_template_text(change[:updates])
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ def run(lid: @lid, factype: @factype, starting_number: 1, dir: Pathname.getwd)
69
+ changes = dry_run(lid: lid, factype: factype, starting_number: starting_number, dir: dir)
70
+ return if changes.size == 0
71
+ require 'pry'; binding.pry
72
+ Microstation.run(visible: true) do |app|
73
+ changes.each do |change|
74
+ app.render_template(change[:template], name: change[:new_name], output_dir: dir, locals: change[:updates])
75
+ end
76
+ end
77
+ end
78
+
79
+ end
80
+
81
+ module Rco
82
+
83
+ DIR = ::Microstation::TEMPLATES_PATH + 'rco'
84
+
85
+
86
+ class Rack
87
+
88
+ DRAWINGS = (1..3).map{ |n| DIR + "t#{n}.dgn" }
89
+ CHANNEL_TO_DWG = { 1 => DIR + 't1.dgn',
90
+ 2 => DIR + 't2.dgn',
91
+ }
92
+
93
+ attr_reader :change_steps
94
+
95
+ attr_accessor :telco1_tx_drop, :telco1_rx_drop, :telco2_tx_drop, :telco2_rx_drop, :name
96
+
97
+
98
+ def initialize(name = nil, &block)
99
+ @name = name
100
+ @change_steps = {}
101
+ instance_eval(&block) if block_given?
102
+ end
103
+
104
+ def add_channel(freq,number)
105
+ add_transmitter(freq,number)
106
+ add_receiver(freq, number)
107
+ end
108
+
109
+ def channel_to_radio_number(chan)
110
+ number_start = case chan
111
+ when 1
112
+ 1
113
+ when 2
114
+ 3
115
+ when 3
116
+ 5
117
+ when 4
118
+ 7
119
+ end
120
+ end
121
+
122
+ def channel_to_drawing(chan)
123
+ case chan
124
+ when 1
125
+ DIR + 't1.dgn'
126
+ when 2
127
+ DIR + 't2.dgn'
128
+ end
129
+
130
+ end
131
+ def add_radio( freq, number: 1, type: :tx, func: main)
132
+ result = []
133
+ string_type = case type
134
+ when :tx, 'transmitter', 'tx'
135
+ 'TRANSMITTER'
136
+ when :rx, 'receiver', 'rx'
137
+ 'RECEIVER'
138
+ else
139
+ raise
140
+ end
141
+ string_func = case func
142
+ when :main, /\bmain\b/
143
+ 'MAIN'
144
+ when :stby, /\bstby\b/i, /\bstandby\b/i
145
+ 'STBY'
146
+ end
147
+
148
+ result << "#{string_type}#{number}"
149
+ result << "#{freq} MHz #{string_func}"
150
+ result << "CM-300 V2"
151
+ result.join("\n")
152
+ end
153
+
154
+ def add_channel(freq:, channel: 1)
155
+ change_steps[channel] = add_channel_changes(freq, channel)
156
+ end
157
+
158
+ def add_channel_changes(freq, ch)
159
+ changes = {}
160
+ changes[:channel] = ch
161
+ changes[:updates] = text_for_freq_and_channel(freq,ch)
162
+ end
163
+
164
+ def text_for_freq_and_channel(freq,ch)
165
+ number_start = channel_to_radio_number(ch)
166
+ { 'tx1' => add_radio(freq, number: number_start, type: :tx, func: :main),
167
+ 'rx1' => add_radio(freq, number: number_start, type: :rx, func: :main),
168
+ 'tx2' => add_radio( freq, number: number_start + 1, type: :tx, func: :stby),
169
+ 'rx2' => add_radio( freq, number: number_start + 1, type: :rx, func: :stby),
170
+ }
171
+ end
172
+
173
+
174
+ def dry_run(lid: , factype: , starting_number: 1, ending_number: nil)
175
+ starting_number = ending_number || starting_number
176
+ results = []
177
+ DRAWINGS.each.with_index(1) do |drawing,ch|
178
+ new_name = "%s-%s-Q-%03d.dgn" % [lid,factype, starting_number]
179
+ changes = change_steps.fetch(ch, {})
180
+ ch = ch + 1
181
+ starting_number += 1
182
+ result_hash = { template: drawing, new_name: new_name, updates: changes}
183
+ results << result_hash
184
+
185
+ end
186
+
187
+ [results,starting_number]
188
+ end
189
+ end
190
+
191
+ end
192
+
193
+ end
194
+
195
+ end
196
+
197
+
198
+ if $0 == __FILE__
199
+ app = Faa::Templates::App.new
200
+
201
+
202
+ app.add_rco_rack do |r|
203
+ r.add_channel(freq: 255.4, channel: 1)
204
+ end
205
+ app.add_rco_rack do |r|
206
+ r.add_channel(freq: 122.2, channel: 1)
207
+ r.add_channel(freq: 122.6, channel: 2)
208
+ end
209
+ app.add_rco_rack do |r|
210
+ r.add_channel(freq: 121.5, channel: 1)
211
+ r.add_channel(freq: 243, channel: 2)
212
+ end
213
+ app.run(lid: 'BTF', factype: 'RTR', starting_number: 110, dir: 'btf')
214
+
215
+ end
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+ # drawing.scan_cells_for_text do |t|
224
+ # puts t
225
+ # end
226
+
227
+
228
+ # drawing.scan_cells_for_text do |t|
229
+ # if t =~ /{{\s+(\w+)\s+}}/
230
+ # end
231
+ # end
data/bin/pw_print ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+ require 'methadone'
4
+
5
+ require 'microstation'
6
+ require 'microstation/extensions/faa'
7
+ require 'pry'
8
+
9
+ class PwApp
10
+ include Methadone::Main
11
+ include Methadone::CLILogging
12
+
13
+ main do
14
+ directory_path = Pathname( options['save-dir']).expand_path
15
+ exit_now! "arg directory: #{directory_path} doesn't exist" unless directory_path.directory?
16
+
17
+
18
+ app =Microstation.save_current_drawing(directory_path,exit: options['exit'])
19
+ binding.pry unless options['exit']
20
+
21
+
22
+ end
23
+
24
+ description "Save the currently open projectwise drawing"
25
+
26
+ options['save-dir'] = Pathname.getwd
27
+ options['exit'] = true
28
+ on("-d DIR", "--save-dir", "Set the location of the save dir")
29
+ on("-e", "--[no-]exit",TrueClass, "Close the Microstation instance")
30
+
31
+ version Microstation::VERSION
32
+
33
+ use_log_level_option
34
+ go!
35
+ end