Create 3D Text#

Generate extruded text geometry with pyvista.Text3D().

import pyvista as pv

Create an extruded text mesh#

The text is standard PolyData and can be transformed and plotted like any other surface.

text = pv.Text3D('PyVista', depth=0.3)
text
PolyData (0x7bf170026440)
  N Cells:    856
  N Points:   440
  N Strips:   0
  X Bounds:   -2.790e+00, 2.790e+00
  Y Bounds:   -7.112e-01, 7.112e-01
  Z Bounds:   -1.500e-01, 1.500e-01
  N Arrays:   0


Compare flat and extruded text#

depth=0 produces flat glyphs; a positive depth extrudes them into 3D.

flat = pv.Text3D('PyVista', depth=0)
extruded = pv.Text3D('PyVista', depth=0.4)

pl = pv.Plotter(shape=(1, 2))
pl.subplot(0, 0)
pl.add_mesh(flat, color='royalblue')
pl.view_xy()
pl.subplot(0, 1)
pl.add_mesh(extruded, color='royalblue')
pl.view_xy()
pl.camera.azimuth = -25
pl.camera.elevation = 20
pl.camera.zoom(0.85)
pl.show()
create text 3d

Tags: load

Total running time of the script: (0 minutes 0.155 seconds)

Gallery generated by Sphinx-Gallery