.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SelectImplied Help

1 REPLY 1
Reply
Message 1 of 2
cgay
1580 Views, 1 Reply

SelectImplied Help

Hello All,

Using AutoCAD 2007 & VB.NET(2005)
I was following Kean's fine example here,
http://through-the-interface.typepad.com/through_the_interface/2006/09/using_the_pickf.html
,to use Implied Selection Set. I converted it to VB.NET.
I get the error:
[code]
Unhandled error,Autodesk.AutoCAD.Runtime.Exception: eNullObjectId
at Autodesk.AutoCAD.Runtime.Interop.Check(Int32 returnValue)
at Autodesk.AutoCAD.EditorInput.SelectionSet.GetAdsName()
at Autodesk.AutoCAD.EditorInput.Editor.SetImpliedSelection(ObjectId[]
selectedObjects)
[/code]
When this line:
ed.SetImpliedSelection(New AcadDS.ObjectId() {New AcadDS.ObjectId(0)})
is executed.
Kean's original C# code looks like this:
ed.SetImpliedSelection(new ObjectId[0]);

Anyone have an idea as to what is going wrong here?

Here is some code:
[code]
Imports AcadAS = AutoDesk.AutoCAD.ApplicationServices
Imports AcadApp = AutoDesk.AutoCAD.ApplicationServices.Application
Imports AcadEI = AutoDesk.AutoCAD.EditorInput
Imports AcadDS = AutoDesk.AutoCAD.DatabaseServices

<AcadRT.CommandMethod("PFT", AcadRT.CommandFlags.Modal Or _
AcadRT.CommandFlags.UsePickSet Or AcadRT.CommandFlags.Redraw)> _
Public Shared Sub PickFirstTest()
Dim doc As AcadAS.Document = AcadApp.DocumentManager.MdiActiveDocument
Dim ed As AcadEI.Editor = doc.Editor
Try
Dim selectionRes As AcadEI.PromptSelectionResult = ed.SelectImplied
If selectionRes.Status = AcadEI.PromptStatus.Error Then
Dim selectionOpts As AcadEI.PromptSelectionOptions = New AcadEI.PromptSelectionOptions
selectionOpts.MessageForAdding = "\nSelect objects to list: "
selectionRes = ed.GetSelection(selectionOpts)
Else
ed.SetImpliedSelection(New AcadDS.ObjectId() {New AcadDS.ObjectId(0)})
End If
If selectionRes.Status = AcadEI.PromptStatus.OK Then
Using tr As AcadDS.Transaction = doc.TransactionManager.StartTransaction
Try
Dim objIds() As AcadDS.ObjectId = selectionRes.Value.GetObjectIds
For Each objId As AcadDS.ObjectId In objIds
Using ent As AcadDS.Entity = DirectCast(tr.GetObject(objId, AcadDS.OpenMode.ForRead), AcadDS.Entity)
ent.List()
End Using
Next
tr.Commit()
Catch ex As Exception
ed.WriteMessage("Unhandled error," & ex.ToString)
tr.Abort()
End Try
End Using
End If
Catch ex As Exception
ed.WriteMessage("Unhandled error," & ex.ToString)
End Try
End Sub
[/code]
1 REPLY 1
Message 2 of 2
cgay
in reply to: cgay

All,
So I tried:
ed.SetImpliedSelection(Nothing)
Seems to work now.

C

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost