autocad 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop/minitest.yml +2 -0
  3. data/.rubocop/strict.yml +4 -0
  4. data/.rubocop.yml +33 -0
  5. data/.solargraph.yml +22 -0
  6. data/.vscode/launch.json +30 -0
  7. data/CHANGELOG.md +5 -0
  8. data/CODE_OF_CONDUCT.md +132 -0
  9. data/Guardfile +66 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +39 -0
  12. data/Rakefile +10 -0
  13. data/Steepfile +35 -0
  14. data/WASD-D-TDS-C001.dwg +0 -0
  15. data/WASD-D-TDS-C001.pdf +0 -0
  16. data/autocad.log +1 -0
  17. data/autocad_example.rb +26 -0
  18. data/event_handler.log +24 -0
  19. data/examples/example_save_pdf.rb +5 -0
  20. data/exe/autocad +3 -0
  21. data/exe/dgn2pdf +50 -0
  22. data/exe/pw_print +43 -0
  23. data/gemfiles/rubocop.gemfile +6 -0
  24. data/lib/autocad/app.rb +655 -0
  25. data/lib/autocad/arc.rb +29 -0
  26. data/lib/autocad/block.rb +141 -0
  27. data/lib/autocad/block_reference.rb +198 -0
  28. data/lib/autocad/drawing.rb +426 -0
  29. data/lib/autocad/element.rb +454 -0
  30. data/lib/autocad/enumerator.rb +24 -0
  31. data/lib/autocad/errors.rb +37 -0
  32. data/lib/autocad/event_handler.rb +30 -0
  33. data/lib/autocad/filter.rb +168 -0
  34. data/lib/autocad/layer.rb +41 -0
  35. data/lib/autocad/line.rb +55 -0
  36. data/lib/autocad/message_box.rb +95 -0
  37. data/lib/autocad/model.rb +89 -0
  38. data/lib/autocad/mtext.rb +110 -0
  39. data/lib/autocad/paths.rb +29 -0
  40. data/lib/autocad/point3d.rb +143 -0
  41. data/lib/autocad/pviewport.rb +21 -0
  42. data/lib/autocad/selection_filter.rb +180 -0
  43. data/lib/autocad/selection_set.rb +61 -0
  44. data/lib/autocad/selection_set_adapter.rb +146 -0
  45. data/lib/autocad/text.rb +74 -0
  46. data/lib/autocad/version.rb +5 -0
  47. data/lib/autocad.rb +161 -0
  48. data/olegen.rb +341 -0
  49. data/rbs_collection.lock.yaml +188 -0
  50. data/rbs_collection.yaml +19 -0
  51. data/scanner.obj +0 -0
  52. data/sig/generated/autocad/app.rbs +251 -0
  53. data/sig/generated/autocad/arc.rbs +17 -0
  54. data/sig/generated/autocad/block.rbs +63 -0
  55. data/sig/generated/autocad/block_reference.rbs +59 -0
  56. data/sig/generated/autocad/drawing.rbs +158 -0
  57. data/sig/generated/autocad/element.rbs +166 -0
  58. data/sig/generated/autocad/enumerator.rbs +15 -0
  59. data/sig/generated/autocad/errors.rbs +23 -0
  60. data/sig/generated/autocad/event_handler.rbs +14 -0
  61. data/sig/generated/autocad/filter.rbs +60 -0
  62. data/sig/generated/autocad/layer.rbs +19 -0
  63. data/sig/generated/autocad/line.rbs +25 -0
  64. data/sig/generated/autocad/message_box.rbs +81 -0
  65. data/sig/generated/autocad/model.rbs +41 -0
  66. data/sig/generated/autocad/paths.rbs +19 -0
  67. data/sig/generated/autocad/point3d.rbs +66 -0
  68. data/sig/generated/autocad/selection_filter.rbs +50 -0
  69. data/sig/generated/autocad/selection_set.rbs +37 -0
  70. data/sig/generated/autocad/selection_set_adapter.rbs +28 -0
  71. data/sig/generated/autocad/text.rbs +19 -0
  72. data/sig/generated/autocad/text_node.rbs +37 -0
  73. data/sig/generated/autocad/version.rbs +5 -0
  74. data/sig/generated/autocad/viewport.rbs +11 -0
  75. data/sig/generated/autocad.rbs +68 -0
  76. data/sig/prototype/lib/autocad/app.rbs +34 -0
  77. data/sig/prototype/lib/autocad/block.rbs +5 -0
  78. data/sig/prototype/lib/autocad/block_reference.rbs +5 -0
  79. data/sig/prototype/lib/autocad/drawing.rbs +13 -0
  80. data/sig/prototype/lib/autocad/element.rbs +9 -0
  81. data/sig/prototype/lib/autocad/enumerator.rbs +5 -0
  82. data/sig/prototype/lib/autocad/event_handler.rbs +7 -0
  83. data/sig/prototype/lib/autocad/model.rbs +5 -0
  84. data/sig/prototype/lib/autocad/paths.rbs +5 -0
  85. data/sig/prototype/lib/autocad.rbs +3 -0
  86. data/temp/autocad.dwg +0 -0
  87. data/temp/autocad.log +1 -0
  88. data/temp/event_handler.log +0 -0
  89. metadata +147 -0
