2 different brushes for 4 printheads
-
Hello,
I use a E3D tool changer. Core xy, Duet 2 Wifi with extension board V3.45.I do have 2 V6 and 2 Hemera extruders. This makes it due to geometricl issues nessesary to use a brush on the left and right side.
Is there a way to impement a if case depending on the active extruder which macro to use?Thanks!
Mike -
@MIke-1 why not call the macro as part of tpost?
Otherwise query the current tool in the object model and then run the appropriate commands
-
Oh, I am not sure if I understand the sentence correctly. Do you mean that I shall call the makro in one of the tool changes skripts? That's what I am doing now. But I would like to wipe on layer change controlled by superslicer.
-
@MIke-1 then call the macro at later change and have an if statement to check the current too in the object model and if tool 0 and 1 do this else if 2 or 3 do that
-
@jay_s_uk said in 2 different brushes for 4 printheads:
rrent too in the object model and if tool 0 and 1 do this else if 2 or 3 do that
That's what I need, but how does it work?
-
-
OK, did my best and got this error message:
T0
Error: in file macro line 2 column 21: meta command: unknown value 'active'if tools[0].state = active
M98 P"brush_right.g"
elif tools[1].state = active
M98 P"brush_left.g"
elif tools[2].state = active
M98 P"brush_right.g"
elif tools[3].state = active
M98 P"brush_left.g"
else
continue -
are you using indentation with your statements?
Perhaps you could use
state.currentTool Number of the currently selected tool or -1 if none is selected
and then check for the tool number and act accordingly.
-
@MIke-1
Try something like this
The indentation is importantif state.currentTool != -1 ; check if a tool selected if state.currentTool < 2 ; must be 0 or 1 M98 P"leftbrush.g" else M98 P"rightbrush.g ; must be 2 or higher
-
-
@OwenD
Oh, I can't use this version because my tools are alternating. -
@dc42
Oh thanks! Now it is working fine!You are all awsome!
-
@MIke-1 said in 2 different brushes for 4 printheads:
@OwenD
Oh, I can't use this version because my tools are alternating.Apologies
I missed that -
@OwenD
Thanks anyway! -
@MIke-1
My clumsy effort was mainly to prompt you to try to condense your code if possible.
Whilst manually creating an if / elif for every tool works, it's often more efficient in code and easier to read if you look for a pattern that will work regardless of the number of tools (or heaters or whatever).
In your case, one pattern is whether the tool selected is an odd or even number.
We can check that using mod()
What I should have posted was something like this.if state.currentTool != -1 ; check if a tool selected if mod(state.currentTool,2) = 0 ; tool must be even number or zero M98 P"brush_right.g" else M98 P"brush_left.g" ; must be odd numbered tool else echo "no tool selected"
You do however have to ensure that there is indeed a tool selected, otherwise state.currentTool is -1 and it would resolve to false and run the brush left macro
mod(-1,2)=0
is false
Whereas in your code, you don't have a condition for -1, so that wouldn't occur.If the code works, it's not wrong and it terms of lines of code there's not much difference in this case, so there's no reason for you to change what you have now.
-
Sorry for the late reply, I did not expect an answer.
But your code hepled me to better understand how the coding here works
I used the first line to make homing more save, as I can only do homing without a tool attached to the printheard.
I will keep my code because it ist more simpple to read and allows me to select a 3rd or 4th macro with different bush settings. It might get interesting, if I will use a vulacono hotened in the future.
Thanx!
-
@OwenD said in 2 different brushes for 4 printheads:
if state.currentTool != -1 ; check if a tool selected
if mod(state.currentTool,2) = 0 ; tool must be even number or zero
M98 P"brush_right.g"
else
M98 P"brush_left.g" ; must be odd numbered tool
else
echo "no tool selected"Can I use 2 commands after an if? How do I know when the if ends? I am missing () or endif to understand when something ends
-
@MIke-1 The meta commands in RRF use indentation to indicate which statements are part of the body for conditional statements so for instance
if state.currentTool != -1 G28 X G28 Y
Makes both home commands conditional but in
if state.currentTool != -1 G28 X G28 Y
only the G28 X is conditional
See: https://docs.duet3d.com/User_manual/Reference/Gcode_meta_commands#conditional-construct
-
@gloomyandy
Thanx!Topic can be closed
-
-