Change the draw order of an entity with VBA

VBA does not provide functions to change the draw order of an entity. However, we can use SendCommand to run the command _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.

Etiquettes:

Ajouter un commentaire