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
Solved! Go to Solution.
Solved by _gile. Go to Solution.
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.
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)
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")})
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
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