CoordinateSystemManager#
- class CoordinateSystemManager[source]#
Bases:
objectManage coordinate systems, hierarchy, and entity assignments inside a DraftContext.
This manager provides: - Registration of coordinate systems with optional parent relationships (inheritance). - Validation of the parent graph (no missing parents, no cycles). - Assignment of coordinate systems to draft entities.
Notes
Coordinate systems are treated as draft-local objects. They are registered and validated here, and can be serialized to a CoordinateSystemStatus snapshot for persistence in the asset cache.
Methods
- add(coordinate_system, *, parent=None)[source]#
Register a coordinate system in this draft, optionally with a parent.
- Parameters:
coordinate_system (CoordinateSystem) – The coordinate system instance to register.
parent (CoordinateSystem, optional) – Optional parent coordinate system. If provided and not yet registered, the parent will be auto-registered as a root coordinate system first.
- Returns:
The registered coordinate system (same instance as coordinate_system).
- Return type:
CoordinateSystem
- Raises:
Flow360RuntimeError – If coordinate_system is not an exact CoordinateSystem instance, if the id or name is already registered, or if the resulting parent graph is invalid (e.g. cycle).
- update_parent(*, coordinate_system, parent)[source]#
Update the parent of a registered coordinate system.
- Parameters:
coordinate_system (CoordinateSystem) – A coordinate system that is already registered in this manager.
parent (CoordinateSystem, optional) – The new parent. If provided and not yet registered, it will be auto-registered as a root coordinate system first.
- Raises:
Flow360RuntimeError – If coordinate_system is not registered, or if updating the parent would make the parent graph invalid (e.g. introduce a cycle). In that case, the change is rolled back.
- Return type:
None
- remove(coordinate_system)[source]#
Remove a coordinate system if it has no dependents.
This also removes any entity assignments that reference the removed coordinate system.
- Parameters:
coordinate_system (CoordinateSystem) – The coordinate system to remove.
- Raises:
Flow360RuntimeError – If the coordinate system is not registered, or if other registered coordinate systems depend on it (i.e. it is a parent).
- Return type:
None
- get_by_name(name)[source]#
Retrieve a registered coordinate system by name.
- Parameters:
name (str) – Coordinate system name.
- Returns:
The matching coordinate system.
- Return type:
CoordinateSystem
- Raises:
Flow360RuntimeError – If no coordinate system with the given name exists in this draft.
- assign(*, entities, coordinate_system)[source]#
Assign a coordinate system to one or more draft entities.
- Parameters:
entities (EntityBase or list[EntityBase]) – One entity or a list of entities to assign.
coordinate_system (CoordinateSystem) – Coordinate system to assign. If not yet registered, it is auto-registered as a root coordinate system.
- Raises:
Flow360RuntimeError – If coordinate_system is not an exact CoordinateSystem instance or if any item in entities is not an entity instance.
- Return type:
None
Notes
If an entity already has a different coordinate system assigned, the assignment is overwritten and a warning is logged.