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.
- checksums.yaml +4 -4
- data/.rubocop/minitest.yml +2 -2
- data/.rubocop/strict.yml +4 -4
- data/.rubocop.yml +36 -33
- data/CHANGELOG.md +5 -5
- data/LICENSE.txt +21 -21
- data/README.md +134 -39
- data/Rakefile +26 -10
- data/exe/autocad +3 -3
- data/gemfiles/rubocop.gemfile +2 -1
- data/lib/autocad/app.rb +127 -28
- data/lib/autocad/arc.rb +3 -0
- data/lib/autocad/block.rb +11 -6
- data/lib/autocad/block_reference.rb +33 -4
- data/lib/autocad/bounding_box.rb +202 -0
- data/lib/autocad/dim_style.rb +4 -0
- data/lib/autocad/drawing.rb +873 -172
- data/lib/autocad/element.rb +217 -25
- data/lib/autocad/errors.rb +9 -0
- data/lib/autocad/filter.rb +502 -168
- data/lib/autocad/layer.rb +129 -41
- data/lib/autocad/layout.rb +120 -0
- data/lib/autocad/line.rb +154 -55
- data/lib/autocad/message_box.rb +95 -95
- data/lib/autocad/model.rb +217 -89
- data/lib/autocad/mtext.rb +189 -110
- data/lib/autocad/plot.rb +45 -0
- data/lib/autocad/plot_configuration.rb +372 -0
- data/lib/autocad/point.rb +7 -0
- data/lib/autocad/point3d.rb +18 -11
- data/lib/autocad/pviewport.rb +136 -21
- data/lib/autocad/selection_filter.rb +358 -180
- data/lib/autocad/selection_set.rb +140 -61
- data/lib/autocad/selection_set_adapter.rb +187 -8
- data/lib/autocad/spline.rb +27 -0
- data/lib/autocad/text.rb +66 -11
- data/lib/autocad/text_style.rb +4 -0
- data/lib/autocad/version.rb +1 -1
- data/lib/autocad/viewport.rb +57 -0
- data/lib/autocad.rb +126 -30
- data/lib/faa/cleanup.rb +137 -0
- data/lib/win32ole_helper.rb +52 -0
- data/rbs_collection.lock.yaml +38 -18
- data/sig/generated/autocad/app.rbs +278 -251
- data/sig/generated/autocad/arc.rbs +6 -3
- data/sig/generated/autocad/block.rbs +8 -5
- data/sig/generated/autocad/block_reference.rbs +99 -59
- data/sig/generated/autocad/bounding_box.rbs +78 -0
- data/sig/generated/autocad/dim_style.rbs +6 -0
- data/sig/generated/autocad/drawing.rbs +597 -158
- data/sig/generated/autocad/element.rbs +233 -166
- data/sig/generated/autocad/errors.rbs +29 -23
- data/sig/generated/autocad/filter.rbs +388 -60
- data/sig/generated/autocad/layer.rbs +76 -19
- data/sig/generated/autocad/layout.rbs +64 -0
- data/sig/generated/autocad/line.rbs +128 -25
- data/sig/generated/autocad/message_box.rbs +81 -81
- data/sig/generated/autocad/model.rbs +115 -41
- data/sig/generated/autocad/mtext.rbs +123 -0
- data/sig/generated/autocad/plot.rbs +26 -0
- data/sig/generated/autocad/plot_configuration.rbs +176 -0
- data/sig/generated/autocad/point.rbs +7 -0
- data/sig/generated/autocad/point3d.rbs +70 -66
- data/sig/generated/autocad/pviewport.rbs +64 -0
- data/sig/generated/autocad/selection_filter.rbs +226 -50
- data/sig/generated/autocad/selection_set.rbs +112 -37
- data/sig/generated/autocad/selection_set_adapter.rbs +235 -28
- data/sig/generated/autocad/spline.rbs +22 -0
- data/sig/generated/autocad/text.rbs +66 -7
- data/sig/generated/autocad/text_style.rbs +6 -0
- data/sig/generated/autocad/viewport.rbs +19 -2
- data/sig/generated/autocad.rbs +140 -68
- data/sig/generated/faa/cleanup.rbs +53 -0
- data/sig/generated/win32ole_helper.rbs +9 -0
- data/sig/prototype/lib/autocad/app.rbs +3 -1
- data/sig/prototype/lib/autocad/bounding_box.rbs +15 -0
- data/sig/prototype/lib/autocad/drawing.rbs +6 -0
- data/sig/prototype/lib/autocad/layer.rbs +5 -0
- data/sig/prototype/lib/autocad/viewport.rbs +7 -0
- data/sig/prototype/lib/autocad.rbs +1 -1
- metadata +29 -5
- data/event_handler.log +0 -24
- data/sig/generated/autocad/text_node.rbs +0 -37
@@ -1,180 +1,358 @@
|
|
1
|
-
module Autocad
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
@
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
@
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
#
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
@
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
@
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
@
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
@
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
@types
|
146
|
-
@values
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
@
|
165
|
-
|
166
|
-
#
|
167
|
-
@
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
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
|