Showing posts with label Clau. Show all posts
Showing posts with label Clau. Show all posts

Wednesday, July 22, 2009

Claudia_Ex04B_Nurbs Surfaces









########## EX04B ###########
# 1) Create a curve from points
# 2) Tubulize the curve
# 3) Create 3 more tubes displaced in a radial way
# 4) Move the Cvs of each tube
# according to a locator distance
# 5) Populate each tube with cylinders
# 6) finish!

###########################
import maya.cmds as cmds
from math import*
from random import*

# 1) Create a list of points to generate a curve
# define initial variables
numPoints= 15
# create an empty list to store the points
myPoints= []

# def Curve
def Curve(amplitude):
#loop and gather point information
for i in range (0, numPoints, 1):
# function of the helix to generate a curve
x= cos(7*i)
y= sin(7*i)
z= i*amplitude
myPoint= (x,y,z)
# store the points in the list
myPoints.append(myPoint)
#create the curve
Curve= cmds.curve(d=3, p=myPoints, n="myCurve") #curve of degree 3

#call function
myCurve=Curve(5)

# 2) Create a tube
# first select the curve
myCurve= cmds.filterExpand(sm=9)

# define the function
def tubulize(path,radius,tubeSections):
# function to create tubes out of a curve
#position on end of the curve where I will put the circle profile
pos= cmds.pointOnCurve(path, position=1, pr=0.001, top=1)
#get tangent of this point
tan= cmds.pointOnCurve(path,tangent=1,pr=0.001,top=1)
#create the profile circle
profile=cmds.circle(c=pos,r=radius,normal=tan,s=tubeSections,ch=1, n="circle")
#center the circle pivot
cmds.xform(cp=1)

#extrude the circle along the path
tube=cmds.extrude(profile[0], path, ucp=1, upn=1, et=2, rb=1, dl=3, ch=1,n="spiralTube")

# call function
myTube=tubulize(myCurve,6,10)

# 3) duplicate tubes rotating them according to a Locator
# create a locator
pivot= (-12,15,0)
myPoint= cmds.spaceLocator( p=pivot, n="myPoint")

# create a list to store the tubes
myTubes=[]
# select the tube to copy
selObjects=cmds.select("spiralTube")

# define variables
numTubes=3
rot = 0
# duplicate the tubes
for e in range (0,numTubes,1):
rot=rot+70
mynewTubes= cmds.duplicate("spiralTube", n="myNewTubes_%s" %e)
cmds.rotate(0,0,rot, "myNewTubes_%s" %e, p=pivot)
myTubes.append("myNewTubes_%s" %e)

#4) Move the vertices of each tube according
# a locator distance
# 4.1) For the Spiral Tube
#define distance between cvs and locator
def magnitude (v):
#v is a list of x,y,z values
x= v[0]
y= v[1]
z= v[2]
m= math.sqrt( (x*x) + (y*y) + (z*z) )
return m

def distance (posPoint,pivot):
#subtract both vectors
x1= posPoint[0]
y1= posPoint[1]
z1= posPoint[2]
x2= pivot[0]
y2= pivot[1]
z2= pivot[2]
x= x1 - x2
y= y1 - y2
z= z1 - z2
m= magnitude ([x,y,z])
return m

#define moveToLocator function
def moveToLocator():
# A) get all the cvsNames of myTubes
spiralTubeCvs = cmds.ls("spiralTube.cv[:]", fl=1)

#create an empty list to store the points
mySpiralCvs=[]

#get selected Locator
#myPoint= cmds.filterExpand(sm=22)
myPointPos= cmds.ls("myPoint", fl=1)

#loop through cvs
for i in spiralTubeCvs:
posPoint= cmds.pointPosition(i)
posPivot= cmds.pointPosition(myPoint)
d= distance(posPoint, pivot)
cmds.move (d,d,d,i,r=True)

#store the cvs in a list
mySpiralCvs.append(spiralTubeCvs)

#call the function
moveToLocator()

#####################3
# 4.2) For myNewTubes_0

#define moveToLocator function
def moveToLocator():
# A) get all the cvsNames of myTubes
newTubeCvs = cmds.ls("myNewTubes_0.cv[:]", fl=1)

