Im trying to build a UI for my script that list Groups and children
similar to Outliner. The issue Im having is that I just needs a list
where users can add items to the list. Not a global list that list all
the objects in scene. I search the MEL documentation already but unsure
as to which command i should be using.
Replies
eg:
string $listOfTransforms[] = `ls -tr`; //this gets all transforms in the scene
string $listOfTransforms[] = `ls -dag`; //this gets all DAG objects in the scene
string $selectList[] = `ls -as`; // this gets all top level transforms in the scene
https://help.autodesk.com/cloudhelp/2016/ENU/Maya-Tech-Docs/Commands/ls.html
to add to your list you can use appendStringArray()
https://download.autodesk.com/us/maya/2011help/Commands/appendStringArray.html
1) Getting a list of the things you want - such as transforms. See above answer.
2) Create a window
3) Create a layout (columnLayout should be perfectly ok here)
4) Create a UI control for displaying the data. A textScrollList sounds like what you want to use here
5) Loop over the list of things you wanna display and append them to the textScrollList
6) When the user adds a new thing, you do the same: append to the textScrollList
7) For refreshing the UI you want to destroy all children of the textScrollList and then rebuild them. This is how all UI-refreshing code works. Destroy - Rebuild.
(Don't destroy the parent textScrollList)
The official docs have some boilerplate code you can try (bottom): http://download.autodesk.com/us/maya/2009help/commandspython/show.html?textScrollList.html&cat=Windows
You can switch to MEL in the upper right corner.
(And the sooner you can transition to Python from MEL, the better for your sanity. MEL is a garbage language).