Reputation: 1702
I am currently using VB to add functionality into AutoCAD.
I am trying to get a handle on the ObjectId of my Text Object, I was wondering if there was a way for me to view the ObjectId straight from Autocad (maybe in some type of properties viewer?)
Any help or advice on how i could do this would be helpful, thank you in advance.
Upvotes: 1
Views: 4610
Reputation: 8604
The ObjectId of any AutoCAD entity is for programming use only, there is no UI feature to see it (unless you develop a plugin).
Also, the actual ID number will change from one session to another. It's just a number used to open and manipulate entities in memory faster. The ObjectId is not save into the .dwg file. If you close and open a drawing, all IDs will be different.
Now the Handle is persistent (saved into .dwg files) and don't change between sessions.
NOTE: there are some scenario where the Handle also changes, like for entities inside a block during a BEDIT command.
Here is a quick sample to loop through entities using VBA/ActiveX
Public Sub LoopMText()
For i = 0 To ThisDrawing.ModelSpace.Count - 1
If TypeOf ThisDrawing.ModelSpace.Item(i) Is AcadMText Then
Dim t As AcadMText
Set t = ThisDrawing.ModelSpace.Item(i)
If t.TextString = "something here" Then
' do something...
End If
End If
Next
End Sub
Upvotes: 7