#create an empty list to store the points
myNewTubeCvs=[]

#get selected Locator
#myPoint= cmds.filterExpand(sm=22)
myPointPos= cmds.ls("myPoint", fl=1)

#loop through cvs
for i in newTubeCvs:
posPoint= cmds.pointPosition(i)
posPivot= cmds.pointPosition(myPoint)
d= distance(posPoint, pivot)
cmds.move (d,d,d,i,r=True)

#store the cvs in a list
myNewTubeCvs.append(newTubeCvs)

#call the function
moveToLocator()

###################
#4.3) For myNewTubes_1
#define moveToLocator function
def moveToLocator():
# A) get all the cvsNames of myTubes
newTube1Cvs = cmds.ls("myNewTubes_1.cv[:]", fl=1)

#create an empty list to store the points
myNewTube1Cvs=[]

#get selected Locator
#myPoint= cmds.filterExpand(sm=22)
myPointPos= cmds.ls("myPoint", fl=1)

#loop through cvs
for i in newTube1Cvs:
posPoint= cmds.pointPosition(i)
posPivot= cmds.pointPosition(myPoint)
d= distance(posPoint, pivot)
cmds.move (d,d,d,i,r=True)

#store the cvs in a list
myNewTube1Cvs.append(newTube1Cvs)

#call the function
moveToLocator()

###################
#4.3) For myNewTubes_2

#define moveToLocator function
def moveToLocator():
# A) get all the cvsNames of myTubes
newTube2Cvs = cmds.ls("myNewTubes_2.cv[:]", fl=1)

#create an empty list to store the points
myNewTube2Cvs=[]

#get selected Locator
#myPoint= cmds.filterExpand(sm=22)
myPointPos= cmds.ls("myPoint", fl=1)

#loop through cvs
for i in newTube2Cvs:
posPoint= cmds.pointPosition(i)
posPivot= cmds.pointPosition(myPoint)
d= distance(posPoint, pivot)
print d
cmds.move (d,d,d,i,r=True)

#store the cvs in a list
myNewTube2Cvs.append(newTube2Cvs)

#call the function
moveToLocator()

###############################
# 5) Populate each Tube with cylinders
def cylindersOnSurface(numU, numV):

#5.1)Select objects on stage
SelTubes= cmds.select("spiralTube", "myNewTubes_0", "myNewTubes_1", "myNewTubes_2")
#5.2) get selected objects
tubs= cmds.filterExpand(sm=10)
#5.3) create cylinders on the surface
for srf in tubs:
# first find the maximum number in U and V
U= cmds.getAttr(srf + ".minMaxRangeU")
V= cmds.getAttr(srf + ".minMaxRangeV")
U=U[0]
V=V[0]
rangeU= U[1]-U[0]
stepU= rangeU/numU
rangeV= V[1]-V[0]
stepV= rangeV/numV

#loop in U direction
for i in range (numU):
u = i*stepU
#loop in V direction
for j in range (numV):
v= j*stepV
coord= cmds.pointOnSurface(srf, p=1, u=u, v=v)
cmds.spaceLocator(p=coord)
normal = cmds.pointOnSurface(srf, u=u, v=v, normalizedNormal=1)
#create cilinders perpendicular to the normal of the tube
cmds.cylinder(p=coord, ax=normal, radius=4)
### call the function
cylindersOnSurface(10,10)

# erase the cilinder profile, the initial curve and the locator
cmds.delete("myCurve", "myPoint", "circle")
# 6) Finish!

Claudia_Ex04A_Polygonal Surface









####### Ex04A #######
# a) Create a curve from points
# b) create several curves
# c) loft the curves to create a Nurbs Surface
# d) Convert the Nurbs Surface to a Polygonal Surface
# e) Modify the vertices of the Polygonal Surface randomly
# f) finish
#################################

import maya.cmds as cmds
from math import*
import random

# a) Create a curve from points
# define Curve
def Curve(numPoints):
# define initial variables
numPoints= 60
# create an empty list to store the points
Points= []
#loop and gather point information
for i in range (0, numPoints,1):
# function of the conical helix to generate a curve
x= i*cos(6*i)
y= i*(sin(6*i)+2)
z= i+3
myPoint= (x,y,z)
# store the points in the list
Points.append(myPoint)
#create the curve
Curve= cmds.curve(d=3, p=Points) #curve of degree 3
return Curve

