Community
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.
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