Internal class used to cache rendered results to avoid duplicated rendering.

This class can be used to improve performance when rendering block references. Because different colors will result in different materials, the block name and color are used together to create the cache key.

const cache = AcDbRenderingCache.instance;
const color = new AcCmColor().setRGBValue(0xFF0000);
const key = cache.createKey('MyBlock', color);
const renderedEntity = cache.draw(renderer, blockRecord, color);

Constructors

Accessors

Methods

Constructors

Accessors

Methods

  • Creates a cache key by combining the block name and color.

    Parameters

    • name: string

      The block name

    • color: AcCmColor

      The resolved block color

    Returns string

    A unique key for the cache entry

    const color = new AcCmColor().setRGBValue(0xFF0000);
    const key = cache.createKey('MyBlock', color);
    // Returns: "MyBlock_RGB:255,0,0"
  • Gets rendering results with the specified key.

    Parameters

    • name: string

      The key of the rendering results

    Returns undefined | AcGiEntity

    The rendering results with the specified key, or undefined if not found

    const cachedEntity = cache.get('MyBlock_16711680');
    if (cachedEntity) {
    // Use cached entity
    }
  • Checks if rendering results with the specified key exist in the cache.

    Parameters

    • name: string

      The key to check

    Returns boolean

    True if the key exists in the cache, false otherwise

    if (cache.has('MyBlock_16711680')) {
    console.log('Cached result found');
    }