create_draft

Contents

create_draft#

create_draft(*, new_run_from, face_grouping=None, edge_grouping=None, include_geometries=None, exclude_geometries=None, imported_surfaces=None)[source]#

Create a local draft context from a cloud asset for your run.

A draft is an isolated, in-memory snapshot of an asset’s entity information. It lets you inspect and modify entities (surfaces, edges, volumes, body groups, etc.) locally without mutating the cloud asset.

Draft allows you to:

  • Override grouping tags for faces and edges (geometry assets only).

  • Include or exclude geometry components (projects with a geometry root asset only).

  • Register additional imported surfaces (surface mesh dependencies in the project).

  • Access entities in the draft via DraftContext properties.

  • Manage coordinate systems and mirror actions through draft.coordinate_systems and draft.mirror.

Parameters:
  • new_run_from (Union[Geometry, SurfaceMeshV2, VolumeMeshV2]) – The cloud asset to create the draft from.

  • face_grouping (Optional[Union[str, FaceGroupingRules]]) – Face grouping to activate for geometry assets. A string selects an existing grouping tag. A FaceGroupingRules payload defines RULE-BASED grouping as draft state: the rules are resolved against the geometry’s topology tree (first match wins by group order; faces no rule matches go to the is_remaining catch-all, which is required once there are any; overlaps warn loudly; a rule group left with no faces or a group spanning several model files is refused), the resulting groups are built in the draft’s isolated entity info (the geometry asset itself stays immutable), and the rules + resolved map are persisted automatically when the draft is submitted (including draft_only=True). When None, the draft uses the default grouping stored on the geometry asset.

  • edge_grouping (Optional[str]) – Edge grouping tag to activate for geometry assets. When None, the draft uses the default grouping stored on the geometry asset. If the activated geometry does not have edge grouping attributes, this option is ignored.

  • include_geometries (Optional[List[Geometry]]) – Additional geometry components to activate in the draft (projects with a geometry root asset only). The selected geometries are merged into the draft entity info.

  • exclude_geometries (Optional[List[Geometry]]) – Geometry components to deactivate from the draft (projects with a geometry root asset only). If a geometry is not currently active, its exclusion is ignored with a warning.

  • imported_surfaces (Optional[List[ImportedSurface]]) – Imported surface meshes to register in the draft. This is commonly obtained from Project.imported_surfaces or created via Project.import_surface_mesh(…).

Returns:

A draft context manager. Use it with with to set it as the active draft context.

Return type:

DraftContext

Raises:
  • Flow360RuntimeError – If new_run_from is not a cloud asset instance.

  • Flow360ValueError – If draft creation is attempted from a Case or an imported Geometry, if geometry components are requested for a non-geometry-root project, or if an invalid grouping tag is specified.

Example

>>> import flow360 as fl
>>> geometry = fl.Geometry.from_cloud(id="...")
>>> with fl.create_draft(new_run_from=geometry, face_grouping="groupByName") as draft:
...     print(draft.surfaces["wing*"])