Q:
When I use the following code snippet, the polygon is still white (as default entity color):
AcCmColor acadcolor;
acadcolor.setRed(20);
acadcolor.setGreen(50);
acadcolor.setBlue(110);
AcDbMPolygon *pAcDb = new AcDbMPolygon();
pAcDb->appendMPolygonLoop(points, bulges, false); //append a loop
pAcDb->hatch()->setPattern(AcDbHatch::kPreDefined, "SOLID");
pAcDb->setPatternColor(acadcolor);
//post to database and close..
How do I set the color correctly?
A:
The first option is to call acadcolor.setColorMethod(AcCmEntityColor::kByColor) after you set Red, Green, Blue color.
The second option is to use setRGB() as shown:
acadcolor.setRGB(20,50,110);
After you use acadcolor properly, and then execute the LIST command, it displays the following:
Hatch pattern: SOLID
Fill color: 20,50,110

Leave a Reply