Designer#
The PyAnsys Geometry designer subpackage organizes geometry assemblies and synchronizes to a supporting Geometry service instance.
Architecture overview#
PyAnsys Geometry uses a hierarchical object model to represent 3D geometry. Understanding this hierarchy is essential to effectively using the API.
The core classes in the designer subpackage are:
Design: The top-level container for a geometry model. Each design corresponds to a single session in the Geometry service and can contain components, bodies, materials, named selections, and more.Component: A sub-assembly within a design. Components can be nested to create complex assemblies and can contain other components, bodies, beams, coordinate systems, datum planes, and design points.Body: A 3D solid or surface body within a component. Bodies can be created by extruding, sweeping, or revolving sketches, or by applying boolean operations to existing bodies.
The following diagram illustrates the assembly hierarchy:
Design
├── Component
│ ├── Body
│ ├── Component (nested)
│ │ └── Body
│ ├── CoordinateSystem
│ ├── DatumPlane
│ └── DesignPoint
├── Body
├── Material
└── NamedSelection
Quick start#
The following example demonstrates the typical workflow for creating a geometry model with PyAnsys Geometry.
First, connect to the Geometry service using the
Modeler class:
from ansys.geometry.core import Modeler
modeler = Modeler()
Then, create a design, which is the root container for all geometry:
from ansys.geometry.core.sketch import Sketch
from ansys.geometry.core.math import Point2D
from ansys.geometry.core.misc import UNITS
from pint import Quantity
# Create a sketch and draw a circle
sketch = Sketch()
sketch.circle(Point2D([10, 10], UNITS.mm), Quantity(10, UNITS.mm))
# Create a design on the service
design = modeler.create_design("MyDesign")
Extrude the sketch to create a solid body:
body = design.extrude_sketch("Cylinder", sketch, Quantity(10, UNITS.mm))
Download and save the resulting design:
path = design.export_to_scdocx("path/to")
Warning
To ensure design objects are up to date, access design information (bodies,
components, and so on) via the design instance properties and methods rather
than storing that information separately. For example, use design.bodies
rather than storing the result in a separate variable (bodies =
design.bodies) and accessing it later. The separate variable can become
stale if the design is updated after the initial retrieval.
For detailed usage information on each class, see the following pages: