microstation 0.8.6 → 0.8.7

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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +26 -29
  3. data/Rakefile +45 -45
  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 +53 -68
  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 +26 -12
@@ -1,21 +1,18 @@
1
- require 'microstation/property_handler'
1
+ require "microstation/property_handler"
2
2
 
3
3
  class WIN32OLE
4
-
5
4
  def to_ole
6
5
  self
7
6
  end
8
-
9
7
  end
8
+
10
9
  module Microstation
11
10
  end
12
11
 
13
12
  module Microstation
14
-
15
13
  module ElementTrait
16
-
17
14
  #
18
- #
15
+ #
19
16
  #
20
17
  # @return [Boolean] true if ole type is Text
21
18
  #
@@ -25,7 +22,7 @@ module Microstation
25
22
 
26
23
  # @return [Boolean] true if ole type is TextNode
27
24
  def text_node?
28
- ole_obj.Type == ::Microstation::MSD::MsdElementTypeTextNode
25
+ ole_obj.Type == ::Microstation::MSD::MsdElementTypeTextNode
29
26
  end
30
27
 
31
28
  def has_tags?
@@ -49,9 +46,10 @@ module Microstation
49
46
  text? || text_node?
50
47
  end
51
48
 
52
- def microstation_id()
49
+ def microstation_id
53
50
  id = ole_obj.Id || ole_obj.ID64
54
51
  return nil unless id
52
+
55
53
  id_from_record(id)
56
54
  end
57
55
 
@@ -67,18 +65,16 @@ module Microstation
67
65
  def parent
68
66
  parent_id = ole_obj.ParentID
69
67
  return nil unless parent_id
68
+
70
69
  id = id_from_record(parent_id)
71
70
  app.active_design_file.find_by_id(id)
72
71
  end
73
72
 
74
73
  def id_from_record(id)
75
- if id.class == WIN32OLE_RECORD
76
- if id.Low > id.High
77
- return id.Low
78
- else
79
- return id.High
80
- end
81
- end
74
+ return unless id.instance_of?(WIN32OLE_RECORD)
75
+ return id.Low if id.Low > id.High
76
+
77
+ id.High
82
78
  end
83
79
 
84
80
  def select
@@ -93,55 +89,52 @@ module Microstation
93
89
  ole_obj.Type
94
90
  end
95
91
 
96
-
97
92
  def model
98
93
  Model.new(app, app.current_drawing, ole_obj.ModelReference)
99
94
  end
100
-
101
95
  end
102
96
 
103
97
  class Element
104
-
105
98
  include ElementTrait
106
99
 
107
- def self.convert_item(ole,app, cell=nil)
108
- return Point3d.from_ole(ole) if ole.class == WIN32OLE_RECORD && ole.typename == 'Point3d'
109
- return ole unless ole.class == WIN32OLE
100
+ def self.convert_item(ole, app, cell = nil)
101
+ return Point3d.from_ole(ole) if ole.instance_of?(WIN32OLE_RECORD) && ole.typename == "Point3d"
102
+ return ole unless ole.instance_of?(WIN32OLE)
103
+
110
104
  case ole.Type
111
105
  when ::Microstation::MSD::MsdElementTypeText
112
- ::Microstation::Text.new(ole,app,cell)
106
+ ::Microstation::Text.new(ole, app, cell)
113
107
  when ::Microstation::MSD::MsdElementTypeLine
114
- ::Microstation::Line.new(ole,app,cell)
108
+ ::Microstation::Line.new(ole, app, cell)
115
109
  when ::Microstation::MSD::MsdElementTypeTextNode
116
- ::Microstation::TextNode.new(ole,app,cell)
110
+ ::Microstation::TextNode.new(ole, app, cell)
117
111
  when ::Microstation::MSD::MsdElementTypeTag
118
- ::Microstation::Tag.new(ole,app,cell)
112
+ ::Microstation::Tag.new(ole, app, cell)
119
113
  when ::Microstation::MSD::MsdElementTypeCellHeader
120
- ::Microstation::Cell.new(ole,app,cell)
114
+ ::Microstation::Cell.new(ole, app, cell)
121
115
  when ::Microstation::MSD::MsdElementTypeSharedCell
122
- ::Microstation::Cell.new(ole,app,cell)
116
+ ::Microstation::Cell.new(ole, app, cell)
123
117
  when ::Microstation::MSD::MsdElementTypeArc
