AcGiSubEntityTraits

AcRxObject
    AcGiSubEntityTraits
        AcGiDrawableTraits
class AcGiSubEntityTraits : public AcRxObject;
File

acgi.h

Description

This class is used to control the current values of the color, layer, linetype, fill type, and graphics system marker attributes for graphics primitives. 

Attribute settings are used for all graphics primitives drawn until the setting changed via one of the "set" functions in this class or the end of the current worldDraw() or viewportDraw() execution. 

For instance, you can set the color attribute to blue and all of the subsequent geometry drawn during the current worldDraw() or viewportDraw() execution appears blue until you set the current color to something else. 

 

Note

Upon entry into an entity's worldDraw() or viewportDraw(), the attributes are initialized to the following: 

 

color 
Current entity color in the AutoCAD editor (CECOLOR system variable). 
layer 
Current layer in the AutoCAD editor (CLAYER system variable). 
linetype 
Current linetype in the AutoCAD editor. 
fill type 
If in standard display, kAcGiFillNever; if in hide, shade, render, then kAcGiFillAlways
sel. marker 
Initialized invalid--the user must set this to use it. 

 

Note

Currently, linetype scaling cannot be set here. 

Color 

Note If you modify a layerTableRecord and change its color or linetype during a worldDraw or viewportDraw, and it is the current AcGi layer, then you must call the AcGiSubEntityTraits::setLayer("current layer's ID") to bring the AcGi up to date. This updates any current colors or linetypes that are by layer. 

There are currently 257 color indices used in AutoCAD, two of which are special: color 0 is "color by block" and color 256 is "color by layer." Colors 1 to 6 are guaranteed. Color 7 is white unless it conflicts with the background color and then it's black. Colors 8 and 9 are mostly dark gray and light gray, respectively, but may be settable to other colors by the video driver. Colors 10 to 249 are described in the next paragraph. Colors 250 to 255 are a short ramp from dark gray to almost white. 

Starting at 10 and ending at 249, the hue changes every 10, starting at red and going through the spectrum and almost back to red again. In each of these sets of 10, the last digit determines the brightness and the pastelness of the color: -0, -2, -4, -6, and -8 are the most intense to the darkest of that color; -1, -3, -5, -7, and -9 are the most intense to the darkest of a pastel version of that color. So color 10 is bright red, 18 is dark red, 11 is pink (pastel red), and 19 is dark pale pink; color 145 is a color between cyan and turquoise, is pastel and of medium intensity. 

 

Color 
Description 
Color by block. 
Red 
Yellow 
Green 
Cyan 
Blue 
Magenta 
White (or black if the graphics system considers it easier to see against the background color) 
Dark gray 
Light gray 
10 
Red 
20 
 
30 
Orange 
40 
 
50 
Yellow 
60 
 
70 
Yellow-green 
80 
 
90 
Green 
100 
 
110 
Aquamarine 
120 
 
130 
Cyan 
140 
 
150 
Turquoise 
160 
 
170 
Blue 
180 
 
190 
Purple 
200 
 
210 
Magenta 
220 
 
230 
Maroon 
240 
 
250-255 
A ramp from dark gray to almost white 
256 
Color By Layer 

Layers 

The AcGi currently does not create layers. They must pre-exist in the system for the AcGi to be able to use them. 

If you modify a layerTableRecord and change its color or linetype during a worldDraw or viewportDraw and it is the current layer in use by AcGi, then you have to call the AcGiSubEntityTraits::setLayer("current layer's ID") to bring the AcGi up to date. This updates any portions of the entity with colors or linetypes that are by layer. 

The following example code gets an AcDbObjectId for a LayerTableRecord from the layer's name. 

 

static Acad::ErrorStatus
getLayerIdFromString(const char* pStr,AcDbobjectId& ID)
{
    //  Get a pointer to the drawing's layer table
    //
    AcDbLayerTable* pLayerTable;
    Acad::ErrorStatus err = acdbCurDwg()->getLayerTable(pLayerTable,
        AcDb::kForRead);
    if (err != Acad::eOk)
        return err;

    // Get the ID of the layer with the name in 'pStr' (even if it's
    // erased) and place it in 'id'.
    //
    err = pLayerTable->getAt(pStr, ID, Adesk::kTrue);

    pLayerTable->close();

    return err;
}

Linetypes 

The AcGi currently does not load linetypes. They must be previously loaded into the system for the AcGi to be able to use them. 

Geometry methods polylineEye() and polylineDc() cannot be automatically linetyped by the graphics system. 

If you modify a layerTableRecord and change its color or linetype during a worldDraw or viewportDraw and it is the current layer in use by AcGi, then you have to call the AcGiSubEntityTraits::setLayer("current layer's ID") to bring the AcGi up to date. This updates any portions of the entity with colors or linetypes that are by layer. 

The following example code gets an AcDbObjectId for a linetypeTableRecord from the linetype name. 

 

static Acad::ErrorStatus
getLinetypeIdFromString(const char* pStr, AcDbObjectId& ID)
{
    //  Get the table of currently loaded linetypes.
    //
    AcDbLinetypeTable* pLinetypeTable;
    Acad::ErrorStatus err = acdbCurDwg()->getLinetypeTable(
        pLinetypeTable, AcDb::kForRead);
    if (err != Acad::eOk)
        return err;

    // Get the ID of the linetype with the name in 'pStr'
    // (even if it's erased) and place it in 'id'.
    //
    err = pLinetypeTable->getAt(pStr, ID, Adesk::kTrue);

    pLinetypeTable->close();

    return err;
}
Links
See Also

AcGiViewportDraw, AcGiWorldDraw, AcDbEntity, AcDbObjectId