MyCurve= Curve(60)

#hide the Curve
cmds.hide(MyCurve)

# b) create several curves
# create an empty list to store the curves
myCurves=[]
# define variables
numCrvs= 9
offset= 4
# create a loop
for e in range (0, numCrvs,1):
crv= Curve(e)
offset= offset*1.2
#store the curve in the list
myCurves.append(crv)
#move the curves with an offset in the "z" axis
cmds.move(0,0,offset,crv)

# c) Loft the curves to create a Nurbs surface
myNurbsSurface= cmds.loft(myCurves, n="myNurbsSurf")

#hide the curves
cmds.hide(myCurves)

# d) convert the Nurbs Surface to Polygonal Surface
# get the Nurbs surface
myNurbsSurface= cmds.filterExpand(sm=10)

# convert
myPolySurface=cmds.nurbsToPoly("myNurbsSurf",pt=1, n="myPolySurf")

#hide the Nurbs Surface
cmds.hide("myNurbsSurf")

# e) Move the vertices of the Polygonal surface randomly
# get all the vertices of myPolySurface
allCvs= cmds.ls("myPolySurf.vtx[:][:]", fl=1)

# Move the vertices in PolySurface randomly
def moveVertiRandomly(allCvs, minimum, maximum):
if minimum>= maximum:
print "poly"
# start a loop through all vertices in "x" and "y" axes
else:
for i in allCvs:
x= random.uniform(minimum, maximum)*e
y= random.uniform(minimum, maximum)*e
z= 0
cmds.move (x,y,z,i,r=True)
# move vertices randomly
moveVertiRandomly (allCvs, 0, 0.6)

# f) finish!

Sunday, July 12, 2009

Ex03B_PolyPlane_Deborah&Claudia




#######################
## Ex03B_Move Cvs of a Nurbs according to Locator direction
#######################

import maya.cmds as cmds
import math

#define distance between PolFaces and locator
def magnitude (v):
#v is a list of x,y,z values
x= v[0]
y= v[1]
z= v[2]
m= math.sqrt ( (x*x) + (y*y) + (z*z) )
return m

def distance (posVert, posLoc):
#subtract both vectors
x1= posVert[0]
y1= posVert[1]
z1= posVert[2]
x2= posLoc[0]
y2= posLoc[1]
z2= posLoc[2]
x= x1 - x2
y= y1 - y2
z= z1 - z2
m= magnitude ([x,y,z])
return m

#define moveToLocator function
def moveToLocator():
# A) get all the verticesNames of a plane
allVertices= cmds.ls ("pPlane1.vtx[:]", fl=1)

#create an empty list to store the points
MyVerts=[]

#get selected Locator
selLoc= cmds.filterExpand(sm=22)

#loop through vertices
for v in allVertices:
pos= cmds.pointPosition(v)
x= pos[0]
y= pos[1]
z= pos[2]

#find distance to Locator
posVert= cmds.pointPosition(v)
posLoc= cmds.pointPosition(selLoc)
d= distance(posVert, posLoc)
print d
cmds.move (d,3,d,v,r=True)

#store the cvs in a list
MyVerts.append(allVertices)

#call the function
moveToLocator()

Ex03B_NurbsSphere_Deborah&Claudia




#######################
## Ex03B_Move Cvs of a Nurbs according to Locator direction
#######################

import maya.cmds as cmds
import math

#define distance between cvs and locator
def magnitude (v):
#v is a list of x,y,z values
x= v[0]
y= v[1]
z= v[2]
m= math.sqrt ( (x*x) + (y*y) + (z*z) )
return m

def distance (posPoint, posLoc):
#subtract both vectores
x1= posPoint[0]
y1= posPoint[1]
z1= posPoint[2]
x2= posLoc[0]
y2= posLoc[1]
z2= posLoc[2]
x= x1 - x2
y= y1 - y2
z= z1 - z2
m= magnitude ([x,y,z])
return m

#define moveToLocator function
def moveToLocator():
# A) get all the cvsNames of a NurbsPlane
NurbsCvs = cmds.ls("nurbsSphere1.cv[:]", fl=1)

