How to generate a .seg.nrrd file out of multiple STL files using Python?

Hi together,
I’ve asked this question also in the Slicer forum and got some help but nevertheless I also want to ask here, maybe there is a another way to implement this issue.

I’m trying to write a code snippet in Python for a pipeline that should generate a .seg.nrrd file by using the actual DICOM and the segmented STLs. In Slicer, I have performed this by using the module ‘Segmentations’ → Import models (one by one) → Right-click on the created segmentation node and export it as a .seg.nrrd file. Are there any existing python modules or functions, which can perform exactly this operation?

Thanks for any clue!

To create .seg.nrrd (a Slicer format), no. But a binary mask can be created from a mesh, see this example:
https://examples.itk.org/src/core/mesh/converttrianglemeshtobinaryimage/documentation

Thanks a lot @dzenanz ! I think this can solve my problem.