bimatter-viewer-react 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -238,6 +238,7 @@ viewerRef.current?.selector.addSelected(0, [30]);
238
238
  viewerRef.current?.selector.removeSelected(0, [10]);
239
239
  viewerRef.current?.selector.resetSelection();
240
240
  viewerRef.current?.selector.getSelected();
241
+ viewerRef.current?.selector.collector().ofType("IfcWall").toElements();
241
242
  viewerRef.current?.selector.setSelectionColor("#1194bd");
242
243
  viewerRef.current?.selector.getSelectionColor();
243
244
  viewerRef.current?.selector.setPreselectionColor("#68c6e3");
@@ -282,6 +283,8 @@ viewerRef.current?.dimensions.getDimensions();
282
283
 
283
284
  viewerRef.current?.properties.getModelProps();
284
285
  viewerRef.current?.properties.getModelStructure();
286
+ viewerRef.current?.properties.exportExcel(0);
287
+ viewerRef.current?.properties.exportAllExcel();
285
288
  viewerRef.current?.utils.getUserDevice();
286
289
  viewerRef.current?.utils.getDefaultHotkeysEnabled();
287
290
  viewerRef.current?.utils.setDefaultHotkeysEnabled(false);
@@ -491,6 +494,34 @@ function App() {
491
494
  }
