Cura: where module is the models layout source code?

Created on 5 Jun 2020  路  6Comments  路  Source: Ultimaker/Cura

Dear everyone:
I am a freshman and I am not familiar with the python language, I just want to know where the models layout source code, does any body can answer me?

FixeSolved Question

All 6 comments

Not sure what you mean exactly here. Do you mean the auto-arrange algorithm?
Images, videos, or filling out the issue template will always help us understand and solve your issue faster. I've pasted the issue template below for you to try again:

Please fill in the issue template so we are able to help you:

Application version
(The version of the application this issue occurs with.)

Platform
(Information about the operating system the issue occurs on. Include at least the operating system and maybe GPU.)

Printer
(Which printer was selected in Cura?)

Reproduction steps

  1. (Something you did.)
  2. (Something you did next.)

Screenshot(s)
(Image showing the problem, perhaps before/after images.)

Actual results
(What happens after the above steps have been followed.)

Expected results
(What should happen after the above steps have been followed.)

Project file
(For slicing bugs, provide a project which clearly shows the bug, by going to File->Save. For big files you may need to use WeTransfer or similar file sharing sites.)

Log file
(See https://github.com/Ultimaker/Cura#logging-issues to find the log file to upload, or copy a relevant snippet from it.)

Additional information
(Extra information relevant to the issue.)

Here is the implementation of how Cura decides on a position for a model on the build plate: https://github.com/Ultimaker/Cura/blob/master/cura/Arranging/Arrange.py

Deciding on the position of multiple models at the same time is currently just a repeated iteration of that, positioning all models on the build plate one by one.

In broad strokes, the algorithm works like this:

  • Create a 2mm pixel grid across the build plate.
  • Fill in the pixels that collide with existing models on the build plate.
  • Compute a bitmap for the new model you want to place.
  • Try placing that bitmap on the pixel grid in the centre of the build plate.

    • If the new bitmap doesn't collide with any filled pixels, that's a correct location and the model is placed there.


    • Otherwise (if it does collide), try placing the model centred on a pixel adjacent to the previous centre and check again.

  • It keeps checking different pixels as centre point, ordered by how close they are from the centre, until it either finds a free spot or all of the pixels are checked without finding a free spot.
  • If there is no free spot, the model is placed next to the build plate, outside of the build volume.

Dear Ghostkeeper:
thank you very much! your answer is very helpful for me. my friends told me that Cura call the API of qhull-master(a c program library) to do the models layout algorithm, my friend is right? and where the cura project call these API? can you tell me?
waiting for your favourable reply!

qhull-master c program library download address is "https://github.com/qhull/qhull"

We're calling upon QHull not directly but through Scipy, a library for scientific calculations. It's used in two places:

Note that this is not in Cura itself but in the framework called Uranium upon which Cura is built (intended for any 3D application with a backend to do calculations).

The 3D convex hull is used to create the collision areas underneath each model (which is used for that arrange algorithm). The shadow is 2D, but we're calculating a 3D convex hull because the 3D convex hull doesn't need to be recalculated when the user rotates the model. It can just rotate again. To get the collision area from that, we just project that hull to the build plate. The 2D convex hull is used to combine multiple objects if the user groups them.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nemernemer picture Nemernemer  路  3Comments

Liger0 picture Liger0  路  3Comments

ferociousdiablo picture ferociousdiablo  路  3Comments

JRRN picture JRRN  路  3Comments

timherrm picture timherrm  路  3Comments