[Closed] renaming standard-materials
Hi all
I’m trying to rename and reset the slots of the material editor.
if resetmateditor.checked == true then
(
matcount = meditMaterials.count
for i = 1 to matcount do
(
--matindex = i as string
meditMaterials[i] = standard()
)
resetmateditor.checked = false
)
The script renames all 24 slots of the MEditor but won’t set an index in front of the name.
e.g. My Max9 version is German and after starting Max, I got all materials named like “01 – Default” within the MEditor. After executing my script, all slots have the same name like “Standardmaterial”. I guess, the new name results in the translation of Max9. Uh, I hate the german version :argh:
Does anyone around have an idea on how I can modify the given slot names in a way that incremental indices are set and so on?
sry for my bad english,
toby
after assigning the new material ():
meditmaterials[i].name = (i as string + " - Default")
if resetmateditor.checked == true then
(
matcount = meditMaterials.count
for i = 1 to matcount do
(
--matindex = i as string
meditMaterials[i] = standard name: ("0" + i as string + " - Default Material")
)
resetmateditor.checked = false
)
Thank you m8
Found an option on these forums, while you were posting. This is my solution for now. Thank you very much anyway
…or does my solution have any disadvantages?
same thing. just in a different line. if you want more code you could check your nubberpadding. there are probably more stylish methods to do it, but as an idea:
(
matcount = meditMaterials.count
for i = 1 to matcount do
(
countString = i as string
while countString.count < 2 do (countString = "0" + countString)
meditMaterials[i] = standard name: (countString + " - Default Material")
)
)
Great suggestion so far.
Just a small optimization I did…
I replaced this one:
matcount = meditMaterials.count
for i = 1 to matcount do
with this:
for i = 1 to meditMaterials.count do
Not much more performance, but shorter than the expression above. On bigger projects, short expressions might save performance
Actually your first version where you use matcount = will have better performance. As noted in the Maxscript reference in the “How To Make It Faster?” section storing values in variables is faster as that is called once and stored in memory, instead of evaluating every time though.
-Eric