Could someone point me in the direction of how to get the last entity created in a drawing?
In VBA, I did it this way:
Public Function entLast(Optional Layout As String = "Model", Optional Index As Long = 1) As AcadObject
Dim blk As AcadBlock
Set blk = ThisDrawing.Layouts(Layout).Block
Set entLast = blk.Item(blk.count - Index)
End Function
Thanks.
Chris
Depends on whether you want the last entity in the drawing that
was created by your code, or the last entity regardless of what
created it.
AcMgd.dll has Autodesk.AutoCAD.Internal.Utils.EntLast() which returns an ObjectID.
At least 2011 has it. Not sure about previous versions.
In this case, it would be the last entity regardless of how created. However, I'm now curious how to do both.
Thanks.
Chris
I'm currently in 2010 and it appears it is in the lineup. I'll check it out.
Thanks for the help.
Chris
acdbEntLast() returns the last entity created in any space.
If you want the last entity created in the current space,
you can use the Editor's SelectLast() method.