#create an empty list to store the points
MyCvs=[]

#get selected Locator
selLoc= cmds.filterExpand(sm=22)

#loop through cvs
for i in NurbsCvs:
posPoint= cmds.pointPosition(i)
posLoc= cmds.pointPosition (selLoc)
d= distance(posPoint, posLoc)
print d
cmds.move (d,d,d,i,r=True)

#store the cvs in a list
MyCvs.append(NurbsCvs)

#call the function
moveToLocator()

Ex03B_Curve_Claudia&Deborah




#####################
## Ex03B_Move Cvs of a Curve according to Locator direction
#######################

import maya.cmds as cmds
import math

#define distance between cvs and locator
def magnitude (v):
#v is a list of x,y,z values
x= v[0]
y= v[1]
z= v[2]
m= math.sqrt ( (x*x) + (y*y) + (z*z) )
return m

def distance (posPoint, posLoc):
#subtract both vectores
x1= posPoint[0]
y1= posPoint[1]
z1= posPoint[2]
x2= posLoc[0]
y2= posLoc[1]
z2= posLoc[2]
x= x1 - x2
y= y1 - y2
z= z1 - z2
m= magnitude ([x,y,z])
return m

#define moveToLocator function
def moveToLocator():
# A) get all the cvsNames of a curve
allCvs = cmds.ls("curve1.cv[:]", fl=1)

#create an empty list to store the points
MyCvs=[]

#get selected Locator
selLoc= cmds.filterExpand(sm=22)

#loop through cvs
for i in allCvs:
posPoint= cmds.pointPosition(i)
posLoc= cmds.pointPosition (selLoc)
d= distance(posPoint, posLoc)
print d
cmds.move (0,0,d,i,r=True)

#store the cvs in a list
MyCvs.append(cvs)

#call the function
moveToLocator()

Clau_Ex03B_Doubts

Daniel, I am trying to move the vertices of a Curve according to the direction of a Locator. I could move the position of the Curve to the direction of a locator -see script below- however, when i try to apply this logic to move the vertices of the curve, i get lost. Don't tell you about moving the cv's of a nurbs surface according the direction of a locator. Could you help me?
This is the scripting with probls
## Ex03B_Move Curve Cvs according to Locator direction
#####

import maya.cmds as cmds
import math

#get names of selected objects on Stage
#first select the objects
selObj= cmds.ls(sl=1)
print selObj

#find position of this two objetcs
obj1= selObj[0] #this is for locator1
obj2= selObj[1] #this is for curve1
print obj1
print obj2

pos1= cmds.pointPosition(obj1)
pos2 = cmds.pointOnCurve(obj2)
print pos1
print pos2

#find distance between two objects
d= distance (pos1,pos2)
print d

#move all vertices of obj2 10 times in direction to obj1
# select all vertices of obj2
allCvs = cmds.ls("curve1.cv[:]", fl=1)

# I dont know how to continue....


Here is the script to move the curve position according to loc1 direction
## Ex03B_Move Curve according to Locator direction
#####

import maya.cmds as cmds
import math

#get names of selected objects on Stage
#first select the objects
selObj= cmds.ls(sl=1)
print selObj

#find position of this two objetcs
obj1= selObj[0] #this is for locator1
obj2= selObj[1] #this is for curve1
print obj1
print obj2

pos1= cmds.pointPosition(obj1)
pos2= cmds.pointOnCurve(obj2)
print pos1
print pos2

#find distance between two objects
d= distance (pos1,pos2)
print d

#move obj2 4 times in direction to obj1
# first get vectors between obj2 and obj1
v= vectorBetweenPoints(pos1,pos2)
# get the unit of vector v
dir= unit(v)

#move 4 units in dir obj1
newPos= move (dir,4)

#move obj2 to that position
cmds.move (newPos[0], newPos[1], newPos[2], obj2)

This is the exercise of extruding faces of a polygon according to the distance of a Locator.



### Ex03B ######
## Vector Functions
import maya.cmds as cmds
import math
import random

########### extrude the faces of a polygonal object
# according to its distance to a certain
# locator

