Cura IDEX mode setting plugin

As my plugin is intended to be used with Klipper and is especially designed for @dmbutyugin IDEX branch GitHub - dmbutyugin/klipper at idex I’ll opened this thread here although a bit offtopic.

Link to the plugin:

Currently it is tested with Cura 4.13.1 under Windows 10 but feel free to test it under other versions as well and give feedback here.
If there are programming cracks around here that can help me on the current to-do topic just drop me a line.

Let’s help on getting the IDEX Klipper branch more popularity and maybe becoming implemented into the Klipper master one day! :smiley:

2 Likes

I will give it a test today on 5.1 and 5.4

Not that you need to cater to the Tridex crowd, but they have chosen to use “PRIMARY” as the name of the default mode. It does keep with the terms used in Klipper. Modes are in caps. I am the only one that uses Cura, so I don’t know how much it matters, but it would be nice to have consistency everywhere.

Stratos slicer uses dual, singleT0, singleT1, copy, & mirror. I can see where it would be useful for preheating and purging, but I’d be annoyed at having to choose a mode if not using copy or mirror.
I like sticking with three modes.

Stratos slicer darkens an area of the build plate when copy or mirror is selected. It is different for each. If the toolhead is symetrical, mirror should result in a deadzone in the middle of the built plate that is the width of the toolhead (half of each toolhead added together) + a tiny bit of extra clearance. I don’t know if it’s worth going to that much trouble with all the various toolhead designs out there. I just modified the platform stl to show the no-go areas.

I tried adding the idex plugin and other files from Stratos into Cura 5.4, but had no luck. I do not know what version of Cura it is based on, but you may be able to figure something out by looking at it. It is set up as a plugin, but there is all the extra stuff for the menu, icons, and a bunch of stuff added to the printer definitions. I’m happy with Cura just spitting out the mode.

1 Like

The option shows up and it passes the mode just fine in 5.1 and 5.4 :beers:
Haven’t done any actual printing, but once the mode is defined it’s up the the user’s macros how to utilize it.

1 Like

Thanks for testing! :beers:
I’m currently working on my PRINT_START macro to get it properly set for the three modes. But that is not yet finished.
As a to-do on the project page on github I have the halving of the build plate in mind for copy or mirror as T1 just references on T0.
But I did not yet figure out how to control the build plate… But maybe it is easier to grey out the right half?!

As Dmitrys Klipper branch uses copy and mirror as parameters I wanted to keep it the same and I did not want to use plain numbers to not mix those up with their respective meanings.
For the idex option I might reevaluate the parameter as I did not yet had a gcode file with both heads enabled.
Cura only seems to have a single temp variable for first layer and not for both heads to start heating them up. And a single standby temp variable…
To be honest I need to check first how to slice an object using both heads in Cura, so feedback is nice to have here!
Cura however should work with T0 and T1 after the PRINT_START macro. So I don’t know yet if we have to split the idex parameter into idex and each single print head.

If you can upload a idex sliced gcode file here with a picture of the actual object this would be fine!

And if the Stratos feature is managed via a plugin as well I’d like to have that too. :smiley:

Rather than me upload the IDEX plugin for Stratos, you might as well download Stratus. The folder structure is a little simpler than Cura and stuff is easy to find. Stratos slicer

I modified idex_mode_settings.def to get the options I wanted. I can’t code, but I can follow logic well enough and get things working through trial and error sometimes.

I haven’t figured out what to do for heating the second hotend. As far as Cura knows, the second extruder isn’t being used. For testing I just included set ABS temps that couldn’t be changed, but I did have two different brands of filament loaded one of which prefers to be printed cooler than the other one. One of the things on my to-do list was to see if Cura would pass info for the filament loaded on the second toolhead even if it wasn’t being used (as far as Cura knows, anyway). If it won’t pass any info, then I guess I’ll just have the macro set to the same temp as the first.

When copy or mirror mode are selected, Stratos takes away all filament options for the second toolhead. It assumes you are using the same filament, same temps, etc. as the first toolhead. It does specify each toolhead separately when heating though. There are lines in the machine definition file that lock the cooling fans together, so it just calls M106 without specifying specific fans.

