Skip to content

g90_set_coordinate_absolute

g90_set_coordinate_absolute

Wrapper for G90 token.

SetAbsoluteNotation

Bases: CommandToken

Wrapper for G90 token.

Set the Coordinate format to Absolute notation.

This historic code performs a function handled by the FS command. See 4.1. Very rarely used nowadays. Deprecated in 2012.

See section 8.1 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/g90_set_coordinate_absolute.py
class SetAbsoluteNotation(CommandToken):
    """Wrapper for G90 token.

    Set the `Coordinate format` to `Absolute notation`.

    This historic code performs a function handled by the FS command. See 4.1. Very
    rarely used nowadays. Deprecated in 2012.

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

    def update_drawing_state(
        self,
        state: State,
        _backend: Backend,
    ) -> Tuple[State, Iterable[DrawCommand]]:
        """Set drawing polarity."""
        warn_deprecated_code("G90", "8.1")
        if state.coordinate_parser is not None:
            logging.warning(
                "Overriding coordinate format is illegal. "
                "(See section 4.2.2 of The Gerber Layer Format Specification "
                "Revision 2023.03 - https://argmaster.github.io/pygerber/latest/gerber_specification/revision_2023_03.html)",
            )
        return (
            state.model_copy(deep=True),
            (),
        )

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

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

update_drawing_state

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

Set drawing polarity.

Source code in src/pygerber/gerberx3/tokenizer/tokens/g90_set_coordinate_absolute.py
def update_drawing_state(
    self,
    state: State,
    _backend: Backend,
) -> Tuple[State, Iterable[DrawCommand]]:
    """Set drawing polarity."""
    warn_deprecated_code("G90", "8.1")
    if state.coordinate_parser is not None:
        logging.warning(
            "Overriding coordinate format is illegal. "
            "(See section 4.2.2 of The Gerber Layer Format Specification "
            "Revision 2023.03 - https://argmaster.github.io/pygerber/latest/gerber_specification/revision_2023_03.html)",
        )
    return (
        state.model_copy(deep=True),
        (),
    )

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/g90_set_coordinate_absolute.py
def parser2_visit_token(self, context: Parser2Context) -> None:
    """Perform actions on the context implicated by this token."""
    context.get_hooks().set_coordinate_absolute.pre_parser_visit_token(
        self,
        context,
    )
    context.get_hooks().set_coordinate_absolute.on_parser_visit_token(self, context)
    context.get_hooks().set_coordinate_absolute.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/g90_set_coordinate_absolute.py
def get_gerber_code(
    self,
    indent: str = "",
    endline: str = "\n",  # noqa: ARG002
) -> str:
    """Get gerber code represented by this token."""
    return f"{indent}G90"