Idea for LUA script to create a knolling layout


Idea for LUA script to create a knolling layout
#1
Hi all,

A question came up about creating a nice and satisfying knolled layout for a model.
This can now be done in LDPub3D, but the output is either a PDF page or PNG images showing the knolled BOM of a model.

If we want this in an LDraw file, we could be able to do this in a LUA script in LDCad.
There are a few sample scripts that take the bricks of a model and reorder them.
I was thinking about what if we can make something like the Selection Circle script does.

I am slowly learning (self taught) LUA and am trying to modify the Selection Circle myself.
But this is complex.

Maybe a LUA wizard or programmer can shine a light on this?

The steps involved, I think, would be something like this:

  1. Select all bricks in the model. This should be done in Nested mode to select all bricks in submodels too. Deleting all metacommands other then the header and bricks (for example steps, LPub commands, etc.) The result is a nice stack of all bricks in just one big model.
  2. Next we should reset all parts to plane level. So every brick that has a rotation should be reset to default straight rotation level on the y-plane (I hope I explain this correct) and maybe put all parts at the 0,0,0, coordinate. This can already be done with the provide sample script "Copy orientation"
  3. Then, we will want to sort the bricks based on size and color (or other order?)
  4. Next, starting with the smallest brick on the 0,0,0 position, rows and columns of the other bricks should be made to get a square or rectangular shape for the layout. You should be able to set the amount of rows or columns or calculate the best ratio for your model.
  5. After the first brick, the next should be positioned at say 20 LDU from the previous brick (distance between bricks would be 1 stud) either to form a row or column
  6. Then the next and the next and so on until the first X amount of bricks are neatly positioned and aligned in a row or column
  7. Then do the next row or column and so on
  8. A collision check should be done to make sure no bricks overlap

Am I on the right track? Is it too complex or can it be done in other ways?

LMKWYT
Jaco van der Molen
lpub.binarybricks.nl
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Idea for LUA script to create a knolling layout - by Jaco van der Molen - 2024-10-11, 6:49

Forum Jump:


Users browsing this thread: 5 Guest(s)