I don’t actually plan to use Stratos. I just wanted to see if I could get my machine into it (had to modify an already existing BCND machine definition file) and to make sure M605 macros could work with slicers that already support marlin’s IDEX gcode. I did successfully print a couple items in each mode, but there was a constant stream of acceleration and jerk cgode that klipper didn’t recognize and ignored. I stripped that stuff out of the machine definition, but don’t know how much more I’ll bother with it. I’d rather focus on Cura which I plan to use.

I don’t know how much time I’ll have to mess with this stuff this week. Too many irons in the fire.



mirrored_part.gcode (2.2 MB)

1 Like

gcode sliced in Stratos attached to last post ^^

Here is the macro I used for testing the M605 stuff.
It is by r2pdx on the tridex channel of the doomcube discord.
The MODE_FULL_CONTROL for the standard modes didn’t work because it’s no longer used in klipper or I didn’t have it and autopark stuff as a macro.
For some reason Stratos uses M605 S5 and S6 which means the print is on a raft.
I do not know what difference that makes.

This can be simplified. The start positions of the toolheads is calculated and assigned rather than just plugging in your preferred locations. I am not a programmer so I prefer to keep things simple enough for me to understand by glancing at it.

## DUAL-CARRIAGES : MODES ACTIVATION
[gcode_macro M605]
description: Set the dual-carriages mode
gcode:
    {% set mode = params.S|default(1)|int %}

    {% if (mode) == 0 %}
        SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=autopark VALUE=0
        SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY        
    {% elif (mode) == 1 %}
        SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=autopark VALUE=1
        SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
    {% elif (mode) == 2 or (mode) == 5 %}
        # Copy
        {% set T0_START = printer.configfile.config.stepper_x.position_min|float + 55 %}
        {% set T1_START = printer.configfile.config.stepper_y.position_max|float / 2 + 5  %}
        SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
        G0 X{T0_START} Y5 Z5 F6000
        STATUS_PRINTING
        SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
        G0 X{T1_START} F6000
        STATUS_PRINTING
        SET_DUAL_CARRIAGE CARRIAGE=1 MODE=COPY
        SYNC_EXTRUDER_MOTION EXTRUDER=extruder1 MOTION_QUEUE=extruder

    {% elif (mode) == 3 or (mode) == 6 %}
        # Mirror
        {% set T0_START = printer.configfile.config.stepper_x.position_min|float + 55 %}
        {% set T1_START = printer.configfile.config.stepper_y.position_max|float - 5 %}
        SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
        G0 X{T0_START} Y5 Z5 F6000
        STATUS_PRINTING
        SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
        G0 X{T1_START} F6000
        STATUS_PRINTING
        SET_DUAL_CARRIAGE CARRIAGE=1 MODE=MIRROR
        SYNC_EXTRUDER_MOTION EXTRUDER=extruder1 MOTION_QUEUE=extruder
    {% endif %}

    {% if (mode) == 5 or (mode) == 6 %}
        SET_DISPLAY_TEXT MSG="Please setup rafts in your slicer"
    {% endif %}
1 Like

Will check this tomorrow I think but thank you already!

I need a gcode file of a single object being printed in two colours or with two different filaments. Copy mode is working and I’m able to slice it with Cura as it is a single object not bigger than half of the build plate.
I mean I can stack a couple of primitives and could assign each to a different print head. Just need some sequences where the print heads change for the same printed object.
Because I also have to check how to change/adapt the parking macros to clean the nozzles and whether or not I’ll call this from the extruder start and end codes from within Cura or just from within Klipper…

Yeah for you it should be enough to adjust the json-file and feed the options with your desired modes. This will populate the respective drop down field in cura and report back the set modes to the resulting gcode file.

But this Stratos slicer good give me the missing answers if its source code is available on github as well. But I’ll look into this later. :coffee:
Thank you already for the feedback!

I’m not 100% sure what you are asking for.

Here is a dual color print sliced in Cura. To make the differences stand out I made the second extruder PLA with temps of 190 with a 195 first layer. Standby is 100. The first is ABS at 240 with a 245 first layer. Standby is 200.

