Skip to content

Commit 3da9057

Browse files
FEAT: extensions link (#6021)
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
1 parent c25dda9 commit 3da9057

4 files changed

Lines changed: 62 additions & 7 deletions

File tree

doc/changelog.d/6021.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extensions link

src/ansys/aedt/core/visualization/post/post_common_3d.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"""
3131

3232
import os
33+
import pathlib
3334
import random
3435
import string
3536
from typing import Dict
@@ -1649,7 +1650,7 @@ def export_model_obj(self, assignment=None, export_path=None, export_as_multiple
16491650
assignment = [assignment]
16501651
if self._app._aedt_version < "2021.2":
16511652
raise RuntimeError("Object is supported from AEDT 2021 R2.") # pragma: no cover
1652-
if not export_path:
1653+
if not export_path or isinstance(export_path, pathlib.Path) and not export_path.name:
16531654
export_path = self._app.working_directory
16541655
if not assignment:
16551656
self._app.modeler.refresh_all_ids()

src/ansys/aedt/core/workflows/maxwell3d/transformer_loss_distribution.py

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
# SOFTWARE.
2323

2424
from pathlib import Path
25+
import tkinter as tk
26+
from tkinter.font import Font
2527

2628
import ansys.aedt.core
2729
from ansys.aedt.core.generic.design_types import get_pyaedt_app
@@ -49,8 +51,29 @@
4951
extension_description = "Transformer loss distribution"
5052

5153

54+
def _text_size(path, entry): # pragma: no cover
55+
# Calculate the length of the text
56+
text_length = len(path)
57+
58+
# Adjust font size based on text length
59+
if text_length < 20:
60+
font_size = 20
61+
elif text_length < 50:
62+
font_size = 15
63+
else:
64+
font_size = 10
65+
66+
# Set the font size
67+
text_font = Font(size=font_size)
68+
entry.configure(font=text_font)
69+
70+
# Adjust the width of the Text widget based on text length
71+
entry.configure(width=max(20, text_length // 2))
72+
73+
entry.insert(tk.END, path)
74+
75+
5276
def frontend(): # pragma: no cover
53-
import tkinter as tk
5477
from tkinter import filedialog
5578
from tkinter import messagebox
5679
import tkinter.ttk as ttk
@@ -278,8 +301,7 @@ def callback(button_id):
278301
elif button_id == 2:
279302
master.flag = False
280303
setup_name = master.solution_option.split(":")[0].strip()
281-
is_solved = [s.is_solved for s in maxwell.setups if s.name == setup_name][0]
282-
if not is_solved:
304+
if maxwell.get_setup(setup_name) and not maxwell.get_setup(setup_name).is_solved:
283305
messagebox.showerror("Error", "Selected setup is not solved.")
284306
return None
285307

@@ -309,9 +331,40 @@ def browse_files():
309331
master.file_path = sample_points_entry.get("1.0", tk.END).strip()
310332
# master.destroy()
311333

334+
def show_popup():
335+
popup = tk.Toplevel(master)
336+
popup.title("Select an Option")
337+
338+
tk.Label(popup, text="Choose an option:").pack(pady=10)
339+
340+
option_var = tk.StringVar(value="Option 1")
341+
342+
tk.Radiobutton(popup, text="Generate mesh grid", variable=option_var, value="Option 1").pack(anchor=tk.W)
343+
number_points_label = tk.Label(popup, text="Number of Points:")
344+
number_points_label.pack(anchor=tk.W, pady=5, padx=20)
345+
points_entry = tk.Text(popup, wrap=tk.WORD, width=20, height=1)
346+
points_entry.pack(pady=5, padx=20)
347+
tk.Radiobutton(popup, text="Import .pts file", variable=option_var, value="Option 2").pack(anchor=tk.W)
348+
349+
def submit():
350+
if option_var.get() == "Option 1":
351+
from ansys.aedt.core.workflows.project.points_cloud import main as points_main
352+
353+
selected_objects = objects_list_lb.curselection()
354+
master.objects_list = [objects_list_lb.get(i) for i in selected_objects]
355+
points = points_entry.get("1.0", tk.END).strip()
356+
pts_path = points_main({"is_test": False, "choice": master.objects_list, "points": int(points)})
357+
358+
_text_size(pts_path, sample_points_entry)
359+
else:
360+
browse_files()
361+
popup.destroy()
362+
363+
tk.Button(popup, text="OK", command=submit).pack(pady=10)
364+
312365
# Export points file button
313366
export_points_button = ttk.Button(
314-
sample_points_frame, text="...", command=browse_files, width=10, style="PyAEDT.TButton"
367+
sample_points_frame, text="...", command=show_popup, width=10, style="PyAEDT.TButton"
315368
)
316369
export_points_button.pack(side=tk.RIGHT, padx=10)
317370

@@ -326,7 +379,7 @@ def save_as_files():
326379
("Numpy array", ".npy"),
327380
],
328381
)
329-
export_file_entry.insert(tk.END, filename)
382+
_text_size(filename, export_file_entry)
330383
master.file_path = export_file_entry.get("1.0", tk.END).strip()
331384
# master.destroy()
332385

src/ansys/aedt/core/workflows/project/points_cloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def main(extension_args):
355355

356356
if not extension_args["is_test"]: # pragma: no cover
357357
app.release_desktop(False, False)
358-
return True
358+
return str(point_values[list(point_values.keys())[0]][0])
359359

360360

361361
if __name__ == "__main__":

0 commit comments

Comments
 (0)