'//switchMasters vbs
'//Thursday April 29th 2004
'//mail2004@grahamdclark.com
'//select instance model, then new master modelk, run script
'//probably better written changing port inputs if possible, instead of this hack

Set oColl = CreateObject("XSI.Collection")
oColl.Add selection(0)
oColl.Add selection(1)

tempInstance oColl.item(1)
switchMasters oColl.item(0),oColl.item(1)

function tempInstance(newMaster)
	set temporaryInstance = Instantiate(newMaster)
	set master = GetMaster(temporaryInstance)
	RemoveFromGroup master&".InstanceGroup", temporaryInstance
	deleteObj temporaryInstance	
end function	
	
function switchMasters(oInstantiate,newMaster)
	set master = GetMaster(oInstantiate)
	RemoveFromGroup master&".InstanceGroup", oInstantiate	
	set ModelInstanceGroup =  newMaster.groups.item("InstanceGroup")
	SIAddToGroup ModelInstanceGroup, oInstantiate
end function