About Changing an Object's Color (VBA/ActiveX)

To change an object's color, use the TrueColor property provided for that object.

You can assign colors to individual objects in a drawing. Each color is identified by an AcCmColor object. This object can hold an RGB value, an ACI number (an integer from 1 to 255), or a named color. Using an RGB value, you can choose from millions of colors.

Setting a color for the object overrides the color setting for the layer on which the object resides. If you want to retain an object on a specific layer but you do not want it to keep the color of that layer, you can change the object's color.

Change the color of a circle

This example creates a circle and then colors the circle blue.

Sub Ch4_ColorCircle()
  Dim color As AcadAcCmColor
  Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.20")
  Call color.SetRGB(80, 100, 244)

  Dim circleObj As AcadCircle
  Dim centerPoint(0 To 2) As Double
  Dim radius As Double
  centerPoint(0) = 0#: centerPoint(1) = 0#: centerPoint(2) = 0#
  radius = 5#
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius)
  circleObj.TrueColor = color
  ZoomAll
End Sub