detect scene texture -- please answer!!!

I've found some ideas here:
http://forums.cgsociety.org/archive/index.php/t-1028393.html :

gc() -- just for this example, to make sure everything is nice and clean
 
-- find the scene root. The rootnode, medit, etc are references off this scene root
sceneroot = (for r in (refs.dependents rootnode) where (classof r == Scene) collect r)[1]
 
-- collect all the assets
origAssets = for i = 1 to AssetManager.GetNumAssets() collect (AssetManager.GetAssetByIndex i)
 
-- for each of the assets...
for AUIO in origAssets do
(
-- dump info on the asset
local AID = AUIO.GetAssetId() --get the Asset�s ID
local AType = AUIO.getType() --get the Asset�s Type
local AFile = AUIO.getfilename() --get the Asset�s File Name
format "ID:% Type:% File:%\n" AID AType AFile --format the info
-- generate new filename, prepend "XXXX_"
local lFile = filenameFromPath AFile
local lPath = getFileNamePath AFile
local lNewName = lPath + "\\" + "XXXX_" + lFile
-- do the retargetting
atsops.RetargetAssets sceneroot AFile lNewName CreateOutputFolder:false
)

and here:

http://www.scriptspot.com/forums/3ds-max/general-scripting/resource-get-...

fn GetBitmapTextures theObjects =
(
	-- Because some submaps can also contain submaps we have to collect materials first, and then still append subMapContainers in the loop bitmapTextureMaps loop
	subMapContainers = #()
	for obj in theObjects do
	(
		if obj.material != undefined then
		(
			submatcount = getNumSubMtls obj.material
			for i in 1 to submatcount do
			(
				append subMapContainers (getSubMtl obj.material i)
			)
			append subMapContainers (obj.material)
		)
	)
	bitmapTextureMaps = #()
	for subMapContainer in subMapContainers do
	(
		subtexcount = getNumSubTexmaps subMapContainer
		for i in 1 to subtexcount do
		(
			theSubTexMap = (getSubTexMap subMapContainer i)
			if theSubTexMap != undefined then
			(
				if (getNumSubTexmaps theSubTexMap) > 0 then
				(
					append subMapContainers theSubTexMap
				)
				else if classof theSubTexMap == bitmapTexture then
				(
					append bitmapTextureMaps theSubTexMap
				)
			)
		)
	)
	makeUniqueArray bitmapTextureMaps
)

texmaps = (GetBitmapTextures selection)
for texmap in texmaps do print (texmap.filename)

Here is how I detect textures inside materials for the selected objects:

		for s in selection do		
		(
			--textID = 0
			if s.material!=undefined then
			(
				if (finditem uniquematerials s.material==0) do
				(
					append uniquematerials s.material
					newbitmaps=getclassinstances Bitmaptexture target:s.material
				)
			)
		)

I don't use this code:

	fn getmapsfromselection = 
	(
		for s in selection do 
		(
			if s.material!=undefined then 
			(
				newbitmaps=getclassinstances Bitmaptexture target:s.material
                    		for b in newbitmaps do 
					if (finditem bitmaps_for_selection b==0) then append bitmaps_for_selection b
			)
		)
         )

because I need to investigate the materials for map tree, id and so on.

Now the question is:
1. Is the code I have enough and correct for detecting textures inside material?
2. How to detect the textures inside modifiers for the selected objects?
3. How to detect textures used in any other places(sky, hdr etc)
4. How to detect all scene textures
5. How to detect unused textures!

Please answer!!!

Comments

Comment viewing options

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

wow

they look wonderful! You're a great specialist!

artrender.info's picture

Thx Barigazy!

I will try and I will let you know how it works later!!!
I'm working now with buttons that you told me to use! I'm starting to understand how they work! It's very interesting! But what kind of architecture you do, may I see some of your portfolio projects?

barigazy's picture

:)

I prepare my site when I have free time.
Here a post some images for John script Cobwebs http://jokermartini.com/2012/05/09/cobwebs/ (named by Branko Zivkovic)
I will send you a few links in PM.

barigazy

artrender.info's picture

Thx, I know how to detect missing files!

The question is:

I download often 3d models from internet with missing files inside scene. There are cases when some textures are important for the object, but there are situations when a scene had missing textures from other objects, but when save/selected there were saved missing paths for those unused files from objects that are not in the new scene anymore! How do you get rid of them?

I thought to make smth like this:

1 find textures used in all hidden and unhidden models (material and modifiers)
2 find textures used in lights
3 find textures used in environment map
4 after these find textures from all scene and those textures that are not mentioned in first 3 situations - are unused--it means I can delete them somehow(I don't know how)

Am I right or not?

barigazy's picture

...

U can delete missing maps:
Find all materials and props that have theses maps (create multidimensional array)

--example
tempArr = #(#($Box001.material, #DiffuseMap),#($.Cone001.material, #BumpMap))
for i = 1 to tempArr.count do setproperty tempArr[1] tempArr[2] undefined
--how to delete only unused mtl in M.Editor
for i in 1 to meditMaterials.count where (MeditUtilities.isMaterialInUse meditMaterials[i] == false) do meditMaterials[i] = Standard()
--Sometime asset tracking hold path strings
ATSOps.Refresh()
--is good to use this function at the end
freeSceneBitmaps()

Also slate M.Editor can hold materials
Look these thread for some useful infos how to acess
http://www.scriptspot.com/forums/3ds-max/general-scripting/how-to-loop-t...

barigazy

artrender.info's picture

Barigazy

Take a look to this max file! How to detect the location of its 2 missing files? and how to clean them?

By the way, Buttons started to work as I want, just remained to update location when scrolling, but I know how to do this.

Take a look please to this max file!

AttachmentSize
3ddd1366191879.rar 6.59 MB
barigazy's picture

...

I can't remeber what more can cause problems, maybe someone have better idea?

barigazy

barigazy's picture

I and fajar are not

I and fajar are not programmers but architects.
Yup. I forget Vojtech Cada. Great guy.
And he answered here http://forums.cgsociety.org/showthread.php?f=98&t=1098017&highlight=miss...
http://www.scriptspot.com/forums/3ds-max/general-scripting/missing-files
I this not enough to solve problem then post snippet that not understand

barigazy

artrender.info's picture

I LOVE this website, because here you can find GREAT PEOPLE

I would mention also Swordslayer! He is also a very great programmer and knows very very deep how maxscript works!

I LOVE YOU ALL!!!

By the way, I've found sometime ago a script which could delete missing textures, and I can't find again!

How to detect unused files, because in ZOA path editor it's difficult to understand!

fajar's picture

never to think that you use

never to think that you use getprop names, I only using getpropname for collecting ies, ...hahah, i guest I must need train tooo....btw barigazy has you even try your script that collecting material by that ways, it look like to its heavy compute if I must loop thru' every material thru' every property in every material in every object , say if I had 500 obj in different material...cause it compute loop in loop....btw I'll try your script tommorow in much more object scene with many material. But I must say its good thing other than using getClassInstance....

Comment viewing options

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