# Class MarkupSheet2DCollection

Collection of all the MarkupSheet2D instances that have been created locally and loaded via the markup API.

##### Index

### Properties

attachedTo
observable

### Accessors

changeCount
conflictCount
isLoaded
objects
permission
version

### Methods

[iterator]
addSheet
clear
conflicts
get
loadAndMerge
saveAndMergeSheets
sheets

## Properties

### `Readonly` attachedTo

attachedTo: BimChangeBlob | BimChangeDwg

### `Readonly` observable

observable: Observable<MarkupLayerEvent2D>

## Accessors

### changeCount

- get changeCount(): number

  Number of objects in layer not marked with state MergableObjectState.Unchanged.

  #### Returns number

### conflictCount

- get conflictCount(): number

  Number of objects with conflicts in the layer. A conflict occurs if there is a mismatch between the local and the remote representation of the layer. Conflicts can only occur when Layer.saveAndMerge or Layer.loadAndMerge is called.

  #### Returns number

### isLoaded

- get isLoaded(): boolean

  `true` if a layer exists and if Layer.saveAndMerge or Layer.loadAndMerge has been called successfully at least once.

  #### Returns boolean

### objects

- get objects(): IterableIterator<
  Readonly<MergableObjectWithState<MarkupEntityBase>>,
  >

  Get the objects currently in the layer

  #### Returns IterableIterator<Readonly<MergableObjectWithState<MarkupEntityBase>>>

### permission

- get permission(): Permissions

  `true` if user has permission to update the layer.

  #### Returns Permissions

### version

- get version(): number

  Get the version of the currently loaded layer. [-1] if no layer has yet been loaded.

  #### Returns number

## Methods

### [iterator]

- "[iterator]"(): IterableIterator<MarkupSheet2D>

  #### Returns IterableIterator<MarkupSheet2D>

### addSheet

- addSheet(id: string, properties?: Map<string, MarkupProperty>): MarkupSheet2D

  Creates a new markup sheet and adds it to the layer api.

  #### Parameters

  - id: string

    The id for the new sheet (has to be unique).

  - `Optional` properties: Map<string, MarkupProperty>

    Properties for the sheet.

  #### Returns MarkupSheet2D

  The new markup sheet.

### clear

- clear(): void

  Clear the layer.

  #### Returns void

### conflicts

- conflicts(): Readonly<MergableObjectWithState<MarkupEntityBase>>[]

  Conflicts in the layer. A conflict occurs if there is a mismatch between the local and the remote representation of a object in the layer. Conflicts can only occur when Layer.saveAndMerge or Layer.loadAndMerge is called.

  #### Returns Readonly<MergableObjectWithState<MarkupEntityBase>>[]

### get

- get(
  entityOrId: string | Pick<MarkupEntityBase, "id">,
  ): undefined | MergableObjectWithState<MarkupEntityBase>

  Get a markup sheet based on id.

  #### Parameters

  - entityOrId: string | Pick<MarkupEntityBase, "id">

    Id of the markup sheet you are trying to get.

  #### Returns undefined | MergableObjectWithState<MarkupEntityBase>

  The markup sheet if it exists, undefined if no markup sheet of that id exists.

### loadAndMerge

- loadAndMerge(): Promise<number | LayerFailure>

  Loads all existing (remote) objects from the backend and attempts to merge them into objects. This may result in conflicts between the local and the remote objects. A typical example is if the same object has been modified locally but also remotely (in the backend.)

  #### Returns Promise<number | LayerFailure>

### saveAndMergeSheets

- saveAndMergeSheets(overwrite?: boolean): Promise<number | LayerFailure>

  Save the sheets using the layer api.

  #### Parameters

  - overwrite: boolean = false

    If true then the last version will be overwritten.

  #### Returns Promise<number | LayerFailure>

  Number of conflicts, if > 0 then save was not successfull.

### sheets

- sheets(states?: MergableObjectState[]): IterableIterator<MarkupSheet2D>

  #### Parameters

  - states: MergableObjectState[] = []

    Array of states used to filter out sheets, default is [MergableObjectState.Added, MergableObjectState.Modified, MergableObjectState.Unchanged].

  #### Returns IterableIterator<MarkupSheet2D>

  #### Example

      // Loops all modified sheets in this collection.
      for(const modifiedSheets of collection.sheets([MergableObjectState.Modified])) {
       ...
      }