UNPKG

forma-embedded-view-sdk

Version:

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

81 lines (80 loc) 2.63 kB
import type { IframeMessenger } from "./iframe-messenger.js"; export type UnitOfMeasurement = "COUNT" | "SQUARE_METER" | undefined; export type FunctionBreakdownMetric = { functionId: string; functionName: string; functionColor: string; value: number | "UNABLE_TO_CALCULATE"; }; export type MetricWithFunctionBreakdown = { id: string; name: string; unitOfMeasurement?: UnitOfMeasurement; functionBreakdown: FunctionBreakdownMetric[]; }; export type MetricWithValue = { id: string; name: string; unitOfMeasurement?: UnitOfMeasurement; value: number | "UNABLE_TO_CALCULATE"; }; /** * Area metrics / key figures for a collection of elements which support it. * See https://help.autodeskforma.com/en/articles/6995661-introduction-to-area-metrics for a thorough introduction */ export type AreaMetrics = { /** Metrics created by user */ customMetrics: MetricWithFunctionBreakdown[]; /** Standard metrics for all Forma projects */ builtInMetrics: { /** Total area of all building model polygons (on all floors) */ grossFloorArea: MetricWithFunctionBreakdown; /** Total area covered by buildings */ buildingCoverage: MetricWithValue; /** Total area of all site limit polygons */ siteArea: MetricWithValue; }; /** Unit-level metrics */ unitStatistics: { /** Total number of units */ count: MetricWithValue; }; /** Parking statistics */ parkingStatistics: { /** Total number of parking spots */ spots: number; /** Total area of all parking spots */ area: number; }; }; /** * Calculate [area metrics](https://help.autodeskforma.com/en/articles/6995661-introduction-to-area-metrics). * * @remarks * Available via {@link index.EmbeddedViewSdk.areaMetrics | EmbeddedViewSdk.areaMetrics}. */ export declare class AreaMetricsApi { #private; /** @hidden */ constructor(iframeMessenger: IframeMessenger); /** * Calculate area metrics for the given paths. * If no paths are given, the metrics will be calculated for all elements. * * @returns * Area metrics for the given paths. * * @example * // Calculate area metrics for selected elements * const currentlySelected = await Forma.selection.getSelection() * const areaMetrics = await Forma.areaMetrics.calculate({ * paths: currentlySelected * }) */ calculate(request: { /** * Selection of paths to calculate metrics for. */ paths?: string[]; }): Promise<AreaMetrics>; }