MLightCAD
    Preparing search index...

    Manages a collection of selected CAD entities in the current view.

    This class maintains a set of selected entity IDs and provides methods to:

    • Add entities to the selection
    • Remove entities from the selection
    • Clear all selections
    • Query selection state and count
    • Listen for selection change events

    The selection set fires events when entities are added or removed, allowing other components (like the view) to respond to selection changes by showing grip points, updating UI, etc.

    const selectionSet = new AcEdSelectionSet();

    // Listen for selection changes
    selectionSet.events.selectionAdded.addEventListener(args => {
    console.log('Added entities:', args.ids);
    });

    // Add entities to selection
    selectionSet.add(['entity1', 'entity2']);

    // Check selection
    if (selectionSet.count > 0) {
    console.log(`${selectionSet.count} entities selected`);
    }

    // Clear selection
    selectionSet.clear();
    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    events: {
        selectionAdded: AcCmEventManager<AcEdSelectionEventArgs>;
        selectionRemoved: AcCmEventManager<AcEdSelectionEventArgs>;
    } = ...

    Events fired when selection changes

    Type Declaration

    Accessors

    Methods

    • Adds one or more entities to the selection.

      Fires a selectionAdded event with the added entity IDs. Duplicate IDs are automatically handled by the internal Set.

      Parameters

      • value: string | string[]

        Single entity ID or array of entity IDs to add

      Returns void

      // Add single entity
      selectionSet.add('entity1');

      // Add multiple entities
      selectionSet.add(['entity2', 'entity3', 'entity4']);
    • Removes one or more entities from the selection.

      Fires a selectionRemoved event with the removed entity IDs. Non-existent IDs are silently ignored.

      Parameters

      • value: string | string[]

        Single entity ID or array of entity IDs to remove

      Returns void

      // Remove single entity
      selectionSet.delete('entity1');

      // Remove multiple entities
      selectionSet.delete(['entity2', 'entity3']);
    • Checks if an entity is currently selected.

      Parameters

      • id: string

        The entity ID to check

      Returns boolean

      True if the entity is selected, false otherwise

      if (selectionSet.has('entity1')) {
      console.log('Entity1 is selected');
      }