Notifications
Clear all

[Closed] get list of all modifiers

Hello,

Is there a way I can get a list of all the modifier names as an array? I’m not talking about the list of modifers applied to an object but the complete list we see in the modifier list drop down.

Cheers,
Vikram.

17 Replies

From the maxscript help:

showClass "*:mod*" -- all the modifier classes

If you dump that to a stream and filter by “:” you should be able to get the creation names.

-Eric

EDIT: This should build an array of the creation names:

ss = stringstream ""
 showClass "*:mod*" to:ss
 seek ss 0
 modArr = #()
 while not (eof ss) do (
 	modNm = (readdelimitedstring ss " :")
 	append modArr modNm
 	skipToNextLine ss
 )

EDIT 2: This will build 2 arrays, one for the creation name “modArr” and one for the default name of the applied modifier “modNmArr”. NOTE: You will need to handle the catch for non-creatable modifiers on however you want to handle it.

ss = stringstream ""
showClass "*:mod*" to:ss
seek ss 0
modArr = #() -- these are the creation names, ie execute (modArr[1]+"()") will create an instance of the modifier
modNmArr = #() -- these are the names as they appear on a newly created modifier in the modifier stack
while not (eof ss) do (
	modNm = (readdelimitedstring ss " :")
	append modArr modNm
	try (append modNmArr (execute (modNm+"()")).name) catch (append modNmArr "") -- modifiy the catch to handle non-creatable modifiers, right now it is an empty string
	skipToNextLine ss
)
2 Replies
(@lucpet)
Joined: 10 months ago

Posts: 0

When I run the last piece of code I get

StringStream:””
OK
OK
#()
#()
OK

That doesn’t seem right as this

showClass "*:mod*"

does give me the results I expect

(@pixel_monkey)
Joined: 10 months ago

Posts: 0

Print the modArr and/or modNmArr arrays as the code is dumping the results to those arrays. Better to use the modified code, as it is cleaner and should get what you want.

-Eric

also:

modArr = sort (for i in modifier.classes collect i as string)
3 Replies
(@lucpet)
Joined: 10 months ago

Posts: 0

:shrug: Why does this only give you a limited array and end in ,… when there are obviously more modifiers

#("Affect_Region", "Bend", "Bevel", "Bevel_Profile", "CamPerspCorrect", "CameraMap", "Cap_Holes", "Civil_View_Divide_Spline", "Civil_View_Guard_Rail", "Civil_View_Road_Marking", "Civil_View_Spline_to_Mesh", "Cloth", "CrossSection", "DeleteMesh", "DeletePatch", "DeleteSplineModifier", "Disp_Approx", "Displace", "DynBuilding", "Edit_Mesh", ...)
(@pixel_monkey)
Joined: 10 months ago

Posts: 0

Look up “printallelements” in the maxscript help.

-Eric

(@lucpet)
Joined: 10 months ago

Posts: 0

Thanks Eric

Oh sure come in here being all efficient and tidy with your code.

-Eric

Although I dont think my version will give you names exactly as they appear in the list like yours does

i can’t check it now but i remember that any class has a property localizedname. what does it show?

That is just as easy though, just loop through your array and collect as I outlined before. Again it needs to be a try/catch as some of the classes aren’t creatable through maxscript and will throw an error:

modNmArr = for nm in modArr collect (try ((execute (nm+"()")).name) catch (""))

-Eric

for this case it should be another property creatable or iscreatable

because i don’t have max open to double-check the code please excuse me if it not works:


-- version #1
for c in modifier.classes collect c.localizedname
-- version #2
for c in modifier.classes where c.creatable collect (c()).name

3 Replies
(@floopyb)
Joined: 10 months ago

Posts: 0

both work… version 2 seems to give better names (“PhysX Rigid Body” rather than “PhysXModRB”)

(@denist)
Joined: 10 months ago

Posts: 0

i remember that was a reason for me to use them both. i don’t like the second method because it creates max nodes to get the names. #1 doesn’t return right names. probably it should be #3

(@matanh)
Joined: 10 months ago

Posts: 0

how about version 1.5:

for c in modifier.classes collect if c.creatable then (c()).name else c.localizedname
 PEN

I remember poking at this years ago to try and get the names in a more efficient way and I couldn’t find one. I was either parsing strings or doing as you did Denis and make an instance of each to get the information. In the end it really didn’t mater as it only needed to run once to get all the data when the tool launched.