diff --git a/_unittest/test_02_2D_modeler.py b/_unittest/test_02_2D_modeler.py index 1dde8e3caab..20ba52d9be7 100644 --- a/_unittest/test_02_2D_modeler.py +++ b/_unittest/test_02_2D_modeler.py @@ -10,6 +10,8 @@ # Setup paths for module imports try: + import filecmp + import pytest # noqa: F401 except ImportError: import _unittest_ironpython.conf_unittest as pytest # noqa: F401 @@ -136,6 +138,10 @@ def test_09_plot(self): ) obj = self.aedtapp.plot(show=False, export_path=os.path.join(self.local_scratch.path, "image.jpg")) assert os.path.exists(obj.image_file) + obj2 = self.aedtapp.plot(show=False, export_path=os.path.join(self.local_scratch.path, "image.jpg"), view="xy") + assert os.path.exists(obj2.image_file) + obj3 = self.aedtapp.plot(show=False, export_path=os.path.join(self.local_scratch.path, "image.jpg"), view="xy1") + assert filecmp.cmp(obj.image_file, obj3.image_file) def test_10_edit_menu_commands(self): rect1 = self.aedtapp.modeler.create_rectangle([1, 0, -2], [8, 3]) diff --git a/pyaedt/application/Analysis3D.py b/pyaedt/application/Analysis3D.py index 146b5933964..c83aaa0cd94 100644 --- a/pyaedt/application/Analysis3D.py +++ b/pyaedt/application/Analysis3D.py @@ -181,6 +181,7 @@ def plot( plot_air_objects=True, force_opacity_value=None, clean_files=False, + view="isometric", ): """Plot the model or a subset of objects. @@ -206,6 +207,9 @@ def plot( clean_files : bool, optional Whether to clean created files after plot generation. The default is ``False``, which means that the cache is maintained in the model object that is returned. + view : str, optional + View to export. Options are ``"isometric"``, ``"xy"``, ``"xz"``, ``"yz"``. + The default is ``"isometric"``. Returns ------- @@ -225,6 +229,7 @@ def plot( plot_air_objects=plot_air_objects, force_opacity_value=force_opacity_value, clean_files=clean_files, + view=view, ) @pyaedt_function_handler() diff --git a/pyaedt/generic/plot.py b/pyaedt/generic/plot.py index c4b264619fb..62c2beb433c 100644 --- a/pyaedt/generic/plot.py +++ b/pyaedt/generic/plot.py @@ -711,7 +711,10 @@ def __init__(self): self.gif_file = None self._background_color = (255, 255, 255) self.off_screen = False - self.windows_size = [1024, 768] + if self.is_notebook: + self.windows_size = [600, 600] + else: + self.windows_size = [1024, 768] self.pv = None self._orientation = ["xy", 0, 0, 0] self.units = "meter" diff --git a/pyaedt/hfss.py b/pyaedt/hfss.py index c75887b9c38..025a0c0f41c 100644 --- a/pyaedt/hfss.py +++ b/pyaedt/hfss.py @@ -3918,12 +3918,13 @@ def thicken_port_sheets(self, inputlist, value, internalExtr=True, internalvalue tol = 1e-6 ports_ID = {} aedt_bounding_box = self.modeler.get_model_bounding_box() + aedt_bounding_dim = self.modeler.get_bounding_dimension() directions = {} for el in inputlist: objID = self.modeler.oeditor.GetFaceIDs(el) faceCenter = self.modeler.oeditor.GetFaceCenter(int(objID[0])) directionfound = False - l = 10 + l = min(aedt_bounding_dim) / 2 while not directionfound: self.modeler.oeditor.ThickenSheet( ["NAME:Selections", "Selections:=", el, "NewPartsModelFlag:=", "Model"], @@ -3948,7 +3949,7 @@ def thicken_port_sheets(self, inputlist, value, internalExtr=True, internalvalue directions[el] = "Internal" directionfound = True else: - l = l + 10 + l = l + min(aedt_bounding_dim) / 2 for el in inputlist: objID = self.modeler.oeditor.GetFaceIDs(el) maxarea = 0 diff --git a/pyaedt/modules/AdvancedPostProcessing.py b/pyaedt/modules/AdvancedPostProcessing.py index 806c929bb1b..5e55142c6e1 100644 --- a/pyaedt/modules/AdvancedPostProcessing.py +++ b/pyaedt/modules/AdvancedPostProcessing.py @@ -224,6 +224,7 @@ def plot_model_obj( force_opacity_value=None, clean_files=False, array_coordinates=None, + view="isometric", ): """Plot the model or a substet of objects. @@ -248,6 +249,9 @@ def plot_model_obj( array_coordinates : list of list List of array element centers. The modeler objects will be duplicated and translated. List of [[x1,y1,z1], [x2,y2,z2]...]. + view : str, optional + View to export. Options are ``"isometric"``, ``"xy"``, ``"xz"``, ``"yz"``. + The default is ``"isometric"``. Returns ------- @@ -264,6 +268,10 @@ def plot_model_obj( ) model.off_screen = not show + if view != "isometric" and view in ["xy", "xz", "yz"]: + model.camera_position = view + else: + self.logger.warning("Wrong view setup. It has to be one of xy, xz, yz, isometric.") if export_path: model.plot(export_path) elif show: @@ -305,8 +313,7 @@ def plot_field_from_fieldplot( ``"png"``, ``"svg"``, and ``"webp"``. The default is ``"jpg"``. view : str, optional - View to export. Options are ``isometric``, ``top``, ``front``, - ``left``, ``all``.. The default is ``"iso"``. If ``"all"``, all views are exported. + View to export. Options are ``"isometric"``, ``"xy"``, ``"xz"``, ``"yz"``. plot_label : str, optional Type of the plot. The default is ``"Temperature"``. plot_folder : str, optional @@ -341,7 +348,10 @@ def plot_field_from_fieldplot( if plot_label: model.fields[0].label = plot_label - model.view = view + if view != "isometric" and view in ["xy", "xz", "yz"]: + model.camera_position = view + else: + self.logger.warning("Wrong view setup. It has to be one of xy, xz, yz, isometric.") if scale_min and scale_max: model.range_min = scale_min diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index f1b8431bae4..ce9f489170a 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -2880,8 +2880,7 @@ def export_field_image_with_view(self, plotName, foldername, exportFilePath, vie exportFilePath : Path for exporting the image file. view : str, optional - View to export. Options are ``"isometric"``, ``"top"``, ``"bottom"``, ``"right"``, ``"left"`` and any - custom orientation. + View to export. Options are ``"isometric"``, ``"xy"``, ``"xz"``, ``"yz"``. The default is ``"isometric"``. wireframe : bool, optional Whether to put the objects in the wireframe mode. The default is ``True``. diff --git a/pyaedt/modules/solutions.py b/pyaedt/modules/solutions.py index 572abbcbe13..fbefc9af4f5 100644 --- a/pyaedt/modules/solutions.py +++ b/pyaedt/modules/solutions.py @@ -2835,8 +2835,7 @@ def export_image_from_aedtplt( Path where image will be saved. The default is ``None`` which export file in working_directory. view : str, optional - View of the exported plot. Options are ``isometric``, - ``top``, ``front``, ``left``, and ``all``. + View to export. Options are ``"isometric"``, ``"xy"``, ``"xz"``, ``"yz"``. plot_mesh : bool, optional Plot mesh. scale_min : float, optional