Color property example

 

Sub Color_Example()

'This example demonstrates how to return and change the .Color property.

    Dim ent As AcadEntity

    Dim NewColor As Integer

    Dim Response As VbMsgBoxResult

    MsgBox "Number of entities in ModelSpace = " & ActiveDocument.ModelSpace.Count

    For Each ent In ThisDrawing.ModelSpace

        Response = MsgBox("Found a " & ent.ObjectName & " with color: " & ent.Color & Chr(13) & "Do you want to change it?", vbYesNo, "Color of Entities")

        If Response = vbYes Then

            NewColor = InputBox("New color [0-256]: for " & ent.ObjectName)

            ent.Color = NewColor

            ent.Update

        End If

        ' Display message.

        Response = MsgBox("Continue listing entities?", vbYesNo, "Color of Entities")

        If Response = vbNo Then Exit For

    Next ent

End Sub

 


Bricscad™ is commercialized by Bricsys NV. Bricsys NV and Vondle NV are fully owned subsidiaries of Menhirs NV. © 2001- Menhirs NV - All rights reserved.