### Subscribe to our free newsletter

To make sure you won't miss any valuable content we share with our community.

# Different Kinds of Lattice Structure Using Blender

In this article, we are going to directly use the Blender modifiers to create an aesthetic costume lattice structure in Blender. But, as we have said before, the purpose of creating these kinds of lattice structures is art and aesthetics, because the end result is more stochastic rather than deterministic. We start with adding a simple shape like a cube, cylinder, or cone and use modifiers to change the formation of the mesh, then use the Wireframe modifier to make a lattice form out of our mesh, after that, by using other modifiers like Multiresolution or smooth, we post-process our design.

## Using Blender Modifiers to Create A Lattice Structure

In this 3rd part of our tutorial, we are going to directly use the Blender modifiers to create an aesthetic costume lattice structure but as we have said before the purpose of creating this kind of lattice structure is art and aesthetics, because the end result is more stochastic rather than deterministic.

We start with adding a simple shape like a cube, cylinder, or cone and use modifiers to change the formation of the mesh, then use the Wireframe modifier to make a lattice form out of our mesh, after that, by using other modifiers like Multiresolution or smooth, we post-process our design. With that said, let’s get started:
1. creating a cone:
Click on add button, on top of the page and go to `mesh >> cone`. And you can see that a cone like below is created:

2. Modifying the object:
In the modifiers section, choose the multiresolution modifier and by using `Multiresulotion >> Subdivide`, you can subdivide (increase) the number of meshes on the object like the below photo:

3. Scaling:
Now, scale the the modified cone in x-y direction To get a shape like below:

4. Decreasing the number of meshes:
In the modifiers section, select the Decimate modifier and by using the `Decimate >> Unsubdivide`, decrease the number of meshes:

5. Creating a lattice form:
In the modifiers section, find the wireframe and use it to create lattice form of the object like below:

6. Finding the right thickness:
Change the thickness of the wireframe according to the size of the object. This part is a little bit tricky because if they are too thin, the wireframe will shrink at the time of smoothing and if they are too thick, they may not create a nice structure or holes may shrink instead of the wireframes.

7. Smoothing the object:
Use the Multiresolution modifier once again to make the object smoother:

8. Final scaling:
Scale the object according to your design preferences.

Notice that the procedure of designing the lattice structure is not the same for all the objects. It is very optional and based on your taste which method to choose.

In the next part, we are going to create a lattice structure using Blender for a different object with a few differences in the procedure.

## Tricky Parts of Designing Lattice Structures in Blender

In this section, we are going to directly use the Blender modifiers to create aesthetic costume lattice structures but as we have said before the purpose of creating this kind of lattice structure is art and aesthetics, because the end result is more stochastic rather than deterministic. The main focus of this section is to teach you the tricky parts of designing these structures.

Mesh structures:

The most important part of designing every lattice structure is the mesh formation and there are many ways to change the way the meshes are formed. Different mesh formations are as follows:
1. Triangular mesh
2. Voxel mesh
4. Blocks
5. Smooth
And so on.

The trickiest part about designing lattice structures is finding the best option for forming the meshes.

### Lattice Structure for A Clyinder

The next design we are going to work on is the lattice structure for a cylinder. The recommended steps are as follows:
1. Creating a cylinder:
From the top of the page, click on `Add >> Mesh >> Cylinder` and you will be able to see that we have a cylinder created in the origin.

2. Remesh the object in voxel form:
By using the Remesh modifier from the modifiers section, you can change the formation of the meshes from triangular to voxel-based.

3. Change the size of the voxels:
By selecting the remesh modifier from the modifiers section, you can remesh the object from triangular to voxel-based and also decrease the number of meshes leading to making it larger.

4. Subdivide the mesh
Using the Multi-resolution modifier, make the object smoother.

5. Unsubdivide the mesh:
Using the decimate modifier, unsubdivided the mesh so that we will have larger holes in our lattice structure. The reason why we subdivide and then unsubdivided is that the shape of the meshes changes and becomes more beautiful.

6. Wireframe modifier:
And then, use the Wireframe modifier to form the lattice shape.

7. thickness of the wireframe:
Change the thickness of the wireframe to reach the optimal shape.

8. Another subdivision:
Again, using the Multi-resolution modifier, subdivide the mesh to get a smooth shape.

You might want to have your own costume lattice shape to be applied to an object. In that case, we have a more complex process of placing the lattice objects on the main object and smoothing the end result. That kind of lattice is better to be performed with the aid of python blender API. In the next chapter, we work on the dependencies that will lead us to the costume shape lattice. The benefit of this kind of lattice is that the dimension of the main object will not be affected by the other modifiers that try to remesh it.

## Translating Shapes of the Lattice Structure Using Blender

So far we have learned many ways to create lattice structures, but what we haven’t learned about is how we can create these holes with the shape that we want and the places that we choose to be. In this section, we are going to create a tool to translate our desired shape to the specified vertex of an object and then we will Boolean the difference between the translated object from the main object. We use many of the functions that we used in Creating a tool in Blender to instantly translate an object to the point we show with the cursor article.

### Python Scripts

So let’s get started:
``````
import  bpy
import bmesh
import math

####################################################################
#####                Utility Functions
####################################################################
class BOOLEAN_TYPE:
UNION = 'UNION'
DIFFERENCE = 'DIFFERENCE'
INTERSECT = 'INTERSECT'

def make_boolean(obj1, obj2, boolean_type):
if not obj1 or not obj2:
return

