UNPKG

forma-embedded-view-sdk

Version:

The Forma Embedded View SDK is a JavaScript library for creating custom extensions in Autodesk Forma (previously Spacemaker).

43 lines (42 loc) 1.39 kB
/** * Set custom colors on elements in the scene. * * @remarks * Available via {@link auto.Forma | Forma}.{@link index.EmbeddedViewSdk.render | render}.{@link render.RenderApi.elementColors | elementColors}. */ export class ElementColorApi { #iframeMessenger; /** @hidden */ constructor(iframeMessenger) { this.#iframeMessenger = iframeMessenger; } /** * Set color override on the speficied elements. * The color is set as a hex string, e.g. `#ff0000` in the sRGB color space. * * @example * void Forma.selection.subscribe(({ paths }) => { * Forma.render.elementColors.clearAll() * const pathsToColor = new Map<string, string>() * for (const path of paths) { * pathsToColor.set(path, "#00ff00") * } * Forma.render.elementColors.set({ pathsToColor }) * }) */ async set(request) { return await this.#iframeMessenger.sendRequest("scene/elements/color/set", request); } /** * Clear color override on the speficied elements. */ async clear(request) { return await this.#iframeMessenger.sendRequest("scene/elements/color/clear", request); } /** * Clear color override on the speficied elements. */ async clearAll() { return await this.#iframeMessenger.sendRequest("scene/elements/color/clear-all"); } }