Version: Python 3.7
for obj in group_obj.objects:
bpy.ops.ed.undo_push()
--> move_rotate(obj, T, T_0)
|
| if check_if_cross_wall(obj):
| bpy.ops.ed.undo()
________from there
count += 1
accessableArea(obj)
Here is my code, My target is to check if the condition satisfied, if True, it will reverse the operation and goto first line directly. I think goto is the most suitable way to do this, but I just know goto in C or C++, python do not contain this. Is there any other way to alter it?
My code logic is:
move & rotate object, then check if it cross the wall, if True, reverse the operation, then move & rotate again and check if it cross the wall. If False, it will save current state and go to next object
>Solution :
No, there is no "goto" in Python. To accomplish the sort of jump you describe, you can just use a loop though with a continue statement to move back to the start of the loop and break to exit the loop, like this:
for obj in group_obj.objects:
bpy.ops.ed.undo_push()
while True:
move_rotate(obj, T, T_0)
# as long as this is true, it will keep
# moving back to the start of the loop
if check_if_cross_wall(obj):
bpy.ops.ed.undo()
continue
# Exit the loop
break
count += 1
accessableArea(obj)