.NET

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

Selecting objects on screen from Handle or ObjectID

273 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,398
Registered: ‎04-09-2008
Message 2 of 7 (270 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 (246 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 (244 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 (242 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 (239 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 (229 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)

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community