View Single Post
  #5  
Old 01-04-2012, 05:35 PM
starlingstm starlingstm is offline
Member
 
Join Date: May 2011
Posts: 19
Thanks, I was trying to apply the INT function, but the ROUND function works great! I'm struggling now with ending a loop within a function. I've tried to apply the BREAK and SYS Exit functions but its yielding the results I'm seeking.

Goal: When the first function is true, the student must reply accordingly and this part of the program will no execute. The student moves to the second function and when its true, student will reply and this also will no longer execute... and so on with the remaining functions. Instead, when the program is ran it continues to loop through each function.

import viz
import vizact
import vizshape
viz.go()

ar = viz.add('artoolkit.dle')
#Setting Board as Reference Marker
camera = ar.addWebCamera()
board = camera.addMatrixMarker(0,width=1000)
camera.setGlobalMarker(board)


#Assigning Bars to Markers
bar_a = camera.addMatrixMarker(1,width=1000)
bar_b = camera.addMatrixMarker(2,width=1000)
bar_c = camera.addMatrixMarker(3,width=1000)
bar_d = camera.addMatrixMarker(4,width=1000)
bar_e = camera.addMatrixMarker(5,width=1000)
bar_f = camera.addMatrixMarker(6,width=1000)





#Connecting Bar A
def barA():
for number in range(1):
bar_a_pos = bar_a.getPosition(viz.ABS_GLOBAL)
bar_a_ang = bar_a.getEuler(viz.ABS_GLOBAL)
for pos in bar_a_pos and bar_a_ang:
print 'You now have bar a'
if round(bar_a_pos [0]) <= -1.0 and round(bar_a_pos[0]) >= -4.0 and round(bar_a_pos[1]) >= 5.0 and round(bar_a_pos[1]) <= 8.0 and round(bar_a_pos[2]) >= 5.0 and round(bar_a_pos[2]) <= 8.0:
if round(bar_a_ang [0]) <= -39.0 and round(bar_a_ang[0]) >= -42.0 and round(bar_a_ang[1]) >= 5.0 and round(bar_a_ang[1]) <= 8.0 and round(bar_a_ang[2]) >= 3.0 and round(bar_a_ang[2]) <= 6.0:
input("Bar A has been place correctly, Mount with screws then type done")
return
else:
print 'Check position or orientation for Bar A', bar_a_pos, bar_a_ang
return


#Printing Bar A position and orientation
vizact.ontimer(2,barA)
#Connecting Bar B
def barB():
for number in range(1):
bar_b_pos = bar_b.getPosition(viz.ABS_GLOBAL)
bar_b_ang = bar_b.getEuler(viz.ABS_GLOBAL)
for pos in bar_b_pos and bar_b_ang:
if round(bar_b_pos [0]) >= -5.0 and round(bar_b_pos[0]) <= -2.0 and round(bar_b_pos[1]) >= 0.0 and round(bar_b_pos[1]) <= 3.0 and round(bar_b_pos[2]) >= 0.0 and round(bar_b_pos[2]) <= 3.0:
if round(bar_b_ang [0]) >= 173.0 and round(bar_b_ang[0]) <= 176.0 and round(bar_b_ang[1]) >= 6.0 and round(bar_b_ang[1]) <= 9.0 and round(bar_b_ang[2]) >= -5.0 and round(bar_b_ang[2]) <= -2.0:
input("Bar B has been placed correctly, Mount with screws then type done")
return
else:
print 'Check position or orientation for Bar B', bar_b_pos, bar_b_ang
return


#Printing Bar B position and orientation
vizact.ontimer(2,barB)

#Connecting Bar
def barC():
for number in range(1):
bar_c_pos = bar_c.getPosition(viz.ABS_GLOBAL)
bar_c_ang = bar_c.getEuler(viz.ABS_GLOBAL)
for pos in bar_c_pos and bar_c_ang:
if round(bar_c_pos [0]) <= -6.0 and round(bar_c_pos[0]) >= -8.0 and round(bar_c_pos[1]) >= 1.0 and round(bar_c_pos[1]) <= 4.0 and round(bar_c_pos[2]) >= 0.0 and round(bar_c_pos[2]) <= 3.0:
if round(bar_c_ang [0]) >= 86.0 and round(bar_c_ang[0]) <= 89.0 and round(bar_c_ang[1]) <= -2.0 and round(bar_c_ang[1]) >= -6.0 and round(bar_c_ang[2]) <= -7.0 and round(bar_c_ang[2]) >= -10.0:
input("Bar C has been place correctly, Mount with screws then type done")
return
else:
print 'Check position or orientation for Bar C', bar_c_pos, bar_c_ang
return


