raygeo.template
CounterSettings
An immutable job counter.
The counter is the number the next job starts with, the value a reset returns to, the increment per
copy and per job, and an optional end value after which the range wraps back to start.
advance_on_export
advance_on_export: bool
Whether exporting G-code advances the counter.
auto_advance
auto_advance: bool
Whether a finished job advances the counter.
current
current: int
The value the next job starts with.
end
end: Optional[int]
The optional last value of the range.
start
start: int
The value a reset returns to and a wrapped range restarts at.
step
step: int
The increment per copy and per job.
advanced()
advanced(copies: int = 1) -> CounterSettings
A counter moved on (or back, if negative) by copies.
| Parameter | Type | Description |
|---|---|---|
copies | int = 1 | |
| Returns | CounterSettings |
from_dict()
from_dict(dict: dict) -> CounterSettings
Deserializes a counter from the project dictionary shape.
| Parameter | Type | Description |
|---|---|---|
dict | dict | |
| Returns | CounterSettings |
reset()
reset() -> CounterSettings
A counter whose current value is back at start.
| Parameter | Type | Description |
|---|---|---|
| Returns | CounterSettings |
to_dict()
to_dict() -> dict
Serializes the counter to the project dictionary shape.
| Parameter | Type | Description |
|---|---|---|
| Returns | dict |
value_at()
value_at(offset: int) -> int
The value shown by a copy that is offset copies further.
| Parameter | Type | Description |
|---|---|---|
offset | int | |
| Returns | int |
values_for()
values_for(copies: int) -> list[int]
The values of copies consecutive copies.
| Parameter | Type | Description |
|---|---|---|
copies | int | |
| Returns | list[int] |
Functions
evaluate()
evaluate(
expression: str,
values: dict,
functions: dict | None = None,
) -> object
Evaluate an expression with host variables and functions.
| Parameter | Type | Description |
|---|---|---|
expression | str | |
values | dict | |
functions | dict | None = None | |
| Returns | object |
evaluate_number()
evaluate_number(
expression: str,
values: dict,
functions: dict | None = None,
) -> float
Evaluate an expression and return a float.
| Parameter | Type | Description |
|---|---|---|
expression | str | |
values | dict | |
functions | dict | None = None | |
| Returns | float |
format_value()
format_value(value: object, spec: str) -> str
Format a value with a Python-style format spec.
| Parameter | Type | Description |
|---|---|---|
value | object | |
spec | str | |
| Returns | str |
names_in_expression()
names_in_expression(expression: str) -> set[str]
Return the variable names an expression reads.
String literals, keywords, numeric literals and attribute names are ignored.
| Parameter | Type | Description |
|---|---|---|
expression | str | |
| Returns | set[str] |
placeholder_names()
placeholder_names(template: str) -> set[str]
Return the placeholder names of a template.
Dotted path names such as workpiece.counter are returned verbatim; a format spec after the first
colon is not part of the name.
| Parameter | Type | Description |
|---|---|---|
template | str | |
| Returns | set[str] |
referenced_names()
referenced_names(template: str) -> set[str]
Return the variable names a template reads.
A format spec after the first colon is ignored. String literals, keywords and attribute names are not reported.
| Parameter | Type | Description |
|---|---|---|
template | str | |
| Returns | set[str] |
resolve_text()
resolve_text(
template: str,
values: dict,
functions: dict,
previous: tuple | None = None,
) -> tuple[str | None, tuple, bool]
Resolve a text template.
values are the variables, functions the host's zero-argument template functions, and previous
the entry returned by an earlier call. Returns (resolved, entry, volatile).
| Parameter | Type | Description |
|---|---|---|
template | str | |
values | dict | |
functions | dict | |
previous | tuple | None = None | |
| Returns | tuple[str | None, tuple, bool] |