def ExtrudeToLocator():
"Extrude based on a distance of a certain Locator"
#get selected Poly and selected Locator
selPoly= cmds.filterExpand(sm=12)
selLoc= cmds.filterExpand(sm=22)
selPoly= selPoly[0]

#get all faces of the Poly
allFaces= cmds.ls(selPoly + ".f[:]", fl=1)

#start a loop through all faces
for face in allFaces:
vertex= cmds.polyListComponentConversion (face, fromFace=1, toVertex=1)
vertex= cmds.ls (vertex, fl=1)
# find the center of the face
xs= 0
ys= 0
zs= 0

#loop through vertices
for v in vertex:
pos= cmds.pointPosition(v)
x= pos[0]
y= pos[1]
z= pos[2]
xs= xs + x
ys= ys + y
zs= zs + z
centerX= xs/len(vertex)
centerY= ys/len(vertex)
centerZ= zs/len(vertex)

#check by placing a Locator
cmds.spaceLocator(p=(centerX, centerY, centerZ))

#find distance to Locator
posLoc= cmds.pointPosition(selLoc)
d= distance([centerX, centerY, centerZ], posLoc)

#extrude based on distance
cmds.polyExtrudeFacet(face, ltz=d)

#extrude to locator
ExtrudeToLocator()

Saturday, July 11, 2009

Claudia_Ex03A










######### Excercise 03A
import maya.cmds as cmds
import random
import math

###### CURVE ######
# A) get all the cvsNames of a curve
allCvs = cmds.ls("curve1.cv[:]", fl=1)

# B) define move cvs randomly
def moveVertRandomly (allCvs, minimum, maximum):
if minimum>= maximum:
print "hello!"
# B.1) start a loop through all cvs
else:
for cv in allCvs:
rx = random.uniform(minimum, maximum)
ry = random.uniform(minimum, maximum)
rz = random.uniform(minimum, maximum)
cmds.move (rx,ry,rz,cv,r=2)

# C) move cvs randomly
moveVertRandomly (allCvs, 0, 17)

####### Nurbs Surface #######
# A) get all the vertices of the Nurbs
allCvs= cmds.ls("nurbsPlane1.cv[:][:]", fl=1)

# B) define move cvs in nurbsPlane randomly
def moveVertiRandomly(allCvs, minimum, maximum,x,y,z):
if minimum>= maximum:
print "hello!"
# B.1) start a loop through all cvs in z axis
else:
for i in allCvs:
x= 0
y= 0
z= random.uniform(minimum, maximum)
cmds.move (x,y,z,i,r=True)
# C) move dvs randomly
moveVertiRandomly (allCvs, 2, 18, 0,0,7)

####### Faces of a Polygon #######
# A) get all faces of a Polygon
allFaces= cmds.ls ("pCone1.f[:]", fl=1)

# B) define extrude faces of a polygon
def ExtrudeFacesRandom (allFaces, minimum, maximum):
if minimum>= maximum:
print "polygon"
# B.1 start a loop through all faces in y axix
else:
for face in allFaces:
ry= random.uniform(minimum, maximum)
cmds.polyExtrudeFacet(face, ltz=ry)

# C) extrude faces
ExtrudeFacesRandom(allFaces, 0,10)

####### Polygon Vertices #######
# A) get all vertices of a Polygon
allVertices= cmds.ls ("pPlane1.vtx[:]", fl=1)

# B) define movePolVertices
def movePolVert (allVertices, minimum, maximum):
if minimum>= maximum:
print "polygon"
# B.1 start a loop through vertices in z axis
else:
for e in allVertices:
rx= random.uniform (minimum, maximum)
ry= random.uniform (minimum, maximum)
rz= random.uniform (minimum, maximum)
cmds.move (rx,ry,rz,e,r=True)

# C) move Polygon Vertices
movePolVert(allVertices,1,7)

Monday, June 8, 2009

Clau_Ex 02B



#Exercise 02B
import maya.cmds as cmds
from math import*
from random import*
#from curves to surfaces
#1 Step: create a curve
def curves (amplitude):
#def initial variables
numPoints= 50
#create an empty list to store the points
points=[]
#loop and gather information
for i in range (1,numPoints,1):
#function of the spiral curve:
x=sin(i)*amplitude
y=cos(i)*amplitude/1.2
z= i
myPoint= (x,y,z)
#store the points in the list
points.append(myPoint)
myCurve=cmds.curve(d=3, p=points)
return myCurve

