Changing an Objects True Color Property

AutoCAD 2004's TrueColor property lets you specify RGB color values, Pantone color palette values, and color-book values. This is a vast improvement for users who need accurate color matching for precision rendering and presentation graphics. The following example shows how to create a new Line entity and assign it an RGB color value of 80, 100, 244. Figure 10-10 also shows how the new color palette options appear in AutoCAD 2004.

Autocad Colour Index
Figure 10-10. Color palette options

Sub Example_TrueColor()

' This example draws a line and returns the RGB values Dim color As AcadAcCmColor

Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.16") Call color.SetRGB(80, 100, 244)

Dim line As AcadLine

Dim startPoint(0 To 2) As Double

Dim endPoint(0 To 2) As Double startPoint(0) = 1#: startPoint(1) = 1#: startPoint(2) = 0# endPoint(0) = 5#: endPoint(1) = 5#: endPoint(2) = 0#

Set line = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint) ZoomAll line.TrueColor = color

Dim retcolor As AcadAcCmColor

Set retcolor = line.TrueColor

MsgBox "Red = " & retcolor.Red & vbCrLf & _

"Green = " & retcolor.Green & vbCrLf & _ "Blue = " & retcolor.Blue

End Sub

The AutoCAD 2006 developer's documentation gives more examples for using the TrueColor object.

Was this article helpful?

0 0

Post a comment