Generate random string:
fn generateRandString length symb:false = (
local chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", result = "", symbol = "~!@#$%^&*()_+:<>?"
chars = if symb then append chars symbol else chars; charsC = chars.count
for i=1 to length do (result += substring chars (random 1 charsC) 1)
result
)
/* -- example:
generateRandString 64
-- "mrnn0flR2Vx4KWoM77qxKqEATn131PGVDnL4ukmEXArcPcyV72KjgjLAgpTdbRxY"
generateRandString 64 symb:true
-- "ITiZK~Nk1SVHr#G7@fhV$))8a%:)+6Gm(KlV$*J7mbvH~AnA+Va@>+RlifoK3q^9"
*/
<integer>length: generated string length
<boolean>symb: Use symbol. Default is false
Collect materials with realworld UV’s. Link
function collectRealWorldMats savetoFile:False = (
rwMats = materialLibrary()
for mat in sceneMaterials do (
local maps = getproperty mat "Maps"
for m in maps where superclassof m == textureMap do (
try ( if getproperty m.coords "realWorldScale" != undefined do ( if m.coords.realWorldScale do (appendifunique rwMats mat) ) ) catch()
)
)
if rwMats.count > 0 do (
if savetoFile then (
-- save these materials to C:\Users\User\AppData\Local\Autodesk\3dsMax\2013 - 64bit\ENU\temp\realWorldMats.mat
local rwMatsFile = getdir #temp + "\\realWorldMats.mat"
saveTempMaterialLibrary rwMats rwMatsFile
) else (for m in rwMats do print m.name) -- or simply output to listener
-- select objects with these mats
objs = #(); for m in rwMats do (for o in objects where o.material == m do append objs o)
select objs
)
rwMats
)
collectRealWorldMats()
-- or if you want to save to realWorldMats.mat
-- collectRealWorldMats savetoFile:true
<boolean>savetoFile: Save collected materials to file. Default:false
Array to string with tabbed format
fn arrToStringFormat arr str:"#(\n" tab:1 = (
local tb = "\t", tn = "\r\n", ts = "#(", te = ")", tc = ",", t = ""
for f=1 to tab do t += tb
for i=1 to arr.count do (
if classof arr[i] == array then (
if i == 1 then tab += 1
str += t + ts + tn
str = arrToStringFormat arr[i] str:str tab:tab
str += t + te + (if i == arr.count then "" else tc) + tn
) else (
arr[i] = "\"" + arr[i] + "\""
str += t + arr[i] + (if i == arr.count then "" else tc) + tn
if i == 1 then tab += 1
)
)
str
)
<string>arrToStringFormat arr<array>. Usage: (arrToStringFormat arr) + “)”.
End parentheses need to add manually or use in a wrapper like fn arrToStringWrapper arr = ((arrToStringFormat arr) + “)”).