Notifications
Clear all

[Closed] Help: Arrays and DeleteModifier

Hey Guys having some trouble with a script that deletes modifiers cant work out why it does not work, i get no errors which is good but on the other hand nothing hapends…

Anyways maybe you guys can point out where i went wrong!!

Cheers
Dave

Heres the Code

rollout ModManRoll “ModifierMan” width:160 height:176

(

local SelMod

local ModManVar

local SelArray

local AllObjs

groupBox grp1 “Delete Modifier” pos:[8,8] width:144 height:136

pickbutton btnGet “Select obj with modifier” pos:[16,24] width:128 height:32

button btnDelS “Del on All” pos:[16,104] width:128 height:32

button btnDelA “Del Modifiers on Selected” pos:[16,64] width:128 height:32

on btnGet picked obj do

(

SelMod = obj.modifiers[1]

print SelMod

)

on btnDelS pressed do

(

SelArray = selection as array

for i in SelArray do

(

for m in i.modifiers do

(

if classof i == SelMod do

(

deletemodifier m

)

)

)

)

on btnDelA pressed do

(

AllObjs = objects as array

for i in AllObjs do

(

for m in i.modifiers do

(

if classof m == SelMod do

(

deleteModifier m

)

)

)

)

)

createDialog ModManRoll 160 176

2 Replies

Here you go, try this:

rollout ModManRoll "ModifierMan" width:160 height:176
 
 	(
 	
 	local SelMod
 	
 	local ModManVar
 	
 	local SelArray
 	
 	local AllObjs
 	
 	
 	
 	groupBox grp1 "Delete Modifier" pos:[8,8] width:144 height:136
 	
 	pickbutton btnGet "Select obj with modifier" pos:[16,24] width:128 height:32
 	
 	button btnDelA "Del on All" pos:[16,104] width:128 height:32
 	
 	button btnDelS "Del Modifiers on Selected" pos:[16,64] width:128 height:32
 	
 	
 	
 	on btnGet picked obj do
 	
 		(
 		
 		SelMod = obj.modifiers[1]
 		
 		print SelMod
 		
 		)
 	
 	
 	
 	on btnDelS pressed do
 	
 		(
 		
 		SelArray = selection as array
 		
 		
 		
 		for eachObj in SelArray do
 		
 			(
 
 			for m in eachObj.modifiers do
 			
 				(
 				if (classof m) == (classof SelMod) do
 				
 					(
 					
 				    deletemodifier eachObj m
 					
 					)
 				
 				)
 			
 			)
 		
 		)
 	
 	
 	
 	on btnDelA pressed do
 	
 		(
 		
 		AllObjs = objects as array
 		
 		
 		
 		for eachObj in AllObjs do
 		
 			(
 			
 			for m in eachObj.modifiers do
 			
 				(
 				
 				if (classof m) == (classof SelMod) do
 				
 					(
 					
 				    deleteModifier eachObj m
 					
 					)
 				
 				)
 			
 			)
 		
 		)
 	
 	)
 
 createDialog ModManRoll 160 176

Main changes I made were ‘i’ now represented as ‘eachObj’ and that you need to do ‘classof SelMod’ when comparing it to ‘classof m’ so:

if classof i == SelMod do
 
 and
 
 if classof m == SelMod do
 
 changed to:
 
 if (classof m) == (classof SelMod) do

Also I flipped the names of the buttons ‘btnDelS’ and ‘btnDelA’ around as they were incorrect.

Hey thanx a bunch for your help i had been beating my brain with this one, why is it always something simple that fixes it…

So any way thanx

cheers
dave