Removing Modifiers

Removing Modifiers

Anonymous
Not applicable
2,378 Views
7 Replies
Message 1 of 8

Removing Modifiers

Anonymous
Not applicable
Good day,

Is there a good way to recognize an UVWmap modifier and delete those modifiers on the selected objects (if they exist).
I have some troubles with the "deleteModifier" command as it does not seem to recognize the "uvwmap" as a modifier.

With kind regards,

Bas Mettes
0 Likes
2,379 Views
7 Replies
Replies (7)
Message 2 of 8

stigatle
Enthusiast
Enthusiast


allObjects = objects as array
for o in allObjects do
(
try
(
if (ClassOf o.modifiers) == uvwmap then --checks modifier on top of stack
(
deleteModifier o 1 --de
)
)
catch
(
--to catch errors..
)
)


0 Likes
Message 3 of 8

Anonymous
Not applicable
You can also use the modifierUtilities script:

http://www.neilblevins.com/soulburnscripts/soulburnscripts.htm

That does exactly what you're after.

- Neil
0 Likes
Message 4 of 8

Anonymous
Not applicable
Good day,

Is there a good way to recognize an UVWmap modifier and delete those modifiers on the selected objects (if they exist).
I have some troubles with the "deleteModifier" command as it does not seem to recognize the "uvwmap" as a modifier.

With kind regards,

Bas Mettes


There are some pitfalls here.

First, you cannot use a CLASS name in deleteModifier, but a class INSTANCE (read about the wonderful world of classes and class instances in the MAXScript Reference and have a laugh! ;))
Alternatively, you can delete modifiers by index, which is easier, but...
If you have multiple modifiers of the same type on the stack, the stack is counted from top to bottom, so deleting the top modifier causes the rest to renumber and the script could skip some. For example, if both the first and second modifiers from top of the stack are of uvwmap class, deleting the first in a straight loop would make the second become number 1, but the loop will continue with number 2 and forget to delete the old 2/new 1 modifier! The solution is to loop backwards from bottom to top of the stack:


(
for o in selection do
for i = o.modifiers.count to 1 by -1 where classof o.modifiers == uvwmap do
deleteModifier o i
)
0 Likes
Message 5 of 8

Anonymous
Not applicable
nobody can answer better than bobo... but i am an architect and i made this script a lot time ago... it works for me.

for i in 1 to geometry.count do
(
select geometry
try
if $.modifiers == $.uvw_Mapping then deletemodifier $ $.UVW_Mapping
catch ()
)

i create this script and i want to made an interface with another modifiers that make me some trouble, but when i need it to remove another modifier i only replace the name and execute again..ja,jaa.. not to profesional, but works for me.. maybe someday i make an interface por it.

Good luck and forgive my english...is very bad.
0 Likes
Message 6 of 8

Anonymous
Not applicable
nobody can answer better than bobo... but i am an architect and i made this script a lot time ago... it works for me.

for i in 1 to geometry.count do
(
select geometry
try
if $.modifiers == $.uvw_Mapping then deletemodifier $ $.UVW_Mapping
catch ()
)

i create this script and i want to made an interface with another modifiers that make me some trouble, but when i need it to remove another modifier i only replace the name and execute again..ja,jaa.. not to profesional, but works for me.. maybe someday i make an interface por it.

Good luck and forgive my english...is very bad.


Your English is quite good actually! Your MAXScript on the other hand... 😉

Your code is slower than necessary because it selected every object just to be able to use the $ sign to access it and I bet it causes the command panel to flash a lot if in modify mode.
Then the test for modifier will only work if you never rename your modifiers, because you are checking the modifier by name (the string shown on the stack), not by its class. I could add a UVWmap modifier and rename it to "FrenchFries" and your script would miss it. The test you are performing does not do anything - you are asking if something is equal to itself using two different access methods, but the IF would always be true because the modifier accessed by #name in the modifiers collection is always equal to the modifier accessed as property of the node (it is the SAME modifier, after all).
Also, if you have multiple UVWmap modifiers on the stack, you would have to run the script multiple times.

Still, I am happy to see people solving their problems with scripting. Keep it on!
0 Likes
Message 7 of 8

Anonymous
Not applicable
thanks for the reply. obviously you have the rigth, my code have a lot of problems..ja,aj,a.. i notice when i test your script... is smaller, faster, dont flash a lot like mine... and really work... thanks a lot, for the script and for the comment.
0 Likes
Message 8 of 8

Anonymous
Not applicable
Thanks alot everybody.

Neil - It is indeed exactly what i am looking for. Though i prefer to solve the problem on my own. (Must learn maxscript someday 😉 )

Bobo - Thank you for the explanation. Solving problems with maxscript is quite useful, although most of the time it is pretty hard to find out how something exactly works. Most of my scripts (simple ones) were born by trail and error.
0 Likes