pythonvtkparaview

How can I write a vtkTextActor3D to a file?


I have a set of tubes representing boreholes in a vtp-file (written by vtkXMLPolyDataWriter). Now for clarity I would like to add text labels to identify the boreholes when displaying them in paraview.

My idea was to create labels with vtkTextActor3D, to convert these actors to polydata, and then output these labels, split into polygons, to a vtp-file with the polydatawriter.

How can I do this? In paraview I was able to create a 3D Text source and save it to a vtp-file. However, I can't figure out how to do this in python.

Thanks!


Solution

  • I think to do it the way you described you should actually use vtkVectorText instead of vtkTextActor3D, because accroding to the documentation for vtkTextActor3D, it works like this: The input text is rendered into a buffer, which in turn is used as a texture applied onto a quad (a vtkImageActor is used under the hood). So you actually don't get any geometry for individual characters of your text, instead you would have to save the texture and display that in paraview. Meanwhile, vtkVectorText should (I've never used it personally...) produce an actual geometry for your characters so you can save them as any other polydata.