[Closed] How to show it up?
Hey everyone:
An issue puzzled me so long:
There’re some models in the scene, and one of them didn’t have textures,or were applied the empty materials, i want to find out them by the script.
My script can only find out those models have no material applied, but when some models have applied one material ball without texture it couldn’t be find out.
Where the wrong was?
rollout selectnomat "UnmaterialsObj"
(
button click1 "check" height:30 width:100
fn selectUnMaterialObj =
(
clearSelection()
num=0
for obj in geometry where obj.material==undefined do (num+=1;selectMore obj)
pushPrompt (num as string+" objects have no material")
)
on click1 pressed do
(
selectUnMaterialObj()
)
)
newroll=newrolloutfloater "selectnomat" 200 80
addrollout selectnomat newroll
Hi perfectboy,
your script checks only if a material is applied to an object regardless of material maps.
If you want to select objects that have applied materials without any map, you should check for them. The following modified code has one check added to the diffuse channel of the material. It collects objects without any material assigned or without any map in the diffuse channel.
rollout selectnomat "UnmaterialsObj"
(
button click1 "check" height:30 width:100
fn selectUnMaterialObj =
(
clearSelection()
num = 0
for obj in geometry where ((obj.material == undefined) or (obj.material.diffuseMap == undefined)) do (num += 1; selectMore obj)
pushPrompt (num as string + " objects have no material")
)
on click1 pressed do
(
selectUnMaterialObj()
)
)
newroll = newrolloutfloater "selectnomat" 200 80
addrollout selectnomat newroll
You can check for other channels too. Look at “StandardMaterial : Material” in the MaxScript reference.
- Enrico
OhHo“`Enrico, i have solved the problem with you help.And i looked the reference earnest.
Thank you very much !
Looping through the geometry array might not be the best idea because if you have an renderable spline that has no material applied to it, it won’t be selected. So traversing “objects” will be better for this. Also, I’ve slimmed it down a bit, take a look, plus it’s faster.
rollout selectnomat "UnmaterialsObj" (
button click1 "check" height:30 width:100
fn selectUnMaterialObj = (
objArr = for o in objects where o.material == undefined collect o
pushPrompt (objArr.count as string+" objects have no material.")
select objArr
)
on click1 pressed do (
clearSelection()
selectUnMaterialObj()
)
)
newroll=newrolloutfloater "selectnomat" 200 80
addrollout selectnomat newroll
hope it helps.
-Colin