492
495
  ```
493
496
 
497
+ ## Filtered Elements Collector
498
+
499
+ Use `selector.collector()` to query element properties from loaded models:
500
+
501
+ ```tsx
502
+ import type { IfcClass } from "bimatter-viewer-react";
503
+
504
+ const wallType: IfcClass = "IfcWall";
505
+
506
+ const walls = viewerRef.current?.selector
507
+ .collector()
508
+ .ofType(wallType)
509
+ .toElements();
510
+
511
+ const basicWallIds = viewerRef.current?.selector
512
+ .collector()
513
+ .ofModel(0)
514
+ .ofType("IfcWall")
515
+ .Where((element) => element.props.Name.startsWith("basic wall"))
516
+ .toElementsIds();
517
+ ```
518
+
519
+ Without `ofModel()`, `toElements()` returns `{ [modelID]: { elementID, props }[] }` and `toElementsIds()` returns `{ [modelID]: number[] }`.
520
+
521
+ With `ofModel(0)`, `toElements()` returns `{ elementID, props }[]` and `toElementsIds()` returns `number[]`.
522
+
523
+ `ofType()` accepts `IfcClass | string`, so TypeScript suggests IFC classes like `"IfcWall"` while still allowing custom type strings.
524
+
494
525
  ## Stats And Profiling
495
526
 
496
527
  Enable FPS stats and console timing logs:
@@ -55,6 +55,7 @@ export interface BmtModelData {
55
55
  coordinationMatrix?: string;
56
56
  data: BmtModelGeometryData;
57
57
  grids?: ModelGridsData;
58
+ name?: string;
58
59
  props: BmtModelProps;
59
60
  structure: BmtModelStructure;
60
61
  }
@@ -91,6 +92,7 @@ export declare class BMTLoader {
91
92
  parseMesh(data: Uint8Array): BmtMeshData;
92
93
  private getExternalMetadataPath;
93
94
  private loadExternalMetadata;
95
+ private getModelNameFromPath;
94
96
  loadModel(path: string): Promise<BmtModelData>;
95
97
  parseBinaryFile(data: ArrayBuffer): BmtModelData;
96
98
  }
@@ -0,0 +1,38 @@
1
+ import type * as WebIfc from "web-ifc";
2
+ import type { BmtElementProps, BmtModelData, BmtModelProps } from "../Loaders/BmtLoader";
3
+ type IfcClassConstructor = abstract new (...args: never[]) => unknown;
4
+ type IfcNamespaceClassNames<TNamespace> = Extract<{
5
+ [Key in keyof TNamespace]: TNamespace[Key] extends IfcClassConstructor ? Key : never;
6
+ }[keyof TNamespace], `Ifc${string}`>;
7
+ export type IfcClass = IfcNamespaceClassNames<typeof WebIfc.IFC2X3> | IfcNamespaceClassNames<typeof WebIfc.IFC4> | IfcNamespaceClassNames<typeof WebIfc.IFC4X3>;
8
+ export type IfcClassName = IfcClass | (string & {});
9
+ export type FilteredElement = {
10
+ elementID: number;
11
+ props: BmtElementProps;
12
+ };
13
+ export type FilteredElementWithModel = FilteredElement & {
14
+ modelID: number;
15
+ };
16
+ export type FilteredElementId = number;
17
+ export type FilteredElementsResult = Record<number, FilteredElement[]>;
18
+ export type FilteredElementIdsResult = Record<number, number[]>;
19
+ export type FilteredElementPredicate = (element: FilteredElementWithModel) => unknown;
20
+ export type FilteredElementsSource = BmtModelData | BmtModelProps | Record<number, BmtModelData> | Record<number, BmtModelProps> | null | undefined;
21
+ export declare class FilteredElementsCollector<TSingleModel extends boolean = false> {
22
+ private elements;
23
+ private filters;
24
+ private selectedModelIDs;
25
+ constructor(source?: FilteredElementsSource);
26
+ from(source: FilteredElementsSource): this;
27
+ ofType(type: IfcClassName | readonly IfcClassName[]): this;
28
+ ofModel(modelID: number): FilteredElementsCollector<true>;
29
+ ofModel(modelID: number[]): FilteredElementsCollector<false>;
30
+ Where(predicate: FilteredElementPredicate): this;
31
+ where(predicate: FilteredElementPredicate): this;
32
+ private getFilteredElements;
33
+ private hasSingleSelectedModel;
34
+ toElements(): TSingleModel extends true ? FilteredElement[] : FilteredElementsResult;
35
+ toElementsIds(): TSingleModel extends true ? number[] : FilteredElementIdsResult;
36
+ toElementIds(): TSingleModel extends true ? number[] : FilteredElementIdsResult;
37
+ }
38
+ export {};
@@ -5,6 +5,7 @@ import type { ViewerClippingApi } from "../utils/ClippingUtils";
5
5
  import type { ViewerDimensionsApi } from "../utils/DimentionsUtils";
6
6
  import type { ViewerCameraGetIntersection } from "../Camera/useCameraUtils";
7
7
  import type { BmtConversionResult, BmtConverterOptions, BmtConverterSource } from "../Loaders/BmtConverter";
8
+ import { FilteredElementsCollector } from "../Selector/FilteredElementsCollector";
8
9
  export type { ViewerClippingApi } from "../utils/ClippingUtils";
9
10
  export type { ViewerDimensionsApi } from "../utils/DimentionsUtils";
10
11
  export type { ViewerCameraGetIntersection } from "../Camera/useCameraUtils";
@@ -24,6 +25,7 @@ export type ViewerGeometryUtilsApi = {
24
25
  };
25
26
  export type ViewerSelectorApi = {
26
27
  addSelected: (modelID: number, ids: number[]) => void;
28
+ collector: () => FilteredElementsCollector;
27
29
  getPreselectionColor: () => ColorRepresentation;
28
30
  getSelectionColor: () => ColorRepresentation;
29
31
  getSelected: () => ViewerSelection;
@@ -1,5 +1,9 @@
1
1
  import type { ViewerModelPropsStore, ViewerModelStructureStore, ViewerStoreApi } from "../store/ViewerStore";
2
+ import { type ExportedExcelFile, type ModelPropertiesExcelOptions } from "../utils/ExportUtils";
3
+ export type ViewerPropertiesExcelOptions = ModelPropertiesExcelOptions;
2
4
  export type ViewerPropertiesApi = {
5
+ exportAllExcel: (options?: ViewerPropertiesExcelOptions) => ExportedExcelFile[];
6
+ exportExcel: (modelID: number, options?: ViewerPropertiesExcelOptions) => ExportedExcelFile | null;
3
7
  getModelProps: () => ViewerModelPropsStore;
4
8
  getModelStructure: () => ViewerModelStructureStore;
5
9
  };
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { default as Viewer } from "./Viewer";
2
2
  export type { ViewerModelsData, ViewerProps } from "./Viewer";
3
3
  export type { ViewerApi, ViewerCameraApi, ViewerCameraGetIntersection, ViewerClippingApi, ViewerColorsApi, ViewerBmtConverterOptions, ViewerConverterApi, ViewerDimensionsApi, ViewerGeometryUtilsApi, ViewerSelection, ViewerSelectorApi, ViewerUtilsApi, } from "./api/ViewerApi";
4
- export type { ViewerPropertiesApi } from "./api/ViewerPropertiesApi";
4
+ export type { ViewerPropertiesApi, ViewerPropertiesExcelOptions, } from "./api/ViewerPropertiesApi";
5
5
  export { BMTLoader } from "./Loaders/BmtLoader";
6
6
  export type { BmtModelGeometryData, BmtGeomData, BmtIndexArray, BmtMaterialData, BmtElementProps, BmtModelData, BmtModelProps, BmtModelStructure, BmtModelStructureNode, BmtPropertyRecord, BmtPropertySet, BmtPropertyValue, } from "./Loaders/BmtLoader";
7
7
  export { IFCLoader } from "./Loaders/IFCLoader/IFCLoader";
@@ -10,11 +10,15 @@ export { BmtConverter, ConvertIfcFileToBmt, ConvertToBmt, bmtConverter, } from "
10
10
  export type { BmtActiveViewFilter, BmtActiveViewFilterParams, BmtConvertibleModels, BmtConversionResult, BmtConvertedFile, BmtConvertedFileType, BmtConverterOptions, BmtConverterSource, BmtVisibleIdsByModel, } from "./Loaders/BmtConverter";
11
11
  export { ModelGrids } from "./utils/ModelGrids";
12
12
  export type { ModelGridAxis, ModelGridData, ModelGridPoint, ModelGridsProps, ModelGridsData, } from "./utils/ModelGrids";
13
+ export { exportExcel, exportModelPropertiesToExcel, } from "./utils/ExportUtils";
14
+ export type { ExportedExcelFile, ExportModelSource, ModelPropertiesExcelOptions, } from "./utils/ExportUtils";
13
15
  export { loader } from "./api/loader";
14
16
  export type { ViewerLoadedModels, ViewerLoadModelOptions, ViewerModelSource, } from "./api/loader";
17
+ export { FilteredElementsCollector } from "./Selector/FilteredElementsCollector";
18
+ export type { FilteredElement, FilteredElementId, FilteredElementIdsResult, FilteredElementPredicate, FilteredElementsResult, FilteredElementsSource, FilteredElementWithModel, IfcClass, IfcClassName, } from "./Selector/FilteredElementsCollector";
15
19
  export { NavigationCube } from "./utils/NavigationCube";
16
20
  export { DimensionLine, DimensionsUtils, useDimensionsUtils, type DimensionUnit, } from "./utils/DimentionsUtils";
17
21
  export { createViewerStore } from "./store/ViewerStore";
18
22
  export { ViewerStoreProvider } from "./store/ViewerStoreProvider";
19
23
  export { useViewerStore, useViewerStoreApi } from "./store/useViewerStore";
20
- export type { SelectedStore, UserDevice, ViewerGridAxesVisibility, ViewerGridAxisSide, ViewerModelPropsStore, ViewerModelStructureStore, ViewerStore, ViewerStoreApi, } from "./store/ViewerStore";
24
+ export type { SelectedStore, UserDevice, ViewerGridAxesVisibility, ViewerGridAxisSide, ViewerModelNamesStore, ViewerModelPropsStore, ViewerModelStructureStore, ViewerStore, ViewerStoreApi, } from "./store/ViewerStore";