124
- ::Microstation::Arc.new(ole,app,cell)
118
+ ::Microstation::Arc.new(ole, app, cell)
125
119
  when ::Microstation::MSD::MsdElementTypeEllipse
126
- ::Microstation::Ellipse.new(ole,app,cell)
120
+ ::Microstation::Ellipse.new(ole, app, cell)
127
121
  when ::Microstation::MSD::MsdElementTypeBsplineSurface
128
- ::Microstation::BSplineSurface.new(ole,app,cell)
122
+ ::Microstation::BSplineSurface.new(ole, app, cell)
129
123
  when ::Microstation::MSD::MsdElementTypeBsplineCurve
130
- ::Microstation::BSplineCurve.new(ole,app,cell)
124
+ ::Microstation::BSplineCurve.new(ole, app, cell)
131
125
 
132
126
  else
133
- new(ole,app,cell)
127
+ new(ole, app, cell)
134
128
  end
135
129
  end
136
130
 
137
131
  def self.ole_object?
138
- ole.class == WIN32OLE
132
+ ole.instance_of?(WIN32OLE)
139
133
  end
140
134
 
141
-
142
135
  attr_reader :ole_obj, :app, :original
143
136
 
144
- def initialize(ole,app, cell = nil)
137
+ def initialize(ole, app, cell = nil)
145
138
  @ole_obj = ole
146
139
  @original = read_ole(ole)
147
140
  @app = app
@@ -153,23 +146,20 @@ module Microstation
153
146
  end
154
147
 
155
148
  def read_ole(ole)
156
-
157
149
  end
158
150
 
159
151
  def write_ole(value)
160
-
161
152
  end
162
153
 
163
- def method_missing(meth,*args,&block)
164
- if meth.to_s =~ /^[A-Z]/
165
- result = ole_obj.send(meth,*args,&block)
166
- Element.convert_item(result,app)
154
+ def method_missing(meth, *args, &block)
155
+ if /^[A-Z]/.match?(meth.to_s)
156
+ result = ole_obj.send(meth, *args, &block)
157
+ Element.convert_item(result, app)
167
158
  else
168
- super(meth,*args,&block)
159
+ super(meth, *args, &block)
169
160
  end
170
161
  end
171
162
 
172
-
173
163
  def get_property_handler
174
164
  ph_ole = app_ole_obj.CreatePropertyHandler(ole_obj)
175
165
  PropertyHandler.new(ph_ole)
@@ -183,15 +173,14 @@ module Microstation
183
173
  property_handler[name]
184
174
  end
185
175
 
186
-
187
176
  def do_update(value)
188
177
  return false if value == original
178
+
189
179
  saved_original = original
190
180
  begin
191
181
  write_ole(value)
192
182
  @original = read_ole(ole_obj)
193
- return true
194
-
183
+ true
195
184
  rescue => e
196
185
  @original = saved_original
197
186
  false
@@ -231,65 +220,63 @@ module Microstation
231
220
  ole.IsCellElement || ole.IsSharedCellElement
232
221
  end
233
222
 
234
- def each_cell(ole,&block)
223
+ def each_cell(ole, &block)
235
224
  cell = ole if ole_cell(ole)
236
- ole.ResetElementEnumeration rescue binding.pry
225
+ begin
226
+ ole.ResetElementEnumeration
227
+ rescue
228
+ binding.pry
229
+ end
237
230
  while ole.MoveToNextElement
238
231
  component = ole.CopyCurrentElement
239
232
  if component.IsTextNodeElement
240
- yield Microstation::Wrap.wrap(component.AsTextNodeElement,app,cell)
233
+ yield Microstation::Wrap.wrap(component.AsTextNodeElement, app, cell)
241
234
  elsif component.IsTextElement
242
- yield Microstation::Wrap.wrap(component.AsTextElement,app,cell)
235
+ yield Microstation::Wrap.wrap(component.AsTextElement, app, cell)
243
236
  elsif component.IsComplexElement
244
237
  each(component)
245
238
  else
246
- yield Microstation::Wrap.wrap(component,app,cell)
239
+ yield Microstation::Wrap.wrap(component, app, cell)
247
240
  end
248
241
  end
249
242
  end
250
243
 
251
- def each(ole = ole_obj,&block)
244
+ def each(ole = ole_obj, &block)
252
245
  return unless ole.IsComplexElement
