Compare commits

...

2 Commits

Author SHA1 Message Date
Eduard Gerlitz
0dd8a929f5 v2.1.1 2025-03-18 16:23:31 +01:00
Eduard Gerlitz
044f9c1bc4 v2.1 2025-03-13 16:57:12 +01:00
12 changed files with 279 additions and 172 deletions

View File

@ -1,4 +1,16 @@
# CHANGELOG # CHANGELOG
v2.1.1
- Installer und Run Skripte als BAT (ehemals als PS1)
- Bugfix funct_gen: WP_NUM
- Add Button GEN+TRANSFER CFG_DMUAUT.SPF
- Anpassen funct_probe Positionen
v2.1
- Add funct_probe
- abhängig von WP- und CLP-Werten
v2.0.1 v2.0.1
- Anpassung funct_gen.py - Anpassung funct_gen.py
- Anpassung Layout - Anpassung Layout

12
EXEC_INSTALL.bat Normal file
View File

@ -0,0 +1,12 @@
@echo off
setlocal
:: ---------- USER DEFINE --------------
set "ymlPath=condaenv.yml"
:: -------------------------------------
:: Execute the Python script
conda env create -f "%ymlPath%"
:: Pause at the end of the script
pause

View File

@ -1,9 +0,0 @@
#---------- USER DEFINE --------------
$ymlPath = "./condaenv.yml"
#-------------------------------------
# Execute the Python script
& conda env create -f $ymlPath
# Pause at the end of the script
# Read-Host -Prompt "Press any key to exit"

14
EXEC_MAIN.bat Normal file
View File

@ -0,0 +1,14 @@
@echo off
setlocal
:: ---------- USER DEFINE --------------
set "venvName=dmu50_wingui"
set "scriptPath=MAIN.py"
:: -------------------------------------
:: Activate the Conda environment and execute the Python script
call conda activate %venvName%
python "%scriptPath%"
:: Pause at the end of the script
pause

View File

@ -1,10 +0,0 @@
#---------- USER DEFINE --------------
$venvName = "dmu50_wingui"
$scriptPath = "./MAIN.py"
#-------------------------------------
# Activate the Conda environment and execute the Python script
cmd.exe /c "conda activate $venvName && python $scriptPath"
# Pause at the end of the script
# Read-Host -Prompt "Press Enter to exit"

34
MAIN.py
View File

