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.
- checksums.yaml +7 -0
- data/.autotest +23 -23
- data/.rspec +2 -2
- data/Gemfile +28 -10
- data/History.txt +6 -6
- data/LICENSE.adoc +22 -0
- data/Manifest.txt +81 -60
- data/README.adoc +131 -0
- data/Rakefile +71 -30
- data/bin/dgn2pdf +36 -37
- data/bin/dgn_template +107 -0
- data/bin/microstation +231 -0
- data/bin/pw_print +35 -0
- data/cad_files/drawing_faatitle_in_non_default_model.dgn +0 -0
- data/cad_files/drawing_no_block.dgn +0 -0
- data/cad_files/drawing_with_3_block.dgn +0 -0
- data/cad_files/drawing_with_block.dgn +0 -0
- data/cad_files/seed2d.dgn +0 -0
- data/cad_files/test.dgn +0 -0
- data/lib/microstation.rb +252 -88
- data/lib/microstation/app.rb +781 -286
- data/lib/microstation/cad_input_queue.rb +100 -25
- data/lib/microstation/cell.rb +191 -0
- data/lib/microstation/changer.rb +70 -0
- data/lib/microstation/configuration.rb +193 -57
- data/lib/microstation/criteria_creation_t.rb +23 -0
- data/lib/microstation/dir.rb +252 -252
- data/lib/microstation/directory.rb +46 -0
- data/lib/microstation/drawing.rb +690 -189
- data/lib/microstation/element.rb +311 -0
- data/lib/microstation/enumerator.rb +32 -29
- data/lib/microstation/errors.rb +17 -0
- data/lib/microstation/event_handler.rb +28 -0
- data/lib/microstation/ext/pathname.rb +23 -25
- data/lib/microstation/ext/win32ole.rb +7 -0
- data/lib/microstation/extensions/faa.rb +124 -0
- data/lib/microstation/file_tests.rb +68 -0
- data/lib/microstation/functions.rb +60 -0
- data/lib/microstation/graphics.rb +35 -0
- data/lib/microstation/line.rb +19 -0
- data/lib/microstation/model.rb +45 -0
- data/lib/microstation/model_trait.rb +189 -0
- data/lib/microstation/ole_cad_input_message.rb +101 -0
- data/lib/microstation/ole_helper.rb +152 -0
- data/lib/microstation/pdf_support.rb +40 -40
- data/lib/microstation/point3d.rb +71 -0
- data/lib/microstation/primitive_command_interface.rb +66 -0
- data/lib/microstation/properties.rb +61 -57
- data/lib/microstation/property_handler.rb +48 -0
- data/lib/microstation/scan/color.rb +38 -38
- data/lib/microstation/scan/criteria.rb +89 -85
- data/lib/microstation/scan/klass.rb +43 -43
- data/lib/microstation/scan/level.rb +38 -38
- data/lib/microstation/scan/line_style.rb +45 -45
- data/lib/microstation/scan/line_weight.rb +33 -33
- data/lib/microstation/scan/range.rb +19 -0
- data/lib/microstation/scan/scan_trait.rb +51 -0
- data/lib/microstation/scan/subtype.rb +40 -40
- data/lib/microstation/scan/type.rb +134 -109
- data/lib/microstation/scan_trait.rb +62 -0
- data/lib/microstation/scanner.rb +24 -24
- data/lib/microstation/tag.rb +87 -58
- data/lib/microstation/tag_set.rb +385 -280
- data/lib/microstation/tag_set_trait.rb +51 -0
- data/lib/microstation/tagged_element.rb +105 -0
- data/lib/microstation/template.rb +90 -84
- data/lib/microstation/template_info.rb +172 -0
- data/lib/microstation/template_runner.rb +65 -0
- data/lib/microstation/text.rb +79 -54
- data/lib/microstation/text_node.rb +124 -74
- data/lib/microstation/ts/attribute.rb +140 -139
- data/lib/microstation/ts/instance.rb +146 -112
- data/lib/microstation/ts/tagset_trait.rb +49 -0
- data/lib/microstation/types.rb +91 -91
- data/lib/microstation/version.rb +5 -0
- data/lib/microstation/wrap.rb +28 -214
- data/plot/pdf-bw.plt +164 -164
- data/plot/pdf.plt +163 -163
- data/plot/png.plt +383 -383
- data/plot/tiff.plt +384 -384
- data/plot/wmbw.tbl +324 -66
- data/plot/wmcolor.tbl +62 -62
- metadata +301 -86
- data/.gemtest +0 -0
- data/README.txt +0 -75
- data/lib/microstation/attributes.rb +0 -35
- data/lib/microstation/extensions/hash.rb +0 -27
- data/spec/app_spec.rb +0 -267
- data/spec/configuration_spec.rb +0 -122
- data/spec/drawing_spec.rb +0 -247
- data/spec/drawings/new_drawing.dgn +0 -0
- data/spec/drawings/test.dgn +0 -0
- data/spec/drawings/test1.dgn +0 -0
- data/spec/drawings/testfile.pdf +0 -0
- data/spec/enumerator_spec.rb +0 -60
- data/spec/microstation_spec.rb +0 -36
- data/spec/scanner_spec.rb +0 -155
- data/spec/spec_app.rb +0 -11
- data/spec/spec_helper.rb +0 -31
- data/spec/tag_set_spec.rb +0 -123
- data/spec/text_node_spec.rb +0 -92
- data/spec/text_spec.rb +0 -62
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require_relative 'criteria_creation_t'
|
|
2
|
+
module Microstation
|
|
3
|
+
|
|
4
|
+
module ScanTrait
|
|
5
|
+
|
|
6
|
+
def create_scanner(name,&block)
|
|
7
|
+
app.create_scanner(name, &block)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def text_criteria
|
|
11
|
+
app.scanners[:textual] || app.create_scanner(:textual){ include_textual}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def graphics_criteria
|
|
15
|
+
app.scanners[:graphical] || app.create_scanner(:graphical){ ExcludeNonGraphical}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def tags_criteria
|
|
19
|
+
app.scanners[:tags] || app.create_scanner(:tags){ include_tags}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def cells_criteria
|
|
23
|
+
app.scanners[:cells] || app.create_scanner(:cells){ include_cells}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def lines_criteria
|
|
27
|
+
app.scanners[:lines] || app.create_scanner(:lines){ include_lines}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def scan_graphical(&block)
|
|
31
|
+
self.scan_model(graphic_criteria, &block)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def scan_text(&block)
|
|
35
|
+
self.scan_model(text_criteria,&block)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def scan_tags(&block)
|
|
39
|
+
self.scan_model(tags_criteria,&block)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def scan_cells(&block)
|
|
43
|
+
self.scan_model(cells_criteria,&block)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def scan_lines(&block)
|
|
47
|
+
self.scan_model(lines_criteria, &block)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def scan_cell_with_name(name, &block)
|
|
52
|
+
sc = create_scanner
|
|
53
|
+
sc.IncludeOnlyCell(name)
|
|
54
|
+
sc.include_cell
|
|
55
|
+
self.scan_model(sc,&block)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
data/lib/microstation/scanner.rb
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
module Microstation
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class Scanner
|
|
5
|
-
|
|
6
|
-
attr_reader :app
|
|
7
|
-
|
|
8
|
-
def initialize(app)
|
|
9
|
-
@app = app
|
|
10
|
-
@ole_obj = @app.create_ole_scanner
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
private
|
|
14
|
-
|
|
15
|
-
def ole_obj
|
|
16
|
-
@ole_obj
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
end
|
|
1
|
+
module Microstation
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Scanner
|
|
5
|
+
|
|
6
|
+
attr_reader :app
|
|
7
|
+
|
|
8
|
+
def initialize(app)
|
|
9
|
+
@app = app
|
|
10
|
+
@ole_obj = @app.create_ole_scanner
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def ole_obj
|
|
16
|
+
@ole_obj
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
end
|
data/lib/microstation/tag.rb
CHANGED
|
@@ -1,58 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def
|
|
15
|
-
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
require_relative 'tagged_element'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
module Microstation
|
|
6
|
+
|
|
7
|
+
class Tag < Element
|
|
8
|
+
|
|
9
|
+
# def initialize(ole)
|
|
10
|
+
# @ole_obj = ole
|
|
11
|
+
# @original = @ole_obj.Value
|
|
12
|
+
# end
|
|
13
|
+
|
|
14
|
+
def read_ole(ole)
|
|
15
|
+
ole.Value
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def write_ole(value)
|
|
19
|
+
value = value.nil? ? "" : value
|
|
20
|
+
ole_obj.Value = value
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def ole_value
|
|
25
|
+
@ole_obj.Value
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def name
|
|
29
|
+
@ole_obj.TagDefinitionName
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def inspect
|
|
34
|
+
"#{name}: #{value} ts ->#{tagset_name}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def to_s
|
|
38
|
+
"#{value}"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def value
|
|
42
|
+
@original
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def tagset
|
|
46
|
+
@ole_obj.TagSetName
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def tagset_name
|
|
50
|
+
@ole_obj.TagSetName
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def update_ole(value)
|
|
54
|
+
value = value.nil? ? "" : value
|
|
55
|
+
@ole_obj.Value = value
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def base_element=(ele)
|
|
59
|
+
@base_element = ele
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def ole_base_element
|
|
63
|
+
@ole_obj.BaseElement
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def base_element_id
|
|
67
|
+
base = ole_base_element
|
|
68
|
+
id = base.Id || base.ID64 rescue nil
|
|
69
|
+
if id.class == WIN32OLE_RECORD
|
|
70
|
+
if id.Low > id.High
|
|
71
|
+
return id.Low
|
|
72
|
+
else
|
|
73
|
+
return id.High
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
id
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def base_element
|
|
80
|
+
@base_element ||= TaggedElement.new(ole_base_element)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
end
|
data/lib/microstation/tag_set.rb
CHANGED
|
@@ -1,280 +1,385 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__) , 'attributes')
|
|
2
|
-
require File.join(File.dirname(__FILE__), 'ts/instance')
|
|
3
|
-
require File.join(File.dirname(__FILE__), 'ts/attribute')
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def initialize(
|
|
10
|
-
@ole_obj = ole
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
ts
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def
|
|
79
|
-
tagsets
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
@
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
def
|
|
187
|
-
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
#
|
|
206
|
-
#
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
def
|
|
236
|
-
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
@
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
1
|
+
#require File.join(File.dirname(__FILE__) , 'attributes')
|
|
2
|
+
require File.join(File.dirname(__FILE__), 'ts/instance')
|
|
3
|
+
require File.join(File.dirname(__FILE__), 'ts/attribute')
|
|
4
|
+
|
|
5
|
+
module Microstation
|
|
6
|
+
|
|
7
|
+
module OleCollection
|
|
8
|
+
|
|
9
|
+
def initialize(ole_col)
|
|
10
|
+
@ole_obj = ole
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def [](name)
|
|
14
|
+
ole_obj(name) rescue nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def each
|
|
18
|
+
@ole_obj.each do |ts|
|
|
19
|
+
yield wrap(ts)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def wrap(ts)
|
|
24
|
+
ts
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class TagSets
|
|
31
|
+
include Enumerable
|
|
32
|
+
|
|
33
|
+
attr_reader :drawing, :ole_obj
|
|
34
|
+
|
|
35
|
+
def initialize(drawing,ole)
|
|
36
|
+
raise if ole == nil
|
|
37
|
+
@drawing = drawing
|
|
38
|
+
@ole_obj = ole
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def init_ts
|
|
42
|
+
result = []
|
|
43
|
+
@ole_obj.each do |ts|
|
|
44
|
+
result << TagSet.new(drawing,ts)
|
|
45
|
+
end
|
|
46
|
+
result
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def to_s
|
|
50
|
+
"Tagsets: #{tagsets.to_s}"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def reset
|
|
54
|
+
@tagsets = nil
|
|
55
|
+
@drawing.reset_tagset_instances
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def names
|
|
59
|
+
self.map{|ts| ts.name}
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def tagsets
|
|
64
|
+
@tagsets ||= init_ts
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def each
|
|
68
|
+
tagsets.each do |obj|
|
|
69
|
+
yield obj
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def find(name)
|
|
74
|
+
return nil if empty?
|
|
75
|
+
tagsets.detect{|ts| ts.name == name}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def last
|
|
79
|
+
tagsets[-1]
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def [](name)
|
|
83
|
+
find(name)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def remove(name)
|
|
87
|
+
ts = find(name)
|
|
88
|
+
if ts
|
|
89
|
+
@ole_obj.Remove(name) rescue nil
|
|
90
|
+
ts.close
|
|
91
|
+
ts = nil
|
|
92
|
+
end
|
|
93
|
+
reset
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def empty?
|
|
97
|
+
tagsets.empty?
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def create(name)
|
|
101
|
+
raise if self[name]
|
|
102
|
+
|
|
103
|
+
ole = @ole_obj.add(name) rescue binding.pry
|
|
104
|
+
# ts = Tagset.new(ole)
|
|
105
|
+
# yield definer if block_given?
|
|
106
|
+
reset
|
|
107
|
+
ts = self[name]
|
|
108
|
+
raise if ts.nil?
|
|
109
|
+
yield ts if block_given?
|
|
110
|
+
ts
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def size
|
|
114
|
+
tagsets.size
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# class Definer
|
|
120
|
+
|
|
121
|
+
# attr_reader :tagset
|
|
122
|
+
|
|
123
|
+
# def initialize(tagset)
|
|
124
|
+
# @tagset = tagset
|
|
125
|
+
# end
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# def add_attribute(name,type,prompt: name, is_hidden: false, is_constant: false, default: nil)
|
|
129
|
+
# ole_td = create_ole_definition(name, type)
|
|
130
|
+
# td = TS::Attribute.new(ole_td)
|
|
131
|
+
# td.prompt = prompt
|
|
132
|
+
# td.hidden = is_hidden
|
|
133
|
+
# td.constant = is_constant
|
|
134
|
+
# td.default = default
|
|
135
|
+
# #td.hidden = td.fetch(:is_hidden)
|
|
136
|
+
# yield td if block_given?
|
|
137
|
+
# td
|
|
138
|
+
# end
|
|
139
|
+
|
|
140
|
+
# private
|
|
141
|
+
|
|
142
|
+
# def tag_definitions
|
|
143
|
+
# tagset.ole_tag_definitions
|
|
144
|
+
# end
|
|
145
|
+
|
|
146
|
+
# def close
|
|
147
|
+
|
|
148
|
+
# end
|
|
149
|
+
|
|
150
|
+
# def ole_type(type)
|
|
151
|
+
# TS::Attribute.tag_type(type)
|
|
152
|
+
# end
|
|
153
|
+
|
|
154
|
+
# def create_ole_definition(name,type)
|
|
155
|
+
# tag_definitions.Add(name,ole_type(type))
|
|
156
|
+
# end
|
|
157
|
+
|
|
158
|
+
# end
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class Definition
|
|
163
|
+
|
|
164
|
+
attr_reader :tagset
|
|
165
|
+
|
|
166
|
+
def initialize(tagset)
|
|
167
|
+
@tagset = tagset
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def add_attribute(*args, **kwargs)
|
|
171
|
+
td = create_attribute(*args, **kwargs)
|
|
172
|
+
yield td if block_given?
|
|
173
|
+
reset
|
|
174
|
+
td
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# def definer
|
|
178
|
+
# @definer ||= Definer.new(tagset)
|
|
179
|
+
# end
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def attributes
|
|
183
|
+
@attributes ||= init_definitions
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def attribute_names
|
|
187
|
+
attributes.map{|a| a.name}
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def reset
|
|
191
|
+
@attributes = nil
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def close
|
|
195
|
+
attributes.each{| a| a.close}
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def [](name)
|
|
199
|
+
attributes.find{|d| d.name == name}
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
protected
|
|
203
|
+
|
|
204
|
+
# def ole_tag_definitions
|
|
205
|
+
# tagset.ole_tag_definitions
|
|
206
|
+
# end
|
|
207
|
+
|
|
208
|
+
def ole_tag_definitions
|
|
209
|
+
@tagset.ole_obj.TagDefinitions
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def create_ole_definition(name,type)
|
|
213
|
+
ole_tag_definitions.Add(name,ole_type(type))
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def init_definitions
|
|
217
|
+
results = []
|
|
218
|
+
ole_tag_definitions.each do |ole|
|
|
219
|
+
results << TS::Attribute.new(ole, {definer: self})
|
|
220
|
+
end
|
|
221
|
+
results
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def create_attribute(name,type,prompt: name, is_hidden: false, is_constant: false, default: nil)
|
|
225
|
+
ole_td = create_ole_definition(name, type)
|
|
226
|
+
td = TS::Attribute.new(ole_td)
|
|
227
|
+
td.prompt = prompt
|
|
228
|
+
td.hidden = is_hidden
|
|
229
|
+
td.constant = is_constant
|
|
230
|
+
td.default = default
|
|
231
|
+
yield td if block_given?
|
|
232
|
+
td
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def ole_type(type)
|
|
236
|
+
TS::Attribute.tag_type(type)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
class TagSet
|
|
242
|
+
|
|
243
|
+
attr_reader :ole_obj
|
|
244
|
+
|
|
245
|
+
attr_reader :instances, :drawing
|
|
246
|
+
|
|
247
|
+
def initialize(drawing,ole)
|
|
248
|
+
@drawing = drawing
|
|
249
|
+
@ole_obj = ole
|
|
250
|
+
@instances = nil
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def add_attribute(name,type,**options, &block)
|
|
254
|
+
ts = definition.add_attribute(name,type,**options, &block)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# def definer
|
|
258
|
+
# @definer ||= Definer.new(self)
|
|
259
|
+
# end
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def add_instance(array)
|
|
264
|
+
@instances << TS::Instance.new(self,array)
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def create_instance(base_element_id , tags , model )
|
|
268
|
+
if @instaces.nil?
|
|
269
|
+
@instance = []
|
|
270
|
+
ti = TS::Instances.new(self, base_element_id, tags, model)
|
|
271
|
+
@instances << ti
|
|
272
|
+
ti
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
def create_instance(id, elements, model)
|
|
277
|
+
if @instances.nil?
|
|
278
|
+
@instances = []
|
|
279
|
+
end
|
|
280
|
+
ti = TS::Instance.new(self,id,elements,model)
|
|
281
|
+
@instances << ti
|
|
282
|
+
ti
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
# def instances(drawing = Microstation.app.current_drawing)
|
|
286
|
+
# @instances = create_instances(drawing.scan_tags)
|
|
287
|
+
# end
|
|
288
|
+
|
|
289
|
+
# def find_instances_in_model(model)
|
|
290
|
+
# result = create_instances(model.scan_tags)
|
|
291
|
+
# instances[model.name] = result
|
|
292
|
+
# result
|
|
293
|
+
# end
|
|
294
|
+
|
|
295
|
+
def instances
|
|
296
|
+
if @instances.nil? && find_tagset_instances_not_called?
|
|
297
|
+
@instances = @drawing.create_tagset_instances( ts_name: name).to_a
|
|
298
|
+
end
|
|
299
|
+
raise if find_tagset_instances_not_called?
|
|
300
|
+
@instances.nil? ? [] : @instances
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
# def create_instances_from_drawing(drawing)
|
|
307
|
+
# mytags = tags_for_self(tags)
|
|
308
|
+
# grouped = grouped_tags_to_host(mytags)
|
|
309
|
+
# grouped.map{|group| create_instance(group)}
|
|
310
|
+
# end
|
|
311
|
+
|
|
312
|
+
# def all_tags_in_drawing
|
|
313
|
+
# Microstation.app.current_drawing.scan_tags
|
|
314
|
+
# end
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
def close
|
|
318
|
+
@ole_obj = nil
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
def name
|
|
322
|
+
@ole_obj.name
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
def to_s
|
|
326
|
+
"TagSet: #{name}"
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
def ==(other)
|
|
330
|
+
@ole_obj == other.ole_obj
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
def attribute_names
|
|
334
|
+
definition.attribute_names
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
def attributes
|
|
338
|
+
definition.attributes
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
def [](name)
|
|
342
|
+
definition[name]
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
protected
|
|
346
|
+
|
|
347
|
+
def definition
|
|
348
|
+
@definition ||= Definition.new(self)
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
def reset
|
|
352
|
+
@tag_definitions = nil
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def find_tagset_instances_not_called?
|
|
357
|
+
!drawing.find_tagset_instances_called?
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
# def create_ole_definition(name,type)
|
|
362
|
+
# ole_tag_definitions.Add(name, ole_type(type))
|
|
363
|
+
# end
|
|
364
|
+
|
|
365
|
+
private
|
|
366
|
+
|
|
367
|
+
# protected
|
|
368
|
+
|
|
369
|
+
# def tags_for_self(tags)
|
|
370
|
+
# tags.select{|t| t.tagset_name == name}
|
|
371
|
+
# end
|
|
372
|
+
|
|
373
|
+
# def grouped_tags_to_host(tags)
|
|
374
|
+
# tags.group_by{|t| t.base_element_id}
|
|
375
|
+
# end
|
|
376
|
+
|
|
377
|
+
# def ole_tag_definitions
|
|
378
|
+
# @ole_obj.TagDefinitions
|
|
379
|
+
# end
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
end
|