253
- return to_enum(:each) unless block_given?
246
+ return to_enum(:each) unless block
247
+
254
248
  if ole.IsCellElement
255
- each_cell(ole,&block)
249
+ each_cell(ole, &block)
256
250
  else
257
- each_complex(ole,&block)
251
+ each_complex(ole, &block)
258
252
  end
259
253
  end
260
254
 
261
- def each_complex(ole,&block)
255
+ def each_complex(ole, &block)
262
256
  cell = nil
263
257
  components = ole.GetSubElements
264
258
  while components.MoveNext
265
259
  component = components.Current
266
260
  if component.IsTextNodeElement
267
- yield Microstation::Wrap.wrap(component.AsTextNodeElement,app,cell)
261
+ yield Microstation::Wrap.wrap(component.AsTextNodeElement, app, cell)
268
262
  elsif component.IsTextElement
269
- yield Microstation::Wrap.wrap(component.AsTextElement,app,cell)
263
+ yield Microstation::Wrap.wrap(component.AsTextElement, app, cell)
270
264
  elsif component.IsComplexElement
271
- each(component,&block)
265
+ each(component, &block)
272
266
  else
273
- yield Microstation::Wrap.wrap(component,app,cell)
267
+ yield Microstation::Wrap.wrap(component, app, cell)
274
268
  end
275
269
  end
276
270
  end
277
-
278
271
  end
279
272
 
280
-
281
273
  class App
282
-
283
274
  def ole_to_ruby(ole)
284
- Element.convert_item(ole,self)
275
+ Element.convert_item(ole, self)
285
276
  end
286
-
287
277
  end
288
-
289
278
  end
290
279
 
291
-
292
-
293
280
  module Microstation
294
281
  class Arc < Element
295
282
  end
@@ -1,32 +1,27 @@
1
- require_relative 'wrap'
1
+ require_relative "wrap"
2
2
 
3
3
  module Microstation
4
-
5
4
  class Enumerator
6
-
7
5
  include Enumerable
8
6
 
9
7
  attr_reader :app
10
8
 
11
- def initialize(ole,app)
9
+ def initialize(ole, app)
12
10
  @ole_obj = ole
13
11
  @app = app
14
12
  end
15
13
 
16
14
  def each
17
15
  return enum_for(:each) unless block_given?
16
+
18
17
  while @ole_obj.MoveNext
19
18
  item = @ole_obj.Current
20
- yield Microstation::Wrap.wrap(item,app)
19
+ yield Microstation::Wrap.wrap(item, app)
21
20
  end
22
21
  end
23
22
 
24
23
  def reset
25
24
  @ole_obj.reset
26
25
  end
27
-
28
-
29
-
30
26
  end
31
-
32
27
  end
@@ -1,17 +1,12 @@
1
1
  module Microstation
2
-
3
2
  Error = Class.new(::RuntimeError)
4
3
  NonDGNFile = Class.new(Error)
5
4
  FileNotFound = Class.new(Error)
6
5
  MultipleUpdateError = Class.new(Error)
7
6
  class ExistingFile < Error
8
-
9
7
  def initialize(path)
10
8
  msg = "File at path #{path} already exists"
11
9
  super(msg)
12
10
  end
13
11
  end
14
-
15
-
16
-
17
12
  end
@@ -1,14 +1,11 @@
1
1
  module Microstation
2
-
3
2
  class EventHandler
4
3
  def initialize
5
4
  @handlers = {}
6
5
  end
7
6
 
8
7
  def add_handler(event, &block)
9
- if block_given?
10
- @handlers[event] = block
11
- end
8
+ @handlers[event] = block if block
12
9
  end
13
10
 
14
11
  def get_handler(event)
@@ -24,5 +21,4 @@ module Microstation
24
21
  end
25
22
  end
26
23
  end
27
-
28
24
  end
@@ -1,23 +1,21 @@
1
- require 'pathname'
1
+ require "pathname"
2
2
 
3
-
4
- class Pathname
3
+ class Pathname
4
+ def ext(newext = "")
5
+ str = to_s
6
+ return dup if [".", ".."].include? str
5
7
 
6
- def ext(newext = '')
7
- str = self.to_s
8
- return self.dup if ['.', '..'].include? str
9
- if newext != ''
8
+ if newext != ""
10
9
  newext = (newext =~ /^\./) ? newext : ("." + newext)
11
10
  end
