modules¶
geometor.model¶
provides the core data structures and logic for constructing geometric models in 2D space.
everything centers around Model
Submodules¶
- geometor.model.__main__
- geometor.model.ancestors
- geometor.model.chains
- geometor.model.circles
- geometor.model.cli
- geometor.model.colors
- geometor.model.delete
- geometor.model.element
- geometor.model.helpers
- geometor.model.lines
- geometor.model.model
- geometor.model.points
- geometor.model.polygons
- geometor.model.polynomials
- geometor.model.reports
- geometor.model.sections
- geometor.model.segments
- geometor.model.serialize
- geometor.model.utils
- geometor.model.wedges
Attributes¶
Classes¶
The central class representing a collection of geometric elements. |
Functions¶
|
Load a model from a JSON file and return a new Model instance. |
Package Contents¶
- geometor.model.load_model(file_path: str, logger: logging.Logger | None = None) geometor.model.Model¶
Load a model from a JSON file and return a new Model instance.
This function reads a JSON file containing serialized model data and reconstructs a
geometor.model.Modelobject. It performs a two-pass process: first parsing all symbolic expressions to recreate the geometry objects, and then linking them with their parents and metadata to restore the full dependency graph.- Parameters:
file_path – The path to the JSON file to load.
logger – An optional logger instance to attach to the new model.
- Returns:
A new
geometor.model.Modelinstance populated with the loaded data.
- geometor.model.GeometryObject¶
- class geometor.model.Model(name: str = '', logger: logging.Logger | None = None, use_point_subscript: bool = False)¶
Bases:
dict,geometor.model.points.PointsMixin,geometor.model.lines.LinesMixin,geometor.model.circles.CirclesMixin,geometor.model.polygons.PolygonsMixin,geometor.model.segments.SegmentsMixin,geometor.model.polynomials.PolynomialsMixin,geometor.model.serialize.SerializeMixin,geometor.model.reports.ReportMixin,geometor.model.delete.DeleteMixin,geometor.model.sections.SectionsMixin,geometor.model.wedges.WedgesMixin,geometor.model.ancestors.AncestorsMixinThe central class representing a collection of geometric elements.
The Model class is a comprehensive container that inherits from dict to store geometric elements mapped to their symbolic representations. It composes multiple mixins to provide a rich feature set, including point plotting, circle/line construction, serialization, reporting, and more.
- use_point_subscript = False¶
- ID_gen¶
- last_point_id = ''¶
- set_analysis_hook(hook_function: Callable) None¶
Set a hook function to be called during analysis/point addition.
- __setitem__(key: GeometryObject, value: geometor.model.element.Element) None¶
Set an item in the model, enforcing type checks.
This override of the dictionary setter ensures type safety for the model. It validates that keys are recognized GeometryObjects and values are Element wrappers, maintaining the integrity of the model’s storage.
- Parameters:
key – The geometric object (GeometryObject).
value – The element wrapper (Element).
- Raises:
TypeError – If key or value are not of the expected types.
- property structs: list[geometor.model.element.Struct]¶
Returns struct elements (line or circle) from model as list.
- limits() tuple[tuple[float, float], tuple[float, float]]¶
Find x, y limits from points and circles of the model.
This method calculates the bounding box of all geometric elements currently in the model. It iterates through points and circles (accounting for radii) to determine the minimum and maximum coordinates.
- Returns:
A tuple containing ((min_x, max_x), (min_y, max_y)).
- Return type:
- Raises:
ValueError – If the model contains no geometric elements.
- get_element_by_ID¶