Filter based on layer

Filter based on layer

Anonymous
Not applicable
1,202 Views
6 Replies
Message 1 of 7

Filter based on layer

Anonymous
Not applicable

Hi,

I have a curve which is a set of lines and arcs.This is present on a layer.Can anyone provide me code to filter these objects based on layer.I also need to convert all the object ids to a single entity.Please help.

 

Thanks

Gulzar

0 Likes
Accepted solutions (1)
1,203 Views
6 Replies
Replies (6)
Message 2 of 7

_gile
Consultant
Consultant

Hi,

 

About selection filters (extract from here😞

 

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.

 

To join coincident curves into a polyline, you can get some inspiration from this. It uses the PolylineSegment and PolylineSegmentCollection classes defined in the GeometryExtensions assemby available here.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 7

Anonymous
Not applicable

Thanks a lot.I just have a query that selection filter is a typed array if i have only value then how do i declare it.In the below case it gives error.How do i rectify it.

 

Dim typVal AsTypedValue

typVal = New TypedValue(DxfCode.LayerName, "FirstBias")

Dim sf As SelectionFilter = New SelectionFilter(typVal)

 

0 Likes
Message 4 of 7

_gile
Consultant
Consultant
Accepted solution

The SelectionFilter constructor argument have to be  TypedValue array.

 

            Dim typVal As TypedValue
            typVal = New TypedValue(DxfCode.LayerName, "FirstBias")
            Dim typValArray(0) As TypedValue
            typValArray(0) = typVal
            Dim sf As SelectionFilter = New SelectionFilter(typValArray)

 Or, more concisely:

 

Dim sf As SelectionFilter = New SelectionFilter(New TypedValue() {New TypedValue(8, "Calque7")})

 

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 7

Anonymous
Not applicable

Thanks a lot for the help 🙂

0 Likes
Message 6 of 7

BKSpurgeon
Collaborator
Collaborator

Excellent answer.

 

But suppose I have to select an object that is on Layer1 OR layer2?

 

What if one needs to select objects on either Layer1 OR layer2? 

 

any advice would be appreciated. IF i add || it doesn't seem to work here 😞

 

rgds

 

BK

0 Likes
Message 7 of 7

BKSpurgeon
Collaborator
Collaborator

Found the solution! here it is: http://forums.autodesk.com/t5/net/selection-filter-on-multiple-layers/m-p/3431721/highlight/true#M28...

 

just create a string with possible layer names. and voila!

 

regards

 

BK

0 Likes