Hi to everyone, me and my team are trying to save the scene in the same directory where we have saved the scene before.
def saveScene(self):
"""
Saves the current MRML scene to the specified directory.
This method performs the following actions:
- Displays a message indicating that the scene is being saved.
- Saves the MRML scene to the directory specified by `self.saveResults_path` under the '2_Slicer' subdirectory.
"""
slicer.app.processEvents()
scenePath = os.path.join(self.saveResults_path, '2_Slicer')
# Verify if the path exist
if os.path.exists(scenePath):
# Remove the path
shutil.rmtree(scenePath)
# Create the path
os.makedirs(scenePath)
else:
print(f'El directorio {scenePath} no existe.')
# Save the scene:
slicer.mrmlScene.SaveScene(scenePath)
The problem is that slicer.mrmlScene.SaveScene()
needs empty directories to save properly the data. In case the directory is not empty, the slicer.mrmlScene.SaveScene()
apparently removes the files but don’t save anything.
To satisfy this requirement we tried to remove the files before saving but it does not work…
Literally we are trying to emulate the slicer interface when it asks if we want to override the files and clicks in ‘Yes to all’. First:
, to check all the nodes and data. And second:
, to override all the files needed.
My current Slicer version is : 5.7.0 -2024-10-05
My OS version is: Windows 11
Thanks a lot