Help with a little python script

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  03 March 2013
Help with a little python script

Hey guys im trying to create a script in python. It should create a staircase of equally sized cubes between two selected locators. In the window you have to input the amount of stairs and the width of the staircase and maya calculates the size of the cubes.
I figured how to create the perfect sized cube, but once i added the loop the whole thing broke, giving me syntax error, where there shouldn't be any. Also when i removed the loop it gave additional errors in thing that worked before adding the loop itself. Im kind of stuck on it, so any help or suggestions will be greatly appreciated.
Thanks in advance!


This is how the script looks like right now:


import maya.cmds as cmds

def demStairs(name,width,amount):
selected = cmds.ls(sl=True)
posOne = cmds.xform(selected[0],ws=True,q=True,t=True)
posTwo = cmds.xform(selected[1],ws=True,q=True,t=True)
print(posOne,posTwo)
import math as math

disOne = math.fabs(posTwo[0] -posOne[0])
disTwo = math.fabs(posTwo[1] -posOne[1])
print(disOne, disTwo)
step = cmds.polyCube(n='stair',w=disOne/amount,h=disTwo/amount,d=width)
cmds.xform(ws=True,q=True,t=True, t=((posOne[0]-(disOne/amount)), (posOne[1]-(disTwo-(disOne/amount))))

while i<(amount-1):
cmds.duplicate(stair)
cmds.move((disOne-(disOne/amount), (disTwo-(disOne/amount), 0, [stair])
i =i+1


cmds.window(t='datStairCreator',w=600,h=250)
cmds.columnLayout()

stairAmount=cmds.textFieldGrp(label='Number of steps',)
stairWidth=cmds.textFieldGrp(label='Width of the staircase')

cmds.rowLayout(nc=3)
cmds.button(l='hit me',w=100,h=50,command="demStairs(float(cmds.textFieldGrp(stairWidth,q=Tru e,tx=True)), float(cmds.textFieldGrp(stairAmount,q=True,tx=True )))")
cmds.showWindow()
 
  03 March 2013
See line 15:

cmds.xform(ws=True,q=True,t=True, t=((posOne[0]-(disOne/amount)), (posOne[1]-(disTwo-(disOne/amount))))


It has 7 open parenthesis but only 6 closing ones.

(That is not an exhaustive audit, just the syntax error that was reported over here. Next time, please include the syntax error that was reported, and enclose your code in [.code] tags to make it easier to read.)

 
  03 March 2013
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:53 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.