Class: SelectionSet

PD.SelectionManager. SelectionSet

The selection manager's selection set is similar to a normal selection set, but changes the selected property of items during selection and deselection to reflect their current state.

As per a normal selection set, it also stores a map of selected elements as well as any of their junctions, apertures or nodes 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 first call to any add...() method after the selection set has been cleared.

This type of selection set is used exclusively by the PD.SelectionManager to maintain the selected property of elements, junctions and apertures during selection and deselection. All other classes should use a normal PD.SelectionSet.


new SelectionSet(host)

Creates a new selection set for the selection manager.

Parameters:
Name Type Description
host PD.SelectionManager

The host selection manager that created this instance.

Author:
  • drajmarsh
Throws:

Throws an error if the host parameter is not a valid PD.SelectionManager.

Type
TypeError

Extends

Members


:PD.SelectionManager

host

The selection manager that created and owns this selection set.

Type

:boolean

isSelectionSet <readonly>

A flag identifying this object as a selection set.

Type
  • boolean
Inherited From:
Overrides:

:PD.SELECTED

type <readonly>

Stores the type of the currently stored selection data.

Type
Inherited From:
Overrides:

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.

Inherited From:
Overrides:
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.

Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Overrides:
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.

Inherited From:
Overrides:
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.

Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
Returns:

Returns a new selection set.

Type
PD.SelectionSet

expandSelection( [element] [, all])

Selects all junctions in each element or all apertures in each junction.

Parameters:
Name Type Argument Default Description
element BIM.Element <optional>

An optional element to expand, defaults to all selected elements.

all boolean <optional>
false

Whether or not to select all contours or just contours with selected junctions, defaults to false.

Returns:

Returns true if the selection changed, otherwise false.

Type
boolean

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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
Returns:

Returns an array of selected apertures in this element.

Type
Array.<BIM.Aperture>

getSelectedElements()

Retrieves an array of selected elements.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Overrides:
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.

Inherited From:
Overrides:
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.

Overrides:
Returns:

Returns true if selection state of element 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.

Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:
Returns:

Returns this instance to support method chaining.

Type
PD.SelectionSet

unshift(firstElement [, sub_item])

Inserts the given element as the first item in the map.

Parameters:
Name Type Argument Description
firstElement BIM.Element

The element to set as first.

sub_item BIM.Junction | BIM.Aperture <optional>

The junction or aperture to set as first.