Skip to content

Commit 6026bee

Browse files
authored
Fixed a bug in object3d and removed print from Desktop.py (#1262)
* Fixed a bug in object3d * Fixed a bug in object3d Co-authored-by: maxcapodi78 <Shark78>
1 parent dfc313b commit 6026bee

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

pyaedt/desktop.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ def __init__(
342342
self._main.isoutsideDesktop = True
343343
self.release_on_exit = True
344344
self.logfile = None
345+
self._logger = aedt_logger.AedtLogger(filename=self.logfile, level=logging.DEBUG)
346+
self._logger.info("Logger Started")
347+
self._main.aedt_logger = self._logger
345348
if "oDesktop" in dir(): # pragma: no cover
346349
self.release_on_exit = False
347350
self._main.oDesktop = oDesktop
@@ -361,11 +364,11 @@ def __init__(
361364
del self._main.oDesktop
362365
self._main.student_version, version_key, version = self._set_version(specified_version, student_version)
363366
if _com == "ironpython": # pragma: no cover
364-
print("Launching PyAEDT outside AEDT with IronPython.")
367+
self._logger.info("Launching PyAEDT outside AEDT with IronPython.")
365368
self._init_ironpython(non_graphical, new_desktop_session, version)
366369
elif _com == "pythonnet_v3":
367370
if version_key < "2022.2" or not settings.use_grpc_api:
368-
print("Launching PyAEDT outside Electronics Desktop with CPython and Pythonnet")
371+
self._logger.info("Launching PyAEDT outside Electronics Desktop with CPython and Pythonnet")
369372
self._init_cpython(
370373
non_graphical,
371374
new_desktop_session,
@@ -376,9 +379,6 @@ def __init__(
376379
)
377380
else:
378381
self._init_cpython_new(non_graphical, new_desktop_session, version, self._main.student_version)
379-
# print("Launching PyAEDT outside AEDT with CPython and Pythonnet.")
380-
# self._init_cpython(non_graphical, new_desktop_session, version,
381-
# self._main.student_version, version_key)
382382
else:
383383
oAnsoftApp = win32com.client.Dispatch(version)
384384
self._main.oDesktop = oAnsoftApp.GetAppDesktop()
@@ -465,11 +465,11 @@ def current_version_student(self):
465465
def _init_desktop(self):
466466
self._main.AEDTVersion = self._main.oDesktop.GetVersion()[0:6]
467467
self._main.oDesktop.RestoreWindow()
468-
self._logger = aedt_logger.AedtLogger(filename=self.logfile, level=logging.DEBUG)
469-
self._logger.info("Logger Started on %s", self.logfile)
470-
self._main.aedt_logger = self._logger
471468
self._main.sDesktopinstallDirectory = self._main.oDesktop.GetExeDir()
472469
self._main.pyaedt_initialized = True
470+
self._logger = aedt_logger.AedtLogger(filename=self.logfile, level=logging.DEBUG)
471+
self._logger.info("Logger file %s in use.")
472+
self._main.aedt_logger = self._logger
473473

474474
def _set_version(self, specified_version, student_version):
475475
student_version_flag = False
@@ -569,14 +569,13 @@ def _init_cpython(
569569
sys.path.append(base_path)
570570
sys.path.append(os.path.join(base_path, "PythonFiles", "DesktopPlugin"))
571571
launch_msg = "AEDT installation Path {}.".format(base_path)
572-
print(launch_msg)
573-
print("===================================================================================")
572+
self.logger.info(launch_msg)
574573
clr.AddReference("Ansys.Ansoft.CoreCOMScripting")
575574
AnsoftCOMUtil = __import__("Ansys.Ansoft.CoreCOMScripting")
576575
self.COMUtil = AnsoftCOMUtil.Ansoft.CoreCOMScripting.Util.COMUtil
577576
self._main.COMUtil = self.COMUtil
578577
StandalonePyScriptWrapper = AnsoftCOMUtil.Ansoft.CoreCOMScripting.COM.StandalonePyScriptWrapper
579-
print("pyaedt info: Launching AEDT with module Pythonnet.")
578+
self.logger.info("Launching AEDT with module Pythonnet.")
580579
processID = []
581580
if IsWindows:
582581
processID = self._get_tasks_list_windows(student_version)
@@ -603,9 +602,9 @@ def _init_cpython(
603602
self._dispatch_win32(version)
604603
elif version_key >= "2021.2":
605604
if student_version:
606-
print("pyaedt info: {} Student version started with process ID {}.".format(version, proc[0]))
605+
self.logger.info("{} Student version started with process ID {}.".format(version, proc[0]))
607606
else:
608-
print("pyaedt info: {} Started with process ID {}.".format(version, proc[0]))
607+
self.logger.info("{} Started with process ID {}.".format(version, proc[0]))
609608
context = pythoncom.CreateBindCtx(0)
610609
running_coms = pythoncom.GetRunningObjectTable()
611610
monikiers = running_coms.EnumRunning()
@@ -617,7 +616,7 @@ def _init_cpython(
617616
self._main.oDesktop = win32com.client.Dispatch(obj.QueryInterface(pythoncom.IID_IDispatch))
618617
break
619618
else:
620-
warnings.warn(
619+
self.logger.warning(
621620
"PyAEDT is not supported in AEDT versions older than 2021.2. Trying to launch PyAEDT with PyWin32."
622621
)
623622
self._dispatch_win32(version)
@@ -629,9 +628,8 @@ def _init_cpython_new(self, non_graphical, new_aedt_session, version, student_ve
629628
import ScriptEnv
630629

631630
launch_msg = "AEDT installation Path {}".format(base_path)
632-
print(launch_msg)
633-
print("===================================================================================")
634-
print("pyaedt info: Launching AEDT with PyDesktopPlugin.")
631+
self.logger.info(launch_msg)
632+
self.logger.info("Launching AEDT with PyDesktopPlugin.")
635633
if new_aedt_session or not self.port:
636634
self.port = _find_free_port()
637635
self.machine = ""
@@ -662,12 +660,12 @@ def _init_cpython_new(self, non_graphical, new_aedt_session, version, student_ve
662660
if non_graphical:
663661
settings.enable_desktop_logs = False
664662
if student_version:
665-
print("pyaedt info: {} Student version started with process ID {}.".format(version, _proc))
663+
self.logger.info("{} Student version started with process ID {}.".format(version, _proc))
666664
else:
667-
print("pyaedt info: {} Started with process ID {}.".format(version, _proc))
665+
self.logger.info("{} Started with process ID {}.".format(version, _proc))
668666

669667
else:
670-
warnings.warn("PyDesktopPlugin is not supported in AEDT versions older than 2022.2.")
668+
self.logger.warning("PyDesktopPlugin is not supported in AEDT versions older than 2022.2.")
671669

672670
def _set_logger_file(self):
673671
# Set up the log file in the AEDT project directory

pyaedt/modeler/Object3d.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,19 +2624,19 @@ def faces_by_area(self, area, area_filter="==", tolerance=1e-12):
26242624

26252625
faces = []
26262626
for face in self.faces:
2627-
if area_filter is "==":
2627+
if area_filter == "==":
26282628
if abs(face.area - area) < tolerance:
26292629
faces.append(face)
2630-
if area_filter is ">=":
2630+
if area_filter == ">=":
26312631
if (face.area - area) >= tolerance:
26322632
faces.append(face)
2633-
if area_filter is "<=":
2633+
if area_filter == "<=":
26342634
if (face.area - area) <= tolerance:
26352635
faces.append(face)
2636-
if area_filter is ">":
2636+
if area_filter == ">":
26372637
if (face.area - area) > tolerance:
26382638
faces.append(face)
2639-
if area_filter is "<":
2639+
if area_filter == "<":
26402640
if (face.area - area) < tolerance:
26412641
faces.append(face)
26422642

0 commit comments

Comments
 (0)