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.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
        • 13 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...