Jump to content
Ultimaker Community of 3D Printing Experts

Gcode for different filament?

Recommended Posts

I was wondering if there is a way to insert custom GCode for each different filament in cura?


It doesn't appear that there is an option to do it in default cura, but are there any plugins that can do it?


The reason is I would like to use linear advance, but different types of filament (PLA, PETG, Flexible) require different values for linear advance.

Share this post

Link to post
Share on other sites

Well maybe you could create a different machine for each type of filament?  Then each machine could have different start codes.  You could also create a plugin to do this easily and the plugin input value (the gcode) could show up as one of the many profile settings.  This would probably be a plugin that other people would use.  It's easiest to look at an existing plugin and just make the minor modifications to make it do your gcode insertion thing.

Share this post

Link to post
Share on other sites

The start gcode can contain replacement patterns such as {material_print_temperature} which will be automatically replaced with -in this case- the material temperature. Now there is no setting for linear advance in Cura, so no replacement pattern either (or is there?).


I recently wrote a plugin to be able to enter a Z Offset in the sidebar. I can easily adapt that to add a Linear Advance setting that you can use in your start gcode (but that has no other effect). Does that make sense? I must admit I don’t know what gcode you need for linear advance.



If you really want different start gcode, and you are not affraid of editing text-files, you can manually edit your quality profiles to include start gcode snippets.


In the Configuration folder, there’s a folder named “definition_changes”, which has a .inst.cfg file for your printer(s) containing the changes you make in Machine Settings - including start gcode. The “quality_changes” folder contains very similar files, for the quality profiles you created. You can copy and edit the gcode snippets to the quality_changes files, and that will override what is set in the machine settings.


I would NOT recommend the latter route.

Share this post

Link to post
Share on other sites

So, help me out here... how many settings do you want?


From the documentation I see that you either use one setting: Linear Advance Ratio) which ends up as eg M900 R{material_linear_advance_ratio}

Or you can have a Factor, Width and Height as well as the material(?) diameter.


Would just having the former be enough, or is there a case for requiring the latter?

Share this post

Link to post
Share on other sites

All examples that i have seen so far are using the 'K factor' only, so M900 K{material_linear_advance_factor} should be sufficient.




But i also found a note that for Cura an additional "M900 W[width] H[height] D[diam]" works better.

And layer height, filament diameter, and extrusion width are already known. Should be possible.



(search for "One small note")

Share this post

Link to post
Share on other sites

Here's a quick plugin: http://files.fieldofview.com/temp/LinearAdvanceSettingPlugin.curaplugin

Source: https://github.com/fieldofview/LinearAdvanceSettingPlugin


The plugin adds a single setting named "Linear Advance Factor" to the material category in the sidebar (use the search field!). Note that by itself setting this value has no effect whatsoever on the gcode. Only by using the value in eg the start gcode snippet will there be any effect, eg like this:

M900 K{material_linear_advance_factor}
M900 W{line_width} H{layer_height} D{material_diameter}

Note that beyond a smoke-test in Cura, this plugin has not been tested at all, and I currently have no plans to have it included in the plugin browser. Feedback is welcome.

  • 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


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!