Batch slicing

Following this topic Drafthorse - Layout Management tools for Grasshopper - #49 by julien2

What i’m trying to achieve is something like this :

  1. Getting a GH script wich produce many different 3D objects (done, check the link)
  2. Exporting those objects to a folder (with new rhino grasshopper tools should be fine)
  3. Creating a python script that does quite the same as the drafthorse sequence done above which means :
    a. List all objects files (done with glob command in python)
    b. Split list in sublists of n objects (using slice)
    c. Open prusaslicer and load parameters (using subprocess)
    d. Load the n objects of the first sublist and auto dispatch them on the plate
    e. Slice them
    f. Export Gcode with first and last object of the current sublist indice as a ref in the filename
    g. Delete all, load next sublist and repeat from d until there’s no more sublists.

Has anyone already done something like this with prusaslicer or a similar software?
Guess it, next on list will be export dxf or dwg for laser cutting.

Basic idea works on *.STL
Seems that 3MF files won’t work (not loading, but this was a really fast try, my files may be the cause)
Maybe it will be fun and not that hard to integrate it into grasshopper.

import subprocess
import glob
# Scanne le dossier pour identifier les fichiers à traiter.
PrintList = glob.glob("C:\\My_Path\\*.stl")
# Créer une liste de listes contenant chacune n éléments
n = 9 
PrintSublists = [PrintList[i:i + n] for i in range(0, len(PrintList), n)]
# ouvre prusa & charge le fichier de configuration de découpe
# Pour chaque élément de liste :
    # charge la liste de fichiers en stockant premier et dernier indice
    # Nom des fichiers sources = FileNameA1.stl, ..., FileNameE5.stl, ...
    # repartit les fichiers sur le plateau
    # Découpe
    # Exporte Gcode avec nom composé d'indice a et b
    # supprime tout et recommence
for n in range(len(PrintSublists)) :
    premier = PrintSublists[n][0][-6:-4]
    dernier = PrintSublists[n][-1][-6:-4]
    my_string = " ".join(str(element) for element in PrintSublists[n])
    command =   "prusa-slicer-console.exe \
                --export-gcode {}\
                --scale 1\
                --merge \
                --load config.ini \
                --output FichierSynthese{}.gcode".format(my_string, indice), shell=True)
# Message de succès
# Fermeture prusa

Will test it next week on a 800+ files.