Introduction
Geometric primitives — boxes, cylinders, spheres, hemispheres, and pill capsules — are the building blocks of CFD domain setup. The same five shapes serve three distinct purposes depending on how they are sized relative to the geometry:- Body of Influence (BOI): localised refinement volume for wakes, shear layers, and junctions.
- MRF zone: cylindrical or pill-shaped rotating reference frame region surrounding a fan, propeller, or rotor.
- Enclosure: large outer bounding volume establishing the fluid domain boundary.

- One tool, three use cases — primitive type and offset ratio determine the intent.
- Always up-to-date — bounding boxes derive from live mesh zonelets, adapting automatically when geometry changes.
- Fully parameterised — axis direction, primitive type, and offsets are all runtime parameters.
- Single script — mesh reading, CAD creation, and re-import run in one Python session.

About theNo CAD application is opened by the user. The entire pipeline — from reading a mesh file to appending a fully formed primitive volume — runs from a single Python script..fmdformat. FMD (Fluent Meshing Data) is Ansys’s platform-agnostic binary CAD exchange format. It stores the solid body in a self-contained, OS-independent representation readable on Windows, Linux, or any Ansys-supported platform — no native CAD kernel required. This makes.fmdthe ideal intermediate format when the geometry server and meshing session run on different machines or operating systems.
Code Structure
The solution is built around three Python classes you will implement:_BBox — Bounding Box Container
BoundingBox result.
Step 1 — Querying and Sizing the Bounding Box
The key differentiator of this workflow is deriving the bounding box directly from face zonelets rather than hard-coding coordinates. Implement aPrimitiveCreator class whose constructor queries the tight axis-aligned bounding box of any list of face zonelet IDs using prime.SurfaceUtilities.get_bounding_box_of_zonelets:
_PrimitiveGenerator. A small ratio keeps the primitive snug for a BOI; a large ratio expands it into an enclosure:
add_boi that drives the full pipeline:
Step 2 — Implementing the Primitive Geometry Functions
All five primitives are implemented inside a_PrimitiveGenerator class. Each method follows the same pattern:
- Set length units to millimetres via
DEFAULT_UNITS.LENGTH = UNITS.mm. - Derive axis lengths and cross-section radius from the bounding box.
- Build a
Sketchon aPlaneanchored at the correct origin. - Extrude or revolve the sketch into a solid body.
Shared Helpers
Before looking at individual primitives, two private helpers are used by all of them:__cross_section_radius returns the largest circle that fits within the rectangular cross-section perpendicular to the chosen axis — i.e. half the shorter dimension of that face.
1. Box
The simplest primitive. A rectangular profile is sketched on a plane perpendicular to X and extruded along X by the full bounding-box length.Sketch.box() + Design.extrude_sketch()
The sketch plane is placed at xmin with its local axes along Y and Z, so the extrusion travels in the +X direction for distance_x.
Note: Beyond the box, several other primitive geometries can be produced by the same generator simply by changing the orientation and profile passed to the sketch/extrude/revolve calls — for example a cylinder (circular profile extruded along axis_direction), a hemisphere (quarter-circle profile revolved 360° to form a dome cap), a sphere (circumscribed about the bounding box), a pill/capsule (cylinder with a hemisphere cap merged via Boolean union), and a frustum (tapered profile extruded along an axis). These follow the same bounding-box-driven approach shown above and are omitted here for brevity.
Step 3 — Dispatching the Correct Primitive
Add a single publiccreate_boi method to _PrimitiveGenerator that selects the geometry function by name, writes the .fmd file, and shuts down the geometry service:
.fmd file — a platform-agnostic format readable on any Ansys-supported OS — and the geometry service is shut down.
Step 4 — Appending to the PyPrimeMesh Session
After the CAD file is written,__append_boi uses prime.FileIO to import it back as a new body part — appended to the existing model rather than replacing it. Mesh zonelets are pruned immediately so only the geometry zonelets remain, ready for size-field assignment, MRF setup, or outer-domain meshing:
End-to-End Usage Example
The following example shows a complete workflow: launching Prime, reading a mesh, and generating three primitives — a pill-shaped BOI, a cylinder MRF zone, and a box enclosure — each derived from a different set of zonelets.use_defined_bounding_box=True and supply a _BBox instance directly:
Summary
This guide has shown how to write custom Python helper classes that generate geometric primitive volumes directly from PyPrimeMesh face zonelets, without opening a CAD application. Five primitive types — box, cylinder, hemisphere, sphere, and pill — cover the full range of CFD domain objects: localised BOI refinement zones, MRF rotating regions, and outer domain enclosures. Bounding boxes are computed at runtime from face zonelets, ensuring every primitive is automatically sized to the current geometry. Per-axis offset ratios give fine-grained control over how tightly or loosely each primitive wraps its target region. Once generated, each solid is exported as an.fmd file and appended back into the Prime model in the same Python session, making the workflow fully reproducible and easy to integrate into automated meshing pipelines.
For more details, feel free to reach out on the Synopsys Developer Forum.