.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Filter based on layer

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
gulzar25
774 Views, 6 Replies

Filter based on layer

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

6 REPLIES 6
Message 2 of 7
_gile
in reply to: gulzar25

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

Message 3 of 7
gulzar25
in reply to: _gile

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)

 

Message 4 of 7
_gile
in reply to: gulzar25

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
gulzar25
in reply to: _gile

Thanks a lot for the help 🙂

Message 6 of 7
BKSpurgeon
in reply to: _gile

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

Message 7 of 7
BKSpurgeon
in reply to: _gile

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost