Class: SelectionSet

PD. SelectionSet

Stores a map of elements and any of their path segments, junctions or apertures that are also selected.

Selection sets only store one type of selection, so you cannot add an aperture to a set that already contains junctions, and visa versa. You can check this using the readonly type property. This value is set by the add...() and select...() methods, and cleared by the clear() method.

Selection data for associating junctions and apertures with each element is a simple object with an array property. The array contains references to each selected junction or aperture that belongs to the element.

The reason this is stored as an object rather than just an array is that it allows the undo/redo and other systems to store additional data for each selected element. Literally every action carried out on a multiple selection set creates a copy of that selection set and stores additional data on it, so this is frequent and convenient enough to more than warrant the extra overhead involved.


new SelectionSet( [src])

Creates a new selection set instance.

Parameters:
Name Type Argument Default Description
src Array <optional>
null

An optional selection set array to copy.

Author:
  • drajmarsh

Extends

  • Map

Members


:boolean

isSelectionSet <readonly>

A flag identifying this object as a selection set.

Type
  • boolean

:PD.SELECTED

type <readonly>

Stores the type of the currently stored selection data.

Type

Methods


addAperture(element, aperture)

Adds the given aperture to the selection set.

Parameters:
Name Type Description
element BIM.Element

The element containing the aperture.

aperture BIM.Aperture

The aperture to add to selection set.

Returns:

Returns true if selection state of aperture changed.

Type
boolean

addApertures(element, apertures)

Adds the given element apertures to the selection set.

If the selection set is not already of type PD.SELECTED.APERTURE, this method will clear any existing selection and set the type to PD.SELECTED.APERTURE before adding the apertures.

If any of the items in the array are not valid apertures, they will not be added.

Parameters:
Name Type Description
element BIM.Element

The element containing the apertures.

apertures Array.<BIM.Aperture>

The array of apertures to add to selection set.

Returns:

Returns true if any apertures added.

Type
boolean

addClearCurrentCallback(callback)

Add a callback function to be invoked whenever the clear method is called.

Parameters:
Name Type Description
callback function

The function to call when the selection is cleared.

Returns:

Returns the callback method so it can be removed.

Type
function

addElement(element)

Adds the given element to the selection set.

If the set is empty, this method will add the element and set the selection type to PD.SELECTED.ELEMENT. If the selection set is not empty and not of type PD.SELECTED.ELEMENT, the element will not be added and the method will return false.

Parameters:
Name Type Description
element BIM.Element

The element to add to the selection set.

Returns:

Returns true if selection state of element changed.

Type
boolean

addElements(elements)

Adds an array of elements as the selection set.

If the selection set is not already of type PD.SELECTED.ELEMENT, this method will clear any existing selection and set the type to PD.SELECTED.ELEMENT before adding the elements.

If any of the items in the array are not valid elements, they will not be added.

Parameters:
Name Type Description
elements Array.<BIM.Element>

The array of elements to select.

Returns:

Returns true if element(s) added to selection.

Type
boolean

addJunction(element, junction [, selectedType])

Adds the given junction to the selection set.

Parameters:
Name Type Argument Description
element BIM.Element

The element containing the junction.

junction BIM.Junction

The junction to add to selection set.

selectedType PD.SELECTED <optional>

The selection type to store, defaults to PD.SELECTED.JUNCTION.

Returns:

Returns true if selection state of junction changed.

Type
boolean

addJunctions(element, junctions [, selectedType])

Adds the given element junctions to the selection set.

If the selection set is not already of type PD.SELECTED.JUNCTION or PD.SELECTED.SEGMENT, this method will clear any existing selection and set the type to the given type or PD.SELECTED.JUNCTION before adding the junctions.

If any of the items in the array are not valid junctions, they will not be added.

Parameters:
Name Type Argument Description
element BIM.Element

The element containing the junctions.

junctions Array.<BIM.Junction>

The array of junctions to add to selection set.

selectedType PD.SELECTED <optional>

The selection type to store, defaults to PD.SELECTED.JUNCTION.

Returns:

Returns true if any junctions added.

Type
boolean

addSurface(element, surface)

Adds the given surface to the selection set.

Parameters:
Name Type Description
element BIM.Element

The element containing the aperture.

surface PD.BRep

The surface to add to selection set.

Returns:

Returns true if the surface was added.

Type
boolean

addSurfaceFacet(surface, facet)

Adds the given surface facet to the selection set.

Parameters:
Name Type Description
surface PD.BRep

The surface containing the facet.

facet PD.BRep.Face

The facet to add to selection set.

Returns:

Returns true if the surface facet was added.

Type
boolean

addSurfaceFacets(surface, facets)

Adds the given surface facets to the selection set.

If the selection set is not already of type PD.SELECTED.BREP_FACE, this method will clear any existing selection and set the type before adding the surfaces.

If any of the items in the array are not valid facets, they will not be added.

Parameters:
Name Type Description
surface PD.BRep

The surface containing the facets.

facets Array.<PD.BRep.Face>

The array of facets to add to selection set.

Returns:

Returns true if any surface facets were added.

Type
boolean

addSurfaces(element, surfaces)

Adds the given element surfaces to the selection set.

If the selection set is not already of type PD.SELECTED.BREP, this method will clear any existing selection and set the type to PD.SELECTED.BREP before adding the surfaces.

If any of the items in the array are not valid surfaces, they will not be added.

Parameters:
Name Type Description
element BIM.Element

The element containing the surfaces.

surfaces Array.<BIM.Surface>

The array of surfaces to add to selection set.

Returns:

Returns true if any surfaces added.

Type
boolean

clear( [type])