12
- Pathname.new(str.dup.sub!(%r(([^/\\])\.[^./\\]*$)) { $1 + newext } || str + newext)
13
- end
11
+ Pathname.new(str.dup.sub!(%r{([^/\\])\.[^./\\]*$}) { ::Regexp.last_match(1) + newext } || str + newext)
12
+ end
14
13
 
15
- def extstr(newext='')
16
- Pathname.new( self.to_s.ext(newext))
14
+ def extstr(newext = "")
15
+ Pathname.new(to_s.ext(newext))
17
16
  end
18
-
17
+
19
18
  def glob(pattern)
20
- self.class.glob("#{self.to_s}/#{pattern}")
19
+ self.class.glob("#{self}/#{pattern}")
21
20
  end
22
-
23
21
  end
@@ -1,7 +1,5 @@
1
1
  class WIN32OLE
2
-
3
2
  def ole_obj
4
3
  self
5
4
  end
6
-
7
5
  end
@@ -5,29 +5,21 @@ module Microstation
5
5
  end
6
6
  end
7
7
 
8
-
9
8
  module Microstation
10
-
11
-
12
9
  class Drawing
13
-
14
-
15
-
16
10
  def number
17
11
  binding.pry
18
- Drawing::Number.from_string(self.basename)
12
+ Drawing::Number.from_string(basename)
19
13
  end
20
14
 
21
15
  class Number
22
-
23
16
  DRAWING_RE = /(.+)-.+-(.+)-(.+).dgn/
24
17
 
25
18
  def self.from_string(drawing_name)
26
19
  md = DRAWING_RE.match(drawing_name.to_s)
27
- new(md[1],md[2],md[3])
20
+ new(md[1], md[2], md[3])
28
21
  end
29
22
 
30
-
31
23
  def Index(str)
32
24
  return str if str == Drawing::Index
33
25
  Drawing::Index.new(str.to_s)
@@ -37,37 +29,30 @@ module Microstation
37
29
 
38
30
  attr_reader :locid, :factype, :index
39
31
 
40
- def initialize(locid,factype, index)
32
+ def initialize(locid, factype, index)
41
33
  @locid = locid.to_s.upcase
42
34
  @factype = factype.to_s.upcase
43
35
  @index = Index(index)
44
36
  end
45
37
 
46
-
47
-
48
38
  def to_s
49
- [locid,'D',factype,index.to_s].join("-")
39
+ [locid, "D", factype, index.to_s].join("-")
50
40
  end
51
41
 
52
42
  def discipline
53
43
  index.discipline
54
44
  end
55
45
 
56
- def +(n)
57
- self.class.new(locid,factype,index.+(n))
46
+ def +(other)
47
+ self.class.new(locid, factype, index.+(other))
58
48
  end
59
49
 
60
- def -(n)
61
- self.class.new(locid,factype,index.-(n))
50
+ def -(other)
51
+ self.class.new(locid, factype, index.-(other))
62
52
  end
63
-
64
53
  end
65
54
 
66
-
67
55
  class Index
68
-
69
-
70
-
71
56
  def initialize(str)
72
57
  return str if str === Index
73
58
  @nbr = str
@@ -97,14 +82,12 @@ module Microstation
97
82
  "#{discipline}#{dstring}"
98
83
  end
99
84
 
100
- def +(n)
101
- self.class.new( combined_string( digits_string(as_int + n)))
85
+ def +(other)
86
+ self.class.new(combined_string(digits_string(as_int + other)))
102
87
  end
103
88
 
104
-
105
- def -(n)
106
- self.class.new( combined_string( digits_string(as_int - n)))
107
-
89
+ def -(other)
90
+ self.class.new(combined_string(digits_string(as_int - other)))
108
91
  end
109
92
 
110
93
  def succ
@@ -114,11 +97,6 @@ module Microstation
114
97
  def pred
115
98
  self.-(1)
116
99
  end
117
-
118
-
119
-
120
100
  end
121
-
122
101
  end
123
-
124
102
  end
@@ -1,68 +1,33 @@
1
1
  module Microstation
2
-
3
2
  module FileTests
3
+ def microstation_drawing?(f)
4
+ return true if drawing_dgn?(f)
4
5
 
6
+ f = f&.to_path&.to_str
7
+ drawing_dgn?(f)
8
+ end
5
9
 
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
+ def drawing_dgn?(f)
11
+ File.file?(f) && File.extname(f) == ".dgn"
10
12
  end
11
13
 
12
14
  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
15
+ return true if drawing_type?(f)
17
16
 
17
+ f = f&.to_path&.to_str
18
+ drawing_type(f)
19
+ end
18
20
 
19
21
  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'
22
+ File.file?(f) && (File.extname(f) == ".dgn" || File.extname(f) == ".dwg")
24
23
  end
25
24
 
26
25
  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)
26
+ raise ArgumentError, "File must be a dgn or dwg file" unless drawing?(f)
31
27
  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
28
 
29
+ def check_is_dgn(f)
30
+ raise ArgumentError, "File must be a dgn file" unless microstation_drawing?(f)
52
31
  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
32
  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
33
  end
@@ -1,27 +1,23 @@
1
- require 'dry/monads'
1
+ require "dry/monads"
2
2
  module Microstation
3
-
4
3
  class App
5
4
  include Dry::Monads[:result]
6
5
  end
7
6
 
8
7
  module Functions
9
-
10
8
  extend Dry::Monads[:result]
11
9
 
12
10
  def get_points_by_rectangle
13
11
  queue = cad_input_queue
14
- queue.show_command('Get points by block')
12
+ queue.show_command("Get points by block")
15
13
  start_point = queue.get_point
16
- if start_point.failure?
17
- return Failure(:point1_reset)
18
- end
14
+ return Failure(:point1_reset) if start_point.failure?
15
+
19
16
  queue.send_command "PLACE BLOCK"
20
17
  queue.send_data_point start_point.value!
21
18
  end_point = queue.get_point
22
- if end_point.failure?
23
- return Failure(:point2_reset)
24
- end
19
+ return Failure(:point2_reset) if end_point.failure?
20
+
25
21
  Success([start_point.value!, end_point.value!])
26
22
  end
27
23
 
@@ -29,15 +25,13 @@ module Microstation
29
25
  queue = cad_input_queue
30
26
  queue.show_command("Get points by line")
31
27
  start_point = queue.get_point
32
- if start_point.failure?
33
- return Failure(:point1_reset)
34
- end
28
+ return Failure(:point1_reset) if start_point.failure?
29
+
35
30
  queue.send_command "PLACE LINE"
36
31
  queue.send_data_point start_point.value!
37
32
  end_point = queue.get_point("Enter next vertex")
38
- if end_point.failure?
39
- return Failure(:point2_reset)
40
- end
33
+ return Failure(:point2_reset) if end_point.failure?
34
+
41
35
  Success([start_point.value!, end_point.value!])
42
36
  end
43
37
 
@@ -48,13 +42,9 @@ module Microstation
48
42
  def get_point
49
43
  cad_input_queue.get_point
50
44
  end
51
-
52
-
53
45
  end
54
46
 
55
-
56
47
  class App
57
48
  include Functions
58
49
  end
59
50
  end
60
-
@@ -1,35 +1,28 @@
1
1
  module Microstation
2
-
3
2
  module Graphics
4
-
5
-
6
- def line(p1,p2,el = WIN32OLE_VARIANT::Nothing)
3
+ def line(p1, p2, el = WIN32OLE_VARIANT::Nothing)
7
4
  pt1 = app.to_ole_point3d(p1)
8
5
  pt2 = app.to_ole_point3d(p2)
9
6
  begin
10
- ole = app.ole_obj.CreateLineElement2(el,pt1,pt2)
11
- rescue Exception => ex
7
+ ole = app.ole_obj.CreateLineElement2(el, pt1, pt2)
8
+ rescue Exception => e
12
9
  binding.pry
13
10
  return nil
14
11
  end
15
12
  add_element(ole) if ole
16
13
  end
17
14
 
18
-
19
15
  def line_from_pts(pts, el = WIN32OLE_VARIANT::Nothing)
20
- ole_points = pts.map{ |pt| app.to_ole_point3d(pt) }
16
+ ole_points = pts.map { |pt| app.to_ole_point3d(pt) }
21
17
  ole = app.ole_obj.CreateLineElement1(el, ole_points)
22
18
  if ole
23
- add_element(ole)
19
+ add_element(ole)
24
20
  else
25
21
  binding.pry
26
22
  end
27
23
  rescue Exception => e
28
24
  binding.pry
29
- return nil
25
+ nil
30
26
  end
31
27
  end
32
-
33
-
34
28
  end
35
-