PDA

View Full Version : Delete Modifier by Name not working?


supremepizza
01-11-2008, 03:56 PM
I've been trying to delete a modifier by name so I can re-apply it later in a different place. When I delete it via MAXScript the listener tells me it is deleted but when I go to the object the modifer is still there.

Specifically I do a soft selection on verts then add a noise modifier. Then I often need to delete the modifier and re-apply it after a new smaller/larger vertex selection is made.

Edit:
By the way delete by index works fine but I don't want to delete the wrong modifier in someone's stack by accident.

PiXeL_MoNKeY
01-11-2008, 04:44 PM
What delete modifier by name approach are you using? Why not do something like:
for obj in selection do (
for mod in 1 to obj.modifiers.count do (
if obj.modifiers[mod].name == "Name" do (
deleteModifier obj mod
)
)
)-Eric

JHN
01-11-2008, 06:39 PM
Maybe it requires you to be in:

"max modify mode"

or maybe

"modPanel.setCurrentObject <modifier>"

will help... I think it's something along that line... maybe post a code snippet..

-Johan

supremepizza
01-12-2008, 12:57 AM
Thanks. I wish I could post the offending code but I was so frustrated I deleted that line.

I did try max modify mode. I'll try your solution PM and see if that works. I didn't try an in o do. it was a

deletemodifier <node> <modifier>

single line, where I could delete the modifier only by index but not by name.

hblan
01-13-2008, 11:27 AM
i want help u if u can send ur scene to me . my mailbox : haibo.lan@gmail.com (http://forums.cgsociety.org/haibo.lan@gmail.com)

Thanks. I wish I could post the offending code but I was so frustrated I deleted that line.

I did try max modify mode. I'll try your solution PM and see if that works. I didn't try an in o do. it was a

deletemodifier <node> <modifier>

single line, where I could delete the modifier only by index but not by name.

PiXeL_MoNKeY
01-13-2008, 02:40 PM
BTW, deleteModifier <node> <modifier>, doesn't accept Strings or Names for the modifier. You have to assign the modifier to a variable and then call it:mod = obj.modifier[1]
deleteModifiers obj modThis will delete the referenced modifier that was assigned to index 1, even if you move the modifier in the stack after assigning it but before deleting it. Another way is to assign the modifier to a variable before applying it: mod1 = (bend name:"mod1")
addmodifier obj mod1
deleteModifier obj mod1This will delete the reference of mod1 from the modifier stack, no matter where it is located in the stack. So you need to assign a reference of the modifier to a variable and call that for the <modifier> or use the index.

-Eric

supremepizza
01-14-2008, 02:27 PM
Excellent Eric!

mod1 = (bend name:"mod1")
addmodifier obj mod1
deleteModifier obj mod1

Much appreciated. That's exactly what I'll do.

@ hblan
The script is not scene specific.

PiXeL_MoNKeY
01-14-2008, 04:20 PM
Again it doesn't have to be done that way, but you need to assign the modifier to a variable and then you can access/delete that variable from the stack using the variable.

-Eric

supremepizza
01-14-2008, 06:10 PM
Yep definately the way to go. Thanks for reminding me that if it doesn't work on the object perform the operation on a variable referencing the object and it works. Somehting to do with the object vs. the object node as I recall. Didn't realize the same issue applied to modifiers.

CGTalk Moderation
01-14-2008, 06:10 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.