#create an empty list to store the curves
myCurve=[]
#define the number of curves
numCurves=20
#function to call the curve in a loop
for i in range(0,numCurves,2):
crv= curves (i)
#store the curve in the list
myCurve.append (crv)
print crv
#move the curves
cmds.move (25,15,15, crv)
#loft the curves
cmds.loft(myCurve)

Sunday, May 24, 2009

02A_Clau_from points to curves

In the first part of this exercise I took the code of the previous assingment, but instead of plotting points I generated curves (see image). Then I tried to convert the code into a function and return the value but didn't get a result. I have a Syntax Error. I don't know where is the mistake.


import maya.cmds as cmds
from math import*
from random import*
######################################################
#from points to curves
#defining initial variables
numRows= 40
numColumns=4
numLevels=12
amplitude = 12

#create an empty list to store the points
points= []

#defining the loop and gather information
for i in range (-1,numRows,1):
x= sin(6*i)*amplitude
for j in range (-1,numColumns,2):
y= cos(i)*8
for k in range (0,numLevels,1.5):
z= k+1
myPoint=(x,y,z)
#store the point in the list
points.append(myPoint)

#create the curve
cmds.curve (d= 3, p= points) #curve degree 3

######################################################
######################################################
#2ND PART
#####################################################
#defining initial variables
numRows= 40
numColumns=4
numLevels=12
amplitude = 12

#defining the curve
def Curves (numPoints, amplitude)

#create an empty list to store the points
points= []

#loop and gather point information
for i in range (-1,numRows,1):
x= sin(6*i)*amplitude
for j in range (-1,numColumns,2):
y= cos(i)*8
for k in range (0,numLevels,1.5):
z= k+1
myPoint=(x,y,z)
#store the point in the list
points.append(myPoint)

#creating the curve
myCurve= cmds.curve (d=3, p=points) #curve degree 3

#returning the name of the curve created
return myCurve

Monday, May 18, 2009

clau_tower of points



#creating a tower of points
numRows= 90
numColumns=42
numLevels=12
amplitude = 5
for i in range (-1,numRows,1):
x= sin(6*i)*amplitude
print "row", i
for j in range (-1,numColumns,2):
y= cos(i)*3
print "column", j
for k in range (0,numLevels,1.5):
z= k+1
myPoint=(x,y,z)
cmds.spaceLocator(p=myPoint)

clau_grids of points


