autocad 0.4.6 → 0.5

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop/minitest.yml +2 -2
  3. data/.rubocop/strict.yml +4 -4
  4. data/.rubocop.yml +36 -33
  5. data/CHANGELOG.md +5 -5
  6. data/LICENSE.txt +21 -21
  7. data/README.md +134 -39
  8. data/Rakefile +26 -10
  9. data/exe/autocad +3 -3
  10. data/gemfiles/rubocop.gemfile +2 -1
  11. data/lib/autocad/app.rb +127 -28
  12. data/lib/autocad/arc.rb +3 -0
  13. data/lib/autocad/block.rb +11 -6
  14. data/lib/autocad/block_reference.rb +33 -4
  15. data/lib/autocad/bounding_box.rb +202 -0
  16. data/lib/autocad/dim_style.rb +4 -0
  17. data/lib/autocad/drawing.rb +873 -172
  18. data/lib/autocad/element.rb +217 -25
  19. data/lib/autocad/errors.rb +9 -0
  20. data/lib/autocad/filter.rb +502 -168
  21. data/lib/autocad/layer.rb +129 -41
  22. data/lib/autocad/layout.rb +120 -0
  23. data/lib/autocad/line.rb +154 -55
  24. data/lib/autocad/message_box.rb +95 -95
  25. data/lib/autocad/model.rb +217 -89
  26. data/lib/autocad/mtext.rb +189 -110
  27. data/lib/autocad/plot.rb +45 -0
  28. data/lib/autocad/plot_configuration.rb +372 -0
  29. data/lib/autocad/point.rb +7 -0
  30. data/lib/autocad/point3d.rb +18 -11
  31. data/lib/autocad/pviewport.rb +136 -21
  32. data/lib/autocad/selection_filter.rb +358 -180
  33. data/lib/autocad/selection_set.rb +140 -61
  34. data/lib/autocad/selection_set_adapter.rb +187 -8
  35. data/lib/autocad/spline.rb +27 -0
  36. data/lib/autocad/text.rb +66 -11
  37. data/lib/autocad/text_style.rb +4 -0
  38. data/lib/autocad/version.rb +1 -1
  39. data/lib/autocad/viewport.rb +57 -0
  40. data/lib/autocad.rb +126 -30
  41. data/lib/faa/cleanup.rb +137 -0
  42. data/lib/win32ole_helper.rb +52 -0
  43. data/rbs_collection.lock.yaml +38 -18
  44. data/sig/generated/autocad/app.rbs +278 -251
  45. data/sig/generated/autocad/arc.rbs +6 -3
  46. data/sig/generated/autocad/block.rbs +8 -5
  47. data/sig/generated/autocad/block_reference.rbs +99 -59
  48. data/sig/generated/autocad/bounding_box.rbs +78 -0
  49. data/sig/generated/autocad/dim_style.rbs +6 -0
  50. data/sig/generated/autocad/drawing.rbs +597 -158
  51. data/sig/generated/autocad/element.rbs +233 -166
  52. data/sig/generated/autocad/errors.rbs +29 -23
  53. data/sig/generated/autocad/filter.rbs +388 -60
  54. data/sig/generated/autocad/layer.rbs +76 -19
  55. data/sig/generated/autocad/layout.rbs +64 -0
  56. data/sig/generated/autocad/line.rbs +128 -25
  57. data/sig/generated/autocad/message_box.rbs +81 -81
  58. data/sig/generated/autocad/model.rbs +115 -41
  59. data/sig/generated/autocad/mtext.rbs +123 -0
  60. data/sig/generated/autocad/plot.rbs +26 -0
  61. data/sig/generated/autocad/plot_configuration.rbs +176 -0
  62. data/sig/generated/autocad/point.rbs +7 -0
  63. data/sig/generated/autocad/point3d.rbs +70 -66
  64. data/sig/generated/autocad/pviewport.rbs +64 -0
  65. data/sig/generated/autocad/selection_filter.rbs +226 -50
  66. data/sig/generated/autocad/selection_set.rbs +112 -37
  67. data/sig/generated/autocad/selection_set_adapter.rbs +235 -28
  68. data/sig/generated/autocad/spline.rbs +22 -0
  69. data/sig/generated/autocad/text.rbs +66 -7
  70. data/sig/generated/autocad/text_style.rbs +6 -0
  71. data/sig/generated/autocad/viewport.rbs +19 -2
  72. data/sig/generated/autocad.rbs +140 -68
  73. data/sig/generated/faa/cleanup.rbs +53 -0
  74. data/sig/generated/win32ole_helper.rbs +9 -0
  75. data/sig/prototype/lib/autocad/app.rbs +3 -1
  76. data/sig/prototype/lib/autocad/bounding_box.rbs +15 -0
  77. data/sig/prototype/lib/autocad/drawing.rbs +6 -0
  78. data/sig/prototype/lib/autocad/layer.rbs +5 -0
  79. data/sig/prototype/lib/autocad/viewport.rbs +7 -0
  80. data/sig/prototype/lib/autocad.rbs +1 -1
  81. metadata +29 -5
  82. data/event_handler.log +0 -24
  83. data/sig/generated/autocad/text_node.rbs +0 -37
