#  ----------------------------------------------------------------------------------------------------------
#  gbMatch.py - Maya Python Script 
#  ----------------------------------------------------------------------------------------------------------
#
#  DESCRIPTION:
#  A simple script to match position and rotation of the first selected object to the second selected object.
#
#  USAGE:
#  (PYTHON)  import gbMatch; gbMatch.match()
#  (MEL)     python("import gbMatch;gbMatch.match()")
# 
#  AUTHOR:
#  Giorgio Bertolone - mail@giorgiobertolone.com - www.giorgiobertolone.com
#  Copyright (C)2008 Giorgio Bertolone - All Rights Reserved.
#
#  VERSIONS:
#  1.00 - Aug 03, 2008 - Initial Release
#
#  ----------------------------------------------------------------------------------------------------------


import maya.cmds as mc

def match():

# check for selection errors
	sel = mc.ls( sl=True )
	if len(sel) > 2:
		mc.confirmDialog( title="Selection Error", message="More than two objects are selected. Please select only two.", button=["Ok"], defaultButton="Ok" )
	if len(sel) == 0:
		mc.confirmDialog( title="Selection Error", message="Nothing is selected. Please select two objects.", button=["Ok"], defaultButton="Ok" )
	if len(sel) == 1:
		mc.confirmDialog( title="Selection Error", message="Only one object is selected. Please select two objects.", button=["Ok"], defaultButton="Ok" )
	if len(sel) == 2:

# create parent constraint		
		fir = sel[0]
		sec = sel[1]
		mc.parentConstraint( sec, fir, w=1, n="tempParentConstraint" )
		
# select and delete parent constraint		
		mc.delete( "tempParentConstraint" )
		
# return to the first object
		mc.select( fir )
