-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
maxcapodi78
authored and
maxcapodi78
committed
May 3, 2024
1 parent
554d9a0
commit 2fbbdc7
Showing
4 changed files
with
117 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os.path | ||
|
||
# import filedialog module | ||
from tkinter import filedialog | ||
|
||
from pyaedt import Desktop | ||
from pyaedt import get_pyaedt_app | ||
|
||
|
||
# Function for opening the | ||
# file explorer window | ||
def browseFiles(): | ||
filename = filedialog.askopenfilename( | ||
initialdir="/", title="Select a File", filetypes=(("Nastran files", "*.nas*"), ("all files", "*.*")) | ||
) | ||
|
||
# Change label contents | ||
return filename | ||
|
||
|
||
nas_input = browseFiles() | ||
if "PYAEDT_SCRIPT_PORT" in os.environ and "PYAEDT_SCRIPT_VERSION" in os.environ: | ||
port = os.environ["PYAEDT_SCRIPT_PORT"] | ||
version = os.environ["PYAEDT_SCRIPT_VERSION"] | ||
else: | ||
port = 0 | ||
version = "2024.2" | ||
if os.path.exists(nas_input): | ||
with Desktop(new_desktop_session=False, close_on_exit=False, specified_version=version, port=port) as d: | ||
proj = d.active_project() | ||
des = d.active_design() | ||
projname = proj.GetName() | ||
desname = des.GetName() | ||
app = get_pyaedt_app(projname, desname) | ||
app.modeler.import_nastran(nas_input) | ||
d.logger.info("Nastran imported correctly.") | ||
else: | ||
with Desktop(new_desktop_session=False, close_on_exit=False, specified_version=version, port=port) as d: | ||
d.odesktop.AddMessage("", "", 3, "Wrong file selected. Select a .nas file") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters