Skip to content

g02_set_clockwise_circular

g02_set_clockwise_circular

Wrapper for G01 mode set token.

SetClockwiseCircular

Bases: CommandToken

Wrapper for G02 mode set token.

Sets linear/circular mode to clockwise circular.

See: - section 4.8 of The Gerber Layer Format Specification Revision 2020.09 - https://argmaster.github.io/pygerber/stable/gerber_specification/revision_2020_09.html - section 4.7 of The Gerber Layer Format Specification Revision 2023.03 - https://argmaster.github.io/pygerber/stable/gerber_specification/revision_2023_03.html

Source code in src\pygerber\gerberx3\tokenizer\tokens\g02_set_clockwise_circular.py
class SetClockwiseCircular(CommandToken):
    """Wrapper for G02 mode set token.

    Sets linear/circular mode to clockwise circular.

    See:
    -   section 4.8 of The Gerber Layer Format Specification Revision 2020.09 - https://argmaster.github.io/pygerber/stable/gerber_specification/revision_2020_09.html
    -   section 4.7 of The Gerber Layer Format Specification Revision 2023.03 - https://argmaster.github.io/pygerber/stable/gerber_specification/revision_2023_03.html
    """

    def update_drawing_state(
        self,
        state: State,
        _backend: Backend,
    ) -> Tuple[State, Iterable[DrawCommand]]:
        """Set drawing mode."""
        return (
            state.model_copy(
                update={
                    "draw_mode": DrawMode.ClockwiseCircular,
                },
            ),
            (),
        )

    def parser2_visit_token(self, context: Parser2Context) -> None:
        """Perform actions on the context implicated by this token."""
        context.get_hooks().set_clockwise_circular.pre_parser_visit_token(self, context)
        context.get_hooks().set_clockwise_circular.on_parser_visit_token(self, context)
        context.get_hooks().set_clockwise_circular.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}G02"

update_drawing_state

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

Set drawing mode.

Source code in src\pygerber\gerberx3\tokenizer\tokens\g02_set_clockwise_circular.py
def update_drawing_state(
    self,
    state: State,
    _backend: Backend,
) -> Tuple[State, Iterable[DrawCommand]]:
    """Set drawing mode."""
    return (
        state.model_copy(
            update={
                "draw_mode": DrawMode.ClockwiseCircular,
            },
        ),
        (),
    )

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