PUBLISHED: August 15, 2019
Deprecation Notice: This article was written more than a year ago which means that its information might no longer be up-to-date. We cannot therefore guarantee the accuracy of it's contents.

Table of Contents


Querying the Illuminates by Default attribute in Maya

Finding lights in Autodesk Maya that have the “Illuminates by Default” attribute on/off can be a tricky because we are not querying normal attributes but instead a connection between nodes. Here is a MEL procedure that allows us to select lights that have the flag enabled or disabled.

Example

proc selectIlluminatesByDefault(int $mode) {
    select -clear;
    string $lights[] = `ls -dag -lights`;
    for ($light in $lights) {
        string $transforms[] = `listRelatives -parent $light`;
        string $connections[] = `listConnections $transforms[0]`;
        string $inst = $transforms[0] + ".instObjGroups";
        string $dfs[] = `connectionInfo -dfs ( $inst )`;
        
        int $isConnected = 0;
        if (objExists($dfs[0] ) && `isConnected $inst $dfs[0]`) {
            $isConnected = 1;
        }
        if ($mode == 1) {
            if ($isConnected) {
                select -add $light;
            }
        }
        else {
            if (!$isConnected) {
                select -add $light;
            }
        }
    }
}

Usage

selectIlluminatesByDefault(0)   // 0 for off and 1 for on

See Also

Remove nodes from a set in Maya
Remove nodes from a set in Maya



comments powered by Disqus

See also