The fenicstools package was originally developed with this exact purpose. You can use it to slice your 3D mesh as follows
from dolfin import *
from fenicstools import StructuredGrid, interpolate_nonmatching_mesh
mesh = UnitCubeMesh(30, 30, 30)
V = FunctionSpace(mesh, "CG", 1)
# Create some Function on 3D mesh to be sliced
u = interpolate(Expression("x[0]*x[1]"), V)
# Create a structured grid in x-y plane at z=0.5
dims = (20, 20)
directions = [[1, 0, 0], [0, 1, 0]]
lengths = (1.0, 1.0)
origin = (0, 0, 0.5)
sl = StructuredGrid(V, dims, origin, directions, lengths)
# interpolate u on slice
sl(u)
# Dump result to vtk
sl.tovtk(0, "slice.vtk")
I also have an alternative approach that works without fenicstools. It works by creating a dolfin mesh of topology 2 in 3 dimensions. It goes like this
# Create boundary mesh consisting of the 6 sides of the cube
bmesh = BoundaryMesh(mesh, "exterior")
# Create SubMesh for side at z=0
# This will be a UnitSquareMesh with topology dimension 2 in 3 space dimensions
cc = CellFunction('size_t', bmesh, 0)
xyplane = AutoSubDomain(lambda x: x[2] < 1e-8)
xyplane.mark(cc, 1)
submesh = SubMesh(bmesh, cc, 1)
# Move slice/submesh to z=0.5
x = submesh.coordinates()
x[:, 2] += 0.5
# Create a FunctionSpace on the submesh
Vs = FunctionSpace(submesh, "CG", 1)
# interpolate_nonmatching_mesh required in parallel,
# interpolate works in series
#us = interpolate_nonmatching_mesh(u, Vs)
us = interpolate(u, Vs)
plot(us)
interactive()