PDA

View Full Version : Help: Arrays and DeleteModifier


specxor
07-01-2005, 12:23 AM
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

Impus
07-01-2005, 09:41 AM
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.

specxor
07-01-2005, 02:28 PM
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

CGTalk Moderation
07-01-2005, 02:28 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.