Notifications
Clear all

[Closed] Editing Strings?

Ok i had a quick look in the max help.
Basically we have the naming convention

“M_house10_Standard” for an object/material

how would i go about editing the string after the last “_”

so id like ot change it to M_house10_DX9″

so either delete everything after the last “_”

OR search for “Standard” and replace with “DX9”

Thanks

3 Replies

ok give this a shot:

a = “M_house10_Standard”

b = filterstring a “_”
c = (b[1] as string) + (b[2] as string) + “DX9”

that should allow you to strip the standar from the string. if the name ia any longer then you would need to loop through the count of b and build a string that way:
C = “”
for i = 1 to (b.count-1)
do
(
C= C + (b[i] as string)
)
C = C + “DX9”

i think those should work. am working from memory here

This is ok but you loose the “_”, you can keep it by doing it this way:

a = “M_house10_Standard”
tmpArray = filterstring a “
newName = “”
for i=1 to (tmpArray.Count-1) do newName += tmpArray[i] + “

newName += “DX9”

If you prefer to search for Standard and replace it you can do it this way:

a = “M_house10_Standard”
idx = findstring a “Standard”
if idx != undefined then newString = (substring a 1 (idx-1)) + “DX9”

/Lui

Ok sweet, thanks for the help guys