@@ -1,180 +1,358 @@
1
- module Autocad
2
- class SelectionFilter
3
- attr_reader :types, :values
4
-
5
- def initialize
6
- @types = []
7
- @values = []
8
- end
9
-
10
- def has_filters?
11
- @types.any?
12
- end
13
-
14
- # Logical Operators
15
- def and(*conditions)
16
- return self if conditions.empty?
17
-
18
- @types << -4
19
- @values << "<AND"
20
-
21
- conditions.each do |condition|
22
- @types.concat(condition.types)
23
- @values.concat(condition.values)
24
- end
25
-
26
- @types << -4
27
- @values << "AND>"
28
-
29
- self
30
- end
31
-
32
- def or(*conditions)
33
- return self if conditions.empty?
34
-
35
- @types << -4
36
- @values << "<OR"
37
-
38
- conditions.each do |condition|
39
- @types.concat(condition.types)
40
- @values.concat(condition.values)
41
- end
42
-
43
- @types << -4
44
- @values << "OR>"
45
-
46
- self
47
- end
48
-
49
- def xor(condition1, condition2)
50
- @types << -4
51
- @values << "<XOR"
52
-
53
- @types.concat(condition1.types)
54
- @values.concat(condition1.values)
55
-
56
- @types.concat(condition2.types)
57
- @values.concat(condition2.values)
58
-
59
- @types << -4
60
- @values << "XOR>"
61
-
62
- self
63
- end
64
-
65
- def not(condition)
66
- @types << -4
67
- @values << "<NOT"
68
-
69
- @types.concat(condition.types)
70
- @values.concat(condition.values)
71
-
72
- @types << -4
73
- @values << "NOT>"
74
-
75
- self
76
- end
77
-
78
- # Relational Operators
79
- # f.type("Circle").greater_than(5)
80
- def greater_than(value)
81
- @types << -4
82
- @values << ">="
83
- @types << 40 # floating point
84
- @values << value
85
- self
86
- end
87
-
88
- def less_than(value)
89
- @types << -4
90
- @values << "<="
91
- @types << 40 # floating point
92
- @values << value
93
- self
94
- end
95
-
96
- def equal_to(value)
97
- @types << -4
98
- @values << "="
99
- @types << 40 # floating point
100
- @values << value
101
- self
102
- end
103
-
104
- def not_equal_to(value)
105
- @types << -4
106
- @values << "<>"
107
- @types << 40 # floating point
108
- @values << value
109
- self
110
- end
111
-
112
- def block_reference(name = nil)
113
- # return unless name
114
-
115
- @types << 0
116
- @values << "INSERT"
117
- self
118
- end
119
-
120
- def name(value)
121
- @types << [0, 2]
122
- @values << value
123
- self
124
- end
125
-
126
- def type(kind)
127
- @types << 0
128
- @values << kind
129
- self
130
- end
131
-
132
- def layer(name)
133
- @types << 8
134
- @values << name
135
- self
136
- end
137
-
138
- def visible(vis = true)
139
- @types << 60
140
- @values << (vis ? 0 : 1)
141
- self
142
- end
143
-
144
- def color(num)
145
- @types << 62 # Color number filter
146
- @values << num
147
- self
148
- end
149
-
150
- def paper_space
151
- @types << 67 # Paper space filter
152
- @values << 1
153
- self
154
- end
155
-
156
- def model_space
157
- @types << 67 # Model space filter
158
- @values << 0
159
- self
160
- end
161
-
162
- def contains(str)
163
- @types << -4
164
- @values << "<OR"
165
-
166
- # Filter for TEXT
167
- @types << 1 # Text string group code for TEXT
168
- @values << "*#{str}*"
169
-
170
- # Filter for MTEXT
171
- @types << 1 # Text string group code for MTEXT
172
- @values << "*#{str}*"
173
-
174
- @types << -4
175
- @values << "OR>"
176
-
177
- self
178
- end
179
- end
180
- end
1
+ module Autocad
2
+ # Builds AutoCAD selection filter criteria using group codes
3
+ #
4
+ # Provides a fluent interface for creating complex entity filters
5
+ # based on AutoCAD DXF group codes and logical operations.
6
+ #
7
+ # Key Features:
8
+ # - Logical operators (AND, OR, NOT, XOR)
9
+ # - Comparison operators (>, <, =, !=)
10
+ # - Entity property filters (type, layer, color)
11
+ # - Text content matching
12
+ # - Space-specific filtering (model/paper)
13
+ #
14
+ # @example Create a filter for red circles
15
+ # filter = SelectionFilter.new
16
+ # .and(
17
+ # SelectionFilter.new.type("CIRCLE"),
18
+ # SelectionFilter.new.color(1)
19
+ # )
20
+ #
21
+ # @example Complex filter with nested conditions
22
+ # filter = SelectionFilter.new
23
+ # .and(
24
+ # SelectionFilter.new.layer("WALLS"),
25
+ # SelectionFilter.new.or(
26
+ # SelectionFilter.new.type("LINE"),
27
+ # SelectionFilter.new.type("POLYLINE")
28
+ # )
29
+ # )
30
+ class SelectionFilter
31
+ # @rbs attr_reader types: Array[Integer] -- AutoCAD group codes (e.g., 0=Entity type)
32
+ # @rbs attr_reader values: Array[untyped] -- Filter values matching group codes
33
+ attr_reader :types, :values
34
+
35
+ # Initialize empty filter
36
+ # @return [void]
37
+ # @rbs return void
38
+ def initialize
39
+ @types = []
40
+ @values = []
41
+ end
42
+
43
+ # Check if filter has any conditions
44
+ # @return [Boolean] True if filter has conditions
45
+ # @example Skip empty filter
46
+ # next unless filter.has_filters?
47
+ # @rbs return bool
48
+ def has_filters?
49
+ @types.any?
50
+ end
51
+
52
+ # Logical AND combination of filters
53
+ # @param conditions [Array<SelectionFilter>] Filters to combine
54
+ # @return [self] The filter for chaining
55
+ # @example Combine multiple conditions with AND
56
+ # filter.and(
57
+ # SelectionFilter.new.type("LINE"),
58
+ # SelectionFilter.new.layer("WALLS")
59
+ # )
60
+ # @rbs *conditions: Array[SelectionFilter] -- Filters to combine
61
+ # @rbs return SelectionFilter
62
+ def and(*conditions)
63
+ return self if conditions.empty?
64
+
65
+ @types << -4
66
+ @values << "<AND"
67
+
68
+ conditions.each do |condition|
69
+ @types.concat(condition.types)
70
+ @values.concat(condition.values)
71
+ end
72
+
73
+ @types << -4
74
+ @values << "AND>"
75
+
76
+ self
77
+ end
78
+
79
+ # Logical OR combination of filters
80
+ # @param conditions [Array<SelectionFilter>] Filters to combine
81
+ # @return [self] The filter for chaining
82
+ # @example Match entities on multiple layers
83
+ # filter.or(
84
+ # SelectionFilter.new.layer("WALLS"),
85
+ # SelectionFilter.new.layer("DOORS")
86
+ # )
87
+ # @rbs *conditions: Array[SelectionFilter]
88
+ # @rbs return SelectionFilter
89
+ def or(*conditions)
90
+ return self if conditions.empty?
91
+
92
+ @types << -4
93
+ @values << "<OR"
94
+
95
+ conditions.each do |condition|
96
+ @types.concat(condition.types)
97
+ @values.concat(condition.values)
98
+ end
99
+
100
+ @types << -4
101
+ @values << "OR>"
102
+
103
+ self
104
+ end
105
+
106
+ # Logical XOR combination of two filters
107
+ # @param condition1 [SelectionFilter] First filter
108
+ # @param condition2 [SelectionFilter] Second filter
109
+ # @return [self] The filter for chaining
110
+ # @example Select entities that match exactly one condition
111
+ # filter.xor(
112
+ # SelectionFilter.new.type("CIRCLE"),
113
+ # SelectionFilter.new.layer("SPECIAL")
114
+ # )
115
+ # @rbs condition1: SelectionFilter
116
+ # @rbs condition2: SelectionFilter
117
+ # @rbs return SelectionFilter
118
+ def xor(condition1, condition2)
119
+ @types << -4
120
+ @values << "<XOR"
121
+
122
+ @types.concat(condition1.types)
123
+ @values.concat(condition1.values)
124
+
125
+ @types.concat(condition2.types)
126
+ @values.concat(condition2.values)
127
+
128
+ @types << -4
129
+ @values << "XOR>"
130
+
131
+ self
132
+ end
133
+
134
+ # Logical NOT for a filter condition
135
+ # @param condition [SelectionFilter] Filter to negate
136
+ # @return [self] The filter for chaining
137
+ # @example Select everything except circles
138
+ # filter.not(SelectionFilter.new.type("CIRCLE"))
139
+ # @rbs condition: SelectionFilter
140
+ # @rbs return SelectionFilter
141
+ def not(condition)
142
+ @types << -4
143
+ @values << "<NOT"
144
+
145
+ @types.concat(condition.types)
146
+ @values.concat(condition.values)
147
+
148
+ @types << -4
149
+ @values << "NOT>"
150
+
151
+ self
152
+ end
153
+
154
+ # Relational Operators
155
+
156
+ # Greater than comparison
157
+ # @param value [Numeric] Comparison value
158
+ # @return [self] The filter for chaining
159
+ # @example Find circles with radius > 5
160
+ # filter.type("CIRCLE").greater_than(5)
161
+ # @rbs value: Numeric -- Comparison value
162
+ # @rbs return SelectionFilter
163
+ def greater_than(value)
164
+ @types << -4
165
+ @values << ">="
166
+ @types << 40 # floating point
167
+ @values << value
168
+ self
169
+ end
170
+
171
+ # Less than comparison
172
+ # @param value [Numeric] Comparison value
173
+ # @return [self] The filter for chaining
174
+ # @example Find circles with radius < 10
175
+ # filter.type("CIRCLE").less_than(10)
176
+ # @rbs value: Numeric -- Comparison value
177
+ # @rbs return SelectionFilter
178
+ def less_than(value)
179
+ @types << -4
180
+ @values << "<="
181
+ @types << 40 # floating point
182
+ @values << value
183
+ self
184
+ end
185
+
186
+ # Equal to comparison
187
+ # @param value [Numeric] Comparison value
188
+ # @return [self] The filter for chaining
189
+ # @example Find circles with radius = 7.5
190
+ # filter.type("CIRCLE").equal_to(7.5)
191
+ # @rbs value: Numeric -- Comparison value
192
+ # @rbs return SelectionFilter
193
+ def equal_to(value)
194
+ @types << -4
195
+ @values << "="
196
+ @types << 40 # floating point
197
+ @values << value
198
+ self
199
+ end
200
+
201
+ # Not equal to comparison
202
+ # @param value [Numeric] Comparison value
203
+ # @return [self] The filter for chaining
204
+ # @example Find circles with radius != 5
205
+ # filter.type("CIRCLE").not_equal_to(5)
206
+ # @rbs value: Numeric -- Comparison value
207
+ # @rbs return SelectionFilter
208
+ def not_equal_to(value)
209
+ @types << -4
210
+ @values << "<>"
211
+ @types << 40 # floating point
212
+ @values << value
213
+ self
214
+ end
215
+
216
+ # Filter by block references
217
+ # @param name [String, nil] Optional block name pattern
218
+ # @return [self] The filter for chaining
219
+ # @example Find any block reference
220
+ # filter.block_reference
221
+ # @example Find specific block
222
+ # filter.block_reference("DOOR")
223
+ # @rbs name: String? -- Optional block name pattern
224
+ # @rbs return SelectionFilter
225
+ def block_reference(name = nil)
226
+ # return unless name
227
+
228
+ @types << 0
229
+ @values << "INSERT"
230
+ self
231
+ end
232
+
233
+ # Filter by entity name/type
234
+ # @param value [String] Entity type name (e.g., "CIRCLE")
235
+ # @return [self] The filter for chaining
236
+ # @example Filter by entity name
237
+ # filter.name("CIRCLE")
238
+ # @rbs value: String -- Entity type name (e.g., "CIRCLE")
239
+ # @rbs return SelectionFilter
240
+ def name(value)
241
+ @types << [0, 2]
242
+ @values << value
243
+ self
244
+ end
245
+
246
+ # Filter by entity type
247
+ # @param kind [String] Entity type name (e.g., "CIRCLE")
248
+ # @return [self] The filter for chaining
249
+ # @example Filter for lines
250
+ # filter.type("LINE")
251
+ # @rbs kind: String -- Entity type name (e.g., "CIRCLE")
252
+ # @rbs return SelectionFilter
253
+ def type(kind)
254
+ @types << 0
255
+ @values << kind
256
+ self
257
+ end
258
+
259
+ # Filter by layer name
260
+ # @param name [String] Layer name
261
+ # @return [self] The filter for chaining
262
+ # @example Filter for entities on a specific layer
263
+ # filter.layer("WALLS")
264
+ # @rbs name: String -- Layer name
265
+ # @rbs return SelectionFilter
266
+ def layer(name)
267
+ @types << 8
268
+ @values << name
269
+ self
270
+ end
271
+
272
+ # Filter by visibility state
273
+ # @param vis [Boolean] True for visible entities
274
+ # @return [self] The filter for chaining
275
+ # @example Filter for visible entities
276
+ # filter.visible(true)
277
+ # @example Filter for hidden entities
278
+ # filter.visible(false)
279
+ # @rbs vis: bool -- True for visible entities
280
+ # @rbs return SelectionFilter
281
+ def visible(vis = true)
282
+ @types << 60
283
+ @values << (vis ? 0 : 1)
284
+ self
285
+ end
286
+
287
+ # Filter by color index
288
+ # @param num [Integer] AutoCAD color number (0-256)
289
+ # @return [self] The filter for chaining
290
+ # @example Filter for red entities (color 1)
291
+ # filter.color(1)
292
+ # @rbs num: Integer -- AutoCAD color number (0-256)
293
+ # @rbs return SelectionFilter
294
+ def color(num)
295
+ @types << 62 # Color number filter
296
+ @values << num
297
+ self
298
+ end
299
+
300
+ # Filter for paper space entities
301
+ # @return [self] The filter for chaining
302
+ # @example Filter for paper space entities
303
+ # filter.paper_space
304
+ # @rbs return SelectionFilter
305
+ def paper_space
306
+ @types << 67 # Paper space filter
307
+ @values << 1
308
+ self
309
+ end
310
+
311
+ # Filter for model space entities
312
+ # @return [self] The filter for chaining
313
+ # @example Filter for model space entities
314
+ # filter.model_space
315
+ # @rbs return SelectionFilter
316
+ def model_space
317
+ @types << 67 # Model space filter
318
+ @values << 0
319
+ self
320
+ end
321
+
322
+ # Filter text content using wildcards
323
+ # @param str [String] Search pattern (e.g., "*REV*")
324
+ # @return [self] The filter for chaining
325
+ # @example Find text containing "REVISION"
326
+ # filter.contains("*REVISION*")
327
+ # @rbs str: String -- Search pattern (e.g., "*REV*")
328
+ # @rbs return SelectionFilter
329
+ def contains(str)
330
+ @types << -4
331
+ @values << "<OR"
332
+
333
+ # Filter for TEXT
334
+ @types << 1 # Text string group code for TEXT
335
+ @values << "*#{str}*"
336
+
337
+ # Filter for MTEXT
338
+ @types << 1 # Text string group code for MTEXT
339
+ @values << "*#{str}*"
340
+
341
+ @types << -4
342
+ @values << "OR>"
343
+
344
+ self
345
+ end
346
+
347
+ # Helper method for text content matching
348
+ # @param str [String] Text to search for
349
+ # @return [self] The filter for chaining
350
+ # @example Find text containing specific content
351
+ # filter.has_text("Revision")
352
+ # @rbs str: String -- Text to search for
353
+ # @rbs return SelectionFilter
354
+ def has_text(str)
355
+ contains(str)
356
+ end
357
+ end
358
+ end