================== Composite pieces ================== .. index:: composit pieces, scale, join, name an object .. |a| image:: /images/all/blender-basics/d_composed_pices/halma-figure-100.png Objectives ========== .. tabularcolumns:: | c | l | :border: none +-------+----------------------------------------------------------------------+ | |a| | In this station a figure for the halma game will be created. | | | It is a composition from mesh objects (primitives). | +-------+----------------------------------------------------------------------+ Instructions ============ :Tasks: 1. Create a composite pice as shown in this learning unit. 2. Move the new object with the mouse. 3. Join the parts and name the object »halma_figure«. 4. Move the new object again. 5. Duplicate the object and have a look at the counter in the header of the info window. First version ============= .. literalinclude:: files/halma_figure.py :language: python :linenos: Select the context ================== Selecting the *context* is the first step. Next step is creating and positioning objects. The *context* is assigned to a variable named *scn*. .. literalinclude:: files/halma_figure.py :language: python :lines: 14,15 Name it ======= If you name the objects, later on it is easier to select one of them. .. literalinclude:: files/halma_figure.py :language: python :lines: 17,18 First part of the composite pice ================================ The sphere is the first part. We also scale the object afterwards and name it »head«. .. literalinclude:: files/halma_figure.py :language: python :lines: 20-26 Second part of the composite pice ================================= Same procedure as with the first part. .. literalinclude:: files/halma_figure.py :language: python :lines: 30-36 Call the function ================= Let's have a look to the final version. Are all pieces on the right place and have the right dimension? The old objects are deleted, so a frech and empty scene is used. You can check the info window. There are also statistics about the number of objects. .. literalinclude:: files/halma_figure.py :language: python :lines: 38-41 .. image:: /images/all/blender-basics/d_composed_pices/objectcount1.png How many objects are selected/available? ======================================== .. image:: /images/all/blender-basics/d_composed_pices/objectcount2.png How to connect the parts to one? ================================ Add the following lines of code to glue together the two pieces to a new one. .. code:: python :: # connect parts to a new one scn.objects[parts[0]].select = True scn.objects[parts[1]].select = True bpy.ops.object.join() obj.name = parts[2]