Export segment with transparent material

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

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

Instead of VRML you can use other exporters, such as vtkOBJExporter.

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

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).

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?

i also tried this
segmentationDisplayNode = self.segmentationNode.GetDisplayNode()

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

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

segmentationDisplayNode.SetSegmentOpacity3D worked for me… :slight_smile:

1 Like