.NET

.NET

Reply
Active Contributor
greg
Posts: 33
Registered: ‎02-13-2013
Message 1 of 7 (332 Views)

Selecting objects on screen from Handle or ObjectID

332 Views, 6 Replies
02-15-2013 02:14 PM

If I have a list of handles for Autocad Entities, how would I go about selecting these entities on screen so that the user could add to this selection or remove objects from the selection?  I could go with objectids as well if needed.

 

I have been searching and searching and coming up empty handed or at least coming up with information that doesnt seem to dowhat I want.

 

Thanks,

 

Moderator
Alexander.Rivilis
Posts: 1,450
Registered: ‎04-09-2008
Message 2 of 7 (329 Views)

Re: Selecting objects on screen from Handle or ObjectID

02-15-2013 02:24 PM in reply to: greg

Method Editor.SelectImplied can help you. Command must be registered with CommandFlags.Redraw | CommandFlags.UsePickSet attributes


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Active Contributor
greg
Posts: 33
Registered: ‎02-13-2013
Message 3 of 7 (305 Views)

Re: Selecting objects on screen from Handle or ObjectID

02-15-2013 05:12 PM in reply to: Alexander.Rivilis

Hi Alexander,

 

I am not sure where to head with this.  I attempted but just not sure what to do.  Do I need to build a selection set within code?  Can you do that without prompting a user for selections?  I guess I am a bit lost now.

 

Thanks for your help!  Greatly appreciated!

Active Contributor
greg
Posts: 33
Registered: ‎02-13-2013
Message 4 of 7 (303 Views)

Re: Selecting objects on screen from Handle or ObjectID

02-15-2013 05:27 PM in reply to: Alexander.Rivilis

In addition, I have tried using:

 

Autodesk.AutoCAD.Internal.Utils.SelectObjects(anobjectid)

 

but when I use an objectId in that line I get a message that :

 

Value of type 'System.Collections.Generic.List(Of Autodesk.AutoCAD.DatabaseServices.ObjectId)' cannot be converted to '1-dimensional array of Autodesk.AutoCAD.DatabaseServices.ObjectId'

 

thanks,

Active Contributor
greg
Posts: 33
Registered: ‎02-13-2013
Message 5 of 7 (301 Views)

Re: Selecting objects on screen from Handle or ObjectID

02-15-2013 05:32 PM in reply to: Alexander.Rivilis

Nevermind.  I finally got the code to work I think.  it is as follows:

 

Dim ids(0) As ObjectId
ids(0) = ObjectIdFromHandle(myDocDB, "1D6")
Autodesk.AutoCAD.Internal.Utils.SelectObjects(ids)

 

Thanks for your help!

Active Contributor
greg
Posts: 33
Registered: ‎02-13-2013
Message 6 of 7 (298 Views)

Re: Selecting objects on screen from Handle or ObjectID

02-15-2013 05:45 PM in reply to: greg

I guess this may not work because you not already in a command?

Active Contributor
greg
Posts: 33
Registered: ‎02-13-2013
Message 7 of 7 (288 Views)

Re: Selecting objects on screen from Handle or ObjectID

02-15-2013 06:32 PM in reply to: greg

Okay, I think I got some of this to work.  My only issue is that how do I stop and allow the user to add or remove from the current on screen selection.  This is what I have so far but i never get prompted to revise the selection.

 

                Dim ids(1) As ObjectId
                ids(0) = ObjectIdFromHandle(myDocDB, "1D6")
                ids(1) = ObjectIdFromHandle(myDocDB, "1DE")

                Autodesk.AutoCAD.Internal.Utils.SelectObjects(ids)

                Dim prObjectSelectionOptions As PromptSelectionOptions = New PromptSelectionOptions()

                prObjectSelectionOptions.MessageForAdding = vbCrLf & "Please revise polyline selection:"

                '  Prompt for selections
                Dim prObjectSelectionRes As PromptSelectionResult = ed.SelectImplied()
                '  I am then trying to allow the user to add additional selections, or remove here
                prObjectSelectionRes = ed.GetSelection(prObjectSelectionOptions)

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.