Lock Maya Prefs attributes

Lock Maya Prefs attributes

16497643852
Contributor Contributor
487 Views
1 Reply
Message 1 of 2

Lock Maya Prefs attributes

16497643852
Contributor
Contributor

Hello All,

 

I wanted to know if there is any way i can lock/disable any maya prefs attributes so that no one can edit.

I know it is a qt widget, not sure what is the name of the widget - I tried this script - https://help.autodesk.com/view/MAYAUL/2020/ENU/?guid=Maya_SDK_MERGED_Maya_Python_API_Working_with_Py...

`Creating a QT widget with a tree list view` , but to find the combobox that i want to lock is like finding needle in the haystack

 

for example: can i lock/disable the below attributes? need some suggestions and commands references.

16497643852_0-1683047528611.png

 

0 Likes
488 Views
1 Reply
Reply (1)
Message 2 of 2

Kahylan
Advisor
Advisor

Hi!

 

As far as I know, there is no way to permanently lock/disable a control in the maya preferences window, as this window gets rebuilt from scratch every time it is opened with all controls enabled.

Here is code on how you can temporary lock those two attributes:

import maya.cmds as mc

controls = mc.lsUI(ctl = True, l = True)
l = []
for c in controls:
    if "PreferencesWindow" in c and "linearOpts" in c or "PreferencesWindow" in c and "angularOpts" in c:
        mc.control(c, en= False, e= True)

 Basically this code lists the paths of all existing UI controls, and then checks for a UI elements for the name of the Preference window and the name of the control itself, and if it finds a match disables it. I did it this way, because there are additional not specifically named editors added, so the path of the control can vary depending on when the preferences are opened and how many other windows are open at the time.

 

You could try to set up some kind of callback or scriptjob that disables these options automatically whenever the Preference Window is opened. But I don't know how exactly you would go about this and I don't know if the added benefit of disabling these Preference options does is worth the work you would need to put into figuring this out...

 

Why exactly do you want to disable these options?