Download this example

Download this example as a Jupyter Notebook or as a Python script.


Modeling: Chamfer edges and faces#

A chamfer is an angled cut on an edge. Chamfers can be created using the Modeler.geometry_commands module.

Create a block#

Launch the modeler and create a block.

[1]:
from ansys.geometry.core import launch_modeler, Modeler

modeler = launch_modeler()
print(modeler)
WARNING -  -  docker_instance - _check_port_availability - Service is already running at port 700...
Ansys Geometry Modeler (0x7fc2f1e3be00)

Ansys Geometry Modeler Client (0x7fc2f17de510)
  Target:     localhost:700
  Connection: Healthy
  Backend info:
    Version:            27.1.0
    Backend type:       CORE_LINUX
    Backend number:     20260222.1
    API server number:  2049
    CADIntegration:     27.1.0.13
/home/runner/work/pyansys-geometry/pyansys-geometry/.venv/lib/python3.14/site-packages/ansys/tools/common/cyberchannel.py:188: UserWarning: Starting gRPC client without TLS on localhost:700. This is INSECURE. Consider using a secure connection.
  warn(f"Starting gRPC client without TLS on {target}. This is INSECURE. Consider using a secure connection.")
[2]:
from ansys.geometry.core.sketch import Sketch
from ansys.geometry.core.math import Point2D

design = modeler.create_design("chamfer_block")
body = design.extrude_sketch("block", Sketch().box(Point2D([0, 0]), 1, 1), 1)

body.plot()

Chamfer edges#

Create a uniform chamfer on all edges of the block.

[3]:
modeler.geometry_commands.chamfer(body.edges, distance=0.1)

body.plot()

Chamfer faces#

The chamfer of a face can also be modified. Create a chamfer on a single edge and then modify the chamfer distance value by providing the newly created face that represents the chamfer.

[4]:
body = design.extrude_sketch("box", Sketch().box(Point2D([0,0]), 1, 1), 1)

modeler.geometry_commands.chamfer(body.edges[0], distance=0.1)

body.plot()
[5]:
modeler.geometry_commands.chamfer(body.faces[-1], distance=0.3)

body.plot()

Close session#

When you finish interacting with your modeling service, you should close the active server session. This frees resources wherever the service is running.

Close the server session.

[6]:
modeler.close()
WARNING - localhost:700 -  client - close - Geometry service was not shut down because it was already running...

Download this example

Download this example as a Jupyter Notebook or as a Python script.