Jump to content

Plugin priority during slicing


awit

Recommended Posts

Posted · Plugin priority during slicing

Hi!

 

I have created 2 plugins, X and Y, and I want them to process the gcode sequentially - first X, then Y. However, when I set up both of them, and they work properly on their own, the issue I am facing is that Cura seems to firstly focus on plugin Y, then X, which produces the wrong result. My question is if there is a setting, which can assign a priority to plugins, ie. Cura starts with the most 'important' plugin first.

 

I could merge them into one plugin, and ensure the proper order, but I also want to use them separately.

 

Best regards,

AW

  • Link to post
    Share on other sites

    Posted · Plugin priority during slicing

    Question seems to be quite similar to this post : 

     

     

    So same answer The execution of the plugins follow I think the order of loading and the order of loading is according to the alphabetical order.

     

    Try to dhange the names of the plugins to change the order ?

    • Like 1
    Link to post
    Share on other sites

    Posted · Plugin priority during slicing

    Have you created plugins, or scripts for the PostProcessing plugin to use?

     

    With plugins you have (slightly) more control over the order of things by delaying when you register your postprocessing callback (eg when the plugin is loaded, or delay until after all loading of plugins has been performed).

    • Like 2
    Link to post
    Share on other sites

    Posted · Plugin priority during slicing

    I have created plugins, I have some post-processing scripts also, but they are not relevant to the current issue.

     

    6 minutes ago, ahoeben said:

    by delaying when you register your postprocessing callback

     

    I am not entirely sure I understand. Plugins can be executed in the order of them loading, or being executed all at once, when all of them finish loading?

     

     

     

    12 minutes ago, Cuq said:

    Try to dhange the names of the plugins to change the order ?

     

    On 2/8/2023 at 5:49 PM, ahoeben said:
    On 2/8/2023 at 11:54 AM, Cuq said:

    I don't think there is a possibility to solve this problem via a parameter.  Maybe @ahoeben could give a more accurate answer. 

    Not without modifying code.

     

    I will try the alphabetical workaround, but I would be glad for any information regarding the code modification.

  • Link to post
    Share on other sites

    Posted (edited) · Plugin priority during slicing
    1 hour ago, awit said:

    I am not entirely sure I understand. Plugins can be executed in the order of them loading, or being executed all at once, when all of them finish loading?

     

    At some point in your code, probably in your __init__ function, you register your postprocessor function like this:

        def __init__(self):
            (....)
            self._app = Application.getInstance()
          
            self._app.getOutputDeviceManager().writeStarted.connect(
                self._filterGcode
            )

     

    Instead of making that "connection" in the __init__ function, you can delay it to connect later, after other plugins have connected. The order in which the plugins are executed is the order in which they connected to the writeStarted signal.

     

        def __init__(self):
            (....)
            self._app = Application.getInstance()
          
            self._app.pluginsLoaded.connect(self._onPluginsLoaded)
    
        def _onPluginsLoaded(self):
            # this will run after all other plugins have connected  to the
            # writeStarted signal, so this plugin will execute last
    
            self._app.getOutputDeviceManager().writeStarted.connect(
                self._filterGcode
            )

     

     

    The order scripts in the PostProcessing plugin are executed is directly influenced by the order they are added in the interface. However you cannot change the order of other plugins in that interface.

    Edited by ahoeben
    • Like 1
    • Heart 1
    Link to post
    Share on other sites

    Posted · Plugin priority during slicing

    Do note that the trick I posted above is a bit of a hack, and if every plugin starts doing things like that it is going to be a game of wits who finds out the way to delay things the most. It would be cool if UM.Signal at least would support some sort of execution priority.

    • Like 2
    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.8 beta released
        Another Cura release has arrived and in this 5.8 beta release, the focus is on improving Z seams, as well as completing support for the full Method series of printers by introducing a profile for the UltiMaker Method.
        • 1 reply
      • Introducing the UltiMaker Factor 4
        We are happy to announce the next evolution in the UltiMaker 3D printer lineup: the UltiMaker Factor 4 industrial-grade 3D printer, designed to take manufacturing to new levels of efficiency and reliability. Factor 4 is an end-to-end 3D printing solution for light industrial applications
          • Like
        • 3 replies
    ×
    ×
    • Create New...