# knitout_interpreter.knitout_operations.knitout_instruction_factory module

Factory function for building knitout instructions based on instruction type.

knitout_interpreter.knitout_operations.knitout_instruction_factory.build_instruction(instruction_type, first_needle=None, direction=None, carrier_set=None, second_needle=None, racking=None, comment=None)

  Builds a knitout instruction based on the specified instruction type and parameters.

  This factory function creates the appropriate knitout instruction object based on the instruction type and provided parameters. It handles all supported knitout instruction types including needle operations, carrier operations, and machine control operations.

  Parameters:

    - instruction_type (Knitout_Instruction_Type) – The type of knitout instruction to create.

    - first_needle (Needle | None) – The primary needle for the operation. Required for needle-based instructions like knit, tuck, drop, etc.

    - direction (None | Carriage_Pass_Direction) – The carriage pass direction for directional operations. Required for operations that involve yarn carrier movement.

    - carrier_set (Yarn_Carrier_Set | Yarn_Carrier | None) – The yarn carrier or carrier set to use for the operation. Required for operations that manipulate yarn.

    - second_needle (Needle | None) – The secondary needle for operations requiring two needles, such as transfers and splits.

    - racking (float | None) – The racking value for rack instructions. Specifies the relative position between needle beds.

    - comment (str | None) – Optional comment to include with the instruction for documentation or debugging purposes.

  Returns:

    The constructed knitout instruction object corresponding to the specified type.

  Raises:

    - ValueError – If an unsupported instruction type is provided or

    - if required parameters are missing for the specified instruction type. –

  Return type:

    Knitout_Line