Class: Autocad::SelectionSet
- Inherits:
-
Object
- Object
- Autocad::SelectionSet
- Defined in:
- lib/autocad/selection_set.rb
Overview
Manages named selection criteria for AutoCAD entities
Stores filter criteria for entity selection without executing the selection. Works with SelectionSetAdapter to apply filters and retrieve entities.
Instance Attribute Summary collapse
-
#filter_types ⇒ Object
readonly
Returns the value of attribute filter_types.
-
#filter_values ⇒ Object
readonly
Returns the value of attribute filter_values.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#clear_filter ⇒ self
Clear all filter criteria.
-
#filter {|Filter| ... } ⇒ self
Configure complex filters through block.
-
#filter_block_references(name = nil) ⇒ self
Filter for block references with optional name.
-
#filter_by_layer(*layers) ⇒ self
Filter by layer names.
-
#filter_by_type(*types) ⇒ self
Filter by entity types.
-
#filter_text(str = nil) ⇒ self
Filter for text entities with optional content matching.
-
#filter_text_containing(text) ⇒ self
Filter text entities containing specific text.
-
#has_filter? ⇒ Boolean
Check if set has active filters.
-
#initialize(name) ⇒ SelectionSet
constructor
Initialize a new selection set with a name.
Constructor Details
#initialize(name) ⇒ SelectionSet
Initialize a new selection set with a name
25 26 27 28 29 |
# File 'lib/autocad/selection_set.rb', line 25 def initialize(name) @name = name @filter_types = [] @filter_values = [] end |
Instance Attribute Details
#filter_types ⇒ Object (readonly)
Returns the value of attribute filter_types.
19 20 21 |
# File 'lib/autocad/selection_set.rb', line 19 def filter_types @filter_types end |
#filter_values ⇒ Object (readonly)
Returns the value of attribute filter_values.
19 20 21 |
# File 'lib/autocad/selection_set.rb', line 19 def filter_values @filter_values end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
19 20 21 |
# File 'lib/autocad/selection_set.rb', line 19 def name @name end |
Instance Method Details
#clear_filter ⇒ self
Clear all filter criteria
84 85 86 87 88 |
# File 'lib/autocad/selection_set.rb', line 84 def clear_filter @filter_types = [] @filter_values = [] self end |
#filter {|Filter| ... } ⇒ self
Configure complex filters through block
72 73 74 75 76 77 78 79 |
# File 'lib/autocad/selection_set.rb', line 72 def filter if block_given? filter = Filter.new result = yield filter @filter_types, @filter_values = result.convert_clauses end self end |
#filter_block_references(name = nil) ⇒ self
Filter for block references with optional name
136 137 138 |
# File 'lib/autocad/selection_set.rb', line 136 def filter_block_references(name = nil) filter { |f| f.block_reference(name) } end |
#filter_by_layer(*layers) ⇒ self
Filter by layer names
110 111 112 |
# File 'lib/autocad/selection_set.rb', line 110 def filter_by_layer(*layers) filter { |f| f.or(*layers.map { |l| f.layer(l) }) } end |
#filter_by_type(*types) ⇒ self
Filter by entity types
99 100 101 |
# File 'lib/autocad/selection_set.rb', line 99 def filter_by_type(*types) filter { |f| f.or(*types.map { |t| f.type(t) }) } end |
#filter_text(str = nil) ⇒ self
Filter for text entities with optional content matching
47 48 49 50 51 52 53 54 55 |
# File 'lib/autocad/selection_set.rb', line 47 def filter_text(str = nil) if str filter_text_containing(str) else filter do |f| f.or(f.type("TEXT"), f.type("MTEXT")) end end end |
#filter_text_containing(text) ⇒ self
Filter text entities containing specific text
121 122 123 124 125 |
# File 'lib/autocad/selection_set.rb', line 121 def filter_text_containing(text) filter do |f| f.and(f.has_text(text), f.or(f.type("TEXT"), f.type("MTEXT"))) end end |
#has_filter? ⇒ Boolean
Check if set has active filters
34 35 36 |
# File 'lib/autocad/selection_set.rb', line 34 def has_filter? filter_types && filter_types.any? end |