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,124 @@
|
|
|
1
|
+
module Microstation
|
|
2
|
+
class Drawing
|
|
3
|
+
class Number
|
|
4
|
+
end
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
module Microstation
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Drawing
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def number
|
|
17
|
+
binding.pry
|
|
18
|
+
Drawing::Number.from_string(self.basename)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class Number
|
|
22
|
+
|
|
23
|
+
DRAWING_RE = /(.+)-.+-(.+)-(.+).dgn/
|
|
24
|
+
|
|
25
|
+
def self.from_string(drawing_name)
|
|
26
|
+
md = DRAWING_RE.match(drawing_name.to_s)
|
|
27
|
+
new(md[1],md[2],md[3])
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def Index(str)
|
|
32
|
+
return str if str == Drawing::Index
|
|
33
|
+
Drawing::Index.new(str.to_s)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
attr_reader :locid, :factype, :index
|
|
39
|
+
|
|
40
|
+
def initialize(locid,factype, index)
|
|
41
|
+
@locid = locid.to_s.upcase
|
|
42
|
+
@factype = factype.to_s.upcase
|
|
43
|
+
@index = Index(index)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def to_s
|
|
49
|
+
[locid,'D',factype,index.to_s].join("-")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def discipline
|
|
53
|
+
index.discipline
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def +(n)
|
|
57
|
+
self.class.new(locid,factype,index.+(n))
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def -(n)
|
|
61
|
+
self.class.new(locid,factype,index.-(n))
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class Index
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def initialize(str)
|
|
72
|
+
return str if str === Index
|
|
73
|
+
@nbr = str
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def discipline
|
|
77
|
+
@nbr[0].upcase
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def digits
|
|
81
|
+
@nbr[1..-1]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def to_s
|
|
85
|
+
combined_string(digits_string)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def as_int
|
|
89
|
+
digits.to_i
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def digits_string(n = digits)
|
|
93
|
+
"%03d" % n
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def combined_string(dstring)
|
|
97
|
+
"#{discipline}#{dstring}"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def +(n)
|
|
101
|
+
self.class.new( combined_string( digits_string(as_int + n)))
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def -(n)
|
|
106
|
+
self.class.new( combined_string( digits_string(as_int - n)))
|
|
107
|
+
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def succ
|
|
111
|
+
self.+(1)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def pred
|
|
115
|
+
self.-(1)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
module Microstation
|
|
2
|
+
|
|
3
|
+
module FileTests
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def microstation_drawing?(f)
|
|
7
|
+
f = f.to_path if f.respond_to? :to_path
|
|
8
|
+
f = f.to_str
|
|
9
|
+
File.file?(f) && File.extname(f) == '.dgn'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def drawing?(f)
|
|
13
|
+
f = f.to_path if f.respond_to? :to_path
|
|
14
|
+
f = f.to_str
|
|
15
|
+
File.file?(f) && drawing_type?(f)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def drawing_type?(f)
|
|
20
|
+
f = f.to_path if f.respond_to? :to_path
|
|
21
|
+
f = f.to_str
|
|
22
|
+
ext = File.extname(f)
|
|
23
|
+
ext == '.dwg' || ext == '.dgn'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def check_is_drawing(f)
|
|
27
|
+
raise ArgumentError, 'File must be a dgn or dwg file' unless drawing?(f)
|
|
28
|
+
end
|
|
29
|
+
def check_is_dgn(f)
|
|
30
|
+
raise ArgumentError, 'File must be a dgn file' unless microstation_drawing?(f)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if $0 == __FILE__
|
|
38
|
+
|
|
39
|
+
class Test
|
|
40
|
+
|
|
41
|
+
include Microstation::FileChecks
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
module Microstation
|
|
47
|
+
|
|
48
|
+
class Test2
|
|
49
|
+
|
|
50
|
+
include FileChecks
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
t = Test.new
|
|
57
|
+
t2 = Microstation::Test2.new
|
|
58
|
+
|
|
59
|
+
def check_type(c,c2,f)
|
|
60
|
+
puts "c.drawing_type?(#{f}) == #{c.drawing_type?(f)}"
|
|
61
|
+
puts "c2.drawing_type?(#{f}) == #{c2.drawing_type?(f)}"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
%w( doc.pdf doc.doc doc.rtf doc.dgn doc.dwg doc.rb).each do |f|
|
|
65
|
+
check_type(t,t2,f)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'dry/monads'
|
|
2
|
+
module Microstation
|
|
3
|
+
|
|
4
|
+
class App
|
|
5
|
+
include Dry::Monads[:result]
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module Functions
|
|
9
|
+
|
|
10
|
+
extend Dry::Monads[:result]
|
|
11
|
+
|
|
12
|
+
def get_points_by_rectangle
|
|
13
|
+
queue = cad_input_queue
|
|
14
|
+
queue.show_command('Get points by block')
|
|
15
|
+
start_point = queue.get_point
|
|
16
|
+
if start_point.failure?
|
|
17
|
+
return Failure(:point1_reset)
|
|
18
|
+
end
|
|
19
|
+
queue.send_command "PLACE BLOCK"
|
|
20
|
+
queue.send_data_point start_point.value!
|
|
21
|
+
end_point = queue.get_point
|
|
22
|
+
if end_point.failure?
|
|
23
|
+
return Failure(:point2_reset)
|
|
24
|
+
end
|
|
25
|
+
Success([start_point.value!, end_point.value!])
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def get_points_by_line
|
|
29
|
+
queue = cad_input_queue
|
|
30
|
+
queue.show_command("Get points by line")
|
|
31
|
+
start_point = queue.get_point
|
|
32
|
+
if start_point.failure?
|
|
33
|
+
return Failure(:point1_reset)
|
|
34
|
+
end
|
|
35
|
+
queue.send_command "PLACE LINE"
|
|
36
|
+
queue.send_data_point start_point.value!
|
|
37
|
+
end_point = queue.get_point("Enter next vertex")
|
|
38
|
+
if end_point.failure?
|
|
39
|
+
return Failure(:point2_reset)
|
|
40
|
+
end
|
|
41
|
+
Success([start_point.value!, end_point.value!])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def clear_ui
|
|
45
|
+
cad_input_queue.clear_ui
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def get_point
|
|
49
|
+
cad_input_queue.get_point
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class App
|
|
57
|
+
include Functions
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Microstation
|
|
2
|
+
|
|
3
|
+
module Graphics
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def line(p1,p2,el = WIN32OLE_VARIANT::Nothing)
|
|
7
|
+
pt1 = app.to_ole_point3d(p1)
|
|
8
|
+
pt2 = app.to_ole_point3d(p2)
|
|
9
|
+
begin
|
|
10
|
+
ole = app.ole_obj.CreateLineElement2(el,pt1,pt2)
|
|
11
|
+
rescue Exception => ex
|
|
12
|
+
binding.pry
|
|
13
|
+
return nil
|
|
14
|
+
end
|
|
15
|
+
add_element(ole) if ole
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def line_from_pts(pts, el = WIN32OLE_VARIANT::Nothing)
|
|
20
|
+
ole_points = pts.map{ |pt| app.to_ole_point3d(pt) }
|
|
21
|
+
ole = app.ole_obj.CreateLineElement1(el, ole_points)
|
|
22
|
+
if ole
|
|
23
|
+
add_element(ole)
|
|
24
|
+
else
|
|
25
|
+
binding.pry
|
|
26
|
+
end
|
|
27
|
+
rescue Exception => e
|
|
28
|
+
binding.pry
|
|
29
|
+
return nil
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'microstation/element'
|
|
2
|
+
|
|
3
|
+
module Microstation
|
|
4
|
+
|
|
5
|
+
class Line < Element
|
|
6
|
+
|
|
7
|
+
def length
|
|
8
|
+
ole_obj.Length
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def vertices
|
|
13
|
+
ole_obj.AsVertexList
|
|
14
|
+
n = ole_obj.VerticesCount
|
|
15
|
+
list = ole_obj.GetVertices
|
|
16
|
+
list
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#require_relative 'scan/scan_trait'
|
|
2
|
+
require 'microstation/wrap'
|
|
3
|
+
require_relative 'model_trait'
|
|
4
|
+
|
|
5
|
+
#require_relative 'ts/tagset_trait'
|
|
6
|
+
#require_relative 'graphics'
|
|
7
|
+
#require_relative 'ts/instance'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
module Microstation
|
|
11
|
+
|
|
12
|
+
class DefaultModel
|
|
13
|
+
|
|
14
|
+
include ::Microstation::ModelTrait
|
|
15
|
+
|
|
16
|
+
attr_reader :app,:ole_obj
|
|
17
|
+
|
|
18
|
+
def initialize(app,ole)
|
|
19
|
+
@app = app
|
|
20
|
+
@ole_obj = ole
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def drawing
|
|
24
|
+
@drawing ||= ::Microstation::Drawing.from_ole_obj(app,ole_obj)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Model
|
|
32
|
+
|
|
33
|
+
include ::Microstation::ModelTrait
|
|
34
|
+
|
|
35
|
+
attr_reader :app,:drawing,:ole_obj
|
|
36
|
+
|
|
37
|
+
def initialize(app,drawing,ole)
|
|
38
|
+
@app = app
|
|
39
|
+
@drawing = drawing
|
|
40
|
+
@ole_obj = ole
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
require_relative 'graphics'
|
|
2
|
+
require_relative 'scan_trait'
|
|
3
|
+
|
|
4
|
+
module Microstation
|
|
5
|
+
module ModelTrait
|
|
6
|
+
|
|
7
|
+
include Graphics
|
|
8
|
+
|
|
9
|
+
include ScanTrait
|
|
10
|
+
# include TS::TagSetTrait
|
|
11
|
+
|
|
12
|
+
def name
|
|
13
|
+
ole_obj.name
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def find_by_id(id)
|
|
17
|
+
ele = ole_obj.GetElementById64(id) rescue nil
|
|
18
|
+
return nil unless ele
|
|
19
|
+
app.ole_to_ruby(ele)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def active?
|
|
23
|
+
ole_obj.IsActive
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get_selected_elements
|
|
27
|
+
Enumerator.new(ole_obj.GetSelectedElements,app)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def get_selected_text
|
|
31
|
+
get_selected_elements.select{|t| t.textual?}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def get_matching_text(re)
|
|
35
|
+
result = []
|
|
36
|
+
get_selected_text.each do |t|
|
|
37
|
+
md = re.match( t)
|
|
38
|
+
if md
|
|
39
|
+
if block_given?
|
|
40
|
+
yield t,md
|
|
41
|
+
else
|
|
42
|
+
result << t
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
result
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def change_text_suffix(reg,offset)
|
|
50
|
+
get_matching_text(reg) do |t,md|
|
|
51
|
+
pre = md[1]
|
|
52
|
+
suff = Integer( md[2] ) + offset
|
|
53
|
+
t.replace "#{pre}#{suff}"
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def unselect_element(el)
|
|
58
|
+
ole_obj.UnselectElement(el.ole_obj)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def select_element(el)
|
|
62
|
+
ole_obj.SelectElement(el.ole_obj)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def readonly?
|
|
66
|
+
ole_obj.IsReadOnly
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def activate
|
|
70
|
+
ole_obj.Activate
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def locked?
|
|
74
|
+
ole_obj.IsLocked?
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def to_s
|
|
78
|
+
"Microstation::Model-#{name}"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def add_element(el)
|
|
83
|
+
if el.respond_to? :ole_obj
|
|
84
|
+
el = el.ole_obj
|
|
85
|
+
ole_obj.AddElement(el)
|
|
86
|
+
self
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def select_tagset_instances
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def scan_tags_filtered( ts_name: nil, base_element_id: nil,&block)
|
|
95
|
+
case [ts_name, base_element_id]
|
|
96
|
+
in [nil, nil]
|
|
97
|
+
scan_tags(&block)
|
|
98
|
+
in [String,nil]
|
|
99
|
+
scan_tags.select{ |t| t.tagset_name == ts_name }
|
|
100
|
+
in [String, Numeric]
|
|
101
|
+
scan_tags.select{ |t| t.tagset_name == ts_name && t.base_element_id == base_element_id }
|
|
102
|
+
in [nil, Numeric]
|
|
103
|
+
scan_tags.select{ |t| t.base_element_id == base_element_id }
|
|
104
|
+
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def tags_to_hash(tags)
|
|
109
|
+
return to_enum(__callee__,tags) unless block_given?
|
|
110
|
+
tsets = tags.group_by{ |t| t.tagset_name }
|
|
111
|
+
tsets.each do |tsname, tags|
|
|
112
|
+
elements = tags.group_by{|t| t.base_element_id}
|
|
113
|
+
elements.each do |id, tag_elts|
|
|
114
|
+
result_hash = {
|
|
115
|
+
name: tsname,
|
|
116
|
+
model: name,
|
|
117
|
+
tags: tag_elts,
|
|
118
|
+
base_element_id: id,
|
|
119
|
+
}
|
|
120
|
+
yield result_hash
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def get_tagsets_in_model_hash(ts_name: nil, base_element_id: nil,&block)
|
|
126
|
+
tags = scan_tags_filtered(ts_name: ts_name, base_element_id: base_element_id)
|
|
127
|
+
tags_to_hash(tags, &block)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def get_tagsets_in_model_hash_old
|
|
131
|
+
results = []
|
|
132
|
+
tsets = scan_tags.group_by{|t| t.tagset_name}
|
|
133
|
+
tsets.each do |tsname, tags|
|
|
134
|
+
elements = tags.group_by{|t| t.base_element_id}
|
|
135
|
+
elements.each do |id, tag_elts|
|
|
136
|
+
result_hash = {
|
|
137
|
+
name: tsname,
|
|
138
|
+
model: name,
|
|
139
|
+
tags: tag_elts,
|
|
140
|
+
base_element_id: id,
|
|
141
|
+
}
|
|
142
|
+
if block_given?
|
|
143
|
+
yield result_hash
|
|
144
|
+
else
|
|
145
|
+
results << result_hash
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
results unless block_given?
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# Scan the model with
|
|
155
|
+
# @param [Scan::Criteria] criteria - the criteria to scan
|
|
156
|
+
# @yield the item
|
|
157
|
+
def scan_model(criteria=nil)
|
|
158
|
+
# binding.pry
|
|
159
|
+
criteria = criteria || create_scanner(:nullscanner)
|
|
160
|
+
scan_result = ole_run_scan(criteria)
|
|
161
|
+
return [] unless scan_result
|
|
162
|
+
# binding.pry
|
|
163
|
+
scan_enum = ::Microstation::Enumerator.new(scan_result, app)
|
|
164
|
+
result = []
|
|
165
|
+
if block_given?
|
|
166
|
+
scan_enum.each do |item|
|
|
167
|
+
yield item
|
|
168
|
+
end
|
|
169
|
+
else
|
|
170
|
+
scan_enum.each do |item|
|
|
171
|
+
result << item
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
return result unless block_given?
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
private
|
|
180
|
+
|
|
181
|
+
def ole_run_scan(criteria)
|
|
182
|
+
criteria.resolve
|
|
183
|
+
scan_result = self.ole_obj.Scan(criteria.ole_obj) rescue nil
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
end
|