# Add vtkVectorText programmatically

**URL:** <https://discourse.slicer.org/t/add-vtkvectortext-programmatically/33977>\
**Category:** Development\
**Tags:** vtk\
**Created:** [January 25, 2024, 6:29pm UTC](https://discourse.slicer.org/t/add-vtkvectortext-programmatically/33977 "2024-01-25T18:29:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Zeyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jeff_zeyl/32/70056_2.png) [@Jeff\_Zeyl](https://discourse.slicer.org/u/Jeff_Zeyl)\
**Post date:** [January 25, 2024, 6:29pm UTC](https://discourse.slicer.org/t/add-vtkvectortext-programmatically/33977/1 "2024-01-25T18:29:39Z")

</div>

I would like to engrave many text models onto a skin model, programmatically, based on a set of markup control point coordinates.

My current approach is to generate vtk.vtkVectorText models, set their location, and subtract the text and skin models. I have successfully loaded vtk model, but vtk.vtkVectorText doesn’t have a set center method (like some other vtk model types types) but rather position is set by a vtkActor. If I understand correctly, in Slicer vtkPolyDataActor and vtkPolyDataMapper are tied into Displayable Managers ([Documentation/Nightly/Developers/DisplayableManagers - Slicer Wiki](https://www.slicer.org/wiki/Documentation/Nightly/Developers/DisplayableManagers)) but don’t see relevant methods to set position.

How can i set the position of a model vtkVectorText inside slicer, which would otherwise be controlled by vtkActor outside of the Slicer environment?

 ![vectortext](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/8/889a4bafe4c1734a296ce66d632b677b1af07959.png)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 25, 2024, 6:31pm UTC](https://discourse.slicer.org/t/add-vtkvectortext-programmatically/33977/2 "2024-01-25T18:31:41Z")

</div>

Did you look at this? [New text engrave/emboss effect in Segment Editor](https://discourse.slicer.org/t/new-text-engrave-emboss-effect-in-segment-editor/12013)

---

<div class="post-metadata">

**Author:** ![Jeff\_Zeyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jeff_zeyl/32/70056_2.png) [@Jeff\_Zeyl](https://discourse.slicer.org/u/Jeff_Zeyl)\
**Post date:** [January 25, 2024, 6:54pm UTC](https://discourse.slicer.org/t/add-vtkvectortext-programmatically/33977/3 "2024-01-25T18:54:02Z")

</div>

I have tried the effect but encountered the unclear text issue noted on the same discussion thread (I have not yet followed through with changing volume spacing to make the text clearer).

In terms of programmatic placement of position, the lines in the link below could then potentially be modified?

> <https://github.com/lassoan/SlicerSegmentEditorExtraEffects/blob/f43df35af66a0b60000b008e0fa061d53319dc78/SegmentEditorEngrave/SegmentEditorEngrave.py#L99-L122>

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 25, 2024, 7:20pm UTC](https://discourse.slicer.org/t/add-vtkvectortext-programmatically/33977/4 "2024-01-25T19:20:09Z")

</div>

You could have a look at how the effect is implemented using VTK:

> <https://github.com/lassoan/SlicerSegmentEditorExtraEffects/blob/f43df35af66a0b60000b008e0fa061d53319dc78/SegmentEditorEngrave/SegmentEditorEngraveLib/SegmentEditorEffect.py#L537>

---

<div class="post-metadata">

**Author:** ![Jeff\_Zeyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jeff_zeyl/32/70056_2.png) [@Jeff\_Zeyl](https://discourse.slicer.org/u/Jeff_Zeyl)\
**Post date:** [May 8, 2024, 7:48pm UTC](https://discourse.slicer.org/t/add-vtkvectortext-programmatically/33977/5 "2024-05-08T19:48:30Z")

</div>

Thank you. I was able to reproduce the segmentation effect so that my text labels can engrave or emboss at specific coordinates. However, when plugging in the arguments into the apply function, the letters engrave upside down relative to the default ‘Test’ text in the GUI, even if I apply a transform to the associated segment model, flipping it 180 degrees. Any idea where this transform is getting applied?

here?: [SlicerSegmentEditorExtraEffects/SegmentEditorEngrave/SegmentEditorEngraveLib/SegmentEditorEffect.py at f43df35af66a0b60000b008e0fa061d53319dc78 · lassoan/SlicerSegmentEditorExtraEffects · GitHub](https://github.com/lassoan/SlicerSegmentEditorExtraEffects/blob/f43df35af66a0b60000b008e0fa061d53319dc78/SegmentEditorEngrave/SegmentEditorEngraveLib/SegmentEditorEffect.py#L511)

 ![inversion](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/2/d2e1088f75df237a46817889fbee4fb19bd60353.png)
