Maya 入门之Mel GUI如何使用
白羽 2018-06-13 来源 :网络 阅读 3688 评论 0

摘要:本文将带你了解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;  

 Maya 入门之Mel GUI如何使用

 

 

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;  


 Maya 入门之Mel GUI如何使用

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. }  

 Maya 入门之Mel GUI如何使用

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. }  

 

 Maya 入门之Mel GUI如何使用

 

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 入门之Mel GUI如何使用



本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标常用软件之Maya频道!


本文由 @白羽 发布于职坐标。未经许可,禁止转载。
喜欢 | 2 不喜欢 | 0
看完这篇文章有何感觉?已经有2人表态,100%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved

208小时内训课程