MLightCAD
    Preparing search index...

    Command-line HATCH command (no dialog), inspired by AutoCAD flow.

    Current scope:

    • Build hatch boundaries from selected objects.
    • Support command-line option branches (pattern/scale/angle/style/associative).
    • No island-detection refinement beyond loop construction.

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get globalName(): string

      Gets the global (untranslated) name of the command.

      The global name is typically used for programmatic access and should remain consistent across different language localizations.

      Returns string

      The global command name

    • set globalName(value: string): void

      Sets the global (untranslated) name of the command.

      Parameters

      • value: string

        The global command name (e.g., 'LINE', 'CIRCLE', 'ZOOM')

      Returns void

    • get localName(): string

      Gets the local (translated) name of the command.

      The local name is displayed to users and should be localized to the current language/region.

      Returns string

      The localized command name

    • set localName(value: string): void

      Sets the local (translated) name of the command.

      Parameters

      • value: string

        The localized command name (e.g., 'Draw Line', 'Zoom In')

      Returns void

    • get mode(): AcEdOpenMode

      Gets the minimum access mode required to execute this command.

      Commands with higher mode requirements can only be executed when the document is opened in a compatible mode. Higher value modes are compatible with lower value modes.

      Returns AcEdOpenMode

      The minimum access mode required

    • set mode(value: AcEdOpenMode): void

      Sets the minimum access mode required to execute this command.

      Parameters

      • value: AcEdOpenMode

        The minimum access mode (Read, Review, or Write)

      Returns void

    • get userData(): TUserData

      Gets the custom user-defined data associated with this command.

      userData is a generic, strongly-typed container that allows consumers of the command to attach arbitrary metadata without modifying the command class itself.

      The shape of userData is defined by the generic parameter TUserData when the command is declared:

      Returns TUserData

      The user-defined data object associated with this command

      interface MyCommandData {
      sourceLayerId: string
      isPreview: boolean
      }

      class MyCommand extends AcEdCommand<MyCommandData> {}

      const cmd = new MyCommand()
      cmd.userData.sourceLayerId = 'Layer-01'
      cmd.userData.isPreview = true

      This design provides flexibility similar to THREE.Object3D.userData while preserving full compile-time type safety.

    Methods

    • Creates and appends one hatch entity from computed loops.

      Parameters

      • context: AcApContext

        Active command context.

      • loops: readonly AcGeLoop2d[]

        Boundary loops to be added to the hatch.

      Returns boolean

      true when hatch entity was created; otherwise false.

    • Scans model space and builds closed loops from all supported boundaries.

      This is used by pick-points mode so a seed point can be resolved against all potential loops in the drawing.

      Parameters

      Returns AcGeLoop2d[]

      Closed loops derived from all hatchable entities.

    • Builds closed loops from explicit object ids.

      Parameters

      • context: AcApContext

        Active command context.

      • ids: string[]

        Object ids selected by the user.

      Returns AcGeLoop2d[]

      Closed loops ready for hatch creation.

    • Executes pick-points branch of HATCH.

      The user can place multiple seed points. Each accepted point attempts one hatch creation, and pressing Enter terminates this branch.

      Parameters

      Returns Promise<boolean>

      true if at least one hatch was created.

    • Executes object-selection branch of HATCH.

      Parameters

      Returns Promise<boolean>

      true if a hatch was created from selected objects.

    • Converts command keyword string to hatch style enum.

      Parameters

      • keyword: string

        Keyword returned by prompt API.

      Returns AcDbHatchStyle

      Matching hatch style enum, defaulting to Normal.

    • Normalizes pattern name input.

      Parameters

      • value: string

        Raw user-entered pattern name.

      Returns string

      Trimmed name, or SOLID when input is empty.

    • Sends a message to the UI module through the global event bus.

      Parameters

      • message: string

        Message text to display

      • Optionaltype: AcEdMessageType

        Message severity controlling the rendered style

      Returns void

    • Called after the command has finished executing.

      This lifecycle hook is intended for cleanup or follow-up logic, such as:

      • Releasing resources
      • Resetting editor state
      • Finalizing transactions

      The default implementation does nothing.

      Parameters

      Returns void

    • Called right before the command starts executing.

      This lifecycle hook is intended for subclasses that need to perform setup work before execute() runs, such as:

      • Initializing temporary state
      • Locking resources
      • Preparing UI or editor state

      The default implementation does nothing.

      Parameters

      Returns void

    • Prompts for associative mode switch (Yes / No).

      Returns Promise<void>

      Promise resolved when prompt flow completes.

    • Prompts for pattern angle (degrees) and updates persisted settings.

      Returns Promise<void>

      Promise resolved when prompt flow completes.

    • Prompts for pattern name and updates persisted command settings.

      Returns Promise<void>

      Promise resolved when prompt flow completes.

    • Prompts for pattern scale and updates persisted command settings.

      Returns Promise<void>

      Promise resolved when prompt flow completes.

    • Prompts for hatch style (Normal / Outer / Ignore).

      Returns Promise<void>

      Promise resolved when prompt flow completes.

    • Resolves which loops should be used for one pick-point seed.

      Strategy:

      • Find the smallest containing loop as target.
      • Include direct children as holes unless style is Ignore.

      Parameters

      • point: { x: number; y: number }

        Seed point selected by user.

      • loops: readonly AcGeLoop2d[]

        Candidate loops.

      Returns AcGeLoop2d[]

      Ordered loop set to append into one hatch entity.

    • Displays a message in the command-line output.

      Parameters

      • message: string

        Message text to render

      • Optionaltype: AcEdMessageType

        Message severity controlling the rendered style

      • OptionalmsgKey: string

        Optional localization key associated with the message

      Returns void

    • Converts hatch style enum to command keyword string.

      Parameters

      • style: AcDbHatchStyle

        Hatch style enum value.

      Returns "Normal" | "Outer" | "Ignore"

      Command keyword name used by keyword prompts.

    • Triggers the command execution with proper event handling.

      This method should not be overridden by subclasses as it handles the event notification workflow. Subclasses should implement the execute() method instead.

      The execution flow:

      1. Fires commandWillStart event
      2. Calls the execute() method
      3. Fires commandEnded event

      Parameters

      • context: AcApContext

        The current application context containing view and document

      Returns Promise<void>

      const command = new MyCommand();
      command.trigger(docManager.context);