How to set "Use Outliner Color" with python ?

How to set "Use Outliner Color" with python ?

huseila
Enthusiast Enthusiast
1,423 Views
2 Replies
Message 1 of 3

How to set "Use Outliner Color" with python ?

huseila
Enthusiast
Enthusiast

Hi all,

 

I tried to set "Use Outliner Color", "Hidden In Outliner" and "Outliner Color" with commands like this:

 

import maya.cmds as cmds

cmds.setAttr('pSphere1.useOutlinerColor', True)

cmds.setAttr('pSphere1.hiddenInOutliner', True)

cmds.setAttr('pSphere1.outlinerColor', 0.1, 0.5, 0.7, 'float3')

but it doesn't work at all. The most strange thing is I don't get any mel command feedback when toggling these options. Is this a bug ?

 

 

 

0 Likes
Accepted solutions (1)
1,424 Views
2 Replies
Replies (2)
Message 2 of 3

Kahylan
Advisor
Advisor
Accepted solution

Hi!

 

Your commands work perfectly fine. the only problem is, that your attribute editor and outliner aren't updating, if you select and unselect your "pSphere1" the changes should show.

If you want the changes to show immediately, you need to forcefully update the Attribute editor. Sadly there isn't a command in maya.cmds that updates the Attribute Editor, but you can use python to call the MEL command:

import maya.cmds as cmds
import maya.mel as mm

cmds.setAttr('pSphere1.useOutlinerColor', True)

cmds.setAttr('pSphere1.hiddenInOutliner', True)

cmds.setAttr('pSphere1.outlinerColor', 0.1, 0.5, 0.7, 'float3')

mm.eval("updateAE pSphere1 ")

 

I hope it helps!

Message 3 of 3

huseila
Enthusiast
Enthusiast

It works perfectly ! Thank you for your help 🙂