Jump to content

Multithreading and Multi processing for python script in Cura


VictorMic

Recommended Posts

Posted · Multithreading and Multi processing for python script in Cura

Hello,

I am currently developing a python script to increase E value directly in the Gcode, so I have to work on millions of lines. So i decide to add multiprocessing or multithreading to improve the time of execution. When I launch my program without multiprocessing on cura all is working, but i can't do multiprocessing/multithreading on Cura, it always return me empty list. Have you any advise ?

  • Link to post
    Share on other sites

    Posted · Multithreading and Multi processing for python script in Cura

    So the goal of my company is to create a new way to create industrial metal pieces by using 3d printing firstly to create the piece in plastic and with this plastic piece create a mold in which aluminium is poured and melt the plastic (so we need a 3d printing with the lowest density, so all the plastic will be burn by the aluminium.  I am currently creating a post processing python script for Cura, of which the goal is to increment the E value of the gcode to compensate for the loss of materials, that occur when the extruder of the 3d printer is moving without printing. We need to compensate these loss because otherwise it create holes in the printing. But the size of the pieces are great (millions of gcodes lines), so to be able to modify the gcode in a correct amount of time I used the Multiprocessing of python. I had to work on windows so to use multiprocessing i need to have this line :

    if __name__ == '__main__':  # MultiProcessing
            with Pool() as p:
                resultat = p.map(traitement_gcode_lineaire,liste_traitement)
        if len(resultat)!=0 :
            for result in resultat :
                fichier += result

    When launch by myself (like in VS code) without Cura all is good. But the issue here is that it can't enter the loop because __name__ will never be equal to '__main__', but it always equal to :

    'PostProcessingPlugin.PostProcessingPlugin.ModificationGcodeMultiProcessing'

    where 'ModificationGcodeMultiProcessing' is the name of my postprocessing script and i never found any other script that was using multiprocessing so i was wandering if anybody has any clue for me.

    I don t have any error message but at the end 'Fichier' (which should contain the gcode that i modify) is empty.

    I attach my code. But the issue is located in the function improve_extrusion (the other work perfectly)

    ModificationGcodeMultiProcessing.zip

  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Our picks

      • UltiMaker Cura 5.7 stable released
        Cura 5.7 is here and it brings a handy new workflow improvement when using Thingiverse and Cura together, as well as additional capabilities for Method series printers, and a powerful way of sharing print settings using new printer-agnostic project files! Read on to find out about all of these improvements and more. 
         
          • Like
        • 20 replies
      • S-Line Firmware 8.3.0 was released Nov. 20th on the "Latest" firmware branch.
        (Sorry, was out of office when this released)

        This update is for...
        All UltiMaker S series  
        New features
         
        Temperature status. During print preparation, the temperatures of the print cores and build plate will be shown on the display. This gives a better indication of the progress and remaining wait time. Save log files in paused state. It is now possible to save the printer's log files to USB if the currently active print job is paused. Previously, the Dump logs to USB option was only enabled if the printer was in idle state. Confirm print removal via Digital Factory. If the printer is connected to the Digital Factory, it is now possible to confirm the removal of a previous print job via the Digital Factory interface. This is useful in situations where the build plate is clear, but the operator forgot to select Confirm removal on the printer’s display. Visit this page for more information about this feature.
          • Like
        • 0 replies
    ×
    ×
    • Create New...