Print3r: Multi Color Printing - Spiritdude/Print3r GitHub Wiki

Few hints printing in multi-color:

Prepend Gcode

--prepend-gcode=... gets added to your existing start_gcode, ideal to set mixing ratio or select an extruder, like

% print3r --printer=ashtar-k-2-e3 "--prepend-gcode=M165 C1" --scad --fill-density=0 print 'cube(20)'

given you have 3 extruders in mixing mode like with Diamond Hotend and just print with filament #3 (C), printing a hollow cube.

slicer-start-gcode
start_gcode
prepend_gcode
slicer-gcode
end_gcode
slicer-end-gcode

Layer Gcode

Following variables are available (slicer=cura,slic3r or slic3r-pe), which can be used as ${variable} then:

Layer:

  • layer_relative: fades 0..1
  • layer_percent: fades 0..100
  • layer_total: defines absolute count of layers
  • layer_current: current absolute layer

and for sake of simplicity, additionally:

2 colors with 1 phase:

  • a2: fades 1..0 (bottom)
  • b2: fades 0..1 (top)

2 colors with 2 phases:

  • a22: fades 1..0..1
  • b22: fades 0..1..0

3 colors with 3 phases:

  • a3: fades 1..0 first 1/2 (bottom)
  • b3: fades 0..1..0 (middle)
  • c3: fades 0..1 second 1/2 (top)

3 colors with 4 phases:

  • a34: fades 1..0..0..1 (bottom & top)
  • b34: fades 0..1..0..0 (lower 1/3)
  • c34: fades 0..0..1..0 (upper 1/3)

Examples

% print3r --printer=ashtar-k-2-e3 --slicer=cura '--layer-gcode=M165 A${a2} B${b2} C0' --scad --fill-density=0 print 'cube(20)'

prints fading between filament #1 to #2 (A->B) hollow cube.

% print3r --printer=ashtar-k-2-e3 --slicer=cura '--layer-gcode=M165 A${a3} B${b3} C${c3}' --scad --fill-density=0 print 'cube(20)'

prints color A -> B -> C hollow cube.

See examples with photos at spiritdude.wordpress.com using this feature.

Material/Color per Piece

Currently only slic3r & slic3r-pe provides proper multi-material / multi-color support via command-line using AMF format, each material defined in AMF becomes enumerated with tool 0 to tool N with Gcode T0, T1, T<N> etc.

In order to set material/color per piece there are two options available:

Define Color-Mix per Tool

M163 S0 P0   ; A=0
M163 S1 P1   ; B=1
M163 S2 P0   ; C=0
M164 S0      ; T0 = A=0,B=1,C=0

M163 S0 P1   ; A=1
M163 S1 P1   ; B=1
M163 S2 P0   ; C=0
M164 S1      ; T1 = A=1,B=1,C=0

Map & Remap Tools

You also map the tools (T<n>) with --toolmap=... to another Gcode:

print3r --printer=ashtar-k-2-e3 "--toolmap=T0:M165 C1,T1:M165 A0.5 B0.5" print sample.amf

which essentially defines color-mixes (M165) per tool:

  • T0 = A=0, B=0, C=1 mixing ratio
  • T1 = A=0.5, B=0.5, C=0 mixing ratio

--toolmap=<setting>, whereas settings can be T<num> ':' <new code> and concat multiple mappings with ','.

Additionally --toolremap is available as a 2nd stage mapping stage, where T<n> can be remapped again, e.g. exchanging tools:

print3r --printer=ashtar-k-2-e3 --toolremap=T0:T1,T1:T0 print sample.amf

Inline Functions

&toolcolor(n,a,b,c,d,e)

  • n: number of tool (0,1,2 ..)
  • a, b, c, ...: channel (a or Extruder 1 (E0 in Marlin)), etc.
  • example: &toolcolor(0,${a2},${b2},0) defines T0 to A=${a2}, B=${b2}, C=0

&hsl2cmy(h,s,l)

  • h: hue 0..360 degrees
  • s: saturation 0..1 (ignored)
  • l: lightness 0..1 (ignored)
  • converts CMY in 0..1 fractions.
  • example: &hsl2cmy(0,1,0.5) => 0, 0.5, 0.5 (red = C=0, M=0.5, Y=0.5)

&phases(r,n,p)

  • r: 0..1 (e.g. ${layer_relative})
  • n: n values (2 or 3)
  • p: phases (n=2: [ 1 (default), 2 ], n=3: [ 3 (default), 4 ])
  • example: &phases(${layer_relative},3,3)

M163+M164 vs M165

  • M163 and M164 defines mixing ratios per tool, parts are relative to each other
  • M165 defines mixing ratio, parts must add to 1.0 (will be scaled if it does not)
⚠️ **GitHub.com Fallback** ⚠️