how to find out map type of a texture
for m in bitmaps do
(
print m.?????????
)
when I use print bitmaps
I get
name1:Bitmap
name2:Bitmap
But I need
DIFFUSE
BUMP
Forum topic · General Scripting
By artrender.info · 2013-02-09
how to find out map type of a texture
for m in bitmaps do
(
print m.?????????
)
when I use print bitmaps
I get
name1:Bitmap
name2:Bitmap
But I need
DIFFUSE
BUMP
artrender.info · 2013-02-16
add me to your skype! My skype name is also artrender.info
I need to go out, but when I come, I will ask you about payment methods!
Thank you, you really deserve money for your knowledge!
How much to pay!!!!!
artrender.info · 2013-02-16
I need instead of
Texture: \\S003\all\3d\maps\maps\6_3_9_D.jpg
MAP TREE: Multimaterial\Blend\Multimaterial\Diffuse\Color_Correction\
only
Base material Multimaterial
Texture: \\S003\all\3d\maps\maps\6_3_9_D.jpg
MAP TREE: Blend\Multimaterial\VrayMtl\Diffuse\Color_Correction\
Everything else works fine!!!!
Swordslayer · 2013-02-16
(
struct matDef (mat, path)
local getSubmats, subMats = #()
fn capitalizeFirst str =
toUpper str[1] + subString str 2 -1
fn formatName mat index: =
if isKindOf mat TextureMap OR index == unsupplied then
capitalizeFirst ((classOf mat) as string) + "\\"
else (substituteString (getSubTexmapSlotName mat index) " map" "") + "\\"
fn getSubmatsRecurse mat matInst path:"" =
for propName in (getPropNames mat) do
(
local prop = getProperty mat propname
if superClassOf prop == Material then
getSubmats prop path:path \
format:(capitalizeFirst (propname as string) + "\\" + formatName prop)
else if classOf prop == ArrayParameter do
for sub = 1 to prop.count where superClassOf prop[sub] == Material do
getSubmats prop[sub] path:path \
format:("Map" + sub as string + "\\" + formatName prop[sub])
)
fn getSubmats mat path:"" format:"" =
(
local matInst = matDef mat:mat path:(path + format)
append subMats matInst
getSubmatsRecurse mat matInst path:(path + format)
subMats
)
fn recurseMat mat path:"" =
for i = 1 to (getNumSubTexmaps mat)
where (local map = getSubTexmap mat i) != undefined do
if getNumSubTexmaps map > 0 then
recurseMat map path:(path + formatName mat index:i)
else if isKindOf map BitmapTexture do
(
format "Texture: %\n" map.filename
format (path + formatName mat index:i + "\n\n")
)
local current_mtl = mEdit.getCurMtl()
local subMatInsts = getSubmats current_mtl
format "\nBase material: %\n\n" (classOf current_mtl)
for matInst in subMatInsts do
recurseMat matInst.mat path:("MAP TREE: " + matInst.path)
)
Swordslayer · 2013-02-16
That's what happens when I drop a single argument.. oh well, another iteration:
(
struct matDef (mat, path)
local getSubmats, subMats = #()
fn capitalizeFirst str =
toUpper str[1] + subString str 2 -1
fn formatName mat index: =
if isKindOf mat TextureMap OR index == unsupplied then
capitalizeFirst ((classOf mat) as string) + "\\"
else (substituteString (getSubTexmapSlotName mat index) " map" "") + "\\"
fn getSubmatsRecurse mat matInst path:"" =
for propName in (getPropNames mat) do
(
local prop = getProperty mat propname
if superClassOf prop == Material then
getSubmats prop path:path
else if classOf prop == ArrayParameter do
for sub in prop where superClassOf sub == Material do
getSubmats sub path:path
)
fn getSubmats mat path:"" =
(
local matInst = matDef mat:mat path:path
append subMats matInst
getSubmatsRecurse mat matInst path:(path + formatName mat)
subMats
)
fn recurseMat mat path:"" =
for i = 1 to (getNumSubTexmaps mat)
where (local map = getSubTexmap mat i) != undefined do
if getNumSubTexmaps map > 0 then
recurseMat map path:(path + formatName mat index:i)
else if isKindOf map BitmapTexture do
(
format "Texture: %\n" map.filename
format (path + formatName mat index:i + "\n\n")
)
local current_mtl = mEdit.getCurMtl()
local subMatInsts = getSubmats current_mtl
format "\nBase material: %\n\n" (classOf current_mtl)
for matInst in subMatInsts do
recurseMat matInst.mat path:("MAP TREE: " + matInst.path)
)I want to make such a script:
artrender.info · 2013-02-16
smth like in image
for every ID it's texture paths with it's collor range in bg
I will pay
artrender.info · 2013-02-16
tell me how much!
Thx but smth missing
artrender.info · 2013-02-16
results:
Base material: Multimaterial
Texture: \\S003\all\3d\maps\maps\6_3_9_D.jpg
MAP TREE: Multimaterial\Diffuse\Color_Correction\
Texture: \\S003\all\3d\maps\maps\6_3_9_S.jpg
MAP TREE: Multimaterial\VRayMtl\
Texture: \\S003\all\3d\maps\maps\6_3_9_B.jpg
MAP TREE: Multimaterial\VRayMtl\
Texture: \\S003\all\3d\maps\maps\6_3_9_S.jpg
MAP TREE: Multimaterial\VRayMtl\
Texture: \\S003\all\3d\maps\maps\6_3_9_D.jpg
MAP TREE: Multimaterial\VRayMtl\
in other vrayMtl diffuse, bump reflection etc
close to finish
artrender.info · 2013-02-16
I've excluded the word map inside "diffuse map" "bump map" etc,
(
struct matDef (mat, path)
local subMats = #()
fn capitalizeFirst str =
toUpper str[1] + subString str 2 -1
fn formatName mat index: =
if isKindOf mat TextureMap OR index == unsupplied then
capitalizeFirst ((classOf mat) as string) + "\\"
else (substituteString (getSubTexmapSlotName mat index) " map" "") + "\\"
fn getSubmatsRecurse mat matInst path:"" =
for propName in (getPropNames mat) do
(
local prop = getProperty mat propname
if superClassOf prop == Material do
(
local matInst = matDef mat:prop path:path
append subMats matInst
getSubmatsRecurse prop matInst path:(path + formatName prop)
)
if classOf prop == ArrayParameter do
for sub in prop where superClassOf sub == Material do
(
local matInst = matDef mat:sub path:path
append subMats matInst
getSubmatsRecurse sub matInst path:(path + formatName sub)
)
)
fn getSubmats mat =
(
local matInst = matDef mat:mat path:""
append subMats matInst
getSubmatsRecurse mat matInst path:(formatName mat)
subMats
)
fn recurseMat mat path:"" =
for i = 1 to (getNumSubTexmaps mat)
where (local map = getSubTexmap mat i) != undefined do
if getNumSubTexmaps map > 0 then
recurseMat map path:(path + formatName mat index:i)
else if isKindOf map BitmapTexture do
(
format "Texture: %\n" map.filename
format (path + (substituteString (getSubTexmapSlotName mat i) " map" "") + "\\\n\n")
)
local current_mtl = mEdit.getCurMtl()
local subMatInsts = getSubmats current_mtl
format "\nBase material: %\n\n" (classOf current_mtl)
for matInst in subMatInsts do
recurseMat matInst.mat path:("MAP TREE: " + matInst.path)
)
the result:
Texture: \\S003\all\3d\maps\maps\6_3_9_D.jpg
MAP TREE: Multimaterial\Blend\Multimaterial\Diffuse\Map\
but I still can't figure out how to put color corect instead of "Map"
It worked in your second script that you wrote at 1st page. - here:
(
local bitmaps = getClassInstances BitmapTexture
fn capitalizeFirst str =
(
str[1] = toUpper str[1]
str
)
fn getTopMats sub =
for item in refs.dependents sub
where isKindOf item Material collect item
fn recurseMats mats map previous:#() =
for mat in mats do
for i = 1 to (getNumSubTexmaps mat)
where getSubTexmap mat i == map do
(
local topMats = getTopMats mat
if topMats.count > 0 then
recurseMats topMats mat previous:(join #(capitalizeFirst ((classOf mat) as string) + "/" + getSubTexmapSlotName mat i) previous)
else
(
format "\tSlot name: %" (substituteString (getSubTexmapSlotName mat i) " map" "")
for each in previous do format "/%" each
format "\n"
)
)
for bmp in bitmaps do
(
local mats = getTopMats bmp
format "\nTexture: %\n" bmp.filename
recurseMats mats bmp
)
)
Swordslayer · 2013-02-16
Yeah, my fault:
(
struct matDef (mat, path)
local getSubmats, subMats = #()
fn capitalizeFirst str =
toUpper str[1] + subString str 2 -1
fn formatName mat index: =
if isKindOf mat TextureMap OR index == unsupplied then
capitalizeFirst ((classOf mat) as string) + "\\"
else (substituteString (getSubTexmapSlotName mat index) " map" "") + "\\"
fn getSubmatsRecurse mat matInst path:"" =
for propName in (getPropNames mat) do
(
local prop = getProperty mat propname
if superClassOf prop == Material then
getSubmats prop path:path
else if classOf prop == ArrayParameter do
for sub in prop where superClassOf sub == Material do
getSubmats sub path:path
)
fn getSubmats mat path:"" =
(
local matInst = matDef mat:mat path:path
append subMats matInst
getSubmatsRecurse mat matInst path:(path + formatName mat)
subMats
)
fn recurseMat mat path:"" =
for i = 1 to (getNumSubTexmaps mat)
where (local map = getSubTexmap mat i) != undefined do
if getNumSubTexmaps map > 0 then
recurseMat map path:(path + formatName mat index:i)
else if isKindOf map BitmapTexture do
(
format "Texture: %\n" map.filename
format (path + formatName mat + "\n\n")
)
local current_mtl = mEdit.getCurMtl()
local subMatInsts = getSubmats current_mtl
format "\nBase material: %\n\n" (classOf current_mtl)
for matInst in subMatInsts do
recurseMat matInst.mat path:("MAP TREE: " + matInst.path)
)hurraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay, yay
artrender.info · 2013-02-16
I'm so glad that you helped me! HUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUGS! Finallllllllllyyyyyyyyyyyy! I will just try to exclude the word map and to put color corect inside
Texture: \\S003\all\3d\maps\maps\6_3_9_D.jpg
MAP TREE: Multimaterial\Blend\Multimaterial\Diffuse map\Map\
where diffuse map\Map\
has to be Diffuse\Color_corect
I'm not sure that I can but I will really try
but everything else works perfectly!
Thank you Swordslayer! I will give you this plugin that I'm making now, and your name will be there like a very GOOD supporter!
Swordslayer · 2013-02-16
Glad to be of assistance :)
Swordslayer · 2013-02-16
This is some really horrible code but it might work:
(
struct matDef (mat, path)
local getSubmats, subMats = #()
fn capitalizeFirst str =
toUpper str[1] + subString str 2 -1
fn formatName mat index: =
if isKindOf mat TextureMap OR index == unsupplied then
capitalizeFirst ((classOf mat) as string) + "\\"
else (getSubTexmapSlotName mat index) + "\\"
fn getSubmatsRecurse mat matInst path:"" =
for propName in (getPropNames mat) do
(
local prop = getProperty mat propname
if superClassOf prop == Material then
getSubmats prop path:path
else if classOf prop == ArrayParameter do
for sub in prop where superClassOf sub == Material do
getSubmats sub path:path
)
fn getSubmats mat path:"" =
(
local matInst = matDef mat:mat path:path
append subMats matInst
getSubmatsRecurse mat matInst path:(path + formatName mat)
subMats
)
fn recurseMat mat path:"" =
for i = 1 to (getNumSubTexmaps mat)
where (local map = getSubTexmap mat i) != undefined do
if getNumSubTexmaps map > 0 then
recurseMat map path:(path + formatName mat index:i)
else if isKindOf map BitmapTexture do
(
format "Texture: %\n" map.filename
format (path + getSubTexmapSlotName mat i + "\\\n\n")
)
local current_mtl = mEdit.getCurMtl()
local subMatInsts = getSubmats current_mtl
format "\nBase material: %\n\n" (classOf current_mtl)
for matInst in subMatInsts do
recurseMat matInst.mat path:("MAP TREE: " + matInst.path)
)No idea why refs.dependsOn doesn't work in some cases, in the end I had to switch to the previous implementation you've posted before.
we need to integrate somehow this function
artrender.info · 2013-02-15
Find all submaterials in one mat, but unfortunately it is also limited, not going deep enough!!! And after finding the last submaterial, it is possible to use your code that works for any materials without submaterials
fn All_Submats onematerial =
(
Propertieses = (getPropNames onematerial)
for SubProp in Propertieses do
(
if isProperty onematerial SubProp == true do
(
Insert = getproperty onematerial SubProp
if superclassof Insert == material do
(
append All_SubMaterials Insert
All_Submats Insert
)
if classof Insert == ArrayParameter do
(
for i in Insert do if superclassof i == material do
(
append All_SubMaterials i
All_Submats i
)
)
)
)
)
hmm...
Anubis · 2013-02-16
Who wrote this function?
And how you using it?
I see that it's a recursive function but... it store the result in
All_SubMaterials(that s'd be array), but this variable is not a part of this function (not defined inside, nor yet passed as argument). So that mean, that this function will work properly only if you define array variable with exact the same name before calling the function. In other words:
All_SubMaterials = #()
All_Submats some_materailI found it in materialselector_2
artrender.info · 2013-02-16
sorry for this if smth !!!!
Swordslayer · 2013-02-16
This is shorter and does the same:
subMats = #()
fn getSubmats mat =
for sub in (refs.dependsOn mat)
where isKindOf sub Material AND NOT isKindOf sub TextureMap do
(
append subMats sub
getSubmats sub
)Anyway, I don't think it's a good idea to work from top to bottom and then back again... Have a look at my previous reply, it's certainly not universal and handles Blend material and Multisub material separately (obviously you'd have to add any other material type that can contain other materials - but there are not really that many cases).
Thanks
artrender.info · 2013-02-16
I've wrote the code to find submaterials inside composite material
if isKindOf current_mtl compositematerial then
for m in current_mtl.materialList do
if m!=undifined then
print m
Thanks, Swordslayer, YOU ARE A GREAT MAN!!!!
artrender.info · 2013-02-15
You answer is very GOOD and your code works perfectly! I could not even imagine how to do this! And thank you that you found time to think about this problem.
The only thing is that it does not work now for multisubobject materials, or composite, or blend material(those materials which contain submaterials) - I tried your first code for detecting MAP TREE in ActiveSlot in MTLEDITOR:
fn getmapsfrommateditor =
(
current_mtl=medit.getcurmtl()
print (classOf current_mtl)
current_mtl_slot=medit.GetActiveMtlSlot()
bitmaps_for_selection=getClassInstances Bitmaptexture target:current_mtl
for bmp in bitmaps_for_selection do
(
local mats = for item in refs.dependents bmp where isKindOf item Material collect item
format "\nTexture: %\n" bmp.filename
for mat in mats do
for i = 1 to (getNumSubTexmaps mat)
where getSubTexmap mat i == bmp do
format "\tSlot name: %\n" (getSubTexmapSlotName mat i)
)
)
and it's working well! I have in my slot Multisubobject Material with 3 sub vraymtl's. I get this answer in listener:
Multimaterial
Texture: \\S003\all\3d\maps\maps\6_3_9_D.jpg
Slot name: Map
Texture: \\S003\all\3d\maps\maps\6_3_9_S.jpg
Slot name: Reflect map
Texture: \\S003\all\3d\maps\maps\6_3_9_B.jpg
Slot name: Bump map
Texture: \\S003\all\3d\maps\maps\6_3_9_S.jpg
Slot name: Refl. gloss.
Texture: \\S003\all\3d\maps\maps\6_3_9_D.jpg
Slot name: Diffuse map
Texture: \\S003\all\3d\maps\maps\6_3_9_S.jpg
Slot name: Reflect map
Texture: \\S003\all\3d\maps\maps\6_3_9_B.jpg
Slot name: Bump map
Texture: \\S003\all\3d\maps\maps\6_3_9_S.jpg
Slot name: Refl. gloss.
Texture: \\S003\all\3d\maps\maps\6_3_8_D.jpg
Slot name: Diffuse map
Texture: \\S003\all\3d\maps\maps\6_3_7_R.jpg
Slot name: Reflect map
Texture: C:\VMPP\maps\6_3_1_B.jpg
Slot name: Color 1
Texture: C:\VMPP\maps\6_2_6_B.jpg
Slot name: Color 2
When I get inside 1st VrayMTL, I get this answer:
VRayMtl
Texture: \\S003\all\3d\maps\maps\6_3_9_D.jpg
Slot name: Map
Texture: \\S003\all\3d\maps\maps\6_3_9_S.jpg
Slot name: Reflect map
Texture: \\S003\all\3d\maps\maps\6_3_9_B.jpg
Slot name: Bump map
Texture: \\S003\all\3d\maps\maps\6_3_9_S.jpg
Slot name: Refl. gloss.
And this is typically what I need + submaterials tree + submaps tree:
Base material: Multimaterial
Texture: \\S003\all\3d\maps\maps\6_3_9_D.jpg
MAP TREE: VRayMtl\Diffuse\Color_Correction\
or
Base Material:BlendMTl
Texture: \\S003\all\3d\maps\maps\6_3_9_D.jpg
MAP TREE: Material1:VrayMtl\Diffuse\Color_Correction\
Texture: \\S003\all\3d\maps\maps\6_3_8_D.jpg
MAP TREE: Material2:VrayMtl\Diffuse\
Your second code is very POWERFUL. It's working great for Materials which does not contain submaterials. For a material with no submaterials I get very fine result:
Texture: \\S003\work_s003\Projects_2012\Project 86 Yukki Lesha\Textures\texture_wood_2.jpg
Slot name: Diffuse/Color_Correction/Map
Texture: \\S003\work_s003\Projects_2012\Project 86 Yukki Lesha\Textures\texture_wood_1.jpg
Slot name: Reflect/Mix/Mix Amount
or
Texture: \\S003\work_s003\Projects_2012\Project 86 Yukki Lesha\Textures\texture_wood_1.jpg
Slot name: Bump
Texture: \\S003\work_s003\Projects_2012\Project 86 Yukki Lesha\Textures\texture_wood_1.jpg
Slot name: Refl. gloss./Mix1
but for other materials I get no answer :(
Texture: C:\VMPP\maps\6_3_1_B.jpg
Texture: C:\VMPP\maps\6_2_6_B.jpg
Texture: \\S003\all\3d\maps\maps\6_3_9_D.jpg
Texture: \\S003\all\3d\maps\maps\6_3_9_S.jpg
Texture: \\S003\all\3d\maps\maps\6_3_9_B.jpg
Texture: \\S003\all\3d\maps\maps\6_3_9_S.jpg
We need to combine them somehow!
Swordslayer · 2013-02-16
Is this the way you intend to use it? If that is so, it could have saved a lot of hassle had you said this in the original post... Getting the material tree going from the lowest level up is way harder than going the other way round:
(
fn capitalizeFirst str =
toUpper str[1] + subString str 2 -1
fn formatName mat index =
if isKindOf mat TextureMap then
capitalizeFirst ((classOf mat) as string) + "\\"
else (getSubTexmapSlotName mat index) + "\\"
fn recurseMat mat previous:"" =
for i = 1 to (getNumSubTexmaps mat)
where (local map = getSubTexmap mat i) != undefined do
if getNumSubTexmaps map > 0 then
recurseMat map previous:(previous + formatName mat i)
else if isKindOf map BitmapTexture do
(
format "Texture: %\n" map.filename
format (previous + getSubTexmapSlotName mat i + "\\\n\n")
)
fn parseMat mat format:"MAP TREE: " =
if isKindOf mat Blend then
(
recurseMat mat previous:format
if mat.map1 != undefined do parseMat mat.map1 \
format:(format + "Material1:" + (classOf mat.map1) as string + "\\")
if mat.map2 != undefined do parseMat mat.map2 \
format:(format + "Material2:" + (classOf mat.map2) as string + "\\")
)
else if isKindOf mat MultiMaterial then
for subMat in mat do
recurseMat subMat previous:(format + (classOf subMat) as string + "\\")
else recurseMat mat previous:format
local current_mtl = medit.getcurmtl()
format "\nBase material: %\n\n" (classOf current_mtl)
parseMat current_mtl
)THANKS Swordslayer! You're really perfect scripter
artrender.info · 2013-02-16
This Script is much better!
But how to make it work for all materials, for example, if we have inside multimaterial blend mtl - then it skips it at all!
or if we have composite material, it does not work! This should be Universal! Where we have
else if isKindOf mat MultiMaterial then
for subMat in mat do
recurseMat subMat previous:(format + (classOf subMat) as string + "\\")
it should recall somehow
if isKindOf mat Blend
and all other mtl types
We need smth recursive - material in material in material...
while
( material contains submaterial) do
And it's very interesting that if I have a vrayLightmtl inside multimaterial then it's showing all it's textures, but if we have blend or composite, override etc it doesn't! I'm really stupid at this! I need to test 3 months to make it work by myself!
THANK YOUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU!
artrender.info · 2013-02-13
IT's working very well, the only thing is that when I use it I get
Slot name: Map 1
Slot name: Mask
Slot name: Radius
Slot name: Occluded
Slot name: Diffuse map
Slot name: Bump map
Slot name: Refl. gloss.
Slot name: Reflect map
Slot name: Bump map
Slot name: Refl. gloss.
Slot name: Diffuse map
Slot name: Reflect map
Slot name: Bump map
Slot name: Refl. gloss.
Slot name: Bump map
I get Map instead of Diffuse(I have there collor corect then texture in diffuse)
I want DIFFUSE/COLOR CORRECT/
Except this, I want all this info without the word
map
for example - not BUMP MAP but BUMP.
In this case
Slot name: Map 1
Slot name: Mask
Slot name: Radius
Slot name: Occluded
Slot name: Map 2
Map1 and Map2 are located in Diffuse Slot/Fallof then - Map1 and Map2!
I would like to list tem like:
Difuse/Fallof/Map1
Difuse/Fallof/Map2
Thank you in advance!
Swordslayer · 2013-02-14
(
local bitmaps = getClassInstances BitmapTexture
fn capitalizeFirst str =
(
str[1] = toUpper str[1]
str
)
fn getTopMats sub =
for item in refs.dependents sub
where isKindOf item Material collect item
fn recurseMats mats map previous:#() =
for mat in mats do
for i = 1 to (getNumSubTexmaps mat)
where getSubTexmap mat i == map do
(
local topMats = getTopMats mat
if topMats.count > 0 then
recurseMats topMats mat previous:(join #(capitalizeFirst ((classOf mat) as string) + "/" + getSubTexmapSlotName mat i) previous)
else
(
format "\tSlot name: %" (substituteString (getSubTexmapSlotName mat i) " map" "")
for each in previous do format "/%" each
format "\n"
)
)
for bmp in bitmaps do
(
local mats = getTopMats bmp
format "\nTexture: %\n" bmp.name
recurseMats mats bmp
)
)
Swordslayer · 2013-02-09
This will work in some cases:
(
local bitmaps = getClassInstances BitmapTexture
for bmp in bitmaps do
(
local mats = for item in refs.dependents bmp where isKindOf item Material collect item
format "\nTexture: %\n" bmp.name
for mat in mats do
for i = 1 to (getNumSubTexmaps mat)
where getSubTexmap mat i == bmp do
format "\tSlot name: %\n" (getSubTexmapSlotName mat i)
)
)SubTexmap methods work both for materials and maps, yet it is quite likely that some info will be missing - anything that will be missing in getClassInstances/refs.dependents calls.