Clears and empties the selection set.

Parameters:
Name Type Argument Description
type PD.SELECTED <optional>

An optional type to set once cleared, defaults to PD.SELECTED.NONE.

Returns:

Returns this instance to support method chaining.

Type
PD.SelectionSet

clone()

Creates a shallow copy of the selection set.

This is primarily used by the undo/redo system to keep a copy of the actioned selection set. The arrays stored in the associated data objects are not reused when the selection changes or is cleared, so it is safe for them to nbe stored directly in undo/redo steps.

Returns:

Returns a new selection set.

Type
PD.SelectionSet

getSelectedAperturesAsArray()

Retrieves an array of selected apertures with their element.

This method returns and array where each item is is an array with the first item being the element and the second item being an array of selected apertures within that element.

Returns:

Returns an array of selected apertures by element.

Type
Array.<BIM.Element, Array.<BIM.Aperture>>
Example
const selection = PD.GlobalActions.selectionManager.selectionSet.getSelectedAperturesAsArray();
for (const [ element, apertures ] of selection) {
    for (const aperture of apertures) {
        console.log("Selected aperture: ", aperture.name);
    }
}

getSelectedAperturesOnElement(element)

Retrieves an array of selected apertures in the given element.

Parameters:
Name Type Description
element BIM.Element

The element to obtain selection data for.

Returns:

Returns an array of selected apertures in this element.

Type
Array.<BIM.Aperture>

getSelectedElements()

Retrieves an array of selected elements.

Returns:

Returns an array of selected elements.

Type
Array.<BIM.Element>

getSelectedJunctions(element)

Retrieves an array of selected junctions in the given element.

Parameters:
Name Type Description
element BIM.Element

The element to obtain selection data for.

Returns:

Returns an array of selected junctions.

Type
Array.<BIM.Junction>

getSelectedSurfaceFacets(surface)

Retrieves an array of selected facets in the given surface.

Parameters:
Name Type Description
surface PD.BRep

The surface to obtain selection data for.

Returns:

Returns an array of selected facets in this surface.

Type
Array.<PD.BRep.Face>

getSelectedSurfaces(element)

Retrieves an array of selected surfaces in the given element.

Parameters:
Name Type Description
element BIM.Element

The element to obtain selection data for.

Returns:

Returns an array of selected surfaces in this element.

Type
Array.<BIM.Surface>

hasAperture(element, aperture)

Checks if the selection set contains the given aperture.

Parameters:
Name Type Description
element BIM.Element

The element containing the aperture.

aperture BIM.Aperture

The aperture to check for in selection set.

Returns:

Returns true if selection set contains the aperture.

Type
boolean

hasElement(element)

Checks if the selection set contains the given element.

Parameters:
Name Type Description
element BIM.Element

The element to check for.

Returns:

Returns true if selection set contains the element.

Type
boolean

hasJunction(element, junction)

Checks if the selection set contains the given junction.

Parameters:
Name Type Description
element BIM.Element

The element containing the junction.

junction BIM.Junction

The junction to check for in selection set.

Returns:

Returns true if selection set contains the junction.

Type
boolean

hasSurface(element, surface)

Checks if the selection set contains the given surface.

Parameters:
Name Type Description
element BIM.Element

The element containing the surface.

surface BIM.Surface

The surface to check for in selection set.

Returns:

Returns true if selection set contains the surface.

Type
boolean

hasSurfaceFacet(surface, facet)

Checks if the selection set contains the given facet.

Parameters:
Name Type Description
surface PD.BRep

The surface containing the facet.

facet PD.BRep.Face

The facet to check for in selection set.

Returns:

Returns true if selection set contains the facet.

Type
boolean

removeApertures(element, apertures)

Removes the given element apertures from the selection set.

Parameters:
Name Type Description
element BIM.Element

The element containing the apertures.

apertures Array.<BIM.Aperture>

The array of apertures to remove from selection set.

Returns:

Returns true if any apertures were removed.

Type
boolean

removeClearCurrentCallback(callback)

Add a callback function to be invoked whenever the clear method is called.

Parameters:
Name Type Description
callback function

The callback function added to PD.SelectionSet#addClearCurrentCallback.

Returns:

Returns true if the callback was present and removed.

Type
boolean

removeElement(element)

Removes the given element from the selection set.

Parameters:
Name Type Description
element BIM.Element

The element to remove the selection set.

Returns:

Returns true if selection set changed.

Type
boolean

removeJunctions(element, junctions)

Removes the given element junctions from the selection set.

Parameters:
Name Type Description
element BIM.Element

The element containing the junctions.

junctions Array.<BIM.Junction>

The array of junctions to remove from selection set.

Returns:

Returns true if any junctions were removed.

Type
boolean

removeSurfaceFacets(surface, facets)

Removes the given element surfaces from the selection set.

Parameters:
Name Type Description
surface PD.BRep

The element containing the surfaces.

facets Array.<PD.BRep.Face>

The array of surfaces to remove from selection set.

Returns:

Returns true if any surfaces were removed.

Type
boolean

removeSurfaces(element, surfaces)

Removes the given element surfaces from the selection set.

Parameters:
Name Type Description
element BIM.Element

The element containing the surfaces.

surfaces Array.<BIM.Surface>

The array of surfaces to remove from selection set.

Returns:

Returns true if any surfaces were removed.

Type
boolean

setType(type)

Sets the type of the currently stored selection data.

If the new type is different from the previous type, the existing selection set will be cleared.

Parameters:
Name Type Description
type PD.SELECTED

The new type to set.

Returns:

Returns this instance to support method chaining.

Type
PD.SelectionSet