.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get Last Entity

6 REPLIES 6
Reply
Message 1 of 7
ChrisPicklesimer
4299 Views, 6 Replies

Get Last Entity

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

6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: ChrisPicklesimer

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.

 

Message 3 of 7
Anonymous
in reply to: ChrisPicklesimer

AcMgd.dll has Autodesk.AutoCAD.Internal.Utils.EntLast() which returns an ObjectID.

At least 2011 has it. Not sure about previous versions.

 

Message 4 of 7
ChrisPicklesimer
in reply to: Anonymous

In this case, it would be the last entity regardless of how created.  However, I'm now curious how to do both.

 

Thanks.

 

Chris

Message 5 of 7
ChrisPicklesimer
in reply to: Anonymous

I'm currently in 2010 and it appears it is in the lineup.  I'll check it out.

 

Thanks for the help.

 

Chris

Message 6 of 7
Anonymous
in reply to: ChrisPicklesimer

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.

 

 

Message 7 of 7
ChrisPicklesimer
in reply to: Anonymous

Thanks again for the clarification.

 

Chris

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost