def createJoint(self, jointType):
		if(len(self.selected) == 2):
			id1, node1 = self.selected.items()[0]
			id2, node2 = self.selected.items()[1]
			
			if node1.get('vvpType') == Types.Body and node2.get('vvpType') == Types.Body:
				
				point1 = avgPoint(getPoints(node1.get('d')))
				point2 = avgPoint(getPoints(node2.get('d')))
				
				line = None
				
				if jointType == JointType.DistanceJoint:
					line = self.createDistanceJointLine(id1, id2, point1, point2)
				elif jointType == JointType.RevoluteJoint:
					line = self.createRevoluteJointLine(id1, id2, point1, point2)
				
				self.current_layer.append(line)
				return
		elif len(self.selected) == 1:
			id1, node1 = self.selected.items()[0]
			
			if node1.get('vvpType') == JointType.DistanceJoint:
				self.setDistanceJointParams(node1)				
				return
			elif node1.get('vvpType') == JointType.RevoluteJoint:
				self.setRevoluteJointParams(node1)				
				return

		sys.stderr.write("You have to select exactly two bodys.")			
	def createBody(self, boned):
		for idNr, node in self.selected.iteritems():
			if node.tag == inkex.addNS('path','svg'):
				flattenPath(node, self.options.body_flatness)
				
				color = "#d4ff2a"
				
				if boned:
					direction = self.options.bone_direction
					color = "#00f7ed"
					d = node.get('d')
					points = getPoints(d)
					
					bonePoints = self.getBonePoints(direction, points)
					
					line = self.createBoneLine(bonePoints[0], bonePoints[1], idNr, direction)
					self.current_layer.append(line)
					
			
				node.set('vvpType',  Types.Body)
				node.set('density', str(self.options.body_density))
				
				if self.options.body_fixedRotation:
					node.set('fixedRotation',  '1')
				else:
					node.set('fixedRotation',  '0')
					
				if self.options.body_staticBody:
					node.set('staticBody',  '1')
				else:
					node.set('staticBody',  '0')
				
				if self.options.body_hide:
					node.set('style', 'fill:%s;fill-opacity:0.4;opacity:0;stroke:%s;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:6, 6;stroke-dashoffset:0' % (color,color))
				else:
					node.set('style', 'fill:%s;fill-opacity:0.4;stroke:%s;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:6, 6;stroke-dashoffset:0' % (color, color))
    def exportPaths(self):

        defXml = DefXml()

        for node in self.document.xpath("//svg:path[@vvpType='%s']" % Types.Body, namespaces=inkex.NSS):
            idNum = node.get("id")
            d = node.get("d")

            points = getPoints(d)

            bones = self.document.xpath(
                "//svg:path[@vvpType='%s' and @body='%s']" % (Types.Bone, idNum), namespaces=inkex.NSS
            )

            bone = None
            if len(bones) >= 1:
                bone = bones[0]
                boneD = bone.get("d")
                params = getParams(bone, ["direction"])
                direction = params["direction"]

                bonePoints = getPoints(boneD)

                bonePoints = self.checkBonePoints(bonePoints, direction)

                if len(bonePoints) > 1:
                    bone = defXml.createBone(bonePoints, params)
                else:
                    bone = None

            defXml.addBody(
                str(idNum), points, getParams(node, ["density", "fixedRotation", "staticBody", "collideGroup"]), bone
            )

        for node in self.document.xpath("//svg:path[@vvpType='%s']" % JointType.RevoluteJoint, namespaces=inkex.NSS):
            d = node.get("d")
            idNum = node.get("id")
            idBody1 = node.get("body1")
            idBody2 = node.get("body2")
            limit = node.get("limit")
            motor = node.get("motor")

            points = getPoints(d)

            if len(points) >= 2:
                point1 = points[0]
                point2 = points[len(points) - 1]
                defXml.addRevoluteJoint(idBody1, idBody2, point1, point2, limit, motor)

        for node in self.document.xpath("//svg:path[@vvpType='%s']" % JointType.DistanceJoint, namespaces=inkex.NSS):
            d = node.get("d")
            idNum = node.get("id")
            idBody1 = node.get("body1")
            idBody2 = node.get("body2")

            points = getPoints(d)

            if len(points) >= 2:
                point1 = points[0]
                point2 = points[len(points) - 1]
                distance = getParams(node, ["distance"])["distance"]
                distance = getAllFloats(distance)
                params = getParams(node, ["dampingRatio", "frequencyHz"])
                params["distanceX"] = distance[0]
                params["distanceY"] = distance[1]
                defXml.addDistanceJoint(idBody1, idBody2, point1, point2, params)

        return defXml.toXml()