Message 1 of 6
Not applicable
02-16-2013
01:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have other related posts but felt this was a separate question that could deserve its own post so here goes.
I presently have code that will select objects on screen based on particular stored object handles. The code then prompts the user to add additional selections once these handle selections are made. No problem. The problem lies with attempting to deselect the objects that were selected via object handles. I should say highlighted because that is what the present code is doing. It is highlighting the objects on screen. The code I am using follows:
Dim ids(1) As ObjectId
ids(0) = ObjectIdFromHandle(myDocDB, "1D6")
ids(1) = ObjectIdFromHandle(myDocDB, "1DE")
Autodesk.AutoCAD.Internal.Utils.SelectObjects(ids)
' Get the Pickfirst selection set
Dim acSSPrompt As PromptSelectionResult
acSSPrompt = ed.SelectImplied()
Dim Objs As ObjectIdCollection
If acSSPrompt.Status = PromptStatus.OK Then
Objs = New ObjectIdCollection(acSSPrompt.Value.GetObjectIds)
Else
Objs = New ObjectIdCollection
End If
ed.SetImpliedSelection(New ObjectId(-1) {})
If Objs.Count > 0 Then
HighlightEntities(Objs)
End If
acSSPrompt = ed.GetSelection()
If acSSPrompt.Status = PromptStatus.OK Then
For Each obj As ObjectId In acSSPrompt.Value.GetObjectIds
Objs.Add(obj)
Next
Dim ids2 As ObjectId() = New ObjectId(Objs.Count - 1) {}
Objs.CopyTo(ids, 0)
ed.SetImpliedSelection(ids2)
End If
Private Sub HighlightEntities(objIds As ObjectIdCollection)
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim tr As Transaction = doc.TransactionManager.StartTransaction()
Using tr
For Each objId As ObjectId In objIds
Dim ent As Entity = TryCast(tr.GetObject(objId, OpenMode.ForRead), Entity)
If ent IsNot Nothing Then
ent.Highlight()
End If
Next
End Using
End Sub
Thanks in advance for any help anyone can provide.
Solved! Go to Solution.

