# Convert planar contour to ribbon model in code

**URL:** <https://discourse.slicer.org/t/convert-planar-contour-to-ribbon-model-in-code/34119>\
**Category:** Support\
**Tags:** segmentation, python\
**Created:** [February 2, 2024, 12:07pm UTC](https://discourse.slicer.org/t/convert-planar-contour-to-ribbon-model-in-code/34119 "2024-02-02T12:07:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![susk](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@susk](https://discourse.slicer.org/u/susk)\
**Post date:** [February 2, 2024, 12:07pm UTC](https://discourse.slicer.org/t/convert-planar-contour-to-ribbon-model-in-code/34119/1 "2024-02-02T12:07:08Z")

</div>

Hi there,  
I have loaded a segmentation into 3D slicer as a planar contour, and am able to convert these planar contours into a Ribbon model representation manually in the segmentations module, by pressing ‘create’ for the Ribbon model under the Representations tab. I need to do this in order to see the contours in 2D view.

However, I have been searching but I cannot find out how I can do this conversion from planar contours to ribbon model programmatically in script. Could you help me?

---

<div class="post-metadata">

**Author:** ![susk](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@susk](https://discourse.slicer.org/u/susk)\
**Post date:** [February 5, 2024, 11:17am UTC](https://discourse.slicer.org/t/convert-planar-contour-to-ribbon-model-in-code/34119/2 "2024-02-05T11:17:18Z")

</div>

I found the solution, it was very simple. In case anyone is interested:  
segmentationNode = getNode(“Segmentation”)  
segmentationNode.GetSegmentation().CreateRepresentation(“Ribbon model”)

This will create a representation in all segments, using the conversion path with the lowest cost. Conversion starts from the master representation, which in my case was “Planar contour”