#grid of points using nested loops
#rotating grids of points in "z" axis
numRows=12
numColumns=10
for i in range (0,numRows,2):
x=i
print "row", i
for j in range (0,numColumns,1):
y=j+1
print "column", j
z=1
myPoint = (x,y,z)
cmds.spaceLocator (p=myPoint

numRows=12
numColumns=10
for i in range (0,numRows,2):
x=i/2
print "row", i
for j in range (0,numColumns,1):
y=j+1
print "column", j
z=-1
myPoint = (x,y,z)
cmds.spaceLocator (p=myPoint)

numRows=12
numColumns=10
for i in range (0,numRows,2):
x=-i/2
print "row", i
for j in range (0,numColumns,1):
y=-j
print "column", j
z=2
myPoint = (x,y,z)
cmds.spaceLocator (p=myPoint)

numRows=12
numColumns=10
for i in range (0,numRows,2):
x=-i
print "row", i
for j in range (0,numColumns,1):
y=j
print "column", j
z=3
myPoint = (x,y,z)
cmds.spaceLocator (p=myPoint)

numRows=12
numColumns=10
for i in range (4,numRows,2):
x=i
print "row", i
for j in range (0,numColumns,1):
y=j+2
print "column", j
z=5
myPoint = (x,y,z)
cmds.spaceLocator (p=myPoint)

clau_plot points



#random points loop using negative numbers
numPoints = 60
for i in range (-5,numPoints,1):
x= randint(0,5) #this generate a random integer between 0 and 5
y= randint (0,5)
z= 0
myPoint= (x,y,z)
cmds.spaceLocator (p=myPoint)

numPoints = 100
for i in range (-5,numPoints,1):
x= randint(0,5) #this generate a random integer between 0 and 5
y= randint (0,5)
z= 5
myPoint= (x,y,z)
cmds.spaceLocator (p=myPoint)

numPoints = 60
for i in range (-5,numPoints,1):
x= randint(-5,0) #this generate a random integer between 0 and 5
y= randint (-5,0)
z= 10
myPoint= (x,y,z)
cmds.spaceLocator (p=myPoint)

numPoints = 100
for i in range (-5,numPoints,1):
x= randint(-3,0) #this generate a random integer between -3 and 0
y= randint (0,5)
z= 10
myPoint= (x,y,z)
cmds.spaceLocator (p=myPoint)

numPoints = 180
for i in range (-5,numPoints,1):
x= randint(-3,0) #this generate a random integer between -3 and 0
y= randint (-5,5)
z= -5
myPoint= (x,y,z)
cmds.spaceLocator (p=myPoint)

numPoints = 240
for i in range (-5,numPoints,1):
x= randint(-5,10) #this generate a random integer between -5 and 10
y= randint (-5,0)
z= -3
myPoint= (x,y,z)
cmds.spaceLocator (p=myPoint)

Monday, May 4, 2009

clau.pseudo-code again

I realized what the problem was with my code flow and here I fix it. I hope it is ok. Again I have problems with identation, I don´t know how to controll it in order to have desired order of functions

Buy a train ticket to Berlin in a ticket-vending machine.

For humans
Go to the ticket machine
Press the button Ticket- Reservation
Select the departure and destination cities
Select the date and time
Select the number of travelers
Select the means of transport
Press search button
Select the journey that fit best with your request
Press purchase button and proceed to buy the ticket


For computers
function informationRequest:
with ticketMachine
press ticketMachine.monitor
select ticketReservation.button
press departure.button
with the keyboard on the monitor
write Dessau
press DessauHbf.button
press destination.Key
with the keyboard on the monitor
write Berlin
press BerlinHbf.button
desiredDay = Today
desiredTime = 23:00
desiredTravelers = Adult
desiredTravelers.number = 1
desiredTravel.class= secondClass
desiredMeansTransport = localTransport
press search.button
execute function selectionJourney

function selectionJourney:
on standardFare.column and
along dep 23.17 arr 01:06.row
press purchase.button
execute function buyTicket

function buyTicket:
get credit.Card
with credit.Card
move 20 cm right
move 5 cm up
insert credit.Card inside ticketMachine.slot

when hear “beep” sound
remove creditCard
put creditCard in initial position
with keyboard near ticketMachine.slot
write creditCard.pinCode
press B button
wait monitor change image
move 60 cm down
open window
remove ticket
execute function remove ticket
else:
finish

Friday, April 24, 2009

clau.pseudo-code

Although I tried many times that the format looked nicer (using/not using tab) with the Format for blogging, I couldn´t achieve it. I don´t know what is the mistake. But here is the exercise.

Buy a train ticket to Berlin in a ticket-vending machine.
For humans
Go to the ticket machine
Press the button Ticket- Reservation
Select the departure and destination cities
Select the date and time
Select the number of travelers
Select the means of transport
Press search button
Select the journey that fit best with your request
Press purchase button and proceed to buy the ticket


For computer
function informationRequest:
with ticketMachine
press ticketMachine.monitor
select ticketReservation.button
press departure.button
with the keyboard on the monitor
write Dessau
press DessauHbf.button
press destination.Key
with the keyboard on the monitor
write Berlin
press BerlinHbf.button
desiredDay = Today
desiredTime = 23:00
desiredTravelers = Adult
desiredTravelers.number = 1
desiredTravel.class= secondClass
desiredMeansTransport = localTransport
press search.button
execute function informationRequest

function selectionJourney:
on standardFare.column and
along dep 23.17 arr 01:06.row
press purchase.button
execute selectionJourney

function buyTicket:
get credit.Card
with credit.Card
move 20 cm right
move 5 cm up
insert credit.Card inside ticketMachine.slot

when hear “beep” sound
remove creditCard
put creditCard in initial position
with keyboard near ticketMachine.slot
write creditCard.pinCode
press B button
wait monitor change image
move 60 cm down
open window
remove ticket
execute buyTicket
else:
finish