Jump to content

How to Add a Post Processing Script (.PY) in the Cura folder?


Ltek

Recommended Posts

Posted · How to Add a Post Processing Script (.PY) in the Cura folder?

I found a PY for the SmartTempTower I want into include the Cura folder for reuse

 

no matter what I try Cura doesnt see it

 

instructions I found for WINDOWS....

Copy PY file to 'C:\USERS\<user name>\AppData\Roaming\cura\scripts'  ... then Restart Cura.

 

*** I'm assuming they meant \cura\<version number>\scripts ... I tried both v5 and v4.13 but they do not "see" the script

 

 

@cura please include a simple 'upload' capability in the app!

  • Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?
    10 hours ago, Ltek said:

    I tried both v5 and v4.13 but they do not "see" the script

    Please post a link to your Cura.log, which can also be found in the configuration folder.

     

    Tip: the proper configuration folder can be found via Help -> Show configuration folder. There's a "scripts" folder inside the configuration folder.

  • Link to post
    Share on other sites

    Posted (edited) · How to Add a Post Processing Script (.PY) in the Cura folder?
    19 hours ago, ahoeben said:

    Please post a link to your Cura.log, which can also be found in the configuration folder.

     

    Tip: the proper configuration folder can be found via Help -> Show configuration folder. There's a "scripts" folder inside the configuration folder.

    Log and script attached.

    Verified, I did put the PY in the proper folder.

     

    thx for the help!

     

    Log_and_Script.zip

    Edited by Ltek
  • Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?

    The postprocessing script must be named "TempTower.py", or you must change the class name inside the file to match the file name.

  • Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?
    On 5/30/2022 at 11:58 PM, ahoeben said:

    The postprocessing script must be named "TempTower.py", or you must change the class name inside the file to match the file name.

    thank you!  Cura really needs an Import function to noobie-proof the great contributions that do not get 'published' in the Cura Marketplace.

  • Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?
    9 hours ago, Ltek said:

    Cura really needs an Import function to noobie-proof the great contributions

    That would not have helped in this case. You placed the file in the correct location, so you did the "import" part correctly.

     

    A (community-moderated?) Marketplace for postprocessing scripts could be interesting though.

    • Like 1
    Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?
    58 minutes ago, ahoeben said:

    A (community-moderated?) Marketplace for postprocessing scripts could be interesting though.

    +1

  • Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?

    That might force me to learn to work with Python.  I'm still struggling with Fortran IV.

    The worldwide shortage of punch cards isn't helping.

  • Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?

    I successfully added the old experimental script to Cura 5.6.0 in Ubuntu Mint. First find the location of your config file - Open Cura, select Help, then select "Show Configuration Folder", open the Scripts folder, and copy your python file(s) there.

    Restart Cura - and for me it worked https://www.thingiverse.com/thing:2077884.

    As three of my Ender printers do not support the M600 Change Filament command, I need to use the older experimental script found  on Thingiverse - Change Filament At Z Cura Plugin - 2077884. I am quite annoyed that this was included in my original installation of 5.4.0 and has since disappeared.

    The last version of Ender 2 pro with the newest motherboard, my Ender 3 pro with 4.2.7 motherboard, and my Ender 5 pro. do NOT support the M600 command.

    I have since discovered the earlier version of the Ender 2 Pro came with a different motherboard and firmware (2.0.6.1) and it supported M600, but not the latest motherboard (different CPU), and the older motherboards are no longer found anywhere - ARRRGH - Thank you Creality (no not really - after spending hours on the phone with Creality support)

    I hope this helps someone.

     

  • Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?
    5 hours ago, Solarsmurph said:

    The last version of Ender 2 pro with the newest motherboard, my Ender 3 pro with 4.2.7 motherboard, and my Ender 5 pro. do NOT support the M600 command.

    I have since discovered the earlier version of the Ender 2 Pro came with a different motherboard and firmware (2.0.6.1) and it supported M600, but not the latest motherboard (different CPU), and the older motherboards are no longer found anywhere - ARRRGH - Thank you Creality (no not really - after spending hours on the phone with Creality support)

    Personally I use the Pause At Height script and just change filament that way. Just make sure to set the Disarm timeout to something high like 1800 (the number of seconds it will wait before disengaging the stepper motors, which is important because if they disengage it will need to home them again and probably won't end up in exactly the right spot so you'll have a bit of a layer shift), set the Standby Temperature to your filament's printing temperature and uncheck the box above that so it will use M104 (which keeps the filament hot), and change the park position so that it's at a corner of your bed that's not being used.

     

    Then when it pauses just change the filament the old fashioned way - depends on your printer, but on all the Ender printers I've used there's a little lever on the extruder, just hold that down and pull out the filament, then get your replacement filament ready, hold the lever and push it in until it starts spewing out of the nozzle in the right colour, just grab that ooze and put it in the bin (or whatever) and get it to resume.

  • Link to post
    Share on other sites

    Posted (edited) · How to Add a Post Processing Script (.PY) in the Cura folder?

    This is a re-do.  I added "Unload", "Reload", and "Purge" options.  That makes it more "Filament Change" friendly.

    There are other changes.  The obvious one is that I threw out the "By Height" option as it didn't work with Z-hops enabled, or with Adaptive Layers.  I added a "Reason for Pause" option (if you are just inserting magnets or nuts then you don't need the purge settings).

    PauseAtLayer can co-exist with PauseAtHeight and be installed to the same folder.

    PauseAtLayer.zip

    There are a couple more settings.

    PauseAtLayerSettings.thumb.png.ebd174ff098cca8c3bbf56881dcd5f35.png

     

     

     

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

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?
    9 minutes ago, GregValiant said:

    PauseAtLayer can co-exist with PauseAtHeight and be installed to the same folder.

    Pro-tip: If you install the new script in the "scripts" folder inside the configuration folder instead of in the application folder/bundle (where the default scripts are), the new script will be automatically copied over when you install a new version of Cura at some point in the future.

    • Like 1
    Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?

    I've been using PauseAtHeight quite a bit lately to insert magnets.  I've taken to adding "M18 S0" in the G-code Before Pause to keep all steppers armed without specifying a disarm timeout.  If an overnight print finishes while I'm sleeping,  I can continue in the morning without fear of accidentally moving the built plate.

     

    I like some of the things GregValiant has done there with PauseAtLayer but I don't understand where that script needs to reside.  I looked in C:\Users\(me)\AppData\Roaming\Cura\5.2\scripts but that folder is empty.  ahoeben mentioned the configuration folder.  Where can I find that and do I just copy the .py file into the folder and restart Cura?  I'd like to experiment with some of the scripts to see what kind of damage improvements I can make.

  • Link to post
    Share on other sites

    Posted (edited) · How to Add a Post Processing Script (.PY) in the Cura folder?

    Under the "Help" menu is "Show Configuration Folder" which should take you there.  If you are on Windows it will be something like:

    "C:\Users\...your user name...\AppData\Roaming\cura\5.6\scripts" and it is the "scripts" folder that you want to copy the file to.

     

    BTW - what happens with "M18 S0" (and I suppose M84 S0) is firmware dependent.  Your printer reads "S0" as "don't ever disarm" and mine reads it as "disarm right friggin' now!".  That's a big difference.  The longest my printer will respond to is 4.5 hours.

     

    I made a couple of changes.  If you have more than one pause and all the settings are the same as for the first pause then you can just add a comma and an additional layer number (Ex: 34,110).

    There is a "Reason for Pause" setting with two options "Filament Change" and "All Others".  If you are simply making an insertion (magnets, nuts, etc.) then you don't need all the filament changing settings.

    The "disarm time" option is now in minutes.  I got tired of doing the conversion in my head.

     

    DO NOT use my coding style as any sort of example other than a "bad" example.  (That was for Slashee).

     

    PauseAtLayer_GV.zip

    Edited by GregValiant
  • Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?

    Thanks!  I found that configuration folder path (mine is version 5.2) but the scripts folder is empty.  I thought that was where I would find all the other scripts.  I'll try adding your file to that folder anyway and try it out tomorrow.  One thing I'd like to add is a persistent beep just before the pause.  Basically, have it beep, wait a second and repeat until I press the button.  Then let it do the pause and I'll press the button again to resume the print.  I was going to look at how things work in the scripts and see what I could do.

     

    You raise a good point about how printers respond differently to the same commands.  I'm using Marlin and I THINK M18 S0 is keeping the steppers active indefinitely.  I did discover that setting the disarm timeout to 0 in the script gets me no M18 command at all in the gcode.  The steppers don't disarm immediately but they do timeout eventually.  I assumed something in the firmware was keeping them armed for awhile then telling them disarm.  I'll experiment with that on my printer.

     

    I do a 3mm retraction before moving the head out of the way at the start of the pause and a 3mm extrusion afterwards to minimize the ooze factor.

  • Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?

    In Marlin M84 and M18 are the same.  I used M84 in the script.

    When the pause happens, the printer locks up.  That's true if you use "M0" which is "unconditional stop".  You can't do a loop to keep beeping because the printer will not accept any commands when it is in that state.

    "M25" is "pause SD print".  That works on some firmware but not on others.  If it does work, it usually calls a subroutine in the firmware and you are stuck with that.  You might be able to send commands when it is paused.  Probably firmware specific again.

    Gcode is linear so you can't do a "loop until".  You need a separate device or a piece of software running that is monitoring the USB port.  You could use M118 to start a routine in the computer.  I use an M118 to inform my print server that the print has finished so it can unlock the movement controls.

     

    I have an Ender 3 Pro about 4 years old running Marlin 1.1.8.  Default "Stepper disarm time" is 2 minutes and the printer will accept up to 4 hours (M84 or M18 S14400).  If the steppers disarm during a print you are generally in trouble.  It's possible to home the XY then move the print head to an opening on the build plate and then home the Z.  The problem is that the endstop switches (in my experience) aren't very repeatable.  The Z being off might mean a slightly under or over extruded layer.  If the XY are off it means a layer shift of up to 1/2mm.  It's noticeable for sure.

     

    This has a pause to insert 4 nuts, 6 pauses for color changes, and a final pause to insert a 3/16" x 9" steel rod to try to control warpage in the Florida sun (that seems to have worked).  There are a left and a right, 8 hours each, and I had to stay home and babysit all day for each one.  (the stars are glued into pockets).

    image.thumb.jpeg.c2fbc632882fb833b327211afe2d4bc4.jpeg

  • Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?
    10 hours ago, GregValiant said:

    DO NOT use my coding style as any sort of example other than a "bad" example.  (That was for Slashee).

    So you're saying that when I went through your script and pointed out all the things wrong it with it, it was a waste of my time?

  • Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?
    12 hours ago, GregValiant said:

    In Marlin M84 and M18 are the same.  I used M84 in the script.

    When the pause happens, the printer locks up.  That's true if you use "M0" which is "unconditional stop".  You can't do a loop to keep beeping because the printer will not accept any commands when it is in that state.

     

    Gcode is linear so you can't do a "loop until".  You need a separate device or a piece of software running that is monitoring the USB port.  You could use M118 to start a routine in the computer.  I use an M118 to inform my print server that the print has finished so it can unlock the movement controls.

     

    I have an Ender 3 Pro about 4 years old running Marlin 1.1.8.  Default "Stepper disarm time" is 2 minutes and the printer will accept up to 4 hours (M84 or M18 S14400).  If the steppers disarm during a print you are generally in trouble.  It's possible to home the XY then move the print head to an opening on the build plate and then home the Z.  The problem is that the endstop switches (in my experience) aren't very repeatable.  The Z being off might mean a slightly under or over extruded layer.  If the XY are off it means a layer shift of up to 1/2mm.  It's noticeable for sure.

     

     

    I'm probably complicating this discussion, but I'm using OctoPrint.  When it encounters the M0 in the gcode, it reports that the command is not sent to the printer because it's configured as a blocked command.  The printer has already been sent the M18 S0, the steppers are still armed (indefinitely?), and it's just waiting for the next instruction.  OctoPrint has changed its Pause button to Resume and is waiting for me to click it.  I assume it did that because it intercepted the M0 and recognized it as a pause.  Somehow it knew to stop there.

     

    I wasn't thinking of beeping during the pause, but just before.  When the loop is exited (by a button press), the M0 would be executed and the pause started.  But I understand what you mean about not looping in the gcode so that squelches that idea.

     

    I've tried to rehome just the X and Y axes (G28 X Y) in the G-code After Pause but as you say, that's not reliable.  I ended up with a small but obvious layer shift even if I hadn't moved the build plate while inserting magnets but rehomed just to be sure.

     

    I am curious about the E3Pro maxing out its disarm timeout after 4 hours.  I thought I had paused for longer than that but I'm testing that now with a 12-hour pause.  I'll check on it every hour or so to see when the steppers disarm.

     

    Good information all around.  I feel like I learn something new everyday.  Thanks.

  • Link to post
    Share on other sites

    Posted · How to Add a Post Processing Script (.PY) in the Cura folder?

    You can alternate G4 "dwell" and M300 "beep" in the gcode and get several beeps before a pause.  Personally I'd find it pretty annoying.

    The "S" parameter of a G4 command is in seconds.  The "P" parameter of the M300 beep command is in milliseconds.

    G4 S60

    M300 P1000

    G4 S60

    M300 P1000

    etc.

    That would beep for 1 second every minute.  Those lines would cause the actual pause to move back by 2 minutes.

    There isn't any way out of a G4 so if you happened to be standing right there you would have to wait for the entire string of beeps to end before the pause actually occurred.

     

    "Annoying" might not be strong enough of a word.

     

  • Link to post
    Share on other sites

    Posted (edited) · How to Add a Post Processing Script (.PY) in the Cura folder?
    3 hours ago, GregValiant said:

    "Annoying" might not be strong enough of a word.

    If your printer supports different frequencies on the speaker, the S parameter (frequency in hz) of the M300 command does let you change the tone. Bonus points to anyone who can get their printer to play the "caught Pokémon" sound from Red/Blue/Green/Yellow when a print is finished.

     

    Also worth nothing: In Marlin 1.1.0 (and probably higher), it has a tone queue and background player and doesn't interrupt the command queue, so it won't act as a pause.

    Edited by Slashee_the_Cow
  • 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
        • 23 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...