Ultimaker / CuraEngine

Powerful, fast and robust engine for converting 3D models into g-code instructions for 3D printers. It is part of the larger open source project Cura.
https://ultimaker.com/en/products/cura-software
GNU Affero General Public License v3.0
1.68k stars 882 forks source link

[4.6.2]Fail to generate complete gcode in electron app #1455

Open ianho7 opened 3 years ago

ianho7 commented 3 years ago

Hi guys, I'm developing a desktop app based on Electron and CuarEngine.Now I have some problem while using CuraEngine,in the app, CuraEngine will be packaged as an executable file and saved in my project.When I choose a stl file,the Electron app will run command to generate gcode file by node child_process.spawn function, the command looks like CuraEngine slice -v -p -j "xxx.def.json" -o "xxx.gcode" -l "xxx.stl"

With same config json file and stl model file, the generation gcode file is perfect in Windows platform.However in Mac OS, the generation gcode file is imcomplete, what's more, when I generatate multi times, the generation gcode files are all different and incomplete.

I compared logs and found these warnings,which will not appear when it runs in Windows platform:

export:286:321 0.940358% [WARNING] Layer 285 is empty (or it has empty extruder plans). Temperature control and cross layer travel moves might suffer! Progress:export:287:321 0.942051% [WARNING] Layer 286 is empty (or it has empty extruder plans). Temperature control and cross layer travel moves might suffer! Progress:export:288:321 0.943745% [WARNING] Layer 287 is empty (or it has empty extruder plans). Temperature control and cross layer travel moves might suffer!

I tried to copy the command and run it in bash terminal of Mac OS, it works well, no warnings will appear,which made me feel strange.

Application Version CuraEngine 4.6.2

Platform MacOS Big Sur 11.4 Node version 12.22.1 Electron version 8.5.5

Steps to Reproduce Run command CuraEngine slice -v -p -j "xxx.def.json" -o "xxx.gcode" -l "xxx.stl" in Electron App, Mac OS Big Sur 11.4

Actual Results An different and incomplete gcode file

Expected results A complete gcode file

Ghostkeeper commented 3 years ago

The command looks fine to me.

You're saying that the command also works correctly on MacOS when running it through a terminal. Just not when running it through your Electron app. Based on that information I would conclude that the fault is somewhere inside your Electron app.

Maybe you need to flush the file system cache before reading the file back in?

Maybe you're not waiting for the slicing process to complete entirely before loading it back in?

Note that CuraEngine can also output directly to stdout, by not providing the -o parameter. That might eliminate issues with the file system cache, and also prevent the need for writing to a hard disk, which is going to be slow.

Since writing via the command line works, I have no real reproduction steps here. I have no experience with building an Electron application to test for you, and if I did I would blame it on that Electron application because the terminal works.