56
« on: December 04, 2010, 10:24:53 PM »
In the .NET environment, a SelectionFilter is constructed with a TypedValue array.
A TypedValue can contain various Objects types in its Value property. The Object type is defined in the TypeCode property as an integer (or a DxfCode enum integer) which corresponds to the DXF group code of the Value.
For those who know AutoLISP, a TypedValue looks like a DXF dotted pair (even it is not the same thing, a dotted pair is a LISP specific data).
For the Values which type is String as entity type (DxfCode.Start = 0) or layer (DxfCode.Layer = 8), the Value can contain many patterns separted by commas and use wildcard patterns.
The filter can contain relational tests for the numerical values and logical grouping.
The more complete documentation in the AutoCAD Developer's Help for building sofisticated SelectionFilters is in the AutoLISP Help:
AutoLISP developer's Guide > Using the AutoLISP Language > Using AutoLISP to Manipulate AutoCAD Objects > Selection Set Handling > Selection Set Filter Lists
And the DXF group codes can be found in DXF Reference.
Here's an example to select closed polylines (lw, 2d and 3d) and closed ellipses on layers BASE and CONSTRUCTION
TypedValue[] filter =
{ new TypedValue(-4, "<OR"),
new TypedValue(-4, "<AND"),
new TypedValue(0, "*POLYLINE"), // LWPOLYLINE and POLYLINE
new TypedValue(-4, "&"),
new TypedValue(70, 1), // Closed
new TypedValue(-4, "<NOT"),
new TypedValue(-4, "&"),
new TypedValue(70, 112), // Avoid meshes (bit codes: 16 + 32 + 64)
new TypedValue(-4, "NOT>"),
new TypedValue(-4, "AND>"),
new TypedValue(-4, "<AND"),
new TypedValue(0, "ELLIPSE"),
new TypedValue(-4, "="),
new TypedValue(41, 0.0), // Start parameter
new TypedValue(-4, "="),
new TypedValue(42, 6.283185307179586), // End parameter
new TypedValue(-4, "AND>"),
new TypedValue(-4, "OR>"),
new TypedValue(8, "BASE,CONSTRUCTION")};
SelectionFilter = new SelectionFilter(filter);
target audience:{beginner}