Jump to content
UltiMaker Community of 3D Printing Experts

Cura Script Tutorials?


Psyonic

Recommended Posts

Posted (edited) · Cura Script Tutorials?

Can anyone point me at some tutorials for the scripts in Cura? Can't seem to find anything out there in the ether! Just the basics of what all the Cura specific stuff is what I'm looking for.

Particularly, what the hell does the line

"version": N,

mean?? I've found a script example that has "1" as the version but it doesn't work unless I change it to "2"? I thought it would be version tracking for the script itself but obviously I'm wrong!

Edited by Psyonic
  • Link to post
    Share on other sites

    Posted · Cura Script Tutorials?

    Hi,

     

    the version string is just part of the meta data. I don't know if this is internally used to track changes but I would assume that it is expected to bump up this number when you submit a new plugin update.

     

    As for resources for scripts and plugins I guess the starting point would be here:

    https://github.com/Ultimaker/Cura/wiki/Plugin-Directory

     

    And the wiki:

    https://github.com/Ultimaker/Uranium/wiki/Creating-plugins

  • Link to post
    Share on other sites

    Posted · Cura Script Tutorials?

    Thanks @Nicolinux. The version thing was killing me! Still don't know the reason for it. I'm really looking for the structure of Cura scripts, like is "data" what the script is run against, i.e. the entire gcode? And any other real basics. Not sure I'm ready to write a full-blown plugin yet, just want to get a basic script working. But I'm making some headway now.

    Thanks again!

  • Link to post
    Share on other sites

    Posted (edited) · Cura Script Tutorials?

    The version is actually an API version. Sometimes we make internal (breaking) changes. We try to avoid them, but sometimes we're forced to do it (because previous assumptions of us have been proven wrong, or keeping the API the same would just result in unmaintainable or hard to implement code).

     

    Also; Plugins are completely different from scripts. The scripts are what is used by the post-processing plugin (and are run against the entire g-code).

     

    Plugins can do much, much more than scripts. With a plugin, it's possible to change what slicer is actually being used, change rendering on the screen, add new tools, add new filetypes that can be written/read or even change workflows. This makes them much more powerful, but also harder to actually work with.
     

    Edited by nallath
  • Link to post
    Share on other sites

    Posted · Cura Script Tutorials?

    Thanks @nallath. Yeah, I'm not really interested in creating a plugin, just a script to do simple changes to the gcode.

    Do you know where I could find some info on the structure of the scripts?
    Currently I'm just working on the assumption that

    def execute(self, data):
            return [self._some_other_method()]

    is required and does that actual processing of the gcode, and that "data" is actually the entire gcode to be processed, but this is just an assumption as I can't seem to find any detailed information or tutorials.

    I'm also not very familiar with python, but I'm getting used to it...

  • Link to post
    Share on other sites

    Posted · Cura Script Tutorials?

    Data is a List (the Python name for array) of gcode layer data. The first item of the list is the preamble (data that CuraEngine adds in front of the start gcode), followed by the start gcode, then each layer and finally the end gcode. Your execute method should return the processed data, which has the same structure and is handed to the next script or to the gcode writer.

  • Link to post
    Share on other sites

    Posted · Cura Script Tutorials?

    Thank you @ahoeben!! Things make a LOT more sense now! I was running it like it was one, long string, searching for "LAYER:" to modify at those points. Thank you!! This makes the results I was getting make a lot more sense!!

  • 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.3 stable released
        In this stable release, Cura 5.3 achieves yet another huge leap forward in 3D printing thanks to material interlocking! As well as introducing an expanded recommended print settings menu and lots of print quality improvements. Not to mention, a whole bunch of new printer profiles for non-UltiMaker printers!
          • Thanks
          • Like
        • 31 replies
      • Here it is. The new UltiMaker S7
        The UltiMaker S7 is built on the success of the UltiMaker S5 and its design decisions were heavily based on feedback from customers.
         
         
        So what’s new?
        The obvious change is the S7’s height. It now includes an integrated Air Manager. This filters the exhaust air of every print and also improves build temperature stability. To further enclose the build chamber the S7 only has one magnetically latched door.
         
        The build stack has also been completely redesigned. A PEI-coated flexible steel build plate makes a big difference to productivity. Not only do you not need tools to pop a printed part off. But we also don’t recommend using or adhesion structures for UltiMaker materials (except PC, because...it’s PC). Along with that, 4 pins and 25 magnets make it easy to replace the flex plate perfectly – even with one hand.
         
        The re-engineered print head has an inductive sensor which reduces noise when probing the build plate. This effectively makes it much harder to not achieve a perfect first layer, improving overall print success. We also reversed the front fan direction (fewer plastic hairs, less maintenance), made the print core door magnets stronger, and add a sensor that helps avoid flooding.
         

         
        The UltiMaker S7 also includes quality of life improvements:
        Reliable bed tilt compensation (no more thumbscrews) 2.4 and 5 GHz Wi-Fi A 1080p camera (mounted higher for a better view) Compatibility with 280+ Marketplace materials Compatibility with S5 project files (no reslicing needed) And a whole lot more  
        Curious to see the S7 in action?
        We’re hosting a free tech demo on February 7.
        It will be live and you can ask any questions to our CTO, Miguel Calvo.
        Register here for the Webinar
          • Like
        • 18 replies
      • UltiMaker Cura Alpha 🎄 Tree Support Spotlight 🎄
        Are you a fan of tree support, but dislike the removal process and the amount of filament it uses? Then we would like to invite you to try this special release of UltiMaker Cura. Brought to you by our special community contributor @thomasrahm
         
        We generated a special version of Cura 5.2 called 5.3.0 Alpha + Xmas. The only changes we introduced compared to UltiMaker Cura 5.2.1 are those which are needed for the new supports. So keep in mind, this is not a sneak peek for Cura 5.3 (there are some really cool new features coming up) but a spotlight release highlighting this new version of tree supports.  
          • Like
        • 24 replies
    ×
    ×
    • Create New...