Bring an entity to the foreground with VBA

VBA does not provide functions to change the draw order of an entity. However, we can use SendCommand for executing DRAWORDER:

Public Sub MoveToTop()
    Dim object As AcadObject
    Dim pt As Variant
    ThisDrawing.Utility.GetEntity object, pt, "Select an entity:"
    ThisDrawing.SendCommand "_DRAWORDER" & vbCr _
        & "(handent """ & object.Handle & """)" & vbCr & vbCr _
        & "_F" & vbCr
End Sub

This example brings to the foreground the selected entity. I use a little trick, the AutoLISP function handent to pass an entity name to the command.


Add new comment