def CreateConstraint(_type, name=None):
    '''
    Create a constraint with the given type and optionally with a name
    @param _type: name of constraint type found in kConstraintTypes
    @param name: name to give constraint. Default is used if None 
    '''
    try:
        constraint = FBConstraintManager().TypeCreateConstraint(kConstraintTypes[_type])               
    except KeyError:
        raise Exception("Invalid constraint type '%s'" % _type)
    
    FBSystem().Scene.Constraints.append(constraint)
    
    if name:
        constraint.Name = name
    
    return ConvertToPMBConstraint(constraint)
dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/moBu/site-packages/PyMoBu-0.2/pymobu/components/constraints.py/CreateConstraint/original