.NET

Reply
New Member
h.yang
Posts: 1
Registered: ‎05-13-2014
Message 1 of 3 (124 Views)

how to get an object ID

124 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
Ajilal.Vijayan
Posts: 449
Registered: ‎01-12-2008
Message 2 of 3 (97 Views)

Re: how to get an object ID

05-13-2014 11:12 PM in reply to: h.yang
Mentor
mzakiralam
Posts: 231
Registered: ‎11-09-2012
Message 3 of 3 (86 Views)

Re: how to get an object ID

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

Hi,

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
            Return
        End If
        Dim id As ObjectId = per.ObjectId
        MsgBox(id.ToString)
    End Sub

 

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.