Hi all, I am trying to convert the following Mel into python but was met 
with some trouble.
Though I do not intend to implement the code, still, I would like to be 
enlighten, shedding some light as I am trying to learn / be knowledgeable 
in both Mel and Python..

The following is the Mel code:
string $window = `window -title "Long Name" -iconName "Short Name"`;
columnLayout -adjustableColumn true;


// this is maya's global variable of all the preset film backs
global string $gFilmbackTable[];


// create an option menu that will contain all the preset film backs
optionMenu - l "Film Gate" omFilmbackMenu;


// grab the film backs in the table and add them to the drop down menu
for($i=0; $i < size($gFilmbackTable); $i += 3) {
menuItem -l $gFilmbackTable[$i];
}

showWindow $window;

And the following is the converted Python that I did:
import maya.cmds as cmds
import maya.mel as mel


win = cmds.window(title = "Long Name", iconName = "Short Name", widthHeight 
= (200, 55))
cmds.columnLayout(adjustableColumn = True)


fbTable = mel.eval('global string $gFilmbackTable[]')
# fbValues = mel.eval('$gFilmbackTable')


cmds.optionMenu("omFilmbackMenu", label = "Film Gate")


cmds.showWindow(win)


First problem that I had, is grabbing the value of $gFilmbackTable. As I 
tried printing them out (fbValues), it either prompts me error saying 
- RuntimeError: Error occurred during execution of MEL script

Whereas in Mel tab, it is able to print out a list of things.. Guess I 
screwed up somewhere?

The second issue that I had would be converting the for statement (and 
onwards) in Mel to python. While I can think of replacing 'size' with 
'len', but the other parameters within - $i=0 and $i += 3, how do I do so 
in Python?

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/c8c039f0-dfa9-4372-abd9-9ab26453724e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to