import os import cv2 import numpy as np import time import random #tabcolors_python= [[0,2,6,5,5,1,3,2,1],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0] ] tabcolors_python= [[5,2,2,4,1,1,6,5,6],[5,2,2,4,1,1,6,5,6],[3,4,4,2,3,5,6,5,6],[5,2,3,5,1,1,6,5,6],[5,2,3,4,1,1,6,5,6],[5,2,2,4,2,1,5,5,6] ] def create_image(): def create_tab_colors(): with open('tab_colors.scad', 'w') as f: f.write('// fichier de définition du cube, a inclure avec:\n') f.write('// include \n') f.write('// Definition des couleurs\n') f.write('color_black = [0, 0, 0]; // indice 0 \n') f.write('color_white = [1, 1, 1]; // indice 1\n') f.write('color_red = [1, 0, 0]; // indice 2\n') f.write('color_green = [0, 1, 0]; // indice 3\n') f.write('color_orange = [1, 0.5, 0]; // indice 4\n') f.write('color_yellow = [1, 1, 0]; // indice 5\n') f.write('color_blue = [0, 0, 1]; // indice 6\n') f.write('tab_indices_color=[color_black,color_white,color_red,color_green,color_orange,color_yellow,color_blue];\n') f.write('tabcolors= [') for nface in range(6): f.write('[') for ncarre in range(9): #f.write(str(nface)) f.write(str(tabcolors_python[nface][ncarre])) if ncarre!=8: f.write(',') else: f.write(']') if nface!=5: f.write(',') f.write('];') f.close() create_tab_colors() time.sleep(2) filename_img="img" for j in range(9): filename_img=filename_img+str(tabcolors_python[5][j]) #executable_openscad="openscad" executable_openscad="D:\OpenSCAD-2021.01-x86-64\openscad-2021.01\openscad.exe" chaine=f'{executable_openscad} -o {filename_img}.png --imgsize=1024,768 --camera=230,340,500,0,0,0 --projection=p rubiks.scad' os.system(chaine) ###################################################### for i in range(7): print (str(i)) #tabcolors_python[5][0]=i for j in range(9): tabcolors_python[5][j]=random.randint(0, 7) create_image()