Search code examples
pythonmaya

How do I get the object type of an Arnold Light in Maya


I am working on a way to create light setups from Json files, and the other way around, saving setups in Jsons to load later. Herefore I wanna create an if-statement that says "if the lighttype is a SkyDomeLight, execute this function" but somehow the only type these objects have are transforms. I'm just looking for some kind of way to differentiate between an aiAreaLight and an aiSkyDomeLight for example. Only looking for Arnold lights though.

I've tried ObjectType, select by Type, adding a suffix and then basing on that suffix but that is way to complicated and not user friendly.


Solution

  • if you look at the shape in your attribute editor :

    aiSkyDomeLight is the type of node for skydome aiAreaLight is the type for the area light

    be sure to query your light by the shape :

    sel = cmds.ls(sl=True, dag=True, type='shape')
    nt = [cmds.nodeType(i) for i in sel]
    for s, nt in zip(sel, nt):
        print('"{}" light has "{}" as nodeType')