forma-embedded-view-sdk
Version:
The Forma Embedded View SDK is a JavaScript library for creating custom extensions in Autodesk Forma Site Design (previously Spacemaker).
43 lines (42 loc) • 1.51 kB
TypeScript
import type { IframeMessenger } from "./iframe-messenger.js";
/**
* Interact with user's selection (i.e. shift-clicked elements in the scene)
*
* @remarks
* Available via {@link auto.Forma | Forma}.{@link index.EmbeddedViewSdk.selection | selection}.
*/
export declare class SelectionApi {
#private;
/** @hidden */
constructor(iframeMessenger: IframeMessenger);
/**
* Get selected elements.
*
* @returns List of paths to elements currently selected in the scene.
*
* @example
* // Fetch all paths to selected elements in the current proposal.
* // Count how many of them are buildings.
* const selectedPaths = await Forma.selection.getSelection()
* const buildingPaths = await Forma.geometry.getPathsByCategory({ category: "buildings" })
* const selectedBuildingPaths = selectedPaths.filter(path => buildingPaths.includes(path))
* const numberOfSelectedBuildings = selectedBuildingPaths.length
*/
getSelection(): Promise<string[]>;
/**
* Subscribe to selection changes.
*
* @example
* const { unsubscribe } = await Forma.selection.subscribe(({ paths }) => {
* console.log(paths)
* });
*
* @param callback event handler for each selection change
* @returns { unsubscribe: () => void } object with an `unsubscribe` method to stop listening
*/
subscribe(callback: (payload: {
paths: string[];
}) => void): Promise<{
unsubscribe: () => void;
}>;
}