Projecting vectors on some elements

Hello
I want to project some vectors on only some of elements of a mesh using DG0 function space. Here is the minimal work example:

from dolfin import *

mesh = BoxMesh(Point(0, 0, 0), Point(1, 1, 1), 2, 2, 2)

DG = FunctionSpace(mesh, "DG", 0)

element_index = [0,1,2,3,4,5]

# a1, a2 and a3 are the components of the vectors

a1 = Function(DG)
a1.vector()[element_index] = [1,4,3,2,0,1]

a2 = Function(DG)
a2.vector()[element_index] = [0,1,2,4,1,1]

a3 = Function(DG)
a3.vector()[element_index] = [0,0,0,0,0,0]

V = VectorFunctionSpace(mesh, "DG", 0)

B  = Constant((a1, a2, a3))

C = project(B,V)
File("a.pvd") << C

I am getting this error:

RuntimeError: Cannot convert spatially varying function to float.

Is there any way to resolve this issue?
Thanks

Are you misunderstanding the difference between a constant and a function? Perhaps you meant to construct B using B = as_vector((a1, a2, a3)).

Thank you @nate for your clarification. That was what I was looking at.