Create SelectionSet VB.NET (filtered with conditions)

Create SelectionSet VB.NET (filtered with conditions)

sgrya1
Advocate Advocate
3,329 Views
3 Replies
Message 1 of 4

Create SelectionSet VB.NET (filtered with conditions)

sgrya1
Advocate
Advocate
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
0 Likes
3,330 Views
3 Replies
Replies (3)
Message 2 of 4

chiefbraincloud
Collaborator
Collaborator
There is a difference between a Selection Set and an ObjectIdCollection. If you do a For Each on a SelectionSet, the type of object you will be retrieving is SelectedObject, but there is limited information available from a SelectedObject, so most of the time you need to use the ObjectId to open the object to query or modify parameters.
Dave O.                                                                  Sig-Logos32.png
0 Likes
Message 3 of 4

sgrya1
Advocate
Advocate
Thanks Chiefbraincloud! I'm going to have to try to get my head around that one.
The same object needs to be put in a different context to allow it to be read from the database I guess.
Not sure the reason for a Selection Set now, but it doesn't appear as I can get to the ObjectIdCollection without using one.

Must be able to do colective actions on a selectionset.

Have to look into it... Edited by: sgrya1 on Mar 1, 2010 11:40 PM
0 Likes
Message 4 of 4

Anonymous
Not applicable
{quote}

but there is limited information available from a SelectedObject

{quote}

Nonsense.

That's only the case if you don't understand how it
works, and how to use it.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
0 Likes