Hardware Reference
In-Depth Information
Hand-Crafting a Small Test
Object.to.3D Print
In your maze program, data was stored in a CSV file, where each line in the file repre-
sents a line of blocks inside the Minecraft world. Each column inside that line (sepa-
rated by commas) corresponds to one block in that line of blocks. This is a 2D structure,
because it stores a block for each x and z coordinate of a rectangle region. The mazes
you have built here are really only 2D mazes, as they only have one layer. They are just
built inside the 3D Minecraft world by using 3D blocks.
To build 3D shapes, you need to build up in the y dimension too. If you think of a 3D
object as just multiple layers or slices, then your 3D program is not all that different
from your maze program. All you need to do for a cube that is 5 by 5 by 5 blocks in size,
is to store five layers of information.
There is a problem with this. Your Python program will not know how many lines to
expect until it has processed the whole file. It could assume a certain size, but it would
be nice to design a flexible CSV file format that can work with any size of object.
To solve this problem, you will add some metadata in the first line of the file that
describes the size of the object.
Metadata is data about data. If the data in your file is the block types to build,
then the metadata (data about that data) can be things like how big the object is,
what it is called and who designed it. In the same way that the metadata for a
photo stored on your computer describes the date and time it was taken and the
name of the camera, the metadata in your 3D printer will describe other useful
information about your 3D objects.
You are now going to create a sample object which is a tiny 3D cave so that you can test
the 3D printing capabilities of your program. You can download this sample object as
shown in FigureĀ 6-4 from the companion Wiley website, or just type it in here like you
did with your maze.
Make sure that you put blank lines between each layer of the object. They are
there to help you see where each layer begins, but the Python program you write
will expect them to be there and it won't work if you leave them out.
 
Search WWH ::




Custom Search