I’ve been doing more Lego building from models. This time I made sort of an abstract mushroom tree forest thing. More photos are available on Flickr.
Here’s the original model (left) and the resulting cubeified model after running it through AddCells (right):
I realized of course that with everything grey, it was very difficult to determine which bricks of which color were needed where. So I un-joined the primitives in the original model and ran AddCells on each one individually. I used different colored “cell” blocks for each one, and the resulting models kept the color:
Each peice needed to be moved a little bit so that all the blocks lined up, but other than that it worked pretty well.
Because each piece is separate, I couldn’t use the hide tool to “slice” each layer. But I did find out something interesting: each “cube” in the new models is actually a vertex. I honestly don’t understand a ton about how that’s pulled off, but basically instead of being a point on a line, each vertex represents another object, the source cube.
In order to slice up the model, I wrote a script to delete all but a given layer, with layer 1 being the bottom layer, up to however many layers of cubes are in the model.
import Blender, BPyMessages, BPyMesh from Blender import Scene, Mesh, NMesh, Window, sys, Group, Object, Draw from Blender.Mathutils import \ Matrix, Vector, ProjectVecs, AngleBetweenVecs, TranslationMatrix def trimToLayer(selected,layerNumber, blockHeight,offset): toDelete=  mesh = selected.getData(mesh=1) tmesh = NMesh.GetRawFromObject(selected.name) tmesh.transform(selected.matrix) #Delete verticies above the current layer for v in tmesh.verts: if v.co > blockHeight*layer: toDelete.append(v.index) if layerNumber > 1: #Delete verticies below the current layer for v in tmesh.verts: if v.co < blockHeight*layer-1: toDelete.append(v.index) toDelete = list(set(toDelete)) mesh.verts.delete(toDelete) Window.Redraw() ##################3 if __name__ == "__main__": selection = Object.GetSelected(); layer = Draw.PupIntInput("Layer",1,0,100) Blender.SaveUndoState('Kill Everything') print "\nTrimming First Layer" for s in selection: bbox = s.getBoundBox(1) print bbox trimToLayer(s,layer,1.2,bbox)
There are a couple problems with the script: primarily, I couldn’t find a way to get the software to save a screenshot (ctrl+F3 normally). Because of this, I couldn’t loop through the whole thing at once, I had to go through one layer at a time, running the script, hitting ctrl+f3, saving the image, lather rinse repeat. It was tedious, though not as tedious as manually cutting up each layer. But almost.
The resulting MRI-like were used to build the model. The exact placement of which bricks and where is left as an excercise to the reader. A few layers (from the bottom, middle, and towards the top) are shown below.
This is my first attempt at a Blender script, and admittedly one of my first times using blender, so any feedback on how to streamline this process would be appreciated.
Filed under: LEGOTags: blender, lego, sculpture