Message 1 of 4
Create SelectionSet VB.NET (filtered with conditions)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need to create some filtered SelectionSets.
I converted this example as best as I am able for the filtering. Any comments on the conversion welcome.
http://through-the-interface.typepad.com/through_the_interface/2008/07/conditional-sel.html
Another example I found showed how to create a SelectionSet but it then converts it to an ObjectIdCollection for use.
Is there a difference betwen a SelectionSet and an ObjectIdCollection? They appear to be the same thing.
Public Sub SelectEntitiesWithProperties()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim ent As Entity
Dim ss As Autodesk.AutoCAD.EditorInput.SelectionSet
Dim oIDs As ObjectIdCollection
Dim filter(10) As TypedValue
Try
filter(0) = New TypedValue(DxfCode.Operator, "
filter(1) = New TypedValue(DxfCode.Operator, "
filter(2) = New TypedValue(DxfCode.LayerName, "0")
filter(3) = New TypedValue(DxfCode.Start, "LINE")
filter(4) = New TypedValue(DxfCode.Operator, "and>")
filter(5) = New TypedValue(DxfCode.Operator, "
filter(6) = New TypedValue(DxfCode.Start, "CIRCLE")
filter(7) = New TypedValue(DxfCode.Operator, ">=")
filter(8) = New TypedValue(DxfCode.Real, 10)
filter(9) = New TypedValue(DxfCode.Operator, "and>")
filter(10) = New TypedValue(DxfCode.Operator, "or>")
Dim sf As SelectionFilter = New SelectionFilter(filter)
Dim psr As PromptSelectionResult = ed.SelectAll(sf)
ss = psr.Value
If ss.Count > 0 Then
oids = New ObjectIdCollection(ss.GetObjectIds)
For Each oid In oids
ent = oid.GetObject(OpenMode.ForRead)
If TypeOf ent Is BlockReference Then
'br = CType(ent, BlockReference)
'Debug.Print(br.Name)
End If
Next
End If
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
End Sub
I converted this example as best as I am able for the filtering. Any comments on the conversion welcome.
http://through-the-interface.typepad.com/through_the_interface/2008/07/conditional-sel.html
Another example I found showed how to create a SelectionSet but it then converts it to an ObjectIdCollection for use.
Is there a difference betwen a SelectionSet and an ObjectIdCollection? They appear to be the same thing.
Public Sub SelectEntitiesWithProperties()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim ent As Entity
Dim ss As Autodesk.AutoCAD.EditorInput.SelectionSet
Dim oIDs As ObjectIdCollection
Dim filter(10) As TypedValue
Try
filter(0) = New TypedValue(DxfCode.Operator, "
filter(3) = New TypedValue(DxfCode.Start, "LINE")
filter(4) = New TypedValue(DxfCode.Operator, "and>")
filter(5) = New TypedValue(DxfCode.Operator, "
filter(7) = New TypedValue(DxfCode.Operator, ">=")
filter(8) = New TypedValue(DxfCode.Real, 10)
filter(9) = New TypedValue(DxfCode.Operator, "and>")
filter(10) = New TypedValue(DxfCode.Operator, "or>")
Dim sf As SelectionFilter = New SelectionFilter(filter)
Dim psr As PromptSelectionResult = ed.SelectAll(sf)
ss = psr.Value
If ss.Count > 0 Then
oids = New ObjectIdCollection(ss.GetObjectIds)
For Each oid In oids
ent = oid.GetObject(OpenMode.ForRead)
If TypeOf ent Is BlockReference Then
'br = CType(ent, BlockReference)
'Debug.Print(br.Name)
End If
Next
End If
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
End Sub