Bases: CommandToken
Wrapper for G01 mode set token.
Sets linear/circular mode to linear.
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\g01_set_linear.py
| class SetLinear(CommandToken):
"""Wrapper for G01 mode set token.
Sets linear/circular mode to linear.
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.Linear,
},
),
(),
)
def parser2_visit_token(self, context: Parser2Context) -> None:
"""Perform actions on the context implicated by this token."""
context.get_hooks().set_linear.pre_parser_visit_token(self, context)
context.get_hooks().set_linear.on_parser_visit_token(self, context)
context.get_hooks().set_linear.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}G01"
|
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\g01_set_linear.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.Linear,
},
),
(),
)
|
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\g01_set_linear.py
| def parser2_visit_token(self, context: Parser2Context) -> None:
"""Perform actions on the context implicated by this token."""
context.get_hooks().set_linear.pre_parser_visit_token(self, context)
context.get_hooks().set_linear.on_parser_visit_token(self, context)
context.get_hooks().set_linear.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\g01_set_linear.py
| def get_gerber_code(
self,
indent: str = "",
endline: str = "\n", # noqa: ARG002
) -> str:
"""Get gerber code represented by this token."""
return f"{indent}G01"
|