Jump to content
Ultimaker Community of 3D Printing Experts
BuxZED

Go to Position After Finishing Each Layer

Recommended Posts

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites

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. ?

 

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

 

 

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

Share this post


Link to post
Share on other sites

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 1

Share this post


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

    • Introducing Ultimaker Cura 3.6 | Beta
      Ultimaker Cura 3.6 | Beta is available. It comes with new features, bug fixes, and UX improvements. We would really like to have your feedback on it to make our stable release as good as it can be. As always, you can download the beta for free from our website, for Windows, MacOS, and Linux.
        • Like
      • 82 replies
    • Print Core CC | Red for Ruby
      Q: For some users, abrasive materials may be a new subject matter. Can you explain what it is that makes a material abrasive when you are not sure which print core to use?
      A: Materials which are hard in a solid piece (like metals, ceramics and carbon fibers) will generally also wear down the nozzle. In general one should assume...
        • Like
      • 28 replies
    • "Back To The Future" using Generative Design & Investment Casting
      Designing for light-weight parts is becoming more important, and I’m a firm believer in the need to produce lighter weight, less over-engineered parts for the future. This is for sustainability reasons because we need to be using less raw materials and, in things like transportation, it impacts the energy usage of the product during it’s service life.
        • Like
      • 12 replies
×

Important Information

Welcome to the Ultimaker Community of 3D printing experts. Visit the following links to read more about our Terms of Use or our Privacy Policy. Thank you!