Suggestions / help on Show Diffuse in Viewport Script

Hi.

I 90% of the time name my maps in the diffuse slots with 'texmatnamehere_diffuse.ext'

I've wrote a script below which collects the scene materials and then collects the mats with only '_diffuse' in the filename and then shows them map/s in each associated material (it works with submats BTW).

I just would like any suggestions or help with the following please such as:

1. Is it easy to read a bitmap for colored values and then show texmap in the viewport and possibly ignore values like in normal maps and grey-scale obviously
2. Or just general scripting knowledge to help make the code/script better.

Thanks..

theMats = for i in scenematerials collect i
theMaps = getClassInstances bitmapTexture
thePattern = "*" + "diff" + "*"
theDiffuseMaps = for i in theMaps where matchpattern i.filename pattern:thePattern ignoreCase:false == true collect i
 
for o in theMats do (
-- enableHardwareMaterial o theMaps[5] true
	for i = 1 to theDiffuseMaps.count do try(showHWTextureMap o theDiffuseMaps[i] true)catch()
	for i = 1 to theDiffuseMaps.count do try(showTextureMap o theDiffuseMaps[i] true)catch()
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
3dwannab's picture

Thanks.

I think this script is limited to:
1. Specific render engine.
2. If say the bitmap is pluged into a Color Correct map in the diffuse slot it will not work as the bitmap is not directly in the slot.

I don't use or have VRay so don't have it installed to test.

Is no. 2 above true?

fajar's picture

maybe its better what

maybe its better what renderer u use....

sample for vray...

fn collectAllVrayMat selOnly:true = 
(
	local allVrayMat= #()
	if selOnly==true then
	(
		if selection.count!=0 do 
		(
			for i in selection where i.mat !=undefined do
			(
				join allVrayMat (getclassinstances VRayMtl target:(i.mat))
			)	
		)		
	)
	else
	(
		allVrayMat = getclassinstances VRayMtl processAllAnimatables:true processChildren:true
	)
	makeUniqueArray allVrayMat
)
 
fn showAllBitmapTexInMat selState:true shown:true =
(
	allBitmapTex=#()
	allVMat = collectAllVrayMat selOnly:selState -- return allVray material
	for i in allVMat where (getProperty i #texmap_diffuse != undefined)  do 
	(
              case shown of
                 (
                      true : (showTextureMap i on)
                      false : (showTextureMap i off)
                  )
	)
 
)
 
showAllBitmapTexInMat selState:true shown:true --false to not show maps

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.