modifier = obj1.modifiers.new(name='booly', type='BOOLEAN')
modifier.object = obj2
modifier.operation = boolean_type

res = bpy.ops.object.modifier_apply({"object": obj1}, apply_as='DATA', mod-ifier=modifier.name)

assert "FINISHED" in res, "Error"

def solidify(obj,offset,thickness):

bpy.context.object.modifiers["Solidify"].offset = offset
bpy.context.object.modifiers["Solidify"].thickness = thickness
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Solidify")

```
```
The above function will convert a solid object to a shell of its shape.
``````
def object_closest_point_mesh(p, obj):

result, location, normal, face_index = obj.closest_point_on_mesh(p)
assert result, "Can't find closest point on mesh"
location = location.to_tuple()
normal = normal.to_tuple()
return location + normal  # return tuple of 6 floats

def obj_transform(filename, obj_name, size, location, angle):

ob = bpy.context.scene.objects[obj_name]       # Get the object
bpy.ops.object.select_all(action='DESELECT') # Deselect all objects
bpy.context.view_layer.objects.active = ob   # Make the cube the active object
ob.select_set(True)

obj = bpy.data.objects[obj_name]
obj.location = location

bpy.ops.transform.rotate(value=angle, orient_axis='Z',
orient_type='GLOBAL',
orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)),
constraint_axis=(False, False, True))

def object_put_part2(part_name, point, obj, scale, obj_name):
vx,vy,vz,a,b,c = object_closest_point_mesh(point, obj)
a1 = math.atan2(b, a)
obj_transform(part_name, obj_name, scale, (point[0], point[1], point[2]), a1)

def get_vertex():
bm = bmesh.new()
ob = bpy.context.active_object
bm = bmesh.from_edit_mesh(ob.data)

points = []
for v in bm.verts:
if (v.select == True):
obMat = ob.matrix_world
points.append(obMat @ v.co)

for p in points:
pOb = bpy.data.objects.new("VertexPoint", None)
pOb.location = p
return p

def delete_object(objName):

bpy.ops.object.select_all(action='DESELECT')
bpy.data.objects[objName].select_set(True) # Blender 2.8x
bpy.ops.object.delete()

def get_object_by_name(obj_name):

assert obj_name in bpy.data.objects, "Error getting object by name:{}".format(obj_name)
obj = bpy.data.objects[obj_name]
return obj

####################################################################
########             Main Panel
####################################################################

class MainPanel(bpy.types.Panel):
bl_idname = "VIEW_PT_MainPanel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Design Automation'

def draw(self, context):
layout = self.layout
layout.scale_y = 1.2

row = layout.row()
row.label(text= "Design Automation", icon= 'OBJECT_ORIGIN')
row = layout.row()
row.operator("wm_function.myop", text= "Create single Lattice")

####################################################################
####                  Main UI ّFunctions
####################################################################

class WM_Function_myOp(bpy.types.Operator):
"""Go to edit mode and determine the point then Click the button"""
bl_label = "Our customized function"
bl_idname = "wm_function.myop"

scale = bpy.props.FloatProperty(name= "Enter the scale of lattice", default= 1)
Lattice_Name = bpy.props.StringProperty(name= "Enter the scale of lattice", default= '')

def execute(self, context):

Scale = self.scale
Lattice_Name = self.Lattice_Name
point = get_vertex()
bpy.ops.object.editmode_toggle()
obj = get_object_by_name('Icosphere')
solidify(obj, 0, 0.02)
obj2 = get_object_by_name('%s'%Lattice_Name)
object_put_part2('%s'%Lattice_Name, point, obj, Scale, '%s'%Lattice_Name)
make_boolean(obj,obj2,'DIFFERENCE')
delete_object("VertexPoint")
return {'FINISHED'}

def invoke(self, context, event):

return context.window_manager.invoke_props_dialog(self)

```
```

#### What We Have Done in the Scripts Above

In the above def execute function, at first get the vertex of the object, then we will create the shell of the main object. After that, we get the name of the lattice shape that has been imported or created by the user. In the next step, we will translate the lattice to the specified point by the user and finally we apply the boolean difference function to the objects. Do not forget the below scripts related to registering and unregistering the classes.
``````
####################################################################
#####                     Register and Unregister
####################################################################

def register():
bpy.utils.register_class(MainPanel)
bpy.utils.register_class(WM_Function_myOp)

def unregister():
bpy.utils.unregister_class(MainPanel)
bpy.utils.unregister_class(WM_Function_myOp)

if __name__ == "__main__":
register()

```
```

### How to Use the Translating Tool

Now, it is time to test the panel we have designed and created. To do so, select a vertex on the object in edit mode:

Then, simply click on the button on the panel (Create single lattice).

And here we go! You can now see the lattice structure with the exact shape that you want on the object.

### Wrapping Up

In this tutorial, we have managed to design an aesthetic internal lattice structure manually without the need for any coding python scripts. The design process is easy, however, you need to repeat and practice it in order to easily deal with the tricky parts.

Then, we got familiar with the tricks of creating aesthetic internal lattice structures and how to mesh formations such as triangular, voxel-based, and other ones that can influence the beauty of the design of these objects.

Moreover, we have managed to design a panel using python scripts (Blender Python API) to create any number of lattices with any shape and any size on our object. The only thing that the user interface wants from the user is the vertex on which the lattice is going to be placed. We can use this panel to create our custom shape lattice structure with accurate dimensions.