# Can't export segmentation as Dicom RTStruct in Python Script

**URL:** <https://discourse.slicer.org/t/cant-export-segmentation-as-dicom-rtstruct-in-python-script/16981>\
**Category:** Development\
**Tags:** dicom, slicerrt, python\
**Created:** [April 7, 2021, 2:19pm UTC](https://discourse.slicer.org/t/cant-export-segmentation-as-dicom-rtstruct-in-python-script/16981 "2021-04-07T14:19:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Namng1210](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/namng1210/32/10569_2.png) [@Namng1210](https://discourse.slicer.org/u/Namng1210)\
**Post date:** [April 7, 2021, 2:19pm UTC](https://discourse.slicer.org/t/cant-export-segmentation-as-dicom-rtstruct-in-python-script/16981/1 "2021-04-07T14:19:46Z")

</div>

Operating system: Python Script  
Slicer version: 4.11.20210226  
Dear authors,  
Everything seems to be really good when i exported it by hand and I’ve followed your instructions video of exporting RT-STRUCT file by right click at Study and choose Export to DICOM then click in RT struct and got the result as i want.

 ![ui](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/a/8aef4f677deed6518d2d7989ae69e898651ec8bd.png)  
But when i was doing it in python script by the following code, after passing the studyID as parameter, i got the result return ‘Exportable list contains no exportables’. Then, i have also tried to pass the segmentationID, but got another warning : ‘Must export the primary anatomical (CT/MR) image’. How can i fix this problem ?  
 ![export](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/b/eb83aa576b142a19d4794464c4211c4bced962e6.png)  
Hope you reply me soon. Thank you so much.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [April 7, 2021, 2:28pm UTC](https://discourse.slicer.org/t/cant-export-segmentation-as-dicom-rtstruct-in-python-script/16981/2 "2021-04-07T14:28:34Z")

</div>

This is a duplicate of this issue:

> <https://github.com/SlicerRt/SlicerRT/issues/184#issuecomment-814931832>
>
> Dear authors,
> Everything seems to be really good when i exported it by hand and I've followed your instructions video of exporting...

@Namng1210 Please do not duplicate threads especially without mentioning the other one as the community members helping you will duplicate work that others did in other threads.

Also I just see an email about your comment to that GitHub issue that it worked, but then you seem to have removed that comment. Then you post the original question here without any of the suggestions, and there is no trace about any information why that solution that seemed to work, finally (apparently) didn’t.

Now that we have a thread about this on GitHub let’s keep the discussion there, and a good start would be to react to the last suggestion. Thank you

---

<div class="post-metadata">

**Author:** ![Namng1210](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/namng1210/32/10569_2.png) [@Namng1210](https://discourse.slicer.org/u/Namng1210)\
**Post date:** [April 7, 2021, 2:51pm UTC](https://discourse.slicer.org/t/cant-export-segmentation-as-dicom-rtstruct-in-python-script/16981/3 "2021-04-07T14:51:56Z")

</div>

Dear author,  
This question was actually posted at the same time as my post on github.I’m so sorry because at that time, i really wanted to solve the problem and this is the first time that I joined this community.  
Thanks a lot for your help and i’ll learn from my mistakes next time.  
Best regards,  
Nguyen Phuong Nam

---

<div class="post-metadata">

**Author:** ![rodger](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@rodger](https://discourse.slicer.org/u/rodger)\
**Post date:** [December 1, 2021, 4:22pm UTC](https://discourse.slicer.org/t/cant-export-segmentation-as-dicom-rtstruct-in-python-script/16981/4 "2021-12-01T16:22:42Z")

</div>

Hello,  
I am kinda new with python. Can you explain to me how you manage to solve this issue? (the github post is closed so I am asking here sorry…).

I tried to run the ExamineForExport function on the volume and the segmentations, then past them in a list for the export function, but it did not worked:

exporter = DicomRtImportExportPlugin.DicomRtImportExportPluginClass()  
exportable1 = exporter.examineForExport(segmentationShItem)  
exportable2 = exporter.examineForExport(referenceVolumeShItem)

for exp in exportable1:  
exp.directory=outputFolder  
for exp in exportable2:  
exp.directory=outputFolder

exportables = [exportable1,exportable2]

> > > exporter.export(exportables)  
> > > Traceback (most recent call last):  
> > > File “”, line 1, in   
> > > File “C:/Users/tmp/AppData/Roaming/NA-MIC/Extensions-29402/SlicerRT/lib/Slicer-4.11/qt-scripted-modules/DicomRtImportExportPlugin.py”, line 122, in export  
> > > exportable.copyToVtkExportable(vtkExportable)  
> > > AttributeError: ‘list’ object has no attribute ‘copyToVtkExportable’

thanks !
