xpim3D
Posts: 8
Joined: Fri Dec 22, 2017 3:01 pm

Script to have two different toolchange retractions

Hello everybody!

I've been trying without success to generate a script that allows me to have, using one single Profile, two different values of Tool Change Retraction, one for each extruder.
I am using a single X carriage, with two independent direct drive extruders. E1 with with PVA, E2 with ninjaflex to print one single part (stl) with soluble support.

The thing is that if i set Tool Change Retraction to 10mm, ninjaflex will be perfect and not ooze at all, but PVA will jam the extruder as it does not like to retract so much - also, retraction speeds over 20 mm/s for PVA easily results in the hobbed gear to grind the material. (independent Tool Change Retraction Speed would be a bonus, but not essential)
If i set Tool Change Retraction to 2mm, it's perfect por the PVA but the ninjaflex oozes like cracy :/

So my thought is: in the profile, "standard" Tool Chang Retraction distance is set to 2mm, and then, add extra retraction to E2 ( 8 extra mm) after his layer ends, and then add 8 extra mm of extrusion to compensate the previous retraction - this way E2 would retract and extrude 10 mm.

I was trying to add this to the Retraction Script field, but it ended up retracting in E1 also, and extruding in E1..kind of a mess. I tried several combinations but none worked out; still it was something like this:

{IF NEWTOOL=1}T1
{IF NEWTOOL=1}G1 E-8 F3600 ; retract extra 8mm beyond the 2mm of Tool Change Retraction
{IF OLDTOOL=1}T1
{IF OLDTOOL=1}G1 E8 F3600 ; to extrude the same extra retracted amount

I'm not savant in coding so i'll probably need a drawing in case anyone gently cares to help, hehe.

Tks in advance ;)
garyd9
Posts: 5
Joined: Mon Nov 13, 2017 12:04 pm

Re: Script to have two different toolchange retractions

First thing about the tool change script: It runs immediately after your starting gcode script regardless of which tool is selected. Therefore, I'd suggest checking the old tool _and_ the new tool for conditional lines. Else, you might get some odd retraction/prime behavior at the start of your print.

Code: Select all

{IF NEWTOOL=0} ; new tool is T0, but the old tool might be undefined
{IF OLDTOOL=1}{IF NEWTOOL=0} ; new tool is T0, and the old one was most certainly T1
Anyway, if I understand your question, what you want to do is certainly possible. For the sake of simplicity, assume you want to retract T0 5mm and T1 7mm (and both should prime by the same amount.) First, in the settings, change the tool change retraction amounts to 0. Then, modify this script as needed and plug it into your tool change script:

Code: Select all

; Start Tool Change
{IF OLDTOOL=1}{IF NEWTOOL=0}G1 E-7 F[toolchange_retract_speed]	; retract old tool
{IF OLDTOOL=0}{IF NEWTOOL=1}G1 E-5 F[toolchange_retract_speed]	; retract old tool
T[new_tool]
{IF OLDTOOL=1}{IF NEWTOOL=0}G1 X[next_position_x] Y[next_position_y] Z[next_position_z] F[travel_speed]
{IF OLDTOOL=0}{IF NEWTOOL=1}G1 X[next_position_x] Y[next_position_y] Z[next_position_z] F[travel_speed]
{IF OLDTOOL=1}{IF NEWTOOL=0}G1 E5 F[toolchange_retract_speed]	; un-retract new tool
{IF OLDTOOL=0}{IF NEWTOOL=1}G1 E7 F[toolchange_retract_speed]	; un-retract new tool
; End Tool Change
Or, assuming the same amounts mentioned above, you can configure your tool change retraction amount to 5, and then just add an additional 2 for the specific tool:

Code: Select all

; Start Tool Change
{IF OLDTOOL=1}{IF NEWTOOL=0}G1 E-[toolchange_retract_distance] F[toolchange_retract_speed]	; retract old tool
{IF OLDTOOL=1}{IF NEWTOOL=0}G1 E-2 F[toolchange_retract_speed]	; retract T1 2 extra mm
{IF OLDTOOL=0}{IF NEWTOOL=1}G1 E-[toolchange_retract_distance] F[toolchange_retract_speed]	; retract old tool
T[new_tool]
{IF OLDTOOL=1}{IF NEWTOOL=0}G1 X[next_position_x] Y[next_position_y] Z[next_position_z] F[travel_speed]
{IF OLDTOOL=0}{IF NEWTOOL=1}G1 X[next_position_x] Y[next_position_y] Z[next_position_z] F[travel_speed]
{IF OLDTOOL=1}{IF NEWTOOL=0}G1 E[toolchange_prime_distance] F[toolchange_retract_speed]	; un-retract new tool
{IF OLDTOOL=0}{IF NEWTOOL=1}G1 E[toolchange_prime_distance] F[toolchange_retract_speed]	; un-retract new tool
{IF OLDTOOL=0}{IF NEWTOOL=1}G1 E2 F[toolchange_retract_speed]	; un-retract T1 2 extra mm
; End Tool Change
With this last script being used, S3D seems to detect that the tool change script is doing the tool change retractions and doesn't insert it's own tool change retractions. (It probably just detects the use of "toolchange_retract_distance", but I haven't tested to verify that.)

Note that I always move to the "next_position" before un-retracting. The reason is that un-retracting often causes a bit of extra ooze to come out of the nozzle and I'd rather that "ooze" end up on the proper color (or on the ooze shield.) This mimics the behavior of S3D when a tool change script isn't used at all.

Take care
Gary
24c
Posts: 21
Joined: Thu Jan 04, 2018 2:37 pm

Re: Script to have two different toolchange retractions

@garyd9 That's a really useful answer (y) which I have bookmarked. :D
devinv
Posts: 3
Joined: Fri Mar 09, 2018 12:09 am

Re: Script to have two different toolchange retractions

Would be great to have this as a regular feature; would be so easy to add another parameter to the extruder window.

Return to “General Discussion and Tips”