3939from ansys .aedt .core .extensions .misc import get_process_id
4040from ansys .aedt .core .extensions .misc import is_student
4141from ansys .aedt .core .internal .errors import AEDTRuntimeError
42- from ansys .aedt .core .visualization .advanced .misc import nastran_to_stl
43- from ansys .aedt .core .visualization .advanced .misc import simplify_stl
42+ from ansys .aedt .core .syslib .nastran_import import nastran_to_stl
4443
4544PORT = get_port ()
4645VERSION = get_aedt_version ()
5352 "lightweight" : False ,
5453 "decimate" : 0.0 ,
5554 "planar" : True ,
55+ "remove_multiple_connections" : False ,
5656}
5757EXTENSION_TITLE = "Import Nastran"
5858
@@ -65,6 +65,7 @@ class ImportNastranExtensionData(ExtensionCommonData):
6565 lightweight : bool = EXTENSION_DEFAULT_ARGUMENTS ["lightweight" ]
6666 decimate : float = EXTENSION_DEFAULT_ARGUMENTS ["decimate" ]
6767 planar : bool = EXTENSION_DEFAULT_ARGUMENTS ["planar" ]
68+ remove_multiple_connections : bool = EXTENSION_DEFAULT_ARGUMENTS ["remove_multiple_connections" ]
6869
6970
7071class ImportNastranExtension (ExtensionProjectCommon ):
@@ -85,6 +86,7 @@ def __init__(self, withdraw: bool = False):
8586 self .__decimation_text = None
8687 self .__lightweight_var = None
8788 self .__planar_var = None
89+ self .__remove_multiple_connections_var = None
8890
8991 # Add extension content
9092 self .add_extension_content ()
@@ -155,6 +157,21 @@ def add_extension_content(self):
155157 name = "check_planar_merge" ,
156158 ).grid (row = 3 , column = 1 , pady = 10 , padx = 5 )
157159
160+ # Remove multiple connections option
161+ ttk .Label (
162+ self .root ,
163+ text = "Remove multiple connections:" ,
164+ style = "PyAEDT.TLabel" ,
165+ ).grid (row = 4 , column = 0 , padx = 15 , pady = 10 )
166+
167+ self .__remove_multiple_connections_var = tkinter .IntVar (self .root , name = "var_remove_multiple_connections" )
168+ ttk .Checkbutton (
169+ self .root ,
170+ variable = self .__remove_multiple_connections_var ,
171+ style = "PyAEDT.TCheckbutton" ,
172+ name = "check_remove_multiple_connections" ,
173+ ).grid (row = 4 , column = 1 , pady = 10 , padx = 5 )
174+
158175 # Preview button
159176 ttk .Button (
160177 self .root ,
@@ -163,7 +180,7 @@ def add_extension_content(self):
163180 command = self .__preview ,
164181 style = "PyAEDT.TButton" ,
165182 name = "preview_button" ,
166- ).grid (row = 4 , column = 0 , pady = 10 , padx = 10 )
183+ ).grid (row = 5 , column = 0 , pady = 10 , padx = 10 )
167184
168185 # Import button
169186 ttk .Button (
@@ -173,10 +190,10 @@ def add_extension_content(self):
173190 command = self .__import_callback ,
174191 style = "PyAEDT.TButton" ,
175192 name = "import_button" ,
176- ).grid (row = 4 , column = 1 , pady = 10 , padx = 10 )
193+ ).grid (row = 5 , column = 1 , pady = 10 , padx = 10 )
177194
178195 def __browse_files (self ):
179- """Open file dialog to select Nastran or STL file."""
196+ """Open the file dialog to select Nastran or STL file."""
180197 filename = filedialog .askopenfilename (
181198 initialdir = "/" ,
182199 title = "Select a Nastran or STL File" ,
@@ -205,13 +222,16 @@ def __preview(self):
205222 if file_path_ui .endswith (".nas" ):
206223 nastran_to_stl (file_path_ui , decimation = decimate_ui , preview = True )
207224 else :
208- simplify_stl (file_path_ui , decimation = decimate_ui , preview = True )
225+ from ansys .aedt .core .visualization .advanced .misc import simplify_and_preview_stl
226+
227+ simplify_and_preview_stl (file_path_ui , decimation = decimate_ui , preview = True )
209228
210229 def __import_callback (self ):
211230 """Callback for import button."""
212231 file_path = self .__file_path_text .get ("1.0" , tkinter .END ).strip ()
213232 lightweight_val = self .__lightweight_var .get () == 1
214233 planar_val = self .__planar_var .get () == 1
234+ remove_multiple_connections_val = self .__remove_multiple_connections_var .get () == 1
215235
216236 # Validation
217237 if not file_path :
@@ -231,6 +251,7 @@ def __import_callback(self):
231251 decimate = decimate_val ,
232252 lightweight = lightweight_val ,
233253 planar = planar_val ,
254+ remove_multiple_connections = remove_multiple_connections_val ,
234255 )
235256 self .root .destroy ()
236257
@@ -277,9 +298,12 @@ def main(data: ImportNastranExtensionData):
277298 import_as_light_weight = data .lightweight ,
278299 decimation = data .decimate ,
279300 enable_planar_merge = str (data .planar ),
301+ remove_multiple_connections = data .remove_multiple_connections ,
280302 )
281303 else :
282- outfile = simplify_stl (str (file_path ), decimation = data .decimate )
304+ from ansys .aedt .core .visualization .advanced .misc import simplify_and_preview_stl
305+
306+ outfile = simplify_and_preview_stl (str (file_path ), decimation = data .decimate )
283307 aedtapp .modeler .import_3d_cad (
284308 outfile ,
285309 healing = False ,
0 commit comments