PDA

View Full Version : get list of all modifiers


floyd1510
07-26-2011, 03:09 AM
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.

PiXeL_MoNKeY
07-26-2011, 03:28 AM
From the maxscript help (http://docs.autodesk.com/3DSMAX/14/ENU/MAXScript%20Help%202012/files/GUID-879ECFAD-7928-44B3-BCD7-276D53C89B5-528.htm):showClass "*:mod*" -- all the modifier classesIf 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
)

floopyb
07-26-2011, 04:01 AM
also:
modArr = sort (for i in modifier.classes collect i as string)

PiXeL_MoNKeY
07-26-2011, 04:07 AM
Oh sure come in here being all efficient and tidy with your code. :-P

-Eric

floopyb
07-26-2011, 04:18 AM
Oh sure come in here being all efficient and tidy with your code. :-P

-Eric

;)

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

denisT
07-26-2011, 04:31 AM
;)

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?

lucpet
07-26-2011, 04:32 AM
also:
modArr = sort (for i in modifier.classes collect i as string)

: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
07-26-2011, 04:33 AM
;)

Although I dont think my version will give you names exactly as they appear in the list like yours doesThat 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

PiXeL_MoNKeY
07-26-2011, 04:36 AM
:shrug: Why does this only give you a limited array and end in ,.... when there are obviously more modifiersLook up "printallelements (http://docs.autodesk.com/3DSMAX/14/ENU/MAXScript%20Help%202012/files/GUID-92B98D11-60FF-4742-A1BA-692EE135E08-459.htm)" in the maxscript help.

-Eric

denisT
07-26-2011, 04:37 AM
Again it needs to be a try/catch as some of the classes aren't creatable through maxscript and will throw an error...
-Eric
for this case it should be another property creatable or iscreatable

lucpet
07-26-2011, 04:49 AM
From the maxscript help (http://docs.autodesk.com/3DSMAX/14/ENU/MAXScript%20Help%202012/files/GUID-879ECFAD-7928-44B3-BCD7-276D53C89B5-528.htm):showClass "*:mod*" -- all the modifier classesIf 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
)

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

lucpet
07-26-2011, 04:52 AM
Look up "printallelements (http://docs.autodesk.com/3DSMAX/14/ENU/MAXScript%20Help%202012/files/GUID-92B98D11-60FF-4742-A1BA-692EE135E08-459.htm)" in the maxscript help.

-Eric

Thanks Eric

denisT
07-26-2011, 05:08 AM
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

PiXeL_MoNKeY
07-26-2011, 05:12 AM
That doesn't seem right as thisPrint 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

floopyb
07-26-2011, 05:44 AM
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


both work... version 2 seems to give better names ("PhysX Rigid Body" rather than "PhysXModRB")

denisT
07-26-2011, 05:59 AM
both work... version 2 seems to give better names ("PhysX Rigid Body" rather than "PhysXModRB")
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 ;)

PEN
07-26-2011, 01:19 PM
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.

MatanH
07-26-2011, 01:28 PM
both work... version 2 seems to give better names ("PhysX Rigid Body" rather than "PhysXModRB")

how about version 1.5:

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

CGTalk Moderation
07-26-2011, 01: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.