help - keyerror problem?

I keep getting a keyerror and I don’t understand why, here is the code snippet



#finds the corresponding vertices for mirror
def FindCorrespVerts():
	global myMesh
	correspXVertsDict = {}
	correspYVertsDict = {}
	correspZVertsDict = {}
	vertexDict = {}

	for vertex in myMesh.verts:
		vertexDict[vertex.co] = vertex
	print vertexDict
	
	for vertex in myMesh.verts:
		mirroredXCoord = Vector([-vertex.co[0],vertex.co[1],vertex.co[2]])
		try:
			correspXVertsDict[vertex] = vertexDict[mirroredXCoord]
		except KeyError:
			pass
	print correspXVertsDict
	return correspXVertsDict

Any idea what I am doing wrong?

Thanks,

LetterRIp

Check if Vectors are considered immutable objects. You shouldn’t be able to use mutable objects as keys in dictionaries. Try converting them to tuples, it should work.

Martin

Yep had already done so and forgot to post a followup thanks for the reply though,

LetterRip