Aller au contenu principal

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.

ParameterTypeDescription
copiesint = 1
ReturnsCounterSettings

from_dict()​

from_dict(dict: dict) -> CounterSettings

Deserializes a counter from the project dictionary shape.

ParameterTypeDescription
dictdict
ReturnsCounterSettings

reset()​

reset() -> CounterSettings

A counter whose current value is back at start.

ParameterTypeDescription
ReturnsCounterSettings

to_dict()​

to_dict() -> dict

Serializes the counter to the project dictionary shape.

ParameterTypeDescription
Returnsdict

value_at()​

value_at(offset: int) -> int

The value shown by a copy that is offset copies further.

ParameterTypeDescription
offsetint
Returnsint

values_for()​

values_for(copies: int) -> list[int]

The values of copies consecutive copies.

ParameterTypeDescription
copiesint
Returnslist[int]

Functions​

evaluate()​

evaluate(
expression: str,
values: dict,
functions: dict | None = None,
) -> object

Evaluate an expression with host variables and functions.

ParameterTypeDescription
expressionstr
valuesdict
functionsdict | None = None
Returnsobject

evaluate_number()​

evaluate_number(
expression: str,
values: dict,
functions: dict | None = None,
) -> float

Evaluate an expression and return a float.

ParameterTypeDescription
expressionstr
valuesdict
functionsdict | None = None
Returnsfloat

format_value()​

format_value(value: object, spec: str) -> str

Format a value with a Python-style format spec.

ParameterTypeDescription
valueobject
specstr
Returnsstr

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.

ParameterTypeDescription
expressionstr
Returnsset[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.

ParameterTypeDescription
templatestr
Returnsset[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.

ParameterTypeDescription
templatestr
Returnsset[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).

ParameterTypeDescription
templatestr
valuesdict
functionsdict
previoustuple | None = None
Returnstuple[str | None, tuple, bool]