Jump to content
UltiMaker Community of 3D Printing Experts

A bunch of things PostProcessingPlugIns and debug


JCD
 Share

Recommended Posts

Posted · A bunch of things PostProcessingPlugIns and debug

When I began to work on PostProcessingPlugIns, it was a pain as there is no way to debug the script

No message, even sometimes my plug in not appearing in the list.

 

So I tried to install a standalone Python with debugger and work on it. This is what this post is about ...

 

I Have windows 7 64 bit, Cura 4.0 and Python 3.7 with IDLE

 

I build two configuration, one for the Cura script folder (for me in \AppData\Roaming\cura\4.0\scripts) and one in the script folder for Cura in Python (for me in \AppData\Local\Programs\Python\Python37-32\Scripts\Cura)

 

The basic logic is I create a superClass MyScript derived from tje script class of Cura, in which I put all the stuff to manage the scrip, leaving only in the script the variables and settings definition, and the formulas working to modify the GCode

It gives a feel & look for all the scripts, gives more information to the user in the GCode, and also manage the way to debug a script in Python

 

To debug in Python, you have the same superclass, a DEBUG_SCRIPT script to prepare the GCode for debugging, a tKinter Window class to run the script in python, and a mini script class having only the functions necessary to do like the one in Cura (but only for debugging purpose)

 

In the file below you'll find the two configuration you have only t extract them in the corresponding folders and then restart Cura and deiscover ...

 

As PostProcessingplugIns you'll find

 

1 DEBUG_SCRIPT : to prepare the GCode for debugging a new script

2 Comment : a script only to add a comment a the begining of the Gcode (you can use it several times in one slicing process)

3 Remaining printing Time : to send to the printer LCD at each layer the time remaining up to the end

4 Lower Tiny holes printinting speed on 1st layer : to hav a better printing without filament dragging effect

5 LiftHead without annoying too large Z movement : to have a better quality for small layers

 

Now look at this scenario :

 

CuraPPWindow.thumb.gif.5325165e43a72aed2855a1f59ffb9c45.gif

 

I insert all these scripts (number 1 to 8 to follow the result below), a few of them which will give an error that is handled

 

Here are the resulting pieces of GCode

 

1) Start of GCode

startGcode.thumb.gif.7a9128cb5da32b1b609fd19aa3d6d6d1.gif

 

GCode during the 1st layer within a tiny Hole, speed reduced from 1800 to 600

 

Bottom.thumb.gif.05fe2c49bd6e9086ab9477adbfdd8dc5.gif

 

end of a layer with information from several scripts

 

Remaining.thumb.gif.2a290fa4d8b29c609398fce10b8d18a2.gif

 

Now if I want to debug a script on the resulting Gcode file i have a the end of the slicing in Cura to save it in the IDLE scripts for Cura folder.

 

Then I go in Python's IDLE and run a script I want to debug

 

It appears a window to select the GCode file

selectSTL.thumb.gif.227fc20f3dbf94c9d17d5e2997192b9e.gif

 

Then the next window is to enter the settings for the script

GetParamWindow.thumb.gif.3a682a3176a6e7c206f98cbe21d36116.gif

 

if I close the window, result in IDLE

 

PythonResult0.thumb.gif.97b8a25553ee87863c5e9833e98e6414.gif

 

Or if I enter the correct params

 

IDLEResult1.thumb.gif.76ee4ec73b7bc0ba19dd60d9efde7854.gif

 

If there were errors the IDLE debugger will give you a lot of information to modify your script

InCuraScriptFojder.zip InIDLEscriptFolderForCura.zip

  • Like 1
Link to post
Share on other sites

Posted · A bunch of things PostProcessingPlugIns and debug

Have you looked at iPython/Jupyter?

iPython is basically the original repl on steroids and the "console" versions of it are a great way to merge IDLE and the REPL in one shot. Jupyter, originally called IPython Notebook - takes it a step further and abstracts the backing interpreter so that it can be housed in a web-service, where a "notebook" is basically a webified version of a repl with "cells" containing blocks of code that you can tweak/re-execute, iterate on. The back-end abstraction they called "a kernel" and because of this they're able to actually service pretty much any programming language as a back-end, it's even possible to have different languages in different cells.

It brings a lot else to the table, including "magics" - additional commands that start with "%", e.g. %time and %timeit for benchmarking, "?" and "??" for querying objects/modules etc, ? being an abbreviation for "help(...)" and "??" giving generally better info,

There are various debugger features too, but for me the most convenient is "%load_ext autoreload" and "%autoreload 2" so that as I make source-file changes they get auto-reloaded in the running interpreter.

  • Link to post
    Share on other sites

    Posted · A bunch of things PostProcessingPlugIns and debug

    PS:

    - "def __init__(self) -> None:"
    init doesn't return None, it actually doesn't return anything, so at some point having the "-> None" will break your code.

    - if you make your function-entry comments into strings, python will automatically use them as the function's __doc__ property, so that they are documented by help(function_name, and will the life of anyone who looks at your code as well as your own a lot easier 🙂

    > ipython
    Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)]
    Type 'copyright', 'credits' or 'license' for more information
    IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.
    
    In [1]: def getSettingDataString(self):
       ...:     """ You may either use the normal getSettingDataString function or the getSettingDataStringWithInfo
       ...:         the latter will add a comment setting in which you can enter any relevant information
       ...:         you want to insert at the beginning of the GCode file """
       ...:     pass
       ...:
    
    In [2]: help(getSettingDataString)
    Help on function getSettingDataString in module __main__:
    
    getSettingDataString(self)
        You may either use the normal getSettingDataString function or the getSettingDataStringWithInfo
        the latter will add a comment setting in which you can enter any relevant information
        you want to insert at the beginning of the GCode file
    
    
    In [3]:

    If you'd like to experiment with gcode without always having to remember the gcode names ... it's very preliminary, I've only been hacking at it for a few hours: https://github.com/kfsone/pymcode. If you have a UM3, there's a "ultimaker3.py" script you can run that drops you into an ipython repl with "um3" configured as a connection to your printer and "ops" having all of the command aliases. Or you can then type "repl()" and it will go into a mode where you can basically either type '"M104' to send raw gcode, or you can just use the command names:

     

    Cmd> "M105
    Cmd> set_bedtemp 65
    Cmd> "T0
    Cmd> set_hotendtemp 200
    Cmd> wait_hotendtemp 190
    Cmd> go
    

    There's a "help" command to list the repl commands.

     

     

  • 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
     Share

    • Our picks

      • 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
        • 11 replies
      • UltiMaker Cura 5.3.0-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.  
          • Heart
          • Like
        • 17 replies
      • New here? Get ahead with a free onboarding course
        Hi,
         
        Often getting started is the most difficult part of any process. A good start sets you up for success and saves you time and energy that could be spent elsewhere. That is why we have a onboarding course ready for
        Ultimaker S5 Pro Bundle, Ultimaker S5, Ultimaker S3 Ultimaker 2+ Connect.   
        They're ready for you on the Ultimaker Academy platform. All you need to do to gain access is to register your product to gain free access. 
        Ready? Register your product here in just 60 seconds.
        • 14 replies
    ×
    ×
    • Create New...