#Printing Bar C position and orientation
vizact.ontimer(2,barC)

#Connecting Bar D
def barD():
for number in range(1):
bar_d_pos = bar_d.getPosition(viz.ABS_GLOBAL)
bar_d_ang = bar_d.getEuler(viz.ABS_GLOBAL)
for pos in bar_d_pos and bar_d_ang:
if round(bar_d_pos [0]) >= 1.0 and round(bar_d_pos[0]) <= 4.0 and round(bar_d_pos[1]) >= 0.0 and round(bar_d_pos[1]) <= 3.0 and round(bar_d_pos[2]) <= 0.0 and round(bar_d_pos[2]) >= -3.0:
if round(bar_d_ang [0]) >= 90.0 and round(bar_d_ang[0]) <= 93.0 and round(bar_d_ang[1]) >= 0.0 and round(bar_d_ang[1]) <= 3.0 and round(bar_d_ang[2]) <= 0.0 and round(bar_d_ang[2]) >= -3.0:
input("Bar D has been place correctly, Mount with screws then type done")
return
else:
print 'Check position or orientation for Bar D', bar_d_pos, bar_d_ang
return


#Printing Bar D position and orientation
vizact.ontimer(2,barD)

#Connecting Bar E
def barE():
for number in range(1):
bar_e_pos = bar_e.getPosition(viz.ABS_GLOBAL)
bar_e_ang = bar_e.getEuler(viz.ABS_GLOBAL)
for pos in bar_e_pos and bar_e_ang:
if round(bar_e_pos [0]) <= -1.0 and round(bar_e_pos[0]) >= -4.0 and round(bar_e_pos[1]) >= 5.0 and round(bar_e_pos[1]) <= 8.0 and round(bar_e_pos[2]) >= 5.0 and round(bar_e_pos[2]) <= 8.0:
if round(bar_e_ang [0]) <= -39.0 and round(bar_e_ang[0]) >= -42.0 and round(bar_e_ang[1]) >= 5.0 and round(bar_e_ang[1]) <= 8.0 and round(bar_e_ang[2]) >= 3.0 and round(bar_e_ang[2]) <= 6.0:
input("Bar E has been place correctly, Mount with screws then type done")
return
else:
print 'Check position or orientation for Bar E', bar_e_pos, bar_e_ang
return


#Printing Bar E position and orientation
vizact.ontimer(2,barE)

#Connecting Bar F
def barF():
for number in range(1):
bar_f_pos = bar_f.getPosition(viz.ABS_GLOBAL)
bar_f_ang = bar_f.getEuler(viz.ABS_GLOBAL)
for pos in bar_f_pos and bar_f_ang:
if round(bar_f_pos [0]) <= -1.0 and round(bar_f_pos[0]) >= -4.0 and round(bar_f_pos[1]) >= 5.0 and round(bar_f_pos[1]) <= 8.0 and round(bar_f_pos[2]) >= 5.0 and round(bar_f_pos[2]) <= 8.0:
if round(bar_f_ang [0]) <= -39.0 and round(bar_f_ang[0]) >= -42.0 and round(bar_f_ang[1]) >= 5.0 and round(bar_f_ang[1]) <= 8.0 and round(bar_f_ang[2]) >= 3.0 and round(bar_f_ang[2]) <= 6.0:
input("Bar A has been place correctly, Mount with screws then type done")
return
else:
print 'Check position or orientation for Bar F', bar_f_pos, bar_f_ang
return


#Printing Bar F position and orientation
vizact.ontimer(2,barF)

#Running Functions
barA()

barB()

barC()

barD()

barE()

barF()
Reply With Quote