DraftContext#
- class DraftContext[source]#
Bases:
AbstractContextManager[DraftContext]Context manager that tracks locally modified simulation entities/status. This should (eventually, not right now) be replacement of accessing entities directly from assets.
Properties
- body_groups: EntityRegistryView#
Return the list of body groups in the draft.
Example
>>> with fl.create_draft(new_run_from=geometry) as draft: ... draft.body_groups["body_group_1"] ... draft.body_groups["body_group*"]
- surfaces: EntityRegistryView#
Return the list of surfaces in the draft.
- mirrored_body_groups: EntityRegistryView#
Return the list of mirrored body groups in the draft.
Notes
Mirrored entities are draft-only entities derived from mirror actions and stored in the draft registry.
- mirrored_surfaces: EntityRegistryView#
Return the list of mirrored surfaces in the draft.
Notes
Mirrored entities are draft-only entities derived from mirror actions and stored in the draft registry.
- edges: EntityRegistryView#
Return the list of edges in the draft.
- volumes: EntityRegistryView#
Return the list of volumes (volume zones) in the draft.
- boxes: EntityRegistryView#
Return the list of boxes in the draft.
- cylinders: EntityRegistryView#
Return the list of cylinders in the draft.
- imported_geometries: List#
Return the list of imported geometries in the draft.
- imported_surfaces: EntityRegistryView#
Return the list of imported surfaces in the draft.
- coordinate_systems: CoordinateSystemManager#
Coordinate system manager for this draft.
This is the primary user entry point to create/remove coordinate systems, define parent relationships, and assign coordinate systems to draft entities.
See also
CoordinateSystemManager
- mirror: MirrorManager#
Mirror manager for this draft.
This is the primary user entry point to define mirror planes and create/remove mirrored draft-only entities derived from geometry body groups.
See also
MirrorManager
Methods
- preview_selector(selector, *, return_names=True)[source]#
Preview which entities a selector would match in this draft context.
- Parameters:
selector (EntitySelector) – The selector to preview (SurfaceSelector, EdgeSelector, VolumeSelector, or BodyGroupSelector).
return_names (bool, default True) – When True, returns entity names. When False, returns entity instances.
- Returns:
Matched entity names or instances depending on
return_names.- Return type:
Example
>>> import flow360 as fl >>> geometry = fl.Geometry.from_cloud(id="...") >>> with fl.create_draft(new_run_from=geometry) as draft: ... selector = fl.SurfaceSelector(name="wing_surfaces").match("wing*") ... matched = draft.preview_selector(selector) ... print(matched) # ['wing_upper', 'wing_lower', ...]
- compute_obb(entities, *, rotation_axis_hint=None, lod_level=None)[source]#
Compute oriented bounding box for the given surface entities.
- Parameters:
entities (Surface | List[Surface] | EntityRegistryView | EntitySelector) – Surface entities or an EntitySelector that resolves to surfaces. Accepts: a single Surface, a list of Surface, an EntityRegistryView, or an EntitySelector.
rotation_axis_hint – optional approximate rotation axis direction (e.g. [0, 0, 1]). If provided, the PCA axis most aligned with this hint is chosen as rotation axis. If None, the axis whose perpendicular cross-section is most circular is used.
lod_level (int | None) – LOD level override for tessellation data.
- Returns:
OBBResult with center, axes, extents, axis_of_rotation, and radius as properties.
- Raises:
Flow360RuntimeError – If this draft was not created from a Geometry resource.
Flow360ValueError – If no face IDs could be collected from the provided entities.