.NET

Reply
Active Contributor
gulzar25
Posts: 42
Registered: ‎07-02-2013
Message 1 of 5 (201 Views)
Accepted Solution

Filter based on layer

201 Views, 4 Replies
07-11-2013 03:08 AM

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

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")})

 

 

*Expert Elite*
_gile
Posts: 2,104
Registered: ‎04-29-2006
Message 2 of 5 (198 Views)

Re : Filter based on layer

07-11-2013 03:25 AM 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
Active Contributor
gulzar25
Posts: 42
Registered: ‎07-02-2013
Message 3 of 5 (194 Views)

Re : Filter based on layer

07-11-2013 03:38 AM 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)

 

*Expert Elite*
_gile
Posts: 2,104
Registered: ‎04-29-2006
Message 4 of 5 (188 Views)

Re : Filter based on layer

07-11-2013 04:37 AM 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
Active Contributor
gulzar25
Posts: 42
Registered: ‎07-02-2013
Message 5 of 5 (179 Views)

Re : Filter based on layer

07-11-2013 04:55 AM in reply to: _gile

Thanks a lot for the help :smileyhappy:

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.