Monday, May 18, 2009


import maya.cmds as cmds
x=10
y=10
#Make a Square
initialSqare = cmds.nurbsSquare(sl1=x, sl2=y)
#get outline
isSides = cmds.filterExpand (sm=9)
print isSides
#make an empty list
Squares = []
Squares.append (1)

def squareINsquare (number):
#scale
x=10/(1.5*len(Squares)+1)
y=10/(1.5*len(Squares)+1)
#loop
for j in range (0,len(Squares),1):
cmds.select (Squares[j], r=True)
#get outline
isSides = cmds.filterExpand (sm=9)
#looping in outline
for i in range (0,2,1):
perc1 = 0
perc2 = 1
line1=isSides[1]
line2 = isSides[2]
if i == 0:
poc1 = cmds.pointOnCurve(line1, pr=perc1, top=True, p=True)
print poc1
#change the center of the new square
poc1[0]=poc1[0]-x/2
poc1[1]=poc1[1]+y/2
print poc1
#make a new square
initialSqare1 = cmds.nurbsSquare(c = poc1, sl1=x, sl2=y)
#the same for the oposit corner of the squre
else:
poc2 = cmds.pointOnCurve(line2, pr=perc2, top=True, p=True)
print poc2
poc2[0]=poc2[0]+x/2
poc2[1]=poc2[1]-y/2
print poc2
initialSqare2 = cmds.nurbsSquare(c = poc2, sl1=x, sl2=y)

Squares.append (initialSqare1)
Squares.append (initialSqare2)
Squares=Squares1
Squares1=[]
if number == 0 :
#stop
return "Done."
else:
#did not finish yet
#remove one unit (count down)
number -= 1

squareINsquare (number)

squareINsquare (3)

1 comment:

  1. Grisha,

    A series of questions:

    1) what do you want to do? I did not see any diagrams, any explanations, nothing.
    2) What is this scripting doing? I don't see any screenshots
    3) Are you having problems with it or is it working perfectly?

    I can't run the script from here. But the thing is, I should not have to run your script to see what is it doing. That's why I ask you to upload screenshots. And that's why i ask you to make diagrams. And that's why I ask you to explain in plain english. But you did none.

    Please, it is hard for me to help you if you don't make the necessary effort.

    ReplyDelete