Selecting Faces by diffusemap
I am trying to write a script which will check all the objects(geometry) in a scene individually....and detach the faces having a material with diffuse texture name ending with "_alpha".....then naming and grouping the newly created object (the easiest part). I am able to do this for single material objects.....but the problem starts when multi-subobject materials are there. I am not able to select the faces with specific mat id having a diffuse texture name ending with "_alpha".
the only working part of my script is:
if classof mat.diffuseMap == Bitmaptexture then
(
stringSS = getFileNameFile mat.diffusemap.bitmap.filename
stringcount = stringSS.count
start = stringcount - 5
end = start + 6
TextureName = substring stringSS start end
if TextureName == "_alpha" then
(
objname = $.name
$.name = objname +"_alpha"
)
)
....need help :(
Comments
try this...update
try this...
kimarotta.com.br
3d Artist
Hi kimarotto....thanks a
Hi kimarotto....thanks a lot.....now it is more clear to me.....and the script is working great. But there is a problem, it is naming the whole object as a "*_alpha"....I was looking for something which can detach the faces based on the the mat_id of the material whose diffuse map name ends with "_alpha". Actually I am trying to detach those faces to a separate object, and then name it....not the same object.
I am not able to select those faces by that particular mat_id...because I am not able to detect that exact id.
try this...mapArr =
...
kimarotta.com.br
3d Artist
hi...this case has a
hi...
this case has a parenthesis wrong in the first "if" for a look ...
I used it and it worked...
kimarotta.com.br
3d Artist
Try this one: ( mat =
Try this one:
(
mat = $.material
TextureFileName = "notexture"
if classof mat.diffuseMap == Bitmaptexture then
(
stringSS = getFileNameFile mat.diffusemap.bitmap.filename
stringcount = stringSS.count
start = stringcount - 5
end = start + 6
TextureName = substring stringSS start end
if TextureName == "_alpha" then
(
objname = $.name
$.name = objname +"_alpha"
)
)
)
....this is just a part of the script.....it will return undefined....but I want to know how can I write the remaining part which handles multi-subobject material!!