Skip to content

ln_load_name

ln_load_name

Load Name (LN).

Note: The LN command was deprecated in revision I4 from October 2013.

The historic LN command doesn't influence the image in any manner and can safely be overlooked.

Function of the LN command: - LN is designed to allocate a name to the following section of the file. - It was originally conceptualized to serve as a human-readable comment. - For creating human-readable comments, it's advisable to utilize the standard G04 command. - The LN command has the flexibility to be executed multiple times within a file.

SPEC: 2023.03 SECTION: 8.1.6

LoadName

Bases: ExtendedCommandToken

Comment token.

Load Name (LN)

Note: The LN command was deprecated in revision I4 from October 2013.

The historic LN command doesn't influence the image in any manner and can safely be overlooked.

Function of the LN command: - LN is designed to allocate a name to the following section of the file. - It was originally conceptualized to serve as a human-readable comment. - For creating human-readable comments, it's advisable to utilize the standard G04 command. - The LN command has the flexibility to be executed multiple times within a file.

See section 8.1.6 of The Gerber Layer Format Specification Revision 2023.03 - https://argmaster.github.io/pygerber/latest/gerber_specification/revision_2023_03.html

Source code in src/pygerber/gerberx3/tokenizer/tokens/ln_load_name.py
class LoadName(ExtendedCommandToken):
    """Comment token.

    ### Load Name (LN)

    Note: The LN command was deprecated in revision I4 from October 2013.

    The historic `LN` command doesn't influence the image in any manner and can safely
    be overlooked.

    Function of the `LN` command:
    - `LN` is designed to allocate a name to the following section of the file.
    - It was originally conceptualized to serve as a human-readable comment.
    - For creating human-readable comments, it's advisable to utilize the standard `G04`
        command.
    - The `LN` command has the flexibility to be executed multiple times within a file.

    See section 8.1.6 of The Gerber Layer Format Specification Revision 2023.03 - https://argmaster.github.io/pygerber/latest/gerber_specification/revision_2023_03.html
    """

    def __init__(self, string: str, location: int, content: str) -> None:
        super().__init__(string, location)
        self.content = content

    @classmethod
    def new(cls, string: str, location: int, tokens: ParseResults) -> Self:
        """Create instance of this class.

        Created to be used as callback in `ParserElement.set_parse_action()`.
        """
        content: str = str(tokens["string"])
        return cls(string=string, location=location, content=content)

    def update_drawing_state(
        self,
        state: State,
        _backend: Backend,
    ) -> Tuple[State, Iterable[DrawCommand]]:
        """Update drawing state."""
        warn_deprecated_code("LN", "8.1")
        return super().update_drawing_state(state, _backend)

    def parser2_visit_token(self, context: Parser2Context) -> None:
        """Perform actions on the context implicated by this token."""
        context.get_hooks().load_name.pre_parser_visit_token(self, context)
        context.get_hooks().load_name.on_parser_visit_token(self, context)
        context.get_hooks().load_name.post_parser_visit_token(self, context)

    def get_gerber_code(
        self,
        indent: str = "",  # noqa: ARG002
        endline: str = "\n",  # noqa: ARG002
    ) -> str:
        """Get gerber code represented by this token."""
        return f"LN{self.content}"

new classmethod

new(
    string: str, location: int, tokens: ParseResults
) -> Self

Create instance of this class.

Created to be used as callback in ParserElement.set_parse_action().

Source code in src/pygerber/gerberx3/tokenizer/tokens/ln_load_name.py
@classmethod
def new(cls, string: str, location: int, tokens: ParseResults) -> Self:
    """Create instance of this class.

    Created to be used as callback in `ParserElement.set_parse_action()`.
    """
    content: str = str(tokens["string"])
    return cls(string=string, location=location, content=content)

update_drawing_state

update_drawing_state(
    state: State, _backend: Backend
) -> Tuple[State, Iterable[DrawCommand]]

Update drawing state.

Source code in src/pygerber/gerberx3/tokenizer/tokens/ln_load_name.py
def update_drawing_state(
    self,
    state: State,
    _backend: Backend,
) -> Tuple[State, Iterable[DrawCommand]]:
    """Update drawing state."""
    warn_deprecated_code("LN", "8.1")
    return super().update_drawing_state(state, _backend)

parser2_visit_token

parser2_visit_token(context: Parser2Context) -> None

Perform actions on the context implicated by this token.

Source code in src/pygerber/gerberx3/tokenizer/tokens/ln_load_name.py
def parser2_visit_token(self, context: Parser2Context) -> None:
    """Perform actions on the context implicated by this token."""
    context.get_hooks().load_name.pre_parser_visit_token(self, context)
    context.get_hooks().load_name.on_parser_visit_token(self, context)
    context.get_hooks().load_name.post_parser_visit_token(self, context)

get_gerber_code

get_gerber_code(
    indent: str = "", endline: str = "\n"
) -> str

Get gerber code represented by this token.

Source code in src/pygerber/gerberx3/tokenizer/tokens/ln_load_name.py
def get_gerber_code(
    self,
    indent: str = "",  # noqa: ARG002
    endline: str = "\n",  # noqa: ARG002
) -> str:
    """Get gerber code represented by this token."""
    return f"LN{self.content}"