Set command button valid just in assembly .

I have created some button in command manager and I want it show in gray color in part document like some SOLIDWORKS command indicate user the button is invalid ,but i can't find which function can achieve it.

Thanks for your attention.

SolidworksApi macros