摘要:本文将带你了解Maya 入门之Mel GUI如何使用,
1.创建一个window,里面可以包含很多的控件,比如基本的button,checkbox,textfield等等
[plain] view plain copy
1. window;
2. columnLayout;
3. text -label "My text";
4. button -label "I'm a button";
5. checkBox -label "Check Box";
6. radioCollection;
7. radioButton -label "start";
8. radioButton -label "stop";
9. floatField -value 3.41;
10. textField -text "Hello";
11. showWindow;
2.控件触发执行相应命令
[plain] view plain copy
1. global proc Create_sphere()
2. {
3. sphere -name "MySphere";
4. }
5.
6. window;
7. columnLayout;
8. button -label "My Sphere" -command "Create_sphere()";
9. showWindow;
3.界面布局,有ColumnLayout,RowLayout,FrameLayout等等
[plain] view plain copy
1. window;
2. columnLayout -columnWidth 150;
3. button;
4. button;
5. showWindow;
4.确认对话框
[plain] view plain copy
1. $my_confirm = `confirmDialog -title "Confirm" -message "Yes or No"
2. -button "YES" -button "NO"
3. -defaultButton "YES" -cancelButton "NO"
4. -dismissString "NO"`;
5. if ($my_confirm == "YES"){
6. print "User has picked YES\n";
7. }
8. else if ($my_confirm == "NO"){
9. print "User has picked NO\n";
10. }
4.提示框
[plain] view plain copy
1. string $text;
2. string $my_prompt = `promptDialog
3. -title "Rename An Entity"
4. -message "Enter Name:"
5. -button "OK" -button "Cancel"
6. -defaultButton "OK" -cancelButton "Cancel"
7. -dismissString "Cancel"`;
8.
9. //get new name of entity
10. if ($my_prompt == "OK") {
11. $text = `promptDialog -query -text`;
12. print ("New name for Entity: " + $text + "\n");
13. }
14. else if ($my_prompt == "Cancel") {
15. print ("OK, fine don't rename....\n");
16. }
5.获取输入框中的数字
[plain] view plain copy
1. window intFieldTestWin;
2. columnLayout;
3. intField intergerField;
4. showWindow intFieldTestWin;
5.
6. //then declare an interger variable to store your value
7.
8. int $intStorage;
9.
10. //now, type an interger in the window.
11. //Then, use the infField query mode to query the value of the window into
12. //the variable. You use the single quote (``) signs for this.
13.
14. $intStorage = `intField -q -v intergerField`;
15. print $intStorage;
16. // To do it the other way around, meaning to put the value of a variable into the field
17. // itself, you can try this.
18. // Declare a variable with a value.
19.
20. int $intStorage = 20;
21.
22. // Then use the intField edit mode to input the variable as the arguement
23. // for the window.
24.
25. intField -e -v $intStorage intergerField;
26. // Basically, most UI controls share the same creation/edit/query syntax.
6.取得输入框的值并进行相应的动作
[plain] view plain copy
1. window -t "test";
2. gridLayout -numberOfColumns 3 -cellWidthHeight 100 30 -w 300 -h 50;
3. text -label "个数:";
4. intField -min 1 -max 10 number;
5. button -label "生成" -c "test";
6. showWindow;
7.
8. proc test()
9. {
10. global string $intFieldName = "";
11. int $value;
12. $value = `intField -query -value number`;
13. print($value);
14.
15. int $i = 0;
16. for($i=1;$i<=$value;++$i)
17. {
18. polyCylinder -r 1 -h 2 -sx 20 -sy 1 -sz 1 -ax 0 1 0 -rcp 0 -cuv 3 -ch 1;
19. polyCylinder -r 1 -h 2 -sx 20 -sy 1 -sz 1 -ax 0 1 0 -rcp 0 -cuv 3 -ch 1;
20. move -r 0 1.40901 0 ;
21. //scale -r 0.487535 0.487535 0.487535 ;
22. $randx = rand(0.2,2);
23. $randy = rand(0.2,2);
24. $randz = rand(0.2,2);
25. scale -r $randx $randy $randz;
26. select -r ("pCylinder"+ ($i*2-1)) ("pCylinder"+$i*2) ;
27. move -r ($i*3) 0 0 ;
28. }
29. }
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标常用软件之Maya频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号