# ns_SelectParents
# Initial code generated by Softimage SDK Wizard
# Executed Thu Oct 24 10:43:06 UTC+0200 2013 by freelancer
# 
# Tip: To add a command to this plug-in, right-click in the 
# script editor and choose Tools > Add Command.
import win32com.client
from win32com.client import constants

null = None
false = 0
true = 1

def XSILoadPlugin( in_reg ):
	in_reg.Author = "Niclas Schlapmann"
	in_reg.Name = "ns_SelectParents"
	in_reg.Major = 1
	in_reg.Minor = 0
	
	in_reg.RegisterCommand("ns_SelectParents","ns_SelectParents")
	in_reg.RegisterMenu(2001, "ns_SelectParents_Menu", False, False)


	#RegistrationInsertionPoint - do not remove this line

	return true

def XSIUnloadPlugin( in_reg ):
	strPluginName = in_reg.Name
	Application.LogMessage(str(strPluginName) + str(" has been unloaded."),constants.siVerbose)
	return true
	
	
def ns_SelectParents_Execute(  ):
	oSelection = Application.Selection
	oString = ""
	try:

		for i in range(oSelection.count):
			
			if oString == "":
				oString = oString + str(oSelection.Item(i).Model.Name + "." + oSelection.Item(i).Parent3DObject.Name)
			else:
				oString = oString + "," + str(oSelection.Item(i).Model.Name + "." + oSelection.Item(i).Parent3DObject.Name)
			
		Application.SelectObj(oString, "", "")	
			
	except:
		Application.LogMessage("Upps!", 4)
			
	return true
	
def ns_SelectParents_Menu_Init( in_ctxt ):
	oMenu = in_ctxt.Source
	oMenu.AddCommandItem("ns_SelectParents","ns_SelectParents")
	return true

	



	
	
	
	
	

	