@ -2,14 +2,13 @@
from functions import * from functions import *
from funct_inlay import * from funct_inlay import *
from funct_wp import * from funct_wp import *
from funct_grp import *
from funct_clp import * from funct_clp import *
from funct_gen import * from funct_gen import *
from funct_probe import *
import tkinter as tk import tkinter as tk
from tkinter import ttk from tkinter import ttk
import yaml import yaml
import shutil
folder_parsets = "_cfg_parsets" folder_parsets = "_cfg_parsets"
folder_pictures = "cfg_picture" folder_pictures = "cfg_picture"
@ -62,10 +61,10 @@ def setup_group(frame, group_name, data, input_vars, selected_params, group_widg
generate_picture_inlay(all_group_vars, picture_to_use) generate_picture_inlay(all_group_vars, picture_to_use)
elif grpnm == "wp": elif grpnm == "wp":
generate_picture_wp(all_group_vars, picture_to_use) generate_picture_wp(all_group_vars, picture_to_use)
elif grpnm == "grp":
generate_picture_grp(all_group_vars, picture_to_use)
elif grpnm == "clp": elif grpnm == "clp":
generate_picture_clp(all_group_vars, picture_to_use) generate_picture_clp(all_group_vars, picture_to_use)
elif grpnm == "probe":
generate_picture_probe(all_group_vars, picture_to_use)
group_image_tk = load_image(picture_to_use, pic_sizelimit) group_image_tk = load_image(picture_to_use, pic_sizelimit)
image_label.configure(image=group_image_tk) image_label.configure(image=group_image_tk)
@ -278,22 +277,27 @@ def setup_evaluation(root, folder_pictures, data, folder_output, input_vars, sel
image_label.grid(row=0, column=0, rowspan=2, padx=10, pady=10) image_label.grid(row=0, column=0, rowspan=2, padx=10, pady=10)
# Function to generate configuration file based on current parameters # Function to generate configuration file based on current parameters
def btn_gen(): def btn_gen_cfg_dmuaut1():
generate_config_spf(folder_output, input_vars, selected_params) gen_cfg_dmuaut(folder_output, input_vars, selected_params)
def btn_gen_custom1(): def btn_gen_cfg_dmuaut2():
generate_config_spf_custom1(folder_output, input_vars, selected_params) gen_cfg_dmuaut(folder_output, input_vars, selected_params, filetransfer=True)
def btn_gen_custom2(): def btn_gen_cfg_inlay1():
generate_config_spf_custom1(folder_output, input_vars, selected_params, filetransfer=True) gen_cfg_inlay(folder_output, input_vars, selected_params)
def btn_gen_cfg_inlay2():
gen_cfg_inlay(folder_output, input_vars, selected_params, filetransfer=True)
# Place buttons in the vertical frame for operations # Place buttons in the vertical frame for operations
button_frame = ttk.Frame(frame) button_frame = ttk.Frame(frame)
button_frame.grid(row=0, column=1, padx=10, pady=10, sticky="n") button_frame.grid(row=0, column=1, padx=10, pady=10, sticky="n")
button1 = ttk.Button(button_frame, text="GEN CFG_DMUAUT.SPF FILE", width=45, command=btn_gen) button1 = ttk.Button(button_frame, text="GEN CFG_DMUAUT.SPF FILE", width=45, command=btn_gen_cfg_dmuaut1)
button1.grid(row=0, column=0, padx=10, pady=5) button1.grid(row=0, column=0, padx=10, pady=5)
button2 = ttk.Button(button_frame, text="GEN CFG_INLAY.SPF FILE", width=45, command=btn_gen_custom1) button2 = ttk.Button(button_frame, text="GEN+TRANSFER CFG_DMUAUT.SPF FILE", width=45, command=btn_gen_cfg_dmuaut2)
button2.grid(row=1, column=0, padx=5, pady=5) button2.grid(row=0, column=1, padx=10, pady=5)
button3 = ttk.Button(button_frame, text="GEN+TRANSFER CFG_INLAY.SPF FILE", width=45, command=btn_gen_custom2)
button3.grid(row=1, column=1, padx=5, pady=5) button3 = ttk.Button(button_frame, text="GEN CFG_INLAY.SPF FILE", width=45, command=btn_gen_cfg_inlay1)
button3.grid(row=1, column=0, padx=5, pady=5)
button4 = ttk.Button(button_frame, text="GEN+TRANSFER CFG_INLAY.SPF FILE", width=45, command=btn_gen_cfg_inlay2)
button4.grid(row=1, column=1, padx=5, pady=5)
root.grid_columnconfigure(0, weight=1) root.grid_columnconfigure(0, weight=1)

View File

@ -8,6 +8,7 @@ Diese GUI dient zur Erfassung verschiedener Parameter für die Maschinenautomati
- **Inlay** - **Inlay**
- **Werkstück Roh- und Fertigmaße (WP Raw & Finish)** - **Werkstück Roh- und Fertigmaße (WP Raw & Finish)**
- **Schraubstock** - **Schraubstock**
- **Antasten Werkstück**
- Verwaltung von Parameter-Sets und Jobs - Verwaltung von Parameter-Sets und Jobs
- Erstellung einer ausführbaren G-Code-Datei mit allen erfassten Parametern - Erstellung einer ausführbaren G-Code-Datei mit allen erfassten Parametern
- Möglichkeit zur direkten Übertragung der G-Code-Datei auf die Steuerung - Möglichkeit zur direkten Übertragung der G-Code-Datei auf die Steuerung

30
def.yml
View File

@ -39,20 +39,20 @@ groups:
cfg: cfg:
picture_name: img_clp.png picture_name: img_clp.png
multicolumn_idx: [5] multicolumn_idx: [5]
# probe: probe:
# parameter: parameter:
# PRB_BOD_RE_Y: double PRB_BOD_RE_X: double
# PRB_BOD_RE_Z: double PRB_BOD_RE_Y: double
# PRB_BOD_LI_Y: double PRB_BOD_LI_X: double
# PRB_BOD_LI_Z: double PRB_BOD_LI_Y: double
# PRB_SEI_HI_X: double PRB_SEI_HI_X: double
# PRB_SEI_HI_Y: double PRB_SEI_HI_Z: double
# PRB_SEI_VO_X: double PRB_SEI_VO_X: double
# PRB_SEI_VO_Y: double PRB_SEI_VO_Z: double
# PRB_VERS_X_X: double PRB_VERS_X_Y: double
# PRB_VERS_X_Y: double PRB_VERS_X_Z: double
# cfg: cfg:
# picture_name: img_probe.png picture_name: img_probe.png
# multicolumn_idx: [5] multicolumn_idx: [5]

View File

@ -10,7 +10,7 @@ def generate_picture_clp(all_group_vars, picture_path, DEBUG=False):
WPR_X = CLP_BACKENWEITE/2 WPR_X = CLP_BACKENWEITE/2
WPR_Y = CLP_BACKENWEITE/2 WPR_Y = CLP_BACKENWEITE/2
WPR_Z = CLP_SPANNHOHE * 5 WPR_Z = CLP_BACKENWEITE
if min(WPR_X, WPR_Y, WPR_Z) <= 0: if min(WPR_X, WPR_Y, WPR_Z) <= 0:
raise ValueError("Dimensions must be positive.") raise ValueError("Dimensions must be positive.")
@ -82,8 +82,8 @@ def generate_picture_clp(all_group_vars, picture_path, DEBUG=False):
ax.text(WPR_X*2, 2*WPR_Y-CLP_AUFLAGETIEFE/2, 0, f'{CLP_AUFLAGETIEFE}mm', color='blue', fontsize=9, weight='bold', ha='left', va='bottom') ax.text(WPR_X*2, 2*WPR_Y-CLP_AUFLAGETIEFE/2, 0, f'{CLP_AUFLAGETIEFE}mm', color='blue', fontsize=9, weight='bold', ha='left', va='bottom')
# Set view properties # Set view properties
z_trans = WPR_Z z_trans = WPR_Z*0.3
zoom_factor = 1.5 # Adjust this factor to zoom out more or less zoom_factor = 1.35 # Adjust this factor to zoom out more or less
ax.view_init(elev=30, azim=-160) ax.view_init(elev=30, azim=-160)
ax.set_xlim([-x_cube * zoom_factor * 0.1, x_cube * zoom_factor]) ax.set_xlim([-x_cube * zoom_factor * 0.1, x_cube * zoom_factor])
ax.set_ylim([-y_cube * zoom_factor * 0.1, y_cube * zoom_factor]) ax.set_ylim([-y_cube * zoom_factor * 0.1, y_cube * zoom_factor])

View File

@ -9,7 +9,9 @@ import shutil
# Function to generate the CFG_DMUAUT.SPF configuration file and save selected parameter sets # Function to generate the CFG_DMUAUT.SPF configuration file and save selected parameter sets
def generate_config_spf(folder_output, input_vars, selected_params): def gen_cfg_dmuaut(folder_output, input_vars, selected_params, filetransfer=False):
filename = "CFG_DMUAUT.SPF"
# Get the current timestamp for folder name (format: YYMMDD_HHmmSS) # Get the current timestamp for folder name (format: YYMMDD_HHmmSS)
timestamp = time.strftime("%y%m%d_%H%M%S") timestamp = time.strftime("%y%m%d_%H%M%S")
folder_path = os.path.join(folder_output, f"{timestamp}") folder_path = os.path.join(folder_output, f"{timestamp}")
@ -19,7 +21,7 @@ def generate_config_spf(folder_output, input_vars, selected_params):
os.makedirs(folder_path) os.makedirs(folder_path)
# Define the file path for the SPF configuration file # Define the file path for the SPF configuration file
spf_file_path = os.path.join(folder_path, "CFG_DMUAUT.SPF") spf_file_path = os.path.join(folder_path, filename)
# Generate the SPF file content # Generate the SPF file content
with open(spf_file_path, "w") as spf_file: with open(spf_file_path, "w") as spf_file:
@ -47,12 +49,15 @@ def generate_config_spf(folder_output, input_vars, selected_params):
print(f"Configuration files saved in {folder_path}") print(f"Configuration files saved in {folder_path}")
os.startfile(folder_path) if filetransfer:
_transfer_to_sinumerik(filename, folder_path)
else:
os.startfile(folder_path)
def generate_config_spf_custom1(folder_output, input_vars, selected_params, filetransfer=False):
def gen_cfg_inlay(folder_output, input_vars, selected_params, filetransfer=False):
filename = "CFG_INL.SPF" filename = "CFG_INL.SPF"
filename2 = "_N_CFG_INL_SPF"
# Get the current timestamp for folder name (format: YYMMDD_HHmmSS) # Get the current timestamp for folder name (format: YYMMDD_HHmmSS)
timestamp = time.strftime("%y%m%d_%H%M%S") timestamp = time.strftime("%y%m%d_%H%M%S")
@ -90,44 +95,47 @@ def generate_config_spf_custom1(folder_output, input_vars, selected_params, file
# Write WP_X[i] and WP_Y[i] values # Write WP_X[i] and WP_Y[i] values
cnt = 0 cnt = 0
spf_file.write(f"WP_NUM={cnt}\n")
for j in range(y_num): # Rows for j in range(y_num): # Rows
for i in range(x_num): # Columns for i in range(x_num): # Columns
if df.iloc[i, j] == 1: # Consider only marked positions if df.iloc[i, j] == 1: # Consider only marked positions
spf_file.write(f"WP_X[{cnt}]={x_offset * i}\n") spf_file.write(f"WP_X[{cnt}]={x_offset * i}\n")
spf_file.write(f"WP_Y[{cnt}]={y_offset * j}\n") spf_file.write(f"WP_Y[{cnt}]={y_offset * j}\n")
cnt += 1 cnt += 1
spf_file.write(f"WP_NUM={cnt}\n")
spf_file.write("; ---------------------------------------------------\n") spf_file.write("; ---------------------------------------------------\n")
spf_file.write(f"M17\n") spf_file.write(f"M17\n")
print(f"Configuration file saved at: {spf_file_path}") print(f"Configuration file saved at: {spf_file_path}")
if filetransfer: if filetransfer:
spf_file_path2 = os.path.join(folder_path, filename2) _transfer_to_sinumerik(filename, folder_path)
shutil.copyfile(spf_file_path, spf_file_path2)
# try:
# Transfer to Sinumerik
url2 = "192.168.214.1"
ssh_username = "manufact"
ssh_password = "SUNRISE"
upload_folder_nc = "/nckfs/_N_MPF_DIR/_N_AUTO_ROB_DIR"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(url2, username=ssh_username, password=ssh_password)
sftp = ssh.open_sftp()
sftp.chdir(upload_folder_nc)
if filename2 in sftp.listdir():
sftp.remove(filename2)
sftp.put(spf_file_path2, filename2)
sftp.close()
ssh.close()
os.remove(spf_file_path2)
print(f"------->>>> FILE TRANSFERED TO SINUMERIK ------->>>> ")
# except Exception as e:
# print(f"ERROR IN FILETRANSFER {e}")
else: else:
os.startfile(folder_path) os.startfile(folder_path)
def _transfer_to_sinumerik(filename, folder_path):
filename2 = f"_N_{filename.replace('.', '_')}"
spf_file_path = os.path.join(folder_path, filename)
spf_file_path2 = os.path.join(folder_path, filename2)
shutil.copyfile(spf_file_path, spf_file_path2)
# Transfer to Sinumerik
url2 = "192.168.214.1"
ssh_username = "manufact"
ssh_password = "SUNRISE"
upload_folder_nc = "/nckfs/_N_MPF_DIR/_N_AUTO_ROB_DIR"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(url2, username=ssh_username, password=ssh_password)
sftp = ssh.open_sftp()
sftp.chdir(upload_folder_nc)
if filename2 in sftp.listdir():
sftp.remove(filename2)
sftp.put(spf_file_path2, filename2)
sftp.close()
ssh.close()
os.remove(spf_file_path2)
print(f"------->>>> {filename} TRANSFERED TO SINUMERIK ------->>>> ")

View File

@ -1,88 +0,0 @@
import matplotlib.pyplot as plt
import numpy as np
def generate_picture_grp(all_group_vars, picture_path, DEBUG=False):
try:
# Extract variables for the gripper
vars = all_group_vars['grp']
h_offset = float(vars['h_offset'])
h_step = float(vars['h_step'])
w_offset = float(vars['w_offset'])
w_step = float(vars['w_step'])
steps_num = int(vars['steps_num'])
# ERROR HANDLING
if h_step <= 0 or w_step <= 0 or steps_num <= 0:
raise ValueError("h_step, w_step, and steps_num must be positive values.")
# Initialize figure
fig, ax = plt.subplots(figsize=(6, 6)) # Square figure
ax.set_aspect('equal')
# Draw the gripper finger
def draw_gripper(x_sign=1):
max_width = x_sign * (w_offset + w_step * (steps_num - 1))
current_height = h_offset
current_width = x_sign * w_offset
# Draw the first block
rect = plt.Rectangle((x_sign, 0), max_width - x_sign, h_offset, facecolor='black', linewidth=0)
ax.add_patch(rect)
# Draw the steps
for _ in range(steps_num):
rect = plt.Rectangle((current_width, current_height), max_width - current_width, h_step, facecolor='black', linewidth=0)
ax.add_patch(rect)
current_height += h_step
current_width += x_sign * w_step
# Draw original gripper finger and x flipped
draw_gripper()
draw_gripper(x_sign=-1)
# Plot the origin point at (0, 0)
ax.plot(0, 0, marker='o', markersize=10, color='red') # Red point at origin
# Flip the y-axis (invert it)
ax.invert_yaxis()
# Set equal aspect ratio to make grid cells look square
ax.set_aspect('equal')
# Hide major ticks and labels (only gridlines should be visible)
ax.set_xticks([])
ax.set_yticks([])
# Add a white border around the plot to ensure the outer gridlines are visible
fig.patch.set_facecolor('white')
plt.subplots_adjust(left=0.05, right=0.95, top=0.95, bottom=0.05) # Adjust padding for the white border
if not DEBUG:
# Save the figure to the specified picture path
plt.gca().set_aspect('equal', adjustable='box')
fig.savefig(picture_path, bbox_inches='tight', pad_inches=0.1, dpi=300, transparent=True)
else:
plt.show()
# Close the figure to free memory
plt.close()
except ValueError as ve:
# Handle value error (e.g., invalid input)
print(f"Invalid Input: Error: {ve}")
except Exception as e:
# Catch any other exceptions and show a generic error message
print(f"An error occurred while generating the gripper finger: {e}")
if __name__ == "__main__":
vars = {
'h_offset': 10,
'h_step': 5,
'w_offset': 20,
'w_step': 10,
'steps_num': 5
}
picture_path = "cfg_picture/TEST_gripper_finger.jpg"
generate_picture_grp(vars, picture_path, DEBUG=True)

163
funct_probe.py Normal file
View File

@ -0,0 +1,163 @@
import matplotlib.pyplot as plt
from functions import *
def generate_picture_probe(all_group_vars, picture_path, DEBUG=False):
(PRB_BOD_RE_Y, PRB_BOD_RE_X, PRB_BOD_LI_Y, PRB_BOD_LI_X,
PRB_SEI_HI_Z, PRB_SEI_HI_X, PRB_SEI_VO_Z, PRB_SEI_VO_X,
PRB_VERS_X_Y, PRB_VERS_X_Z) = \
(float(all_group_vars['probe'][k]) for k in [
'PRB_BOD_RE_Y', 'PRB_BOD_RE_X', 'PRB_BOD_LI_Y', 'PRB_BOD_LI_X',
'PRB_SEI_HI_Z', 'PRB_SEI_HI_X', 'PRB_SEI_VO_Z', 'PRB_SEI_VO_X',
'PRB_VERS_X_Y', 'PRB_VERS_X_Z'])
try:
CLP_BACKENWEITE, CLP_BACKENHOHE, CLP_SPANNHOHE, CLP_AUFLAGETIEFE = (
float(all_group_vars['clp'][k]) for k in
['CLP_BACKENWEITE', 'CLP_BACKENHOHE', 'CLP_SPANNHOHE', 'CLP_AUFLAGETIEFE']
)
except (KeyError, ValueError):
CLP_BACKENWEITE = 100
CLP_BACKENHOHE = 50
CLP_SPANNHOHE = 5
CLP_AUFLAGETIEFE = 5
try:
WPR_X, WPR_Y, WPR_Z = (
float(all_group_vars['wp'][k]) for k in ['WPR_X', 'WPR_Y', 'WPR_Z']
)
except (KeyError, ValueError):
WPR_X = CLP_BACKENWEITE / 2
WPR_Y = CLP_BACKENWEITE / 2
WPR_Z = CLP_BACKENWEITE
fig, ax = plt.subplots(subplot_kw={'projection': '3d'})
# Define raw workpiece dimensions
x_cube, y_cube, z_cube = 2 * WPR_X, 2 * WPR_Y, WPR_Z
vertices_raw = np.array([[0, 0, 0], [x_cube, 0, 0], [x_cube, y_cube, 0], [0, y_cube, 0],
[0, 0, WPR_Z], [x_cube, 0, WPR_Z], [x_cube, y_cube, WPR_Z], [0, y_cube, WPR_Z]])
faces_raw = [vertices_raw[[0, 1, 2, 3]], vertices_raw[[4, 5, 6, 7]], vertices_raw[[0, 3, 7, 4]],
vertices_raw[[1, 2, 6, 5]], vertices_raw[[0, 1, 5, 4]], vertices_raw[[2, 3, 7, 6]]]
# Set axis properties
ax.set_box_aspect([x_cube, y_cube, z_cube])
ax.set(xticks=[], yticks=[], zticks=[])
# Draw WP coordinate system
axis_len = max(x_cube, y_cube, z_cube) * 0.2
colors = ['r', 'g', 'b']
origin_x = 0
origin_y = 0
origin_z = 0
for i, vec in enumerate(np.eye(3)):
ax.quiver(origin_x, origin_y, origin_z, *(axis_len * vec), color=colors[i], linewidth=3)
ax.text(origin_x, origin_y, origin_z - axis_len * 0.3, 'WP', color='black', fontsize=9, weight='bold', ha='center',
va='top')
# Draw WP
ax.add_collection3d(Poly3DCollection(faces_raw, facecolors='k', linewidths=1, edgecolors='k', alpha=.15))
# Draw CLP coordinate system
axis_len = max(x_cube, y_cube, z_cube) * 0.15
colors = ['r', 'g', 'b']
origin_x = WPR_X
origin_y = WPR_Y
origin_z = 0
for i, vec in enumerate(np.eye(3)):
ax.quiver(origin_x, origin_y, origin_z, *(axis_len * vec), color=colors[i], linewidth=3)
ax.text(origin_x, origin_y, origin_z - axis_len * 0.3, 'CLP', color='blue', fontsize=9, weight='bold', ha='center',
va='top')
# Define clamping block dimensions
clp_deep = y_cube * 0.3
base_x = WPR_X - CLP_BACKENWEITE / 2
alpha = 0.35
color = 'blue'
linewidth = 1
# Draw clamping blocks
x = base_x
dx = CLP_BACKENWEITE
y = 0
dy1 = clp_deep
dy2 = CLP_AUFLAGETIEFE
z = 0
dz1 = CLP_SPANNHOHE
dz2 = CLP_BACKENHOHE
plot_clamping(ax, x, y, z, dx, dy1, dy2, dz1, dz2, color=color,
alpha=alpha, linewidth=linewidth)
y = y_cube
plot_clamping(ax, x, y, z, dx, dy1, dy2, dz1, dz2, color=color,
alpha=alpha, linewidth=linewidth, inverty=True)
# Draw parameter
def drawball(XXX, YYY, ZZZ, COLR, SCALFAC):
u, v = np.mgrid[0:2 * np.pi:20j, 0:np.pi:20j]
ball_radius = max(x_cube, y_cube, z_cube) * SCALFAC
ax.plot_surface(
XXX + ball_radius * np.cos(u) * np.sin(v),
YYY + ball_radius * np.sin(u) * np.sin(v),
ZZZ + ball_radius * np.cos(v),
color=COLR
)
txt_offs = max(x_cube, y_cube, z_cube) * 0.05
#BODEN
boden_colr = "red"
drawball(x_cube-PRB_BOD_RE_X, WPR_Y+PRB_BOD_RE_Y, 0, boden_colr, 0.03)
ax.text( x_cube-PRB_BOD_RE_X, WPR_Y+PRB_BOD_RE_Y, 0-txt_offs, f'PRB_BOD_RE', color=boden_colr, fontsize=7, weight='bold', ha='center', va='top')
drawball(0+PRB_BOD_LI_X, WPR_Y+PRB_BOD_LI_Y, 0, boden_colr, 0.03)
ax.text( 0+PRB_BOD_LI_X, WPR_Y+PRB_BOD_LI_Y, 0-txt_offs, f'PRB_BOD_LI', color=boden_colr, fontsize=7, weight='bold', ha='center', va='top')
#SEITE
seiten_colr = "green"
drawball(WPR_X+PRB_SEI_HI_X, y_cube, PRB_SEI_HI_Z, seiten_colr, 0.03)
ax.text(WPR_X+PRB_SEI_HI_X, y_cube, PRB_SEI_HI_Z+txt_offs, f'PRB_SEI_HI', color=seiten_colr, fontsize=7, weight='bold', ha='center', va='bottom')
drawball(WPR_X+PRB_SEI_VO_X, 0, PRB_SEI_VO_Z, seiten_colr, 0.03)
ax.text(WPR_X+PRB_SEI_VO_X, 0, PRB_SEI_VO_Z+txt_offs, f'PRB_SEI_VO', color=seiten_colr, fontsize=7, weight='bold', ha='center', va='bottom')
#VERSATZ Y
vers_colr = "blue"
drawball(0, WPR_Y+PRB_VERS_X_Y, PRB_VERS_X_Z, vers_colr, 0.03)
ax.text( 0-txt_offs, WPR_Y+PRB_VERS_X_Y, PRB_VERS_X_Z, f'PRB_SEI_HI', color=vers_colr, fontsize=7, weight='bold', ha='left', va='bottom')
# Set view properties
z_trans = WPR_Z*0.3
zoom_factor = 1.2 # Adjust this factor to zoom out more or less
ax.view_init(elev=30, azim=-160)
ax.set_xlim([-x_cube * zoom_factor * 0.1, x_cube * zoom_factor])
ax.set_ylim([-y_cube * zoom_factor * 0.1, y_cube * zoom_factor])
ax.set_zlim([-WPR_Z * zoom_factor * 0.1 - z_trans, WPR_Z * zoom_factor - z_trans])
ax.set_aspect('auto')
ax.grid(False) # Remove grid lines
ax.set_xticks([])
ax.set_yticks([])
ax.set_zticks([])
for axis in [ax.xaxis, ax.yaxis, ax.zaxis]:
axis.set_pane_color((1, 1, 1, 0)) # Hide background panes
axis.line.set_color((1, 1, 1, 0)) # Hide axis lines
# Save or display the plot
if not DEBUG:
fig.savefig(picture_path, bbox_inches='tight', dpi=300, transparent=True)
else:
plt.show()
plt.close()
# Example use-case
if __name__ == "__main__":
all_group_vars = {
'PRB_BOD_RE_Y': 0,
'PRB_BOD_RE_X': 0,
'PRB_BOD_LI_Y': 0,
'PRB_BOD_LI_X': 0,
'PRB_SEI_HI_X': 0,
'PRB_SEI_HI_Z': 0,
'PRB_SEI_VO_X': 0,
'PRB_SEI_VO_Z': 0,
'PRB_VERS_X_Y': 5.0,
'PRB_VERS_X_Z': 2.5
}
generate_picture_probe({'probe': all_group_vars}, "cfg_picture/TEST_wpraw.jpg", DEBUG=True)