# What is the best way to draw a triangle shape with Python

**URL:** <https://discourse.slicer.org/t/what-is-the-best-way-to-draw-a-triangle-shape-with-python/23572>\
**Category:** Support\
**Tags:** segmentation, python\
**Created:** [May 24, 2022, 7:10pm UTC](https://discourse.slicer.org/t/what-is-the-best-way-to-draw-a-triangle-shape-with-python/23572 "2022-05-24T19:10:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![minhtan16](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@minhtan16](https://discourse.slicer.org/u/minhtan16)\
**Post date:** [May 24, 2022, 7:10pm UTC](https://discourse.slicer.org/t/what-is-the-best-way-to-draw-a-triangle-shape-with-python/23572/1 "2022-05-24T19:10:31Z")

</div>

Hi everyone,

I’m new to 3D Slicer and I was wondering what would be the best way for me to draw a triangle on a 2D and 3D view using python. Considering I have a specific coordinates, I could process it into 3 points (to represent the triangle), at that point what would the best options to draw the triangle?

After some research I saw that I could use Segmentation, a bit like in this [topic](https://discourse.slicer.org/t/programmatically-create-a-segmentationnode-and-labelmapnode-from-polygon-coordinates/8448/4)

Is this the way to go or is there some kind of extension that is already doing such thing?

Thank you in advance,

Minh.

---

<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:** [May 24, 2022, 7:31pm UTC](https://discourse.slicer.org/t/what-is-the-best-way-to-draw-a-triangle-shape-with-python/23572/2 "2022-05-24T19:31:34Z")

</div>

The thread you linked makes sense if your goal is to make a filled triangle (segmentation). If you just want lines, you could make a closed curve markup and set the interpolation to linear.

[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#adding-control-points-programmatically](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#adding-control-points-programmatically)
