Jump to content

Go to Position After Finishing Each Layer


BuxZED

Recommended Posts

Posted · Go to Position After Finishing Each Layer

Hi All,

 

Long time reader, first-time poster.

 

Is there a way I can get Cura to add few extra lines of Gcode after each layer. preferably after the z hop after the layer finish. I'm trying to trigger a microswitch  after each layer by bumping it with the printhead assembly

 

The code I require to be added is something along the lines of 

 

G1 F1350 X100 Y10 ; get the print head into a position so it doesn't approach the microswitch in a different angle every time
G1 F1350 X120 Y10 ; bump against the microswitch lever square on
G4 S03 ; wait 3 seconds with the microswitch triggered 

 

I'm using Cura V 3.3.1

 

 

Kind regards,

BuxZED

  • Link to post
    Share on other sites

    Posted · Go to Position After Finishing Each Layer

    In a text editor it's pretty easy to add these lines with a recorded macro.  Search for "Z" go to end of line, insert gcodes.  Repeat macro for every layer.

     

    The best way to do this would be a plugin.  Do you know a little python?  It's not hard to write cura plugins.

     

    Are you going to take a photo on every layer completion?  To make a sped up video?

  • Link to post
    Share on other sites

    Posted · Go to Position After Finishing Each Layer
    2 minutes ago, gr5 said:

    In a text editor it's pretty easy to add these lines with a recorded macro.  Search for "Z" go to end of line, insert gcodes.  Repeat macro for every layer.

     

    The best way to do this would be a plugin.  Do you know a little python?  It's not hard to write cura plugins.

     

    Are you going to take a photo on every layer completion?  To make a sped up video?

    6

     

     

    fantastic tip. looking at the gcode in a text editor, I can easily write a Python script to spit out a new text file with the extra lines added. would be lovely to import that as a Cura plugin though

     

    I have written python scripts in the past for comparing and renaming files in a folder and such. but never written a Cura plugin. is there a getting started guide anywhere? alternatively some sample code I can look at?

     

    yes. on all time-lapse videos, you can see the print head wissing about. I think that looks quite distracting. if I take each picture with the printhead parked in the corner, I think it would look quite nice. it's an idea, will see how it goes ?

  • Link to post
    Share on other sites

    Posted · Go to Position After Finishing Each Layer

    That's great that you know python as plugins are written in python.  The simpler kind of plugin is called a "post processing plugin" which works on the gcode that cura just created and does a final step.  That's what I recommend.  The existing ones can be found here:

    https://ultimaker.com/en/resources/20442-post-processing-plugins

     

    The code for them to see how they are written is here: plugins/PostProcessingPlugin/scripts

    (what operating system do you use?  The main install folder depends on your OS and then go down from there)

     

    I think maybe you can put your plugin there but it will get lost when you install a new cura so I think it's recommended to go in the user area which can be found in cura by doing "help" "show configuration folder".  You may see a plugins.json file there but I'm not sure what to do at this point.

     

    @ctbeke @ahoeben - is there a post processing plugin writing guide somewhere I can link to?

     

    I sat in a ctbeke course on doing this but now I don't know where the power point presentation went. ?

     

  • Link to post
    Share on other sites

    Posted · Go to Position After Finishing Each Layer

    By the way, make sure you also do a retract.  If you keep track of the E value (extruder) you can do a retract like this:

    G0 E1243.123

     

    where the number after the E is the new position to move the extruder to (for UM2 the position is in cubic mm of filament but for UMO, UM3 and S5 it's in linear mm of filament).

     

    And of course an un-retract when it gets back to printing again.

     

    Also you don't want to pause for a few seconds because even if you only pause for 3 seconds the nozzle will leak (as pla heats up it slowly expands driving filament out) and then that little tiny "sausage" below the nozzle will hang there and when the nozzle moves back into the part it will attach to the side of the part giving you tiny strings sticking out of the print - one on each layer.  So you want to take that photo very quickly.

     

    It might be best to print a tower next to the part (this feature is built into cura) and do the photo  right when it first starts to print the tower.  If the tower is near your switch (you can position the tower) then no need to write any plugin at all!  The advantage of a tower is there is very little delay from when it finishes a layer on the tower to jump over to the print - it will pick a point as close as possible to the tower to start that layer.

     

  • Link to post
    Share on other sites

    Posted · Go to Position After Finishing Each Layer
    38 minutes ago, gr5 said:

    I sat in a ctbeke course on doing this but now I don't know where the power point presentation went.

     

    You can find the slides here: https://docs.google.com/presentation/d/1YY9IE8HPTmXydkej91vKg7MzaWopoPH66_UR1ev3ydc/edit?usp=sharing.

     

    Another good starting point for Python plugins is https://github.com/Ultimaker/Cura/wiki/Plugin-Directory.

     

    For post processing scripts I'm not sure where the best resources are, maybe @ghostkeeper can tell a bit about that?

  • Link to post
    Share on other sites

    Posted · Go to Position After Finishing Each Layer

    thanks @gr5 and @ctbeke

    learning a lot, and making good progress. I'll be sure to post if I run in to a roadblock

    ? 

  • Link to post
    Share on other sites

    Posted · Go to Position After Finishing Each Layer

    There is no guide to post-processing scripts, but I've always recommended people to take a look at the other scripts as example. The search and replace script is really simple and should be clear for adaptation: https://github.com/Ultimaker/Cura/blob/master/plugins/PostProcessingPlugin/scripts/SearchAndReplace.py

  • Link to post
    Share on other sites

    Posted (edited) · Go to Position After Finishing Each Layer

     

     

    Hi all,

     

    this took longer than I initially thought. life got in the way. but here is my first run with the modified Gcode

     

    Things to fix

    • Fix the camera focus
    • Add "Retract", and "Unretract" at each layer stop to prevent the long oozing 

    but all in all, I like the effect ?

    Edited by BuxZED
  • Link to post
    Share on other sites

    Posted · Go to Position After Finishing Each Layer

    ok, I solved the camera focus issue 

    but still having issues with stringing on the way back from the microswitch (this is not passive drooping, the machine is actively extruding on the way back)

     

     

     

    below is the code I'm using. any pointers would be appreciated

     

    file = open("processed_code.txt", "w")
    
    
    with open("to_process_code.txt") as gcode_file_original:
        contents = gcode_file_original.readlines()
        for line in contents:
            line = str(line)
            hit = line.find("LAYER:")
    
            if hit != -1:
                line = line + "\n" + "G10" + "\n" + "G0 X200 Y218" + "\n" + "G0 X223 Y218" + \
                    "\n" + "G4 S03" + "\n" + "G0 X200 Y218" + "\n" + "G11" + "\n\n"
                print(line)
                file.write(line)
            else:
                line = line
                print(line)
                file.write(line)

    I added the G10 and G11 thinking it will solve the issue. the machine still extrudes on the way back  

     

     

    • Like 2
    Link to post
    Share on other sites

    Posted · Go to Position After Finishing Each Layer

    BuxZED how did you work this out? I'm using Simplify 3D to do this but would love a walk through on how to create this in Cura

  • 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
        • 56 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
        • 29 replies
    ×
    ×
    • Create New...