Spiritdude / Print3r

Command line interface (CLI) for 3d printing
GNU General Public License v3.0
59 stars 4 forks source link

Cannot slice with Cura 5.x - missing fdmextruder.def.json file. #1

Closed werdnum closed 1 year ago

werdnum commented 1 year ago

Steps to reproduce:

Use this Dockerfile:

FROM ubuntu:22.04

ARG BUILDARCH

ENV DEBIAN_FRONTEND=noninteractive
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
  --mount=type=cache,target=/var/lib/apt,sharing=locked \
  apt update && apt install -y pkg-config autoconf automake libtool bison flex m4 libprotobuf-dev build-essential ninja-build python3 sudo python3-pip && \
  apt install -y --no-install-recommends ca-certificates libncurses-dev git slic3r openscad openscad-mcad python-is-python3 python3-venv wget
#RUN bash -c 'if [[ ${BUILDARCH} = "arm64" ]]; then arch=aarch64; else arch=${BUILDARCH}; fi; echo $arch && false'
RUN bash -c 'if [[ ${BUILDARCH} = "arm64" ]]; then arch=aarch64; elif [[ ${BUILDARCH} = "amd64" ]]; then arch="x86_64"; else arch=${BUILDARCH}; fi; wget https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-${arch}.sh -O /tmp/cmake-3.24.2-linux.sh'
RUN chmod +x /tmp/cmake-3.24.2-linux.sh && /tmp/cmake-3.24.2-linux.sh --skip-license --prefix=/usr/local
RUN git clone https://github.com/Ultimaker/CuraEngine.git /build/CuraEngine && cd /build/CuraEngine
WORKDIR /build/CuraEngine
ENV CONAN_SYSREQUIRES_MODE=enabled
ENV CONAN_SYSREQUIRES_SUDO=0
RUN --mount=type=cache,target=/root/.cache,sharing=locked pip install conan --upgrade && conan config install https://github.com/ultimaker/conan-config.git && conan profile new default --detect --force && conan remote remove cura
RUN conan install . --build=missing --update
#RUN ls -la /root/.conan/data/rapidjson/1.1.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/ && false
#RUN ls cmake-build-release/conan | grep -i rapidjson && false
#RUN sed --in-place -E 's/rapidjson/RapidJSON/' CMakeLists.txt
RUN cmake --preset release -DCMAKE_BUILD_TYPE=release && cmake --build --preset release -DCMAKE_BUILD_TYPE=release
RUN cp /build/CuraEngine/build/Release/CuraEngine /usr/local/bin/CuraEngine
RUN rm -f /etc/apt/apt.conf.d/assume-yes; echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/assume-yes
RUN git clone https://github.com/Spiritdude/Print3r /build/print3r
WORKDIR /build/print3r
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
  --mount=type=cache,target=/var/lib/apt,sharing=locked \
  --mount=type=cache,target=/root/.cpan,sharing=locked \
  make requirements CPAN='cpan -T'
RUN make install

RUN pip install octoprint-cli

WORKDIR /work

CMD print3r

Run this:

$ docker run --rm -it -v /Volumes/gv0/workspace/3d-printing/print3r:/root/.config/print3r -e PRINT3R_PRINTER=feestfabriek $(docker build -q .) print3r --slicer=cura-slicer --retraction-speed=50 --retraction-distance=0.2 --layer-height=0.2 --scad slice "cube(20)"

Actual output

[2022-10-13 05:01:13.568] [error] Couldn't find definition file with ID: fdmextruder
[2022-10-13 05:01:13.568] [error] Couldn't open JSON file:
[2022-10-13 05:01:13.569] [warning] Unrecognized data type in JSON setting machine_disallowed_areas
[2022-10-13 05:01:13.569] [warning] Unrecognized data type in JSON setting nozzle_disallowed_areas
[2022-10-13 05:01:13.569] [warning] Unrecognized data type in JSON setting machine_head_polygon
[2022-10-13 05:01:13.569] [warning] Unrecognized data type in JSON setting machine_head_with_fans_polygon
[2022-10-13 05:01:13.574] [info] loading '/tmp/print3r-25-1-0.stl' took 0.00021004676818847656 seconds
[2022-10-13 05:01:13.574] [error] Trying to retrieve setting with no value given: material_shrinkage_percentage_z

I see that the fdmextruder file is commented out here (and has been for several years). So how is this supposed to work? Am I supposed to install that file myself or something?

Spiritdude commented 1 year ago

You can ignore the fdmextruder.def.json error message as far I know, but any [error] afterwards you need to take care of, e.g. material_shrinkage_percentage_z add into settings/slicers/cura-slicer/base.ini - you have to start CuraEngine / cura-slicer multiple times as more errors will be listed (one at time, unfortunately - this is how CuraEngine works).

I'm behind supporting CuraEngine in print3r since 5.x as I try to empower cura-slicer (Cura-CLI-Wrapper) - which you use in your example - to handle this better, e.g. supporting multiple versions (3.x, 4.x and 5.x each with their correct/respective fdmprinter.def.json).

Btw, your error actually originates in cura-slicer and isn't really about print3r as you set --slicer=cura-slicer, I used to support CuraEngine 3.0 as --slicer=cura and 4.x as --slicer=cura4 but not sure yet to go this way as fdmprinter.def.json changes at each minor [34].{minor} - it has been messy.

I haven't updated cura-slicer on github but I'm currently try to cover 3.x, 4.x and 5.x - but it's a pain to build the older binaries, even 5.0 and 5.1 are hard on Ubuntu-22.04, and yes, Docker might help here (e.g. building 5.0 and 5.1 on Ubuntu-20.04 worked somehow I recall).

Here the current state with building CuraEngine on Ubuntu 22.04:

