# Export segment with transparent material

**URL:** <https://discourse.slicer.org/t/export-segment-with-transparent-material/8494>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [September 19, 2019, 8:04am UTC](https://discourse.slicer.org/t/export-segment-with-transparent-material/8494 "2019-09-19T08:04:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![prorai](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@prorai](https://discourse.slicer.org/u/prorai)\
**Post date:** [September 19, 2019, 8:04am UTC](https://discourse.slicer.org/t/export-segment-with-transparent-material/8494/1 "2019-09-19T08:04:24Z")

</div>

How can i export segment with transparent material using slicer editor or export functionality using python code.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 19, 2019, 12:32pm UTC](https://discourse.slicer.org/t/export-segment-with-transparent-material/8494/2 "2019-09-19T12:32:38Z")

</div>

You can export the entire scene with all display properties to a model file as shown in this example: [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Export\_entire\_scene\_as\_VRML](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Export_entire_scene_as_VRML)

Instead of VRML you can use [other exporters](https://vtk.org/doc/nightly/html/classvtkExporter.html), such as vtkOBJExporter.

---

<div class="post-metadata">

**Author:** ![prorai](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@prorai](https://discourse.slicer.org/u/prorai)\
**Post date:** [September 19, 2019, 12:37pm UTC](https://discourse.slicer.org/t/export-segment-with-transparent-material/8494/3 "2019-09-19T12:37:50Z")

</div>

in my case i use ExportSegmentsClosedSurfaceRepresentationToFiles() method to export. is it possible with this method ?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 19, 2019, 12:46pm UTC](https://discourse.slicer.org/t/export-segment-with-transparent-material/8494/4 "2019-09-19T12:46:30Z")

</div>

Yes, you can use `ExportSegmentsClosedSurfaceRepresentationToFiles`, too. Make sure to save into OBJ format, since color and transparency of each segment is saved in this file format (while STL file format can only store geometry of the mesh and not any display properties).

---

<div class="post-metadata">

**Author:** ![prorai](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@prorai](https://discourse.slicer.org/u/prorai)\
**Post date:** [September 23, 2019, 7:11am UTC](https://discourse.slicer.org/t/export-segment-with-transparent-material/8494/5 "2019-09-23T07:11:39Z")

</div>

Thanks @lassoan  
Actually i’m using AddSegmentFromClosedSurfaceRepresentation here where i can pass color values [1.0,1.0,1.0] in this format as RGB , how can i add transparency alpha value here?

---

<div class="post-metadata">

**Author:** ![prorai](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@prorai](https://discourse.slicer.org/u/prorai)\
**Post date:** [September 23, 2019, 10:02am UTC](https://discourse.slicer.org/t/export-segment-with-transparent-material/8494/6 "2019-09-23T10:02:26Z")

</div>

Edit:  
i also tried this  
segmentationDisplayNode = self.segmentationNode.GetDisplayNode()  
segmentationDisplayNode.SetOpacity3D(0.5)

but it only updates it in slicer 3D view , i’m not getting that opacity in generated output.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 23, 2019, 11:36am UTC](https://discourse.slicer.org/t/export-segment-with-transparent-material/8494/7 "2019-09-23T11:36:33Z")

</div>

In the exported obj file’s material file you can see that transparency (T value) is set to the opacity of the segment.

---

<div class="post-metadata">

**Author:** ![prorai](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@prorai](https://discourse.slicer.org/u/prorai)\
**Post date:** [September 23, 2019, 12:03pm UTC](https://discourse.slicer.org/t/export-segment-with-transparent-material/8494/8 "2019-09-23T12:03:50Z")

</div>

Thanks,  
segmentationDisplayNode.SetSegmentOpacity3D worked for me… 🙂
