'***************************************
'**			Effector Remover    	     **
'** Homam Bahnassi - In|Framez - 2003 **
'***************************************
'
'************ General Notes ************
' The script seeks in all deformers for
' any deformer with the "eff" charchters
' in its name. So in case that you use
' names with no "eff" in it you could
' change it in the script to match your
' custom names.
'***************************************
' To remove only spcific effecters, answer
' "NO" in the "Auto Removing" dialog.
' This will prompet you for each effecter
' before removing it from the deforming
' list.
'***************************************
'
'**************  Caution  **************
' The script causes the envelope weights
' to be freezed. This is done to ensure
' that no autoassignment operator is active
' which reset the weights when removing
' the effector.
'*************************************** 

dim autodlg,ansdlg
autodlg = msgbox ("Remove All Deforming Effectors?",vbYesNo,"Auto Removing")

if autodlg = 6 then
	'Auto Removing...
	Set oSelection = Application.Selection  
	for i = 0 to (oSelection.Count - 1)
		logmessage "Processing " & oSelection(i).name
		Set oEnvelope = oSelection(i).Envelopes(0)
		Set oDeformers = oEnvelope.Deformers
		for j = 0 to oDeformers.Count - 1 
			if InStr (oDeformers.Item(j),"eff") then
				logmessage "found effector"
				Set oGeometry = oSelection(i).activeprimitive.geometry
				Set oClusters = oGeometry.Clusters
				for each oCluster in oClusters  
					Set oClsProp = oCluster.properties
					for each Prop in oClsProp
						if Prop.type = "envweights" then
							logmessage "freezing " & oCluster.name
							freezeobj (Prop)
						end if
					next
				next
				Set oEnvMesh = oSelection(i)
				Set oEnvEff = oDeformers.Item(j)
				logmessage "removing " & oEnvEff.name & " from deformers list..."
				RemoveFlexEnvDeformer oEnvMesh & ";" & oEnvEff
			end if
		next
	next
	
else
	'Manual Removing...
	Set oSelection = Application.Selection  
	for i = 0 to (oSelection.Count - 1)
		logmessage "Processing " & oSelection(i).name
		Set oEnvelope = oSelection(i).Envelopes(0)
		Set oDeformers = oEnvelope.Deformers
		for j = 0 to oDeformers.Count - 1 
			if InStr (oDeformers.Item(j),"eff") then
				logmessage "found effector"
				Set oEnvMesh = oSelection(i)
				Set oEnvEff = oDeformers.Item(j)
				ansdlg = msgbox ("Remove " & oEnvEff & " from " & oEnvMesh,vbYesNo, "Comfirm Removing")
				if ansdlg = 6 then
					Set oGeometry = oSelection(i).activeprimitive.geometry
					Set oClusters = oGeometry.Clusters
					for each oCluster in oClusters  
						Set oClsProp = oCluster.properties
						for each Prop in oClsProp
							if Prop.type = "envweights" then
								logmessage "freezing " & oCluster.name
								freezeobj (Prop)
							end if
						next
					next
					logmessage "removing " & oEnvEff.name & " from deformers list..."
					RemoveFlexEnvDeformer oEnvMesh & ";" & oEnvEff
				end if
			end if
		next
	next
end if
