2 different brushes for 4 printheads
-
-
@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
-
-