PDA

View Full Version : Python scripting in maya


chrispy301
03-18-2009, 06:56 PM
So I just started out programming in maya about maybe a month ago and I am retaining some of it, but still having some troubles with taking python code and applying it to maya. I was wondering if someone could help me out. I am trying to take a simple ship design that I modeled out and write it out in script so that I can create the code as a button and my ship pops up in one click. However, there seems to be a feww errors in my code and I dont know how to fix them. Here's my code edited, but i have the original output data from the script editor as well.


polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1;
// pCube1 polyCube1 //
setAttr "pCube1.scaleX" 5;
setAttr "pCube1.scaleY" 2;
setAttr "pCube1.scaleZ" 2;
select -addFirst polyCube1 ;
setAttr "polyCube1.subdivisionsWidth" 2;
setAttr "polyCube1.subdivisionsHeight" 1;
setAttr "polyCube1.subdivisionsDepth" 3;
setAttr "polyCube1.subdivisionsDepth" 3;
setAttr "pCube1.scaleY" 1;
select -cl ;
mc.select (tgl, pCube1.vtx[3], pCube1.vtx[6], pCube1.vtx[9], pCube1.vtx[12])
mc.move (r=True, 0, -0.387976, 0)
select -cl ;
select -r pCube1.vtx[0] pCube1.vtx[15] pCube1.vtx[18] pCube1.vtx[21] ;
move -r 0 0.344239 0 ;
select -r pCube1.vtx[6] pCube1.vtx[9] pCube1.vtx[18] pCube1.vtx[21] ;
move -r -1.018293 0 0 ;
select -r pCube1.vtx[2] pCube1.vtx[17] pCube1.vtx[20] pCube1.vtx[23] ;
move -r 0 0.397798 0 ;
select -r pCube1.vtx[8] pCube1.vtx[11] pCube1.vtx[20] pCube1.vtx[23] ;
move -r 0.726864 0 0 ;
select -cl ;
select -r pCube1.f[5] ;
polyExtrudeFacet -constructionHistory 1 -keepFacesTogether 1 -pvx 1.613431871 -pvy 0.5 -pvz -2.980232239e-008 -divisions 1 -twist 0 -taper 1 -off 0 -smoothingAngle 30 pCube1.f[5];
// Result: polyExtrudeFace1 //
setAttr "polyExtrudeFace1.localTranslate" -type double3 0 0 0.794193 ;
select -r pCube1.f[9] ;
polyExtrudeFacet -constructionHistory 1 -keepFacesTogether 1 -pvx 1.25 -pvy 0 -pvz -1 -divisions 1 -twist 0 -taper 1 -off 0 -smoothingAngle 30 pCube1.f[9];
// Result: polyExtrudeFace2 //
setAttr "polyExtrudeFace2.localTranslateZ" 1;
select -r pCube1.f[1] ;
polyExtrudeFacet -constructionHistory 1 -keepFacesTogether 1 -pvx 1.25 -pvy 0 -pvz 1 -divisions 1 -twist 0 -taper 1 -off 0 -smoothingAngle 30 pCube1.f[1];
// Result: polyExtrudeFace3 //
setAttr "polyExtrudeFace3.localTranslateZ" 1;
select -r pCube1.vtx[28] pCube1.vtx[31] ;
select -tgl pCube1.vtx[32] pCube1.vtx[35] ;
move -r 2.358616 0 0 ;
select -cl ;
select -r pCube1.vtx[31] ;
select -tgl pCube1.vtx[32] ;
move -r 0 0.394438 0 ;
select -cl ;
select -r pCube1.vtx[32:33] ;
select -tgl pCube1.vtx[30:31] ;
move -r 0 0.410705 0 ;
select -r pCube1.vtx[34:35] ;
select -tgl pCube1.vtx[28:29] ;
move -r 0 -0.126043 0 ;
select -cl ;
select -r pCube1.vtx[26:27] ;
move -r 0 0 0.328018 ;
select -cl ;
select -r pCube1.vtx[24:25] ;
move -r 0 0 -0.333578 ;
select -r pCube1.vtx[0] pCube1.vtx[3] pCube1.vtx[12] pCube1.vtx[15] ;
move -r 2.137296 0 0 ;
select -r pCube1.vtx[6] pCube1.vtx[9] pCube1.vtx[18] pCube1.vtx[21] ;
select -cl ;
select -r pCube1.vtx[1] pCube1.vtx[16] pCube1.vtx[19] pCube1.vtx[22] ;
move -r 0 0.302481 0 ;
select -r pCube1.vtx[24:27] ;
move -r 0 -0.485023 0 ;
move -r 0 0.185033 0 ;
select -cl ;

chrispy301
03-19-2009, 01:15 PM
nevermind everyone, i figured out the code last night through some deep and heavy hours in front of the monitor

CGTalk Moderation
03-19-2009, 01:15 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.