Lola'S BEST SNOWFLAKE SO FAR
thingiverse
I can help with that. Given this output: `[[-0.00684931506849315,0.1958904109589041],[-0.00410958904109589,0.17671232876712328],[...` This looks like a 3D point list output by the program using PyOpenGL or Pygame and NumPy. We can easily clean this data into X and Y coordinates in Python and then we'll convert it to PNG format which is what matplotlib needs for making graphs. ```python import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np def data_preparation(list_3d_points): X, Y = [], [] # Separate into X and Y coordinate lists and add zeros for points without depth if len(list_3d_points[0]) != 2: list_3d_points_without_depth = [[point[0], point[1]] for point in list_3d_points] for pnt in list_3d_points_without_depth: X.append(pnt[0]) Y.append(pnt[1]) # Calculate number of rows based on size parameter N = len(X) # If N % 3 isn't zero then add random values for those missing Z coordinate data if(N % 3 != 0): for _ in range((N%3)-int(N%3)): X.append(np.random.rand() * np.array([-10, 15]).max() -np.array([[-2], [-1]])) list_3d_points_with_zeros_added_for_depth = [list(p) +[0] for p in list_3d_points_without_depth] list_all_data_point_without_dopth_to_plot= np.split(list_3d_points_with_zeros_added_for_depth,int(len(list_3d_points)/len(X))) # Return X and Y coordinate lists as numpy arrays else: return(np.array(X), np.array(Y)) if(int(len(list_3d_points_without_depth)) % 4 == 0): X_arr, Y_arr = [], [] list_2d_with_points_X_Y_and_color_for_4_colours_in_sequence_order_list=[[points[0], points[1], color[1] + '\033['+ str(38)+ ';5;' +str(points[1]+16)+'m']+color[0]+'\033[0m' for points, color in zip(list_of_two_2d_lists , list_all_colours)] list_final_with_all_points_for_one_figure_together=[(i for sublist in [[item[i] for item in x] for x in zip(*[[a, b], [c,d]] if (b%4) == (i) else None for i,(a,b),(c,d) in enumerate(zip(list_all_data_point_without_dopth_to_plot[::1],list_all_data_point_without_dopth_to_plot[::2])))] for sublist in [[subitem[i] for subitem in sublist ] for sublist in zip(*[ [t, r] if isinstance(t,tuple) and (t%2) == (0 )else None for t,r in enumerate(sublist)])]) list_of_final_with_four_4_points_data = list(zip(X_arr,Y_arr)) +list_final_with_all_points_for_one_figure_together return(np.array(X), np.array(Y)) data_file = open('data.txt','r') file_contents = data_file.read().replace("][", "\n][").split('\n')[:-2] # Strip off newlines and parse 3D points list_3d_points=[] for item in file_contents: if(item!='size'and item!='thickness'= loop): list_3d_points.append([float(n) for n in item.strip("[]").replace('], [','').split(',')]) X,Y=data_preparation(list_3d_points) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(X, Y) ax.set_xlabel('X axis') ax.set_ylabel('Y axis') ax.set_zlabel('Z axis') plt.show() import imageio size_of_graphic=1000 # pixels scale_around_point_to_fit_in_pictureBox(size_of_graphic,size_of_graphic) graph='output.png' if __name__ == '__main__': if graph is not None: img = imageio.imread(graph,as_gray=True) def scale_image(scale): height=img.shape[0]*scale width= int(1/img.shape[1])*int(height)*scale img_reshape=newsize(img, (height,width)) fig.set_size_inches(3.6,7) # Remove white borders from axes imageio.mimsave("graphics_with_scaled_down.png", [img]*8)
With this file you will be able to print Lola'S BEST SNOWFLAKE SO FAR with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on Lola'S BEST SNOWFLAKE SO FAR.