How to use TypedValue array under C# CAD SelectionFilter
How to use TypedValue array
SelectionFilter is a class used to filter AutoCAD entities, in which you can use to select entities with specific attributes.
When constructing a SelectionFilter object, you need to pass in a TypedValue array, which is used to define the selection rules.
In the TypedValue array, each element represents a selection condition, which consists of two parameters: DxfCode and value.
DxfCode is an integer enumeration value used to represent the type of the selection condition, and the value is the corresponding specific attribute value.
Depending on different needs, different TypedValue objects can be defined and combined into an array to implement various custom selection rules.
Commonly used DxfCode enumeration values and their corresponding attribute values
-
(0)
: Select the Start entity -
(1)
: Select the end entity -
(1)
: Select the entity that contains the specified text -
(2)
: Select the entity located in the specified block name -
(8)
: Select the entity located in the specified layer -
(62)
: Select the entity of the specified color -
(6)
: Select the entity located in the specified line type -
(48)
: Select the entity with the specified linear scale -
(370)
: Select the entity with the specified line width -
(5)
: Select the entity with the specified handle -
(10)
: Select the entity with the specified X coordinate -
(20)
: Select the entity with the specified Y coordinate -
(30)
: Select the entity with the specified Z coordinate -
(40)
: Select the entity with the specified radius -
(41)
: Select a solid with a specified diameter -
(50)
: Select the entity with the specified angle -
(38)
: Select the entity with the specified height -
(39)
: Select a solid with a specified thickness -
(7)
: Select the entity that uses the specified text style -
(40)
: Select an entity with the specified text height -
(50)
: Select the entity with the specified text rotation angle -
(1)
: Select the entity containing the specified string -
(330)
: Select the entity with the specified object ID
// Select the line segment with color 1 (red) and located in layer "Layer1"TypedValue[] values = new TypedValue[] { new TypedValue((int), 1), new TypedValue((int), "LINE"), new TypedValue((int), "Layer1") };
Below is a sample code
Demonstrate how to select layers named "rights owner" and "prenumbered"
And the entity of type TEXT:
SelectionFilter innerFilter = new SelectionFilter(new TypedValue[] { new TypedValue((int), "<or"), new TypedValue((int), "Right holder"), new TypedValue((int), "Pre-numbered"), new TypedValue((int), "TEXT"), // Entity type is TEXT new TypedValue((int), "or"), new TypedValue((int), "or"), }); // Use polygon window selection method to let the user select the entity located within the external polyline PromptSelectionResult innerSelRes = (outerPoints, innerFilter);
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.
Related Articles
Complete instance of the custom email sending class implemented by C# (supports multiple people and multiple attachments)
This article mainly introduces the customized email sending class implemented by C#, which has the function of supporting multiple people and multiple attachments. It involves related skills for C# email operation. Friends who need it can refer to it.2015-12-12LINQ to DataSet operation in C# and mutual conversion between DataTable and LINQ
This article introduces the LINQ to DataSet operation in C# and the mutual conversion of DataTable and LINQ. The article introduces it in detail through sample code. It has certain reference value for everyone's study or work. Friends who need it can refer to it.2022-05-05Detailed explanation of the operation of initialization of objects or collections in C#
This article mainly introduces the detailed explanation of the initialization operation of using objects or collections in C#. The article talks about the initialization of objects and dictionaries. Friends who need it can refer to it.2016-01-01C# Use GDI+ to add text that rotates the center (any angle)
This article mainly introduces C# using GDI+ to add center rotation (any angle). Friends who need it can refer to it2018-04-04Example of basic usage of linq syntax
LINQ language integrated query (Language Integrated Query) is a technology that appeared in .NET Framework 3.5. With the help of LINQ technology, we can use a syntax similar to SQL to query any form of data. Let’s learn how to use it.2014-01-01Detailed explanation of the difference between (&&,|) and (&,|) in c#
This article mainly introduces the details of (&&,||) and (&,|) in c#. The article introduces the example code in detail, which has a certain reference learning value for everyone's study or work. Friends who need it, please learn with the editor below.2019-12-12Specific solutions for Unity's multi-screen settings
Multi-screen refers to a computer host connected to multiple monitors. This article mainly introduces the specific plan for Unity's multi-screen settings. The example code is introduced in this article in detail, which has a certain reference learning value for everyone's study or work. Friends who need it, please learn with the editor below.2022-05-05C# implements Hill sorting
This article introduces the method of implementing Hill sorting in C#, and the article introduces it in detail through sample code. It has certain reference value for everyone's study or work. Friends who need it can refer to it.2022-04-04C# development WeChat portal and application (5) User group information management
This article mainly introduces the fifth article of C# development WeChat portal and application. User group information management has certain reference value. Interested friends can refer to it.2017-06-06C# Design Pattern Series Tutorials - Bridge Mode
The bridge mode reduces the complexity when expanding along two or more dimensions, prevents over-expansion of classes, and disconnects the coupling between two or more dimensions so that they change in their respective directions without affecting each other.2016-06-06