Change an Object's Color
 
 
 

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 don't 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.17")
	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