Method 1:
For I in objects do (-- determine whether it is a multi-dimensional material if (classof I. material = multimaterial) Then (-- traverse the sub-material ball (number) for numsubs = 1 to I. material. numsubs do (-- get the filename = getfilenamefile I of the current material ball color texture. material [numsubs]. diffusemap. filename -- Obtain the file type (. extension name) filetype = getfilenametype I. material [numsubs]. diffusemap. filename -- texture name = file name + suffix texname = filename + filetype -- remove the path name of the texture ball texture and only keep the name (relative path) of the texture. material [numsubs]. diffusemap. filename = texname) -- end of if else (filename = getfilenamefile I. material. diffusemap. filename filetype = getfilenametype I. material. diffusemap. filename texname = filename + filetype I. material. diffusemap. filename = texname) -- end of else) -- end of For Loop
Method 2:
For I in objects do (-- determine whether it is a multi-dimensional material if (classof I. material = multimaterial) Then (-- traverse the sub-material ball (number) for numsubs = 1 to I. material. numsubs do (-- obtain the full path of the current texture fullpath = I. material [numsubs]. diffusemap. filename -- splits the full path string and returns it to a collection of filtername = filterstring fullpath "\" -- the last element in the collection is the name of the current texture texname = filtername [filtername. count] -- remove the path name of the texture ball texture and keep only the name (relative path) of the texture. material [numsubs]. diffusemap. filename = texname) -- end of if else (fullpath = I. material. diffusemap. filename filtername = filterstring fullpath "\" texname = filtername [filtername. count] I. material. diffusemap. filename = texname) -- end of else) -- end of For Loop
How to Set relative paths