Ahh awesome.
I did find a alternative earlier today but im not really sure is there some
sort of rule for when to use which one, is there a speed difference or is
it just personal preference....

what i did earlier was

sClassID = "{4C4F7500-51EF-11D0-854E-00A02417D029}"
selection = si.FindObjects( "", sClassID )

i also noticed that i get some unnecessary clutter when calling all
materials  and i had to make a guardian to clean up the selection... Is
there a way to avoid this...
This is what i did, would it  be considered correct.



matGuardianList = [
                    ".filename",
                    ".storage",
                    "exclude",  #exclude material library
                    "Sources.Materials.DefaultLib.Scene_Material",
                    "__SHADERBALL_MATERIAL_LIBRARY__",
                    "light",
                    "TransientObjectContainer",
                    ]

def matGuardian(x):
    global matGuardianList
    if any( i in str(x) for i in matGuardianList):
        return True

for i in selection:
    skipMat = matGuardian(i)
    if skipMat == True:
        pass
    else:
        #code

Sorry for bothering you guys with such trivial stuff, i am still learning
and i was curious at to my alternatives.



On Sun, Nov 10, 2013 at 5:26 PM, Alan Fregtman <[email protected]>wrote:

> Something like this?
>
> xsi = Application
> matLibs = xsi.ActiveProject.ActiveScene.MaterialLibraries
> # As a Python list:
> allMaterials = [mat for lib in matLibs for mat in lib.Items]
> # As an XSICollection:
> allMaterials = XSIFactory.CreateObject('XSI.Collection')for lib in matLibs:
>     allMaterials.AddItems(lib.Items)
> # Either way, just select afterwards:
> xsi.SelectObj(materials)
>
>
>
>
>
>
>
> On Sun, Nov 10, 2013 at 1:44 AM, Ognjen Vukovic <[email protected]> wrote:
>
>> Hi guys,
>> What would be the best way in python to select all the materials in a
>> scene,
>> I have this ..
>>
>> matSelection = Application.SelectObj("Sources.Materials.*.*")
>> Selection = Application.Selection
>>
>> But it just seems a bit hacky, and im sure there is a better method of
>> doing this.
>>
>> Cheers,
>> Ogi.
>>
>
>

Reply via email to