The only thing in my Cura start gcode is print_start and the new line to assign the mode.
Tool change gcode in Cura is blank. I have very basic macros named T0 and T1 to switch toolheads.
My current print_start macro figures out which extruders to purge based on which ones Cura has heated, but I plan to redo it. The purging temps are hard set for ABS. I am not passing them from Cura.
I have been dual material printing with Cura and Klipper for over a year.

Because Ultimaker sells a dual extruder (but not IDEX) machine, there is a lot of nuance baked into it that other slicers do not have. It uses expected cooldown and heatup rates to estimate when the best time to start reheating or cooling down each hotend. It will send the command to reheat the inactive toolhead while the other is still printing. You will see the gcode to set the temperature long before the toolhead change. If there won’t be enough time to cool the hotend all the way down to standby temp and heat it back up, it doesn’t bother cooling it. These rates are not usually accessible to the user. I’ve read that there is a plugin to access them, but I haven’t tried it yet. The default rates seem to work well for me after I upped my standby temp to the maximum temp that didn’t cause filament to ooze (not reflected in the numbers used above).
xyoffsetprint.gcode (164.7 KB)

@BadMouth that Statos slicer was a very good hint as it is a Cura fork and it looks like the basic functions/features are the same.
Looks like I can now enable and disable the extruders depending on the IDEX setting already.

Just the question if we follow their mode options to enable T0 and T1 exclusively as you of course can print with T1 only… But then it might be a bit more complicated to get the PRINT_START macro following with our IDEX Klipper branch.
For that I’ll have to check the resulting gcode after the basic features are implemented.

I’ll have to dig deeper to find how they manage to split the buildplate.
But at least I now have the right event handler to process that task once I discovered it. :nerd_face:

I don’t know how far into the weeds you want to venture.

If you can get copy and mirror modes to heat both extruders before print_start like Cura already does for dual material prints, I think I could work out the rest in the macros. Even just being able to pass the print temperatures that both extruders are set to would work even if they aren’t considered “active”. This may already be possible, I keep putting off trying it.

The syntax to pass things for the second extruder is comma space extruder number at the end: {material_print_temperature_layer_0, 1} for T1
{material_print_temperature_layer_0} or {material_print_temperature_layer_0, 0} for T0

If you haven’t come across it yet, here is a useful list of things you can pass:
http://files.fieldofview.com/cura/Replacement_Patterns.html

I’ve avoided passing a bunch of variables in the start gcode because Cura will automatically add lines to heat the bed and nozzles if you limit the start gcode to print_start. If you add more, it will assume you are setting everything yourself.

My old macros use {% if printer.extruder.target > 160 %} and {% if printer.extruder1.target > 160 %} to determine which toolheads will be used and purge them. That doesn’t tell the macro what the proper printing temperature is, so it’s not the most ideal solution, but it has worked for me doing dual material prints for a while now. I only ever print with ABS and HIPS so the same purge temps work. I could also just use skirts as the purge.

On the topic of the extra modes in Stratos: Somewhere in the machine definitions there are some reaaaalllly long lines where they have different start gcode for each mode. We could have a different heating and purging macro for each mode with print_start calling up the correct one based on which mode is set. I think the extra modes actually simpler to setup, but don’t like having to choose between dual, singleT0, & singleT1 when I haven’t had to do it before. I’d rather just keep it three modes and sort out which extruders are being used in the macro.

I did notice something that might be useful concerning splitting the build plate. For mirror mode it changes if you change the Xmax under printhead settings in the machine settings. So that number is being used in the calculation. To create the darkened no-go area I thought maybe they were just extending the right border area, but where they overlap they are doubly dark. I guess they could still be extending the border for detection with the visual thing done separately.

1 Like

I just took the two minutes it would take to test passing the extruder temps.
Cura already passes the second extruder temp just fine even if it is not being used.

So it should already be possible for the print_start macro to heat the second extruder to its first layer or printing temp based on what mode is selected.

1 Like

That sounds very good and is valuable feedback! Thank you!
The parameter list from fieldofview is not new to me but the fact you can handover the extruder number to the temperature variables.
I was already twisting my mind over this…

My first intention was to halve X when using mirror or copy mode as only one extruder is active but neither my left nor my right extruder fully reach the opposite boundaries. But this fact is the same for greying out the half of the bed as well.
But if I’m not wrong and you properly set the origin coordinates for T1 in the copy/mirror macro it should work great.

