Notifications
Clear all

[Closed] apply new diffusemap to every object

i have a bunch of objects i selected. i would like to apply a new diffuse map and opacity map to each object.
so for example:
plane1 will have diffusemap = image1.jpg and opacitymap = image1.jpg
plane2 will have diffusemap = image2.jpg and opacitymap = image2.jpg
plane3 will have diffusemap = image3.jpg and opacitymap = image3.jpg
…etc…

heres a code someone showed me, but i do not know where the diffusemap and opacity map goes.
any help please…

for o in selection do o.material = standard name:(o.name) diffuse:(random black white)

7 Replies

i got it

o.material.diffuseMap = Bitmaptexture fileName:imgpath
o.material.opacityMap = Bitmaptexture fileName:imgpath

any way to enable “show map in viewport” for each map?

 PEN

You might want to have a look at this script as it might do every thing that you need.

http://paulneale.com/scripts/autoMaterial/autoMaterial.htm

check out the showinviewport function used like this


 objs = getCurrentSelection()
 
 for o in objs do (
    try
 	  showInViewport o.material o.material.diffuseMap on
    catch()
 )
 
 

Thanks for the replies.
Paul Neale Has some helpful scripts. I will look through those.
MoonDoggie
I tried your script and It doesnt work.
I tried running the function outside of the “TRY” and I get:
– Type error: Call needs function or class, got: undefined

showTextureMap materialname on

currentlySelected = getCurrentSelection()
for obj in currentlySelected do (	
		try ( showTextureMap obj.material obj.material.diffuseMap on ) 
		catch ( )
)

I accidently referred you to showInViewport which is a custom function I wrote eons ago to do something similar. You want “showTextureMap”

here is the code, apologies.

-Colin