microstation 0.4.1 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,23 @@
1
+ module Microstation
2
+
3
+ module CriteriaCreationT
4
+
5
+ def text_criteria
6
+ app.scanners[:textual] || app.create_scanner(:textual){ include_textual}
7
+ end
8
+
9
+ def graphic_criteria
10
+ app.scanners[:graphical] || app.create_scanner(:graphical){ ExcludeNonGraphical}
11
+ end
12
+
13
+ def tags_criteria
14
+ app.scanners[:tags] || app.create_scanner(:tags){ include_tags}
15
+ end
16
+
17
+ def cells_criteria
18
+ app.scanners[:cells] || app.create_scanner(:cells){ include_cells}
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -1,252 +1,252 @@
1
- require_relative 'pdf_support'
2
- require 'fileutils'
3
- module Microstation
4
-
5
- class Dir
6
-
7
- include PdfSupport
8
- include FileUtils::Verbose
9
-
10
- attr_reader :dir, :relative_pdf_path
11
-
12
- def initialize(dir,pdf_path=nil)
13
- @dir = Pathname(dir).expand_path
14
- @relative_pdf_path = set_relative_pdf_path(pdf_path)
15
- end
16
-
17
- def self.Dir(path)
18
- case path
19
- when Microstation::Dir
20
- path
21
- else
22
- new(Pathname(path))
23
- end
24
- end
25
-
26
- def ==(other)
27
- self.dir == other.dir && self.relative_pdf_path == other.relative_pdf_path
28
- end
29
-
30
- def to_path
31
- @dir.to_path
32
- end
33
-
34
- def path
35
- @dir
36
- end
37
-
38
- def directory?
39
- path.directory?
40
- end
41
-
42
- def exist?
43
- path.exist?
44
- end
45
-
46
-
47
- def mkdir
48
- @dir.mkdir
49
- end
50
-
51
- def mkpath
52
- @dir.mkpath
53
- end
54
-
55
- def +(other)
56
- self.class.new( self.path + other)
57
- end
58
-
59
-
60
- def copy(drawing,dir)
61
- cp drawing, dir
62
- end
63
-
64
- def select_by_name( re)
65
- re = Regexp.new(re)
66
- drawing_files.select{|n| n.to_path =~ re}
67
- end
68
-
69
-
70
- def find_by_name(re)
71
- re = Regexp.new(re)
72
- drawing_files.find{|n| n.to_path =~ re}
73
- end
74
-
75
- def drawings
76
- Pathname.glob(@dir + "*.d{gn,wg}")
77
- end
78
-
79
- def sort_by(&block)
80
- @sort_by = block
81
- end
82
-
83
- def sort(array_of_files)
84
- sort_lambda = @sort_by || lambda{|f| f.path.to_s}
85
- array_of_files.sort_by(&sort_lambda)
86
- end
87
-
88
- def drawing_files
89
- return @drawing_files if @drawing_files
90
- set_drawing_files(drawings.map{|dwg| Microstation::Drawing::File.new(dwg)} )
91
- @drawing_files
92
- end
93
-
94
- def set_drawing_files(dfiles)
95
- @drawing_files = sort(dfiles)
96
- end
97
-
98
-
99
- def pdf_generation_complete?
100
- drawing_files.all?{|d| not d.needs_pdf?}
101
- end
102
-
103
-
104
- def pdf_files(dir = pdf_dirname)
105
- sort(drawing_files).map{|p| p.pdf_name(dir)}
106
- end
107
-
108
- def concat_pdfs(files)
109
- Pdftk.concat(files)
110
- end
111
-
112
- def drawing_files_needing_pdf(dir = pdf_dirname)
113
- drawing_files.select{|d| d.needs_pdf?(dir) }
114
- end
115
-
116
- def print_pdfs(dir = pdf_dirname)
117
- with_drawing_files( drawing_files_needing_pdf) do |drawing|
118
- drawing.save_as_pdf(:dir => dir)
119
- end
120
- end
121
-
122
- def generate_pdfs(dir = pdf_dirname)
123
- print_pdfs(dir)
124
- concat_pdfs(pdf_files(dir), dir + "dir.combined.drawings.pdf")
125
- end
126
-
127
- def find_pdftk(dirs = nil)
128
- require 'pdf_forms'
129
- @pdftk = PdfForms.new('e:/tools/pdftk-1.44/bin/pdftk.exe')
130
- end
131
-
132
- def pdftk
133
- @pdftk ||= find_pdftk(dirs= nil)
134
- end
135
-
136
-
137
- def concat_pdfs(files,name)
138
- pdftk.cat(files,name.to_s)
139
- puts "generated #{name}"
140
- end
141
-
142
-
143
-
144
- def get_meta_for_drawings
145
- @drawing_files = nil
146
- files = []
147
- with_drawing_files( drawings) do |drawing|
148
- files << Microstation::Drawing::File.from_drawing(drawing)
149
- end
150
- set_drawing_files(files)
151
- end
152
-
153
- def with_drawing_files(dwgs = drawing_files, &block)
154
- Microstation.with_drawings(dwgs,&block)
155
- end
156
-
157
- def pdf_dirname
158
- if relative_pdf_path.absolute?
159
- relative_pdf_path
160
- else
161
- dir + relative_pdf_path
162
- end
163
- end
164
-
165
- def set_relative_pdf_path(path)
166
- rel_path = path.nil? ? "." : path
167
- Pathname(rel_path)
168
- end
169
-
170
-
171
- def relative_pdf_path=(path)
172
- @relative_pdf_path = set_relative_path(path)
173
- end
174
-
175
-
176
-
177
- end
178
- end
179
-
180
- module Microstation
181
-
182
- class Drawing
183
-
184
- class File
185
-
186
- include PdfSupport
187
-
188
- attr_reader :keywords, :creator, :path
189
-
190
- def self.from_drawing(drawing)
191
- file = new(drawing.path)
192
- file.get_meta(drawing)
193
- file
194
- end
195
-
196
- def to_path
197
- @path.to_path
198
- end
199
-
200
-
201
- def initialize(path)
202
- @path = Pathname(path)
203
- end
204
-
205
- def basename
206
- @path.basename
207
- end
208
-
209
- def dirname
210
- @path.dirname
211
- end
212
-
213
- def drawing=(drawing)
214
- @drawing = drawing
215
- end
216
-
217
- def mtime
218
- self.path.mtime
219
- end
220
-
221
- def title
222
- @title ||= get_meta
223
- end
224
-
225
- def app_open_drawing(app, &block)
226
- draw = app.open_drawing(self.path,&block)
227
- end
228
-
229
- def open_drawing(&block)
230
- Microstation.open_drawing(self.path,&block)
231
- end
232
-
233
- def get_meta(dwg)
234
- @title = dwg.title
235
- @keywords = dwg.keywords
236
- @creator = dwg.creator
237
- end
238
-
239
- end
240
-
241
-
242
- end
243
- end
244
-
245
-
246
-
247
-
248
-
249
-
250
-
251
-
252
-
1
+ require_relative 'pdf_support'
2
+ require 'fileutils'
3
+ module Microstation
4
+
5
+ class Dir
6
+
7
+ include PdfSupport
8
+ include FileUtils::Verbose
9
+
10
+ attr_reader :dir, :relative_pdf_path
11
+
12
+ def initialize(dir,pdf_path=nil)
13
+ @dir = Pathname(dir).expand_path
14
+ @relative_pdf_path = set_relative_pdf_path(pdf_path)
15
+ end
16
+
17
+ def self.Dir(path)
18
+ case path
19
+ when Microstation::Dir
20
+ path
21
+ else
22
+ new(Pathname(path))
23
+ end
24
+ end
25
+
26
+ def ==(other)
27
+ self.dir == other.dir && self.relative_pdf_path == other.relative_pdf_path
28
+ end
29
+
30
+ def to_path
31
+ @dir.to_path
32
+ end
33
+
34
+ def path
35
+ @dir
36
+ end
37
+
38
+ def directory?
39
+ path.directory?
40
+ end
41
+
42
+ def exist?
43
+ path.exist?
44
+ end
45
+
46
+
47
+ def mkdir
48
+ @dir.mkdir
49
+ end
50
+
51
+ def mkpath
52
+ @dir.mkpath
53
+ end
54
+
55
+ def +(other)
56
+ self.class.new( self.path + other)
57
+ end
58
+
59
+
60
+ def copy(drawing,dir)
61
+ cp drawing, dir
62
+ end
63
+
64
+ def select_by_name( re)
65
+ re = Regexp.new(re)
66
+ drawing_files.select{|n| n.to_path =~ re}
67
+ end
68
+
69
+
70
+ def find_by_name(re)
71
+ re = Regexp.new(re)
72
+ drawing_files.find{|n| n.to_path =~ re}
73
+ end
74
+
75
+ def drawings
76
+ Pathname.glob(@dir + "*.d{gn,wg}")
77
+ end
78
+
79
+ def sort_by(&block)
80
+ @sort_by = block
81
+ end
82
+
83
+ def sort(array_of_files)
84
+ sort_lambda = @sort_by || lambda{|f| f.path.to_s}
85
+ array_of_files.sort_by(&sort_lambda)
86
+ end
87
+
88
+ def drawing_files
89
+ return @drawing_files if @drawing_files
90
+ set_drawing_files(drawings.map{|dwg| Microstation::Drawing::File.new(dwg)} )
91
+ @drawing_files
92
+ end
93
+
94
+ def set_drawing_files(dfiles)
95
+ @drawing_files = sort(dfiles)
96
+ end
97
+
98
+
99
+ def pdf_generation_complete?
100
+ drawing_files.all?{|d| not d.needs_pdf?}
101
+ end
102
+
103
+
104
+ def pdf_files(dir = pdf_dirname)
105
+ sort(drawing_files).map{|p| p.pdf_name(dir)}
106
+ end
107
+
108
+ def concat_pdfs(files)
109
+ Pdftk.concat(files)
110
+ end
111
+
112
+ def drawing_files_needing_pdf(dir = pdf_dirname)
113
+ drawing_files.select{|d| d.needs_pdf?(dir) }
114
+ end
115
+
116
+ def print_pdfs(dir = pdf_dirname)
117
+ with_drawing_files( drawing_files_needing_pdf) do |drawing|
118
+ drawing.save_as_pdf(:dir => dir)
119
+ end
120
+ end
121
+
122
+ def generate_pdfs(dir = pdf_dirname)
123
+ print_pdfs(dir)
124
+ concat_pdfs(pdf_files(dir), dir + "dir.combined.drawings.pdf")
125
+ end
126
+
127
+ def find_pdftk(dirs = nil)
128
+ require 'pdf_forms'
129
+ @pdftk = PdfForms.new('e:/tools/pdftk-1.44/bin/pdftk.exe')
130
+ end
131
+
132
+ def pdftk
133
+ @pdftk ||= find_pdftk(dirs= nil)
134
+ end
135
+
136
+
137
+ def concat_pdfs(files,name)
138
+ pdftk.cat(files,name.to_s)
139
+ puts "generated #{name}"
140
+ end
141
+
142
+
143
+
144
+ def get_meta_for_drawings
145
+ @drawing_files = nil
146
+ files = []
147
+ with_drawing_files( drawings) do |drawing|
148
+ files << Microstation::Drawing::File.from_drawing(drawing)
149
+ end
150
+ set_drawing_files(files)
151
+ end
152
+
153
+ def with_drawing_files(dwgs = drawing_files, &block)
154
+ Microstation.with_drawings(dwgs,&block)
155
+ end
156
+
157
+ def pdf_dirname
158
+ if relative_pdf_path.absolute?
159
+ relative_pdf_path
160
+ else
161
+ dir + relative_pdf_path
162
+ end
163
+ end
164
+
165
+ def set_relative_pdf_path(path)
166
+ rel_path = path.nil? ? "." : path
167
+ Pathname(rel_path)
168
+ end
169
+
170
+
171
+ def relative_pdf_path=(path)
172
+ @relative_pdf_path = set_relative_path(path)
173
+ end
174
+
175
+
176
+
177
+ end
178
+ end
179
+
180
+ module Microstation
181
+
182
+ class Drawing
183
+
184
+ class File
185
+
186
+ include PdfSupport
187
+
188
+ attr_reader :keywords, :creator, :path
189
+
190
+ def self.from_drawing(drawing)
191
+ file = new(drawing.path)
192
+ file.get_meta(drawing)
193
+ file
194
+ end
195
+
196
+ def to_path
197
+ @path.to_path
198
+ end
199
+
200
+
201
+ def initialize(path)
202
+ @path = Pathname(path)
203
+ end
204
+
205
+ def basename
206
+ @path.basename
207
+ end
208
+
209
+ def dirname
210
+ @path.dirname
211
+ end
212
+
213
+ def drawing=(drawing)
214
+ @drawing = drawing
215
+ end
216
+
217
+ def mtime
218
+ self.path.mtime
219
+ end
220
+
221
+ def title
222
+ @title ||= get_meta
223
+ end
224
+
225
+ def app_open_drawing(app, &block)
226
+ draw = app.open_drawing(self.path,&block)
227
+ end
228
+
229
+ def open_drawing(&block)
230
+ Microstation.open_drawing(self.path,&block)
231
+ end
232
+
233
+ def get_meta(dwg)
234
+ @title = dwg.title
235
+ @keywords = dwg.keywords
236
+ @creator = dwg.creator
237
+ end
238
+
239
+ end
240
+
241
+
242
+ end
243
+ end
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+