Spiritdude commented 1 year ago

The CuraEngine 4.13 in default repo of Ubuntu 22.04 I did not get to actually slice anything with cura-slicer, this is why I started to build the binaries now again.

werdnum commented 1 year ago

Thanks for getting back to me so quickly! I had similar experiences building CuraEngine (e.g.).

I tried both --slicer=cura and --slicer=cura-slicer. When I used cura-slicer, I got a very strange output:


❯ docker run --rm -it -v /Volumes/gv0/workspace/3d-printing/print3r:/root/.config/print3r -e PRINT3R_PRINTER=feestfabriek --entrypoint=/bin/bash $(docker build -q .)
root@fe33deb9016d:/work# print3r --slicer=cura-slicer --retraction-speed=50 --retraction-distance=0.2 --layer-height=0.2 --scad slice "cube(20)"
== Print3r 0.3.17 == https://github.com/Spiritdude/Print3r
print3r: conf: device /dev/ttyUSB0, Prusa i3, build/v 200x200x180mm, nozzle/d 0.4mm, layer/h 0.2mm, filament/d 1.75mm
print3r: scad to stl: 'cube(20)', done.
print3r: slice (cura-slicer) part </tmp/print3r-9.stl> to gcode: prepare, translate 0.0,0.0,0.0, slice, done.
root@fe33deb9016d:/work# ls
'cube(20).gcode'
root@fe33deb9016d:/work# cat cube\(20\).gcode
[2022-10-13 04:54:18.222] [info] Loaded from disk in 0.006911039352416992s

[2022-10-13 04:54:18.227] [info] Progress: start accomplished in 0.0038797855377197266s
[2022-10-13 04:54:18.227] [info] Starting slice...
[2022-10-13 04:54:18.227] [info] Slicing model...
[2022-10-13 04:54:18.228] [info] Slice of mesh took 0.00020813941955566406 seconds
[2022-10-13 04:54:18.229] [info] Make polygons took 0.0013310909271240234 seconds
[2022-10-13 04:54:18.230] [info] Progress: slice accomplished in 0.0035469532012939453s
[2022-10-13 04:54:18.230] [info] Starting layerparts...
[2022-10-13 04:54:18.243] [info] Progress: layerparts accomplished in 0.012549877166748047s
[2022-10-13 04:54:18.243] [info] Starting inset+skin...
[2022-10-13 04:54:18.254] [info] Layer count: 100
[2022-10-13 04:54:18.254] [info] Progress: inset+skin accomplished in 0.011770009994506836s
[2022-10-13 04:54:18.254] [info] Starting support...
[2022-10-13 04:54:18.268] [info] Progress: support accomplished in 0.013277053833007812s
[2022-10-13 04:54:18.268] [info] Starting export...
[2022-10-13 04:54:18.293] [error] Trying to retrieve setting with no value given: roofing_monotonic
[2022-10-13 04:54:18.293] [error] Trying to retrieve setting with no value given: roofing_monotonic
;FLAVOR:Marlin
;TIME:6666
;Filament used: 0m
;Layer height: 0.2
;MINX:2.14748e+06
;MINY:2.14748e+06
;MINZ:2.14748e+06
;MAXX:-2.14748e+06
;MAXY:-2.14748e+06
;MAXZ:-2.14748e+06

;Generated with Cura_SteamEngine 5.3.0-alpha
M140 S60
M105
M190 S60
M104 S210
M105
M109 S210
M82 ;absolute extrusion mode
G28 X0 Y0
G1 X100 F6000
G28 Z0
M206 X0 Y-25 Z0.15

G92 E0
G92 E0
G1 F2100 E-2
;LAYER_COUNT:100
root@fe33deb9016d:/work# print3r --slicer=cura --retraction-speed=50 --retraction-distance=0.2 --layer-height=0.2 --scad slice "cube(20)"
Spiritdude commented 1 year ago

Look at the next [error] as I wrote, e.g. now the "next" error shows up: Trying to retrieve setting with no value given: roofing_monotonic - you need to define it, and repeat calling print3r/cura-slicer looking for all the missing defaults, after defaults are defined, it will go through eventually (it depends on the exact version of fdmprinter.def.json).

Spiritdude commented 1 year ago

And yes, stdout of CuraEngine ends up in .gcode, debug setup with cura-slicer first before using print3r.

werdnum commented 1 year ago

I'm a bit confused about why the settings need to be defined, aren't they included already in the fdmprinter.def.json file? Should I just update that file?

Otherwise, should I fill in all those settings and then send a PR to fix it up?

Spiritdude commented 1 year ago

Not just update (try that first), but try to keep CuraEngine and fdmprinter.def.json in sync - this is exactly what I talked about earlier, to properly support different versions.

Usually the problem comes from fdmprinter.def.json and CuraEngine are not in sync covering the same functionality, but I ended up filling settings even when the CuraEngine and fdmprinter.def.json were supposed in sync => Cura (GUI) provides settings which were missing to be set in fdmprinter.def.json is my suspicion.

Don't compose a PR yet, please read again my longer first reply, I haven't decided yet where I cover CuraEngine 5.x support, whether in Print3r direct or via cura-slicer, and if I support it, I want it to do it granular.

Until then I properly support it, proceed as I suggested and add the settings in your install.

werdnum commented 1 year ago

Surprisingly, roofing_monotonic was the only setting that needed adding to slicer/cura-slicer/base.ini - after that I got something that looked like reasonable gcode, though I didn't try printing it yet. Still have to shift all my printer specific stuff into the ini files before I can try that.

Spiritdude commented 1 year ago

I decided to support CuraEngine-5.x via --slicer=cura5, see https://github.com/Spiritdude/Print3r/commit/b868323d9fafeb3ce81af93f59bb72a2677474d4