New Member
1 Posts
0 Kudos
Registered: ‎05-13-2014
Post 1 of 3

how to get an object ID

125 Views, 2 Replies
05-13-2014 07:05 PM

i am using vb.net , and i am now trying to obtain the id of a certain selected object.

firstly i will promote a message and ask users to select one object, and later, obtain the ID of this object.

what command or function avalible for me to obtain the ID of a selected object.

Valued Mentor
472 Posts
67 Kudos
Registered: ‎01-12-2008
Post 2 of 3

Re: how to get an object ID

05-13-2014 11:12 PM in reply to: h.yang
232 Posts
30 Kudos
Registered: ‎11-09-2012
Post 3 of 3

Re: how to get an object ID

05-14-2014 03:01 AM in reply to: h.yang


you can try below code to get the object id of a selected object.


 <CommandMethod("TST")> Public Sub TESTObject()
        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim ed As Editor = doc.Editor
        Dim peo As PromptEntityOptions = New PromptEntityOptions(vbLf & "Select an object:")
        Dim per As PromptEntityResult = ed.GetEntity(peo)
        If per.Status <> PromptStatus.OK Then
        End If
        Dim id As ObjectId = per.ObjectId
    End Sub


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!