However it looks like I can increase the feature set step by step… :coffee: :nerd_face:

Regarding to Cura and adding heating commands that are not needed… To my knowledge Cura does not add bed or extruder heating commands if it finds the respective variables in the slicer start code.

EDIT:
@BadMouth Maybe the following could shrink your macro:
{initial_extruder_nr} The first extruder train used for the print

Just a short note…
I found a way to adjust the width of the build plate and this properly works when selecting an IDEX mode.
However during my work the plugin lost the functionality to react on changing the printers width in the dialogue window.
So I’ have to get this synced again. Especially as the plugin stores the adjusted x_width in a user config and this loads on the next Cura session and might not be equal to the respective printer setting any longer.

:coffee:

Just a heads up. There is a bug in Cura where if you don’t select some type of bed adhesion (such as a skirt) Cura will always report 1 for {initial_extruder_nr} regardless of which toolhead prints first. I’m working around it for now by using the tool change Cura adds to the start of the gcode.

It’s odd that it still gets the tool change at the beginning for the gcode correct if it is using initial_extruder to set that.

Nice to know.
Thought I could do you a favour with this. However I’m always use brim or skirt so it would work for me.

Made progress today on built plate adaption to selected IDEX mode though I had it already working.
But the first implementation had bad side effects.
Until this you could test my version 0.0.2 that is already online.

Eureka! :crown:

Just finished and uploaded the latest plugin version that now seemingly properly adapts the built plate width depending on the selected IDEX mode:

  • full width on idex
  • half width on mirror and copy mode

And it keeps in sync when changing the machine width under the printer/machine settings dialogue box.
Might be helpful at least for testing purposes.
Also added the extended temperature parameters of Cura for the slicer start code to get both extruder temps passed to Klipper as a nice to know info.

@BadMouth if you might find some time for testing this would be great.
All others riding this are also invited for testing.

I was fortunate enough to get a hold of some modified files by a user called Tricown. I’ve had my custum idex running klipper with mirror and copy mode for almost 2 years now. I would love to try your plugging. Trouble is I haven’t messed with cura much and I can’t seem to get it installed. I would ask such a basic question if I hadn’t banged my head agents the wall for a few days now. Any help would be great.

You just download download the files from github and put those into an own subfolder in Curas plugin folder.
There are at least two locations where to put the plugins and this depends on your operating system as well.

Check the configuration folder inside Cura via Help → Show configuration folder.

Otherwise please specify what OS and Cura version you are using.

Finally found a little time for testing.
Initial test launching cura 5.4 after deleting the old plugin and dropping the new one in did not work. The build area did not change and in mirror/copy modes the object would show as striped (as it is when it is outside the build area) no matter where I placed it.

Then I noticed that under printer proflie, Cura says printing profile not supported. That is why it was showing the object as not printable. I select a different printing profile, it asks to keep or discard changes one of which is the machine width. After that the width of the print area will change as intended and the object shows as printable, but the printing profile always says it is not supported.

I relaunched Cura a few times and the build plate size will now change without having to choose a new printing profile, but the profile still says not supported whichever one I choose. It will still allow me to slice though, which I don’t think it usually does if the printing profile is not supported. The gcode it spits out looks ok, but I did not print anything.

Switching to a non-IDEX printer causes Cura to crash. The first version of your plugin does not cause this.

Because I have a modified platform STL that shows excluded zones for copy and mirror, I don’t like that the new bed width is centered instead of maintaining the same origin point on the left. Someone using a platform STL that shows the whole printer might also find it confusing. I understand that it would be a PITA to change though. Overall, just setting the mode accomplishes what I need.

Mirror mode should be even narrower than copy mode, half the bed less half the toolhead width (assuming the nozzle is centered on the toolhead). But that is just another version of what you’re already doing so shouldn’t be that bad to implement.

Personally I am happy with the old version that just sets the mode and relying on my custom platform stl that shows boundaries for mirror and copy modes.

The attached files are from the crash when switching to a non-IDEX printer.

log.txt (7.5 KB)
Error_traceback.txt (1.1 KB)

1 Like