Reputation: 519
In Maya 2018, using Python, how can you check if the attribute editor is open, and if it is not, open it. Also, can you open multiple instances of the attribute editor, preferably showing the attributes of different nodes?
Upvotes: 0
Views: 1588
Reputation: 2512
I advise you to turn on "echo all command" if your looking to some code. Opening the Attribute Editor will give you in echo :
attributeEditorVisibilityStateChange(`workspaceControl -q -visible AttributeEditor`, "");
In this command you can already guess that :
`workspaceControl -q -visible AttributeEditor`
it is the part to query the visibility of the attribute editor, in python a simple translation :
cmds.workspaceControl('AttributeEditor', q=1, visible=1)
Then you have this mel function :
attributeEditorVisibilityStateChange
In Mel you can use this command to find where the procedure belong :
whatIs attributeEditorVisibilityStateChange;
// Result: Mel procedure found in: D:\maya_path\scripts\startup\initAttributeEditor.mel //
Opening the file and reading the first proc, you find already : showAttributeEditor
This function is commented as obsolet and advise to use : ToggleAttributeEditor
Making a quick whatIs, i find out it was a runtime command (so it should be use straight away):
cmds.ToggleAttributeEditor()
You should have your answer for opening and check if the atrribute editor still exists, if the command is not the one you want because you want maybe some docking ability, there is lots more MEL to read using whatIs; and the second proc in the file.
And now that I've explained you the method to find python command, I think you can use the same technique to create a function for the "copy tab" of the attribute editor !
If you find it is to annoying (maya has sometimes lots of nested code, and it can be tidious), you can use :
import maya.mel
mel.eval('attributeEditorVisibilityStateChange(`workspaceControl -q -visible AttributeEditor`, "");')
it will execute mel code inside python. you can use python format to insert arguments...etc as it must be evaluated as a string.
Upvotes: 2