data/olegen.rb ADDED
@@ -0,0 +1,341 @@
1
+ # frozen_string_literal: false
2
+
3
+ #-----------------------------
4
+ # olegen.rb
5
+ # $Revision$
6
+ #-----------------------------
7
+
8
+ require "win32ole"
9
+
10
+ class WIN32COMGen
11
+ def initialize(typelib)
12
+ @typelib = typelib
13
+ @receiver = ""
14
+ end
15
+ attr_reader :typelib
16
+
17
+ def ole_classes(typelib)
18
+ @ole = WIN32OLE.new(typelib)
19
+ [@ole.ole_obj_help]
20
+ rescue
21
+ WIN32OLE_TYPE.ole_classes(typelib)
22
+ end
23
+
24
+ def generate_args(method)
25
+ args = []
26
+ size_required_params = if method.size_opt_params >= 0
27
+ method.size_params - method.size_opt_params
28
+ else
29
+ method.size_params - 1
30
+ end
31
+ size_required_params.times do |i|
32
+ if method.params[i] && method.params[i].optional?
33
+ args.push "arg#{i}=nil"
34
+ else
35
+ args.push "arg#{i}"
36
+ end
37
+ end
38
+ if method.size_opt_params >= 0
39
+ method.size_opt_params.times do |i|
40
+ args.push "arg#{i + size_required_params}=nil"
41
+ end
42
+ else
43
+ args.push "*arg"
44
+ end
45
+ args.join(", ")
46
+ end
47
+
48
+ def generate_argtype(typedetails)
49
+ ts = ""
50
+ typedetails.each do |t|
51
+ case t
52
+ when "CARRAY", "VOID", "UINT", "RESULT", "DECIMAL", "I8", "UI8"
53
+ # raise "Sorry type\"" + t + "\" not supported"
54
+ ts << "\"??? NOT SUPPORTED TYPE:`#{t}'\""
55
+ when "USERDEFINED", "Unknown Type 9"
56
+ ts << "VT_DISPATCH"
57
+ break
58
+ when "SAFEARRAY"
59
+ ts << "VT_ARRAY|"
60
+ when "PTR"
61
+ ts << "VT_BYREF|"
62
+ when "INT"
63
+ ts << "VT_I4"
64
+ else
65
+ if String === t
66
+ ts << "VT_" + t
67
+ end
68
+ end
69
+ end
70
+ if ts.empty?
71
+ ts = "VT_VARIANT"
72
+ elsif ts.end_with?("|")
73
+ ts += "VT_VARIANT"
74
+ end
75
+ ts
76
+ end
77
+
78
+ def generate_argtypes(method, proptypes)
79
+ types = method.params.collect { |param|
80
+ generate_argtype(param.ole_type_detail)
81
+ }.join(", ")
82
+ if proptypes
83
+ types += ", " if types.size > 0
84
+ types += generate_argtype(proptypes)
85
+ end
86
+ types
87
+ end
88
+
89
+ def generate_method_body(method, disptype, types = nil)
90
+ " ret = #{@receiver}#{disptype}(#{method.dispid}, [" +
91
+ generate_args(method).gsub("=nil", "") +
92
+ "], [" +
93
+ generate_argtypes(method, types) +
94
+ "])\n" +
95
+ " @lastargs = WIN32OLE::ARGV\n" +
96
+ " ret"
97
+ end
98
+
99
+ def generate_method_help(method, type = nil)
100
+ str = " # "
101
+ str += type || method.return_type
102
+ str += " #{method.name}"
103
+ if method.event?
104
+ str += " EVENT"
105
+ str += " in #{method.event_interface}"
106
+ end
107
+ if method.helpstring && method.helpstring != ""
108
+ str += "\n # "
109
+ str += method.helpstring
110
+ end
111
+ args_help = generate_method_args_help(method)
112
+ if args_help
113
+ str += "\n"
114
+ str += args_help
115
+ end
116
+ str
117
+ end
118
+
119
+ def generate_method_args_help(method)
120
+ args = []
121
+ method.params.each_with_index { |param, i|
122
+ h = " # #{param.ole_type} arg#{i} --- #{param.name}"
123
+ inout = []
124
+ inout.push "IN" if param.input?
125
+ inout.push "OUT" if param.output?
126
+ h += " [#{inout.join("/")}]"
127
+ h += " ( = #{param.default})" if param.default
128
+ args.push h
129
+ }
130
+ if args.size > 0
131
+ args.join("\n")
132
+ end
133
+ end
134
+
135
+ def generate_method(method, disptype, io = STDOUT, types = nil)
136
+ io.puts "\n"
137
+ io.puts generate_method_help(method)
138
+ if method.invoke_kind == "PROPERTYPUT"
139
+ io.print " def #{method.name}=("
140
+ else
141
+ io.print " def #{method.name}("
142
+ end
143
+ io.print generate_args(method)
144
+ io.puts ")"
145
+ io.puts generate_method_body(method, disptype, types)
146
+ io.puts " end"
147
+ end
148
+
149
+ def generate_propputref_methods(klass, io = STDOUT)
150
+ klass.ole_methods.select { |method|
151
+ method.invoke_kind == "PROPERTYPUTREF" && method.visible?
152
+ }.each do |method|
153
+ generate_method(method, io)
154
+ end
155
+ end
156
+
157
+ def generate_properties_with_args(klass, io = STDOUT)
158
+ klass.ole_methods.select { |method|
159
+ method.invoke_kind == "PROPERTYGET" &&
160
+ method.visible? &&
161
+ method.size_params > 0
162
+ }.each do |method|
163
+ types = method.return_type_detail
164
+ io.puts "\n"
165
+ io.puts generate_method_help(method, types[0])
166
+ io.puts " def #{method.name}"
167
+ if klass.ole_type == "Class"
168
+ io.print " OLEProperty.new(@dispatch, #{method.dispid}, ["
169
+ else
170
+ io.print " OLEProperty.new(self, #{method.dispid}, ["
171
+ end
172
+ io.print generate_argtypes(method, nil)
173
+ io.print "], ["
174
+ io.print generate_argtypes(method, types)
175
+ io.puts "])"
176
+ io.puts " end"
177
+ end
178
+ end
179
+
180
+ def generate_propput_methods(klass, io = STDOUT)
181
+ klass.ole_methods.select { |method|
182
+ method.invoke_kind == "PROPERTYPUT" && method.visible? &&
183
+ method.size_params == 1
184
+ }.each do |method|
185
+ ms = klass.ole_methods.select { |m|
186
+ m.invoke_kind == "PROPERTYGET" &&
187
+ m.dispid == method.dispid
188
+ }
189
+ types = []
190
+ if ms.size == 1
191
+ types = ms[0].return_type_detail
192
+ end
193
+ generate_method(method, "_setproperty", io, types)
194
+ end
195
+ end
196
+
197
+ def generate_propget_methods(klass, io = STDOUT)
198
+ klass.ole_methods.select { |method|
199
+ method.invoke_kind == "PROPERTYGET" && method.visible? &&
200
+ method.size_params == 0
201
+ }.each do |method|
202
+ generate_method(method, "_getproperty", io)
203
+ end
204
+ end
205
+
206
+ def generate_func_methods(klass, io = STDOUT)
207
+ klass.ole_methods.select { |method|
208
+ method.invoke_kind == "FUNC" && method.visible?
209
+ }.each do |method|
210
+ generate_method(method, "_invoke", io)
211
+ end
212
+ end
213
+
214
+ def generate_methods(klass, io = STDOUT)
215
+ generate_propget_methods(klass, io)
216
+ generate_propput_methods(klass, io)
217
+ generate_properties_with_args(klass, io)
218
+ generate_func_methods(klass, io)
219
+ # generate_propputref_methods(klass, io)
220
+ end
221
+
222
+ def generate_constants(klass, io = STDOUT)
223
+ klass.variables.select { |v|
224
+ v.visible? && v.variable_kind == "CONSTANT"
225
+ }.each do |v|
226
+ io.print " "
227
+ io.print v.name.sub(/^./) { $&.upcase }
228
+ io.print " = "
229
+ io.puts v.value
230
+ end
231
+ end
232
+
233
+ def class_name(klass)
234
+ klass_name = klass.name
235
+ if klass.ole_type == "Class" &&
236
+ klass.guid &&
237
+ klass.progid
238
+ klass_name = klass.progid.tr(".", "_")
239
+ end
240
+ if /^[A-Z]/ !~ klass_name || Module.constants.include?(klass_name)
241
+ klass_name = "OLE" + klass_name
242
+ end
243
+ klass_name
244
+ end
245
+
246
+ def define_initialize(klass)
247
+ <<STR
248
+
249
+ def initialize(obj = nil)
250
+ @clsid = "#{klass.guid}"
251
+ @progid = "#{klass.progid}"
252
+ if obj.nil?
253
+ @dispatch = WIN32OLE.new @progid
254
+ else
255
+ @dispatch = obj
256
+ end
257
+ end
258
+ STR
259
+ end
260
+
261
+ def define_include
262
+ " include WIN32OLE::VARIANT"
263
+ end
264
+
265
+ def define_instance_variables
266
+ " attr_reader :lastargs"
267
+ end
268
+
269
+ def define_method_missing
270
+ <<STR
271
+
272
+ def method_missing(cmd, *arg)
273
+ @dispatch.method_missing(cmd, *arg)
274
+ end
275
+ STR
276
+ end
277
+
278
+ def define_class(klass, io = STDOUT)
279
+ io.puts "class #{class_name(klass)} # #{klass.name}"
280
+ io.puts define_include
281
+ io.puts define_instance_variables
282
+ io.puts " attr_reader :dispatch"
283
+ io.puts " attr_reader :clsid"
284
+ io.puts " attr_reader :progid"
285
+ io.puts define_initialize(klass)
286
+ io.puts define_method_missing
287
+ end
288
+
289
+ def define_module(klass, io = STDOUT)
290
+ io.puts "module #{class_name(klass)}"
291
+ io.puts define_include
292
+ io.puts define_instance_variables
293
+ end
294
+
295
+ def generate_class(klass, io = STDOUT)
296
+ io.puts "\n# #{klass.helpstring}"
297
+ if klass.ole_type == "Class" &&
298
+ klass.guid &&
299
+ klass.progid
300
+ @receiver = "@dispatch."
301
+ define_class(klass, io)
302
+ else
303
+ @receiver = ""
304
+ define_module(klass, io)
305
+ end
306
+ generate_constants(klass, io)
307
+ generate_methods(klass, io)
308
+ io.puts "end"
309
+ end
310
+
311
+ def generate(io = STDOUT)
312
+ io.puts "require 'win32ole'"
313
+ io.puts "require 'win32ole/property'"
314
+
315
+ ole_classes(typelib).select { |klass|
316
+ klass.visible? &&
317
+ (klass.ole_type == "Class" ||
318
+ klass.ole_type == "Interface" ||
319
+ klass.ole_type == "Dispatch" ||
320
+ klass.ole_type == "Enum")
321
+ }.each do |klass|
322
+ generate_class(klass, io)
323
+ end
324
+ begin
325
+ @ole.quit if @ole
326
+ rescue
327
+ end
328
+ end
329
+ end
330
+
331
+ require "win32ole"
332
+ if __FILE__ == $0
333
+ if ARGV.size == 0
334
+ warn "usage: #{$0} Type Library [...]"
335
+ exit 1
336
+ end
337
+ ARGV.each do |typelib|
338
+ comgen = WIN32COMGen.new(typelib)
339
+ comgen.generate
340
+ end
341
+ end
@@ -0,0 +1,188 @@
1
+ ---
2
+ path: ".gem_rbs_collection"
3
+ gems:
4
+ - name: ast
5
+ version: '2.4'
6
+ source:
7
+ type: git
8
+ name: ruby/gem_rbs_collection
9
+ revision: 71fb7ae83789ae150bdee1cd8a7cd3035b5d79e2
10
+ remote: https://github.com/ruby/gem_rbs_collection.git
11
+ repo_dir: gems
12
+ - name: digest
13
+ version: '0'
14
+ source:
15
+ type: stdlib
16
+ - name: erb
17
+ version: '0'
18
+ source:
19
+ type: stdlib
20
+ - name: ffi
21
+ version: 1.17.0
22
+ source:
23
+ type: rubygems
24
+ - name: fileutils
25
+ version: '0'
26
+ source:
27
+ type: stdlib
28
+ - name: io-console
29
+ version: '0'
30
+ source:
31
+ type: stdlib
32
+ - name: json
33
+ version: '0'
34
+ source:
35
+ type: stdlib
36
+ - name: listen
37
+ version: '3.9'
38
+ source:
39
+ type: git
40
+ name: ruby/gem_rbs_collection
41
+ revision: 71fb7ae83789ae150bdee1cd8a7cd3035b5d79e2
42
+ remote: https://github.com/ruby/gem_rbs_collection.git
43
+ repo_dir: gems
44
+ - name: logger
45
+ version: '0'
46
+ source:
47
+ type: stdlib
48
+ - name: minitest
49
+ version: '0'
50
+ source:
51
+ type: stdlib
52
+ - name: monitor
53
+ version: '0'
54
+ source:
55
+ type: stdlib
56
+ - name: openssl
57
+ version: '0'
58
+ source:
59
+ type: stdlib
60
+ - name: optparse
61
+ version: '0'
62
+ source:
63
+ type: stdlib
64
+ - name: parallel
65
+ version: '1.20'
66
+ source:
67
+ type: git
68
+ name: ruby/gem_rbs_collection
69
+ revision: 71fb7ae83789ae150bdee1cd8a7cd3035b5d79e2
70
+ remote: https://github.com/ruby/gem_rbs_collection.git
71
+ repo_dir: gems
72
+ - name: parser
73
+ version: '3.2'
74
+ source:
75
+ type: git
76
+ name: ruby/gem_rbs_collection
77
+ revision: 71fb7ae83789ae150bdee1cd8a7cd3035b5d79e2
78
+ remote: https://github.com/ruby/gem_rbs_collection.git
79
+ repo_dir: gems
80
+ - name: pathname
81
+ version: '0'
82
+ source:
83
+ type: stdlib
84
+ - name: prism
85
+ version: 1.2.0
86
+ source:
87
+ type: rubygems
88
+ - name: rainbow
89
+ version: '3.0'
90
+ source:
91
+ type: git
92
+ name: ruby/gem_rbs_collection
93
+ revision: 71fb7ae83789ae150bdee1cd8a7cd3035b5d79e2
94
+ remote: https://github.com/ruby/gem_rbs_collection.git
95
+ repo_dir: gems
96
+ - name: rake
97
+ version: '13.0'
98
+ source:
99
+ type: git
100
+ name: ruby/gem_rbs_collection
101
+ revision: 71fb7ae83789ae150bdee1cd8a7cd3035b5d79e2
102
+ remote: https://github.com/ruby/gem_rbs_collection.git
103
+ repo_dir: gems
104
+ - name: rbs
105
+ version: 3.7.0
106
+ source:
107
+ type: rubygems
108
+ - name: rbs-inline
109
+ version: 0.10.0
110
+ source:
111
+ type: rubygems
112
+ - name: rdoc
113
+ version: '0'
114
+ source:
115
+ type: stdlib
116
+ - name: regexp_parser
117
+ version: '2.8'
118
+ source:
119
+ type: git
120
+ name: ruby/gem_rbs_collection
121
+ revision: 71fb7ae83789ae150bdee1cd8a7cd3035b5d79e2
122
+ remote: https://github.com/ruby/gem_rbs_collection.git
123
+ repo_dir: gems
124
+ - name: repl_type_completor
125
+ version: 0.1.9
126
+ source:
127
+ type: rubygems
128
+ - name: ripper
129
+ version: '0'
130
+ source:
131
+ type: stdlib
132
+ - name: rubocop
133
+ version: '1.57'
134
+ source:
135
+ type: git
136
+ name: ruby/gem_rbs_collection
137
+ revision: 71fb7ae83789ae150bdee1cd8a7cd3035b5d79e2
138
+ remote: https://github.com/ruby/gem_rbs_collection.git
139
+ repo_dir: gems
140
+ - name: rubocop-ast
141
+ version: '1.30'
142
+ source:
143
+ type: git
144
+ name: ruby/gem_rbs_collection
145
+ revision: 71fb7ae83789ae150bdee1cd8a7cd3035b5d79e2
146
+ remote: https://github.com/ruby/gem_rbs_collection.git
147
+ repo_dir: gems
148
+ - name: singleton
149
+ version: '0'
150
+ source:
151
+ type: stdlib
152
+ - name: socket
153
+ version: '0'
154
+ source:
155
+ type: stdlib
156
+ - name: tempfile
157
+ version: '0'
158
+ source:
159
+ type: stdlib
160
+ - name: thor
161
+ version: '1.2'
162
+ source:
163
+ type: git
164
+ name: ruby/gem_rbs_collection
165
+ revision: 71fb7ae83789ae150bdee1cd8a7cd3035b5d79e2
166
+ remote: https://github.com/ruby/gem_rbs_collection.git
167
+ repo_dir: gems
168
+ - name: tsort
169
+ version: '0'
170
+ source:
171
+ type: stdlib
172
+ - name: uri
173
+ version: '0'
174
+ source:
175
+ type: stdlib
176
+ - name: webrick
177
+ version: 1.9.1
178
+ source:
179
+ type: rubygems
180
+ - name: yard
181
+ version: '0.9'
182
+ source:
183
+ type: git
184
+ name: ruby/gem_rbs_collection
185
+ revision: 71fb7ae83789ae150bdee1cd8a7cd3035b5d79e2
186
+ remote: https://github.com/ruby/gem_rbs_collection.git
187
+ repo_dir: gems
188
+ gemfile_lock_path: Gemfile.lock
@@ -0,0 +1,19 @@
1
+ # Download sources
2
+ sources:
3
+ - type: git
4
+ name: ruby/gem_rbs_collection
5
+ remote: https://github.com/ruby/gem_rbs_collection.git
6
+ revision: main
7
+ repo_dir: gems
8
+
9
+ # You can specify local directories as sources also.
10
+ # - type: local
11
+ # path: path/to/your/local/repository
12
+
13
+ # A directory to install the downloaded RBSs
14
+ path: .gem_rbs_collection
15
+
16
+ # gems:
17
+ # # If you want to avoid installing rbs files for gems, you can specify them here.
18
+ # - name: GEM_NAME
19
+ # ignore: true
data/scanner.obj ADDED
Binary file