microstation 0.4.1 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.autotest +23 -23
- data/.rspec +2 -2
- data/Gemfile +29 -10
- data/History.txt +6 -6
- data/LICENSE.adoc +22 -0
- data/Manifest.txt +91 -60
- data/README.adoc +131 -0
- data/Rakefile +72 -30
- data/bin/dgn2pdf +36 -37
- data/bin/dgn_template +107 -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/drawing_with_text.dgn +0 -0
- data/cad_files/seed2d.dgn +0 -0
- data/cad_files/seed3d.dgn +0 -0
- 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 +686 -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/lib/microstation.rb +252 -88
- 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
- data/spec/microstation/app_spec.rb +184 -0
- data/spec/microstation/configuration_spec.rb +131 -0
- data/spec/microstation/drawing_spec.rb +245 -0
- data/spec/microstation/functions_spec.rb +36 -0
- data/spec/microstation/tag_set_spec.rb +159 -0
- data/spec/microstation/template_spec.rb +159 -0
- data/spec/microstation/text_node_spec.rb +67 -0
- data/spec/microstation/text_spec.rb +42 -0
- data/spec/microstation_spec.rb +47 -36
- data/spec/spec_helper.rb +97 -31
- metadata +308 -84
- 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/scanner_spec.rb +0 -155
- data/spec/spec_app.rb +0 -11
- 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,159 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'digest/md5'
|
6
|
+
|
7
|
+
require 'minitest/spec'
|
8
|
+
require 'minitest/autorun'
|
9
|
+
|
10
|
+
require 'microstation/template'
|
11
|
+
|
12
|
+
module TestHelper
|
13
|
+
def digest_for_path(file)
|
14
|
+
Digest::MD5.hexdigest(File.read(file))
|
15
|
+
end
|
16
|
+
|
17
|
+
def file_same?(p, p2)
|
18
|
+
digest_path(p) == digest_path(p2)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe Microstation::Template do
|
23
|
+
include TestHelper
|
24
|
+
|
25
|
+
describe 'initialization' do
|
26
|
+
it 'needs a drawing argument' do
|
27
|
+
assert_raises { Microstation::Template.new }
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'requires a valid and existing microstation file' do
|
31
|
+
%w[draw.dgn file://adoc.doc file://anexcel.xls file://autocad.dwg].each do |ftype|
|
32
|
+
assert_raises { Microstation::Template.new(ftype) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'given a good dgn file and file exists' do
|
37
|
+
let(:file) { 'file.dgn' }
|
38
|
+
|
39
|
+
it 'does not error' do
|
40
|
+
mock = Minitest::Mock.new
|
41
|
+
mock.expect(:file?, true)
|
42
|
+
File.stub :file?, true do
|
43
|
+
Microstation::Template.new(file)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'sets the template' do
|
48
|
+
mock = Minitest::Mock.new
|
49
|
+
mock.expect(:file?, true)
|
50
|
+
File.stub :file?, true do
|
51
|
+
temp = Microstation::Template.new(file)
|
52
|
+
_(temp.template).must_equal(file)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'a drawing with tags' do
|
59
|
+
before do
|
60
|
+
@dgn_name = 'drawing_with_block.dgn'
|
61
|
+
@dgn_file = drawing_path('drawing_with_block.dgn')
|
62
|
+
@template = Microstation::Template.new(@dgn_file)
|
63
|
+
end
|
64
|
+
|
65
|
+
subject { @template }
|
66
|
+
|
67
|
+
describe '.render' do
|
68
|
+
let(:dgn_name) { @dgn_name }
|
69
|
+
let(:template) { @template }
|
70
|
+
let(:dgn_file) { @dgn_file }
|
71
|
+
let(:copied_file) { drawing_path('copied_file.dgn') }
|
72
|
+
let(:output_file) { output_path(dgn_name) }
|
73
|
+
let(:changed_name) { 'changed_name.dgn' }
|
74
|
+
let(:locals) do
|
75
|
+
{ 'a1' => 'change 1', 'a2' => 'change 2',
|
76
|
+
'a3' => 'c3', 'a4' => 'c4' }
|
77
|
+
end
|
78
|
+
|
79
|
+
before do
|
80
|
+
FileUtils.rm(copied_file) if File.exist? copied_file
|
81
|
+
FileUtils.cp(dgn_file, copied_file)
|
82
|
+
FileUtils.rm(output_file) if File.exist? output_file
|
83
|
+
FileUtils.rm(output_path(changed_name)) if File.exist?(output_path(changed_name))
|
84
|
+
end
|
85
|
+
|
86
|
+
after do
|
87
|
+
FileUtils.rm(output_file) if File.exist? output_file
|
88
|
+
FileUtils.rm(output_path(changed_name)) if File.exist?(output_path(changed_name))
|
89
|
+
end
|
90
|
+
|
91
|
+
it "it doesn't error" do
|
92
|
+
template.render(output_dir: OUTPUT_DIR)
|
93
|
+
end
|
94
|
+
|
95
|
+
describe 'when locals or tagsets not input' do
|
96
|
+
it 'does nothing unless either locals or tagsets' do
|
97
|
+
template.render(output_dir: OUTPUT_DIR)
|
98
|
+
_(File.file?(output_file)).must_equal false
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe 'when locals or tagset is set' do
|
103
|
+
it 'creates a file' do
|
104
|
+
template.render(output_dir: OUTPUT_DIR, locals: locals)
|
105
|
+
_(File.file?(output_file)).must_equal true
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'changes text' do
|
109
|
+
template.render(output_dir: OUTPUT_DIR,
|
110
|
+
locals: { 'a1' => 'change 1', 'a2' => 'change 2', 'a3' => 'c3', 'a4' => 'c4' })
|
111
|
+
text = Microstation.get_text(output_file)
|
112
|
+
['text1 change 1', 'text2 change 2', 'text3 c3', "node1 c4\nnode1 ", "node2 \nnode2 ",
|
113
|
+
'text a1 again change 1'].each do |t|
|
114
|
+
_(text).must_include(t)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
it "doesn't change input file" do
|
119
|
+
template.render(output_dir: OUTPUT_DIR, locals: locals)
|
120
|
+
_(FileUtils.compare_file(dgn_file, copied_file)).must_equal true
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'changes the output' do
|
124
|
+
template.render(output_dir: OUTPUT_DIR, locals: locals)
|
125
|
+
_(FileUtils.compare_file(output_file, copied_file)).must_equal false
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe 'a drawing with multiple blocks of the same block' do
|
130
|
+
# before :all do
|
131
|
+
# @dgn_file = drawing_path('drawing_with_block.dgn')
|
132
|
+
# @template = Microstation::Template.new(@dgn_file)
|
133
|
+
# end
|
134
|
+
|
135
|
+
let(:filename) { 'drawing_with_3_block.dgn' }
|
136
|
+
let(:drawing_file) { drawing_path(filename) }
|
137
|
+
let(:template) { Microstation::Template.new(drawing_file) }
|
138
|
+
let(:output_file) { output_path(filename) }
|
139
|
+
|
140
|
+
before do
|
141
|
+
FileUtils.rm(output_file) if File.exist? output_file
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'updates the drawing_blocks' do
|
145
|
+
panel = { 'brk_1_service' => 'OUTLETS',
|
146
|
+
'brk_2_service' => 'AIR CONDITIONER',
|
147
|
+
'microstation_id' => 324 }
|
148
|
+
template.render(output_dir: OUTPUT_DIR, tagsets: [{ 'electrical_panel_42' => panel }])
|
149
|
+
Microstation.run do |app|
|
150
|
+
drawing = app.open_drawing(output_file)
|
151
|
+
ts = drawing.find_tagset_instance_by_name_and_id('electrical_panel_42', 324)
|
152
|
+
_(ts.brk_2_service).must_equal('AIR CONDITIONER')
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
|
5
|
+
describe 'Microstation::TextNode' do
|
6
|
+
include Minitest::Hooks
|
7
|
+
before(:all) do
|
8
|
+
@app = Microstation::App.new
|
9
|
+
config_app(@app)
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:all) do
|
13
|
+
@app.quit rescue nil
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'given a TextNode' do
|
17
|
+
let(:app) { @app }
|
18
|
+
let(:scanner) { app.create_scanner(:text, &:include_text_nodes) }
|
19
|
+
let(:drawing) { open_existing_drawing('drawing_with_text.dgn') }
|
20
|
+
let(:text_node) { drawing.scan_model(scanner).find { |t| !t.empty? } }
|
21
|
+
|
22
|
+
it 'should forward Capitalized methods to @ole_obj' do
|
23
|
+
ole = Minitest::Mock.new
|
24
|
+
ole.expect(:Type, 'A ole type')
|
25
|
+
text_node.stub(:ole_obj, ole) do
|
26
|
+
_(text_node.Type).must_equal 'A ole type'
|
27
|
+
end
|
28
|
+
ole.verify
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'ruby string methods' do
|
32
|
+
describe "calling with methods that don't change the string" do
|
33
|
+
it 'should not call the update method' do
|
34
|
+
skip
|
35
|
+
ole = Minitest::Mock.new
|
36
|
+
mock.expect(:update, true)
|
37
|
+
text_node.stub(:upcase, true)
|
38
|
+
|
39
|
+
ole = Minitest::Mock.new
|
40
|
+
text_node.reverse
|
41
|
+
text_node.downcase
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should give the correct value' do
|
45
|
+
value = text_node.to_s
|
46
|
+
_(text_node.reverse.to_s).must_equal(value.reverse)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should retain the same value' do
|
50
|
+
value = text_node.to_s
|
51
|
+
result = text_node.reverse
|
52
|
+
_(text_node.to_s).must_equal(value)
|
53
|
+
_(text_node.to_s).wont_equal result
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'calling with methods that change the string' do
|
58
|
+
it 'should change the value' do
|
59
|
+
value = text_node.to_s
|
60
|
+
result = text_node.reverse!
|
61
|
+
_(text_node.to_s).must_equal(result)
|
62
|
+
_(text_node.to_s).wont_equal(value)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
|
5
|
+
describe 'Microstation:Text and Microstation::TextNode' do
|
6
|
+
include Minitest::Hooks
|
7
|
+
before(:all) do
|
8
|
+
@app = Microstation::App.new
|
9
|
+
config_app(@app)
|
10
|
+
end
|
11
|
+
after(:all) do
|
12
|
+
@app.quit rescue nil
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'given a text node initialized by a scan' do
|
16
|
+
let(:drawing) { open_existing_drawing('drawing_with_text.dgn') }
|
17
|
+
let(:criteria) { @app.create_scanner(&:include_textual) }
|
18
|
+
|
19
|
+
before do
|
20
|
+
text_array = drawing.scan_model(criteria).to_a
|
21
|
+
@text = text_array.find { |t| t.instance_of?(Microstation::Text) }
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:text) { @text }
|
25
|
+
|
26
|
+
it 'should be an instance of text' do
|
27
|
+
_(text).must_be_instance_of Microstation::Text
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should forward all the Microstation commands to ole_obj' do
|
31
|
+
_(text.IsTextElement).must_equal true
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should update the drawing if the text is changed' do
|
35
|
+
id = text.microstation_id
|
36
|
+
val = text.to_s
|
37
|
+
text.reverse!
|
38
|
+
drawing_text = drawing.find_by_id(id)
|
39
|
+
_(drawing_text.to_s).must_equal(val.reverse)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/microstation_spec.rb
CHANGED
@@ -1,36 +1,47 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'spec_helper'
|
4
|
+
|
5
|
+
|
6
|
+
describe Microstation do
|
7
|
+
describe '#root' do
|
8
|
+
subject { Microstation.root }
|
9
|
+
|
10
|
+
it 'to_s' do
|
11
|
+
_(subject.to_s).must_equal(Pathname.getwd.to_s)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#run' do
|
16
|
+
it 'opens up and yields an app' do
|
17
|
+
result = nil
|
18
|
+
Microstation.run do |app|
|
19
|
+
_(app).must_be_instance_of(Microstation::App)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#get_text' do
|
25
|
+
let(:drawing_with_text) { drawing_path('drawing_with_text.dgn') }
|
26
|
+
let(:drawing_no_text) { drawing_path('drawing_no_block.dgn') }
|
27
|
+
let(:text_for_drawing_with_text){ [
|
28
|
+
"Four score and seven years ago our fathers brought forth",
|
29
|
+
"Out out brief candle\nLifes but a walking shadow",
|
30
|
+
"It is my lady, it is my love\nOh that she knew she were"
|
31
|
+
]
|
32
|
+
}
|
33
|
+
|
34
|
+
describe 'when drawing has text' do
|
35
|
+
it 'returns the text' do
|
36
|
+
text = Microstation.get_text(drawing_with_text)
|
37
|
+
_(text.sort).must_equal(text_for_drawing_with_text.sort)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'when drawing has no text' do
|
42
|
+
it 'returns an empty array' do
|
43
|
+
_(Microstation.get_text(drawing_no_text)).must_equal([])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,31 +1,97 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
require '
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
SPEC_DIR = Pathname(__dir__).expand_path
|
5
|
+
ROOT_DIR = SPEC_DIR.parent
|
6
|
+
DRAWING_DIR = ROOT_DIR + 'cad_files'
|
7
|
+
OUTPUT_DIR = ROOT_DIR + 'test_outdir'
|
8
|
+
TEMP_DIR = ROOT_DIR + 'tmp'
|
9
|
+
|
10
|
+
require 'bundler/setup'
|
11
|
+
$LOAD_PATH.unshift( ROOT_DIR + 'lib')
|
12
|
+
|
13
|
+
require 'minitest/spec'
|
14
|
+
require 'minitest/autorun'
|
15
|
+
require 'minitest/hooks/default'
|
16
|
+
require 'microstation'
|
17
|
+
require 'pry'
|
18
|
+
def drawing_path(file)
|
19
|
+
(DRAWING_DIR + file).expand_path
|
20
|
+
end
|
21
|
+
|
22
|
+
def output_path(file = nil)
|
23
|
+
if file
|
24
|
+
(OUTPUT_DIR + file).expand_path.to_s
|
25
|
+
else
|
26
|
+
OUTPUT_DIR
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def seedfile_path(file)
|
31
|
+
drawing_path(file)
|
32
|
+
end
|
33
|
+
|
34
|
+
def normalize_path(p)
|
35
|
+
p.to_s.sub(/[c,C]:/, 'C:')
|
36
|
+
end
|
37
|
+
|
38
|
+
def config_app(app)
|
39
|
+
conf = app.configuration
|
40
|
+
conf.prepend('MS_SEEDFILES', DRAWING_DIR)
|
41
|
+
# conf.set!('MS_DESIGNSEED','seed2d')
|
42
|
+
end
|
43
|
+
|
44
|
+
def open_existing_drawing(name)
|
45
|
+
path = drawing_path(name)
|
46
|
+
raise "drawing #{name} doesn't exist" unless File.file?(path)
|
47
|
+
|
48
|
+
@app.open_drawing(path)
|
49
|
+
end
|
50
|
+
|
51
|
+
def new_drawing(name, seedfile: 'seed2d' )
|
52
|
+
seed_path = (drawing_path(seedfile) if seedfile)
|
53
|
+
begin
|
54
|
+
@app.close_active_drawing
|
55
|
+
rescue StandardError
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
@path = output_path(name)
|
59
|
+
File.delete(@path) if File.exist? @path
|
60
|
+
@app.new_drawing(@path, seedfile: seed_path)
|
61
|
+
end
|
62
|
+
|
63
|
+
def non_existent_path(name)
|
64
|
+
path = drawing_path(name)
|
65
|
+
File.delete(path) if File.exist? path
|
66
|
+
path
|
67
|
+
end
|
68
|
+
|
69
|
+
def delete_current_drawing
|
70
|
+
if drawing = @app.current_drawing
|
71
|
+
path = drawing.path
|
72
|
+
begin
|
73
|
+
@app.close_active_drawing
|
74
|
+
rescue StandardError
|
75
|
+
nil
|
76
|
+
end
|
77
|
+
begin
|
78
|
+
File.delete path
|
79
|
+
rescue StandardError
|
80
|
+
nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def before_new_drawing
|
86
|
+
@app.close_active_drawing
|
87
|
+
begin
|
88
|
+
File.delete(@path)
|
89
|
+
rescue StandardError
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# def before_new_drawing
|
95
|
+
# @app.close_active_drawing
|
96
|
+
# File.delete(@drawing_path) if (@drawing_path && File.exist? @drawing_path)
|
97
|
+
# end
|