import random from PIL import Image, ImageDraw import time import sys import numpy as np from stl import mesh import json time.sleep(3) # arg format is like this: args ['test1.py', '{"kiste":{"value":"321"},"labelformat":{"value":"123123"},"print_machine_selection":{"data":{"displayName":"Brother Workplace","ip":"127.0.0.1"},"value":"Brother Workplace"}}', '--undo'] undo is optional json_object = json.loads(sys.argv[1]) labelformat = json_object["labelformat"] kiste = json_object["kiste"] print("args", sys.argv) if len(sys.argv) >= 5: undo = sys.argv[4] if undo == "--undo": print("finish undo") sys.exit(0) print("hello this is test1") if labelformat is None or kiste is None: sys.exit(100) print("hello friend", labelformat, kiste) fp = open("customers.txt", "w") fp.write("first line hey customer") fp.close() # Bildgröße und Pixelgröße festlegen width = 100 height = 100 line_thickness = 5 max_lines = 5 # Das Bildgröße anpassen image_width = width * line_thickness image_height = height * line_thickness # Hintergrundfarbe festlegen background_color = (255, 255, 255) # Weiß for i in range(10): # Ein neues Bild erstellen image = Image.new("RGB", (image_width, image_height), background_color) # Eine Zeichenfläche für das Bild erstellen draw = ImageDraw.Draw(image) # Zufällige Linien zeichnen for _ in range(max_lines): start_x = random.randint(0, image_width) start_y = random.randint(0, image_height) end_x = random.randint(0, image_width) end_y = random.randint(0, image_height) color = (random.randint(0, 255), random.randint( 0, 255), random.randint(0, 255)) draw.line([(start_x, start_y), (end_x, end_y)], fill=color, width=line_thickness) # Bild als Datei speichern image.save("generiertes_bild"+str(i)+".jpg") # Abmessungen des rechteckigen Modells width = 196 height = 196 depth = 26 # Eckpunkte des Modells erstellen vertices = np.array([ [0, 0, 0], [width, 0, 0], [width, height, 0], [0, height, 0], [0, 0, depth], [width, 0, depth], [width, height, depth], [0, height, depth] ]) # Flächen des Modells definieren faces = np.array([ [0, 1, 2], [0, 2, 3], [0, 1, 5], [0, 4, 5], [0, 3, 7], [0, 4, 7], [1, 2, 6], [1, 5, 6], [2, 3, 7], [2, 6, 7], [4, 5, 6], [4, 6, 7] ]) # Erstellen des Modells mit den Eckpunkten und Flächen rectangular_mesh = mesh.Mesh(np.zeros(faces.shape[0], dtype=mesh.Mesh.dtype)) for i, face in enumerate(faces): for j, vertex_id in enumerate(face): rectangular_mesh.vectors[i][j] = vertices[vertex_id] # Exportieren des Modells als .stl-Datei rectangular_mesh.save('rectangular_model.stl') print("Das 3D-Modell wurde erfolgreich als 'rectangular_model.stl' exportiert.") """ try: x = 5 / 0 # Hier wird ein Fehler ausgelöst except ZeroDivisionError: print("Ein Fehler ist aufgetreten: Division durch Null.") raise SystemExit(140) """