Hi All,
What can be the fastest way to find the a model elements ( it's children )
materials. Is there a xsi build-in command for it ?
Thansks !
G
Find the model elements materials
-
Gemini7
- Posts: 14
- Joined: 14 Oct 2012, 20:09
- Skype: gemini4147
-
csaez
- Posts: 253
- Joined: 09 Jul 2012, 13:31
- Skype: csaezmargotta
- Location: Sydney, Australia
Re: Find the model elements materials
I don't know if exist a builtin command but maybe is fast enough iterate over the materials instead of model's children (there're usually more geometry objs than materials so...) and check if it's used.
Something like this...
Hope this help,
Cheers!
Something like this...
Code: Select all
from sipyutils import si
si = si()
def GetMaterialOnModel(p_oModel):
lChildren = p_oModel.FindChildren2("*").GetAsText()
lMats = list()
for oLib in si.ActiveProject.ActiveScene.MaterialLibraries:
for oMat in oLib.Items:
for oObj in oMat.UsedBy:
if oObj.FullName in lChildren:
lMats.append(oMat)
return lMats
for i in GetMaterialOnModel(si.Selection(0)):
print iCheers!
-
Gemini7
- Posts: 14
- Joined: 14 Oct 2012, 20:09
- Skype: gemini4147
Re: Find the model elements materials
Thanks !
I thought something similar like that.
Maybe i will need a faster code than iterate trough so long..
You know there could be nested models and a lot of materials and
the time it requires can be very long.
Thank you again.
G
I thought something similar like that.
Maybe i will need a faster code than iterate trough so long..
You know there could be nested models and a lot of materials and
the time it requires can be very long.
Thank you again.
G
