Hello,
I am looking for some piece of script which will select all scene objects with materials contains real-world scale maps.
Thank you very much for help.
Forum topic · Scripts Wanted
By arch3d · 2020-11-12
Hello,
I am looking for some piece of script which will select all scene objects with materials contains real-world scale maps.
Thank you very much for help.
try
id_ivan · 2020-11-26
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:trueBecause it use sceneMaterials, the file needs to be saved before running this script. Edit: Now it uses "textureMap" instead of "BitmapTexture"
Thank you very much!
arch3d · 2020-11-27
But i got error in line 4:
-- Unknown property: "maps"
Script will run with CoronaBitmap as well?
--
id_ivan · 2020-11-27
I forget that people dont use standardMaterial anymore. LOL.
Yes this works for coronaBitmap.
I change collection using object materials instead of sceneMaterials.
Will not work on any material class other than vrayMtl, CoronaMtl and standardMaterial.
(
function collectRealWorldMats = (
local mats = #(), rwMats = #()
for o in objects where o.material != undefined do appendIfUnique mats o.material
for mat in mats do (
case classof mat of (
standardMaterial:(
local maps = getproperty mat "Maps"
for m in maps where superclassof m == textureMap do (
if isproperty m.coords "realWorldScale" and m.coords.realWorldScale do (appendifunique rwMats mat)
)
)
default: (
for m=1 to mat.numsubs do (
if classof mat[m] == SubAnim and superclassof (tM = mat[m].object) == textureMap do (
if classof mat == coronaMtl and isproperty mat[m] "realWorldScale" and mat[m].realWorldScale do appendifunique rwMats mat
if classof mat == VrayMtl and isproperty mat[m].coords "realWorldScale" and mat[m].coords.realWorldScale do appendifunique rwMats mat
)
)
)
)
)
rwMats
)
mats = collectRealWorldMats()
objs = #()
for m in mats do (for o in objects where o.material == m do appendIfUnique objs o)
select objs
)Thanks again
arch3d · 2020-12-10
Sorry for late respond but i had no time to tests
If i save scene and try to use script nothing happens:(