### Install Requirements Source: https://pyleecan.org/_sources/get.pyleecan.md.txt Install all required packages listed in the requirements-full.txt file. ```bash pip install -U -r requirements-full.txt ``` -------------------------------- ### Install and Run Jupyter Notebook Source: https://pyleecan.org/tutorials.html Instructions to install Jupyter and run notebook tutorials from the console. Ensure you are in the correct directory. ```bash - pip install jupyter - open a console terminal in the folder containing the Tutorials - run the command "jupyter notebook" ``` -------------------------------- ### Install Dependencies Source: https://pyleecan.org/_sources/fork.pyleecan.md.txt Install all required project dependencies using the provided requirements file. ```bash pip install -r requirements.txt ``` -------------------------------- ### GET /Arc3/get_begin Source: https://pyleecan.org/pyleecan.Methods.Geometry.Arc3.get_begin.html Retrieves the starting point of an Arc3 object. ```APIDOC ## GET /Arc3/get_begin ### Description Returns the begin point of the arc. ### Method GET ### Endpoint /Arc3/get_begin ### Parameters #### Path Parameters - **self** (Arc3) - Required - An Arc3 object ### Response #### Success Response (200) - **begin** (complex) - Begin point of the Arc3 ``` -------------------------------- ### Open Tutorial Video Source: https://pyleecan.org/_modules/pyleecan/GUI/Dxf/DXF_Slot.html Opens a tutorial video in the default web browser using QDesktopServices. Requires a valid QUrl object. ```python QDesktopServices.openUrl(QUrl(self.url)) ``` -------------------------------- ### Initialize PHoleM58 UI Source: https://pyleecan.org/_modules/pyleecan/GUI/Dialog/DMachineSetup/SMHoleMag/PHoleM58/Ui_PHoleM58.html The setupUi method configures the layout, widgets, and constraints for the PHoleM58 dialog. ```python ## WARNING! All changes made in this file will be lost when recompiling UI file! ################################################################################ from PySide2.QtCore import * from PySide2.QtGui import * from PySide2.QtWidgets import * from ......GUI.Dialog.DMatLib.WMatSelect.WMatSelect import WMatSelect from ......GUI.Tools.FloatEdit import FloatEdit from pyleecan.GUI.Resources import pyleecan_rc [docs]class Ui_PHoleM58(object): [docs] def setupUi(self, PHoleM58): if not PHoleM58.objectName(): PHoleM58.setObjectName(u"PHoleM58") PHoleM58.resize(1304, 529) PHoleM58.setMinimumSize(QSize(740, 440)) PHoleM58.setMaximumSize(QSize(16777215, 16777215)) self.horizontalLayout = QHBoxLayout(PHoleM58) self.horizontalLayout.setObjectName(u"horizontalLayout") self.verticalLayout_3 = QVBoxLayout() self.verticalLayout_3.setObjectName(u"verticalLayout_3") self.img_slot = QLabel(PHoleM58) self.img_slot.setObjectName(u"img_slot") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.img_slot.sizePolicy().hasHeightForWidth()) self.img_slot.setSizePolicy(sizePolicy) self.img_slot.setMinimumSize(QSize(0, 0)) self.img_slot.setMaximumSize(QSize(16777215, 16777215)) self.img_slot.setPixmap( QPixmap(u":/images/images/MachineSetup/SMHoleMag/HoleM58.png") ) self.img_slot.setScaledContents(False) self.img_slot.setAlignment(Qt.AlignCenter) self.verticalLayout_3.addWidget(self.img_slot) self.txt_constraint = QTextEdit(PHoleM58) self.txt_constraint.setObjectName(u"txt_constraint") sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) sizePolicy1.setHorizontalStretch(0) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth( self.txt_constraint.sizePolicy().hasHeightForWidth() ) self.txt_constraint.setSizePolicy(sizePolicy1) self.txt_constraint.setMinimumSize(QSize(200, 0)) self.txt_constraint.setMaximumSize(QSize(16777215, 50)) self.txt_constraint.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.txt_constraint.setTextInteractionFlags( Qt.TextSelectableByKeyboard | Qt.TextSelectableByMouse ) self.verticalLayout_3.addWidget(self.txt_constraint) self.horizontalLayout.addLayout(self.verticalLayout_3) self.scrollArea = QScrollArea(PHoleM58) self.scrollArea.setObjectName(u"scrollArea") self.scrollArea.setMinimumSize(QSize(270, 0)) self.scrollArea.setMaximumSize(QSize(270, 16777215)) self.scrollArea.setWidgetResizable(True) self.scrollAreaWidgetContents = QWidget() self.scrollAreaWidgetContents.setObjectName(u"scrollAreaWidgetContents") self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 268, 505)) self.verticalLayout_4 = QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout_4.setObjectName(u"verticalLayout_4") self.gridLayout = QGridLayout() self.gridLayout.setObjectName(u"gridLayout") self.in_H0 = QLabel(self.scrollAreaWidgetContents) self.in_H0.setObjectName(u"in_H0") self.gridLayout.addWidget(self.in_H0, 0, 0, 1, 1) self.lf_H0 = FloatEdit(self.scrollAreaWidgetContents) self.lf_H0.setObjectName(u"lf_H0") self.gridLayout.addWidget(self.lf_H0, 0, 1, 1, 1) self.unit_R0 = QLabel(self.scrollAreaWidgetContents) self.unit_R0.setObjectName(u"unit_R0") self.gridLayout.addWidget(self.unit_R0, 7, 2, 1, 1) self.unit_H0 = QLabel(self.scrollAreaWidgetContents) self.unit_H0.setObjectName(u"unit_H0") self.gridLayout.addWidget(self.unit_H0, 0, 2, 1, 1) self.unit_W2 = QLabel(self.scrollAreaWidgetContents) self.unit_W2.setObjectName(u"unit_W2") self.gridLayout.addWidget(self.unit_W2, 5, 2, 1, 1) self.unit_W0 = QLabel(self.scrollAreaWidgetContents) self.unit_W0.setObjectName(u"unit_W0") self.gridLayout.addWidget(self.unit_W0, 3, 2, 1, 1) self.unit_W1 = QLabel(self.scrollAreaWidgetContents) self.unit_W1.setObjectName(u"unit_W1") self.gridLayout.addWidget(self.unit_W1, 4, 2, 1, 1) self.in_W3 = QLabel(self.scrollAreaWidgetContents) self.in_W3.setObjectName(u"in_W3") self.gridLayout.addWidget(self.in_W3, 6, 0, 1, 1) self.lf_W0 = FloatEdit(self.scrollAreaWidgetContents) self.lf_W0.setObjectName(u"lf_W0") self.gridLayout.addWidget(self.lf_W0, 3, 1, 1, 1) self.in_W1 = QLabel(self.scrollAreaWidgetContents) self.in_W1.setObjectName(u"in_W1") self.gridLayout.addWidget(self.in_W1, 4, 0, 1, 1) ``` -------------------------------- ### GET get_begin Source: https://pyleecan.org/_modules/pyleecan/Methods/Geometry/Segment/get_begin.html Retrieves the starting point of a Segment object. ```APIDOC ## GET get_begin ### Description Returns the begin point of the segment. ### Method GET ### Parameters #### Path Parameters - **self** (Segment) - Required - A Segment object ### Response #### Success Response (200) - **begin** (complex) - Begin point of the Segment ``` -------------------------------- ### Open Tutorial URL Source: https://pyleecan.org/_modules/pyleecan/GUI/Dxf/DXF_Hole.html Opens the configured tutorial URL in the system's default web browser. ```python def open_tuto(self): """Open the tutorial video in a web browser""" QDesktopServices.openUrl(QUrl(self.url)) ``` -------------------------------- ### GET /pyleecan.Methods.Geometry.Arc3.get_begin Source: https://pyleecan.org/_modules/pyleecan/Methods/Geometry/Arc3/get_begin.html Retrieves the starting point of an Arc3 object. ```APIDOC ## GET /pyleecan.Methods.Geometry.Arc3.get_begin ### Description Return the begin point of the arc. ### Method GET ### Endpoint /pyleecan.Methods.Geometry.Arc3.get_begin ### Parameters #### Path Parameters - **self** (Arc3) - Required - An Arc3 object ### Response #### Success Response (200) - **begin** (complex) - Begin point of the Arc3 ### Response Example ```json { "begin": "(x+yj)" } ``` ``` -------------------------------- ### setupUi(PWSlot61) Source: https://pyleecan.org/pyleecan.GUI.Dialog.DMachineSetup.SWPole.PWSlot61.Gen_PWSlot61.html Initializes the user interface for the PWSlot61 widget. ```APIDOC ## setupUi(PWSlot61) ### Description Abstract method to update the widget according to the csv documentation and initialize the UI components for PWSlot61. ### Parameters #### Path Parameters - **PWSlot61** (object) - Required - The widget instance to be initialized. ``` -------------------------------- ### GET /pyleecan.Methods.Geometry.Arc1.get_begin Source: https://pyleecan.org/pyleecan.Methods.Geometry.Arc1.get_begin.html Retrieves the starting point coordinates of an Arc1 object. ```APIDOC ## GET /pyleecan.Methods.Geometry.Arc1.get_begin ### Description Return the begin point of the arc. ### Method GET ### Endpoint /pyleecan.Methods.Geometry.Arc1.get_begin ### Parameters #### Path Parameters - **self** (Arc1) - Required - An Arc1 object ### Response #### Success Response (200) - **begin** (complex) - Complex coordinates of the begin point of the Arc1 ``` -------------------------------- ### GET /pyleecan/Methods/Geometry/Arc1/get_begin Source: https://pyleecan.org/_modules/pyleecan/Methods/Geometry/Arc1/get_begin.html Retrieves the complex coordinates of the starting point of an Arc1 object. ```APIDOC ## GET /pyleecan/Methods/Geometry/Arc1/get_begin ### Description Returns the begin point of the Arc1 object. ### Method GET ### Parameters #### Path Parameters - **self** (Arc1) - Required - An Arc1 object instance ### Response #### Success Response (200) - **begin** (complex) - Complex coordinates of the begin point of the Arc1 ``` -------------------------------- ### Gen_PVentUD GUI Setup Source: https://pyleecan.org/_modules/pyleecan/GUI/Dialog/DMachineSetup/DAVDuct/PVentUD/Gen_PVentUD.html Documentation for the setupUi method within the Gen_PVentUD class, which initializes the ventilation duct input widgets. ```APIDOC ## GUI Initialization: Gen_PVentUD.setupUi ### Description Initializes the user interface for the ventilation duct configuration, specifically setting up the input field for the number of holes around the circumference (Zh). ### Method Python Class Method ### Parameters #### Path Parameters - **PVentUD** (object) - Required - The widget instance to be initialized. ### Request Example ```python # Example of calling the setupUi method widget = PVentUD() gen_widget = Gen_PVentUD() gen_widget.setupUi(widget) ``` ``` -------------------------------- ### setupUi Method Source: https://pyleecan.org/pyleecan.GUI.Dialog.DMachineSetup.SSimu.Gen_SSimu.html The setupUi method is responsible for setting up the user interface for the SSimu widget. ```APIDOC ## Method setupUi ### Description Abstract class to update the widget according to the csv doc. ### Parameters * **_SSimu_** (object) - The SSimu object to configure. ``` -------------------------------- ### GET /pyleecan/Methods/Geometry/Segment/get_begin Source: https://pyleecan.org/_sources/pyleecan.Methods.Geometry.Segment.get_begin.rst.txt Retrieves the starting coordinate of a defined segment in the pyleecan geometry framework. ```APIDOC ## GET /pyleecan/Methods/Geometry/Segment/get_begin ### Description This method returns the beginning coordinate of a segment object within the pyleecan geometry module. ### Method GET ### Endpoint pyleecan.Methods.Geometry.Segment.get_begin ``` -------------------------------- ### Initialize User Directory Source: https://pyleecan.org/_modules/pyleecan/Functions/init_environment.html Sets up the main user directory and copies default data files if they do not already exist. ```python def init_user_dir(): """Initialize the USER DIR with the default files""" # dynamic import to avoid loop module = __import__( "pyleecan.definitions", globals=globals(), locals=locals(), fromlist=["USER_DIR", "MAIN_DIR"], level=0, ) USER_DIR = module.USER_DIR MAIN_DIR = module.MAIN_DIR logger = getLogger(GUI_LOG_NAME) # Create the main folder if not isdir(USER_DIR): makedirs(USER_DIR) # Copy initial DATA logger.debug("Initialization of USER_DIR in " + USER_DIR) # Data initialization mach_path = join(USER_DIR, "Machine") if not isdir(mach_path): shutil.copytree(join(MAIN_DIR, "Data", "Machine"), mach_path) logger.debug("Initialization USER_DIR Machines in " + mach_path) mat_path = join(USER_DIR, "Material") if not isdir(mat_path): shutil.copytree(join(MAIN_DIR, "Data", "Material"), mat_path) logger.debug("Initialization USER_DIR Materials in " + mat_path) plot_path = join(USER_DIR, "Plot") if not isdir(plot_path): shutil.copytree(join(MAIN_DIR, "Data", "Plot"), plot_path) logger.debug("Initialization USER_DIR Plot in " + plot_path) gui_path = join(USER_DIR, "GUI") if not isdir(gui_path): shutil.copytree(join(MAIN_DIR, "Data", "GUI"), gui_path) logger.debug("Initialization USER_DIR GUI in " + gui_path) # Create default config dict init_config_dict() ``` -------------------------------- ### Import Get Real Point with Error Handling Source: https://pyleecan.org/_modules/pyleecan/Classes/RefQuad4.html Imports the get_real_point method, capturing any ImportError. This allows the class to function without this method if its module is not installed. ```python try: from ..Methods.Mesh.RefQuad4.get_real_point import get_real_point except ImportError as error: get_real_point = error ``` -------------------------------- ### Setup UI for PVentUD Source: https://pyleecan.org/_modules/pyleecan/GUI/Dialog/DMachineSetup/DAVDuct/PVentUD/Ui_PVentUD.html Initializes the user interface for the PVentUD dialog. This includes setting up layouts, widgets like MPLCanvas, QScrollArea, QPushButton, WPathSelectorV, SpinBox, QLabel, and QSpacerItem. ```python # -*- coding: utf-8 -*- # File generated according to PVentUD.ui # WARNING! All changes made in this file will be lost! ## WARNING! All changes made in this file will be lost when recompiling UI file! ################################################################################ from PySide2.QtCore import * from PySide2.QtGui import * from PySide2.QtWidgets import * from ......GUI.Dialog.DMachineSetup.DAVDuct.WVentOut.WVentOut import WVentOut from ......GUI.Tools.SpinBox import SpinBox from ......GUI.Tools.WPathSelector.WPathSelectorV import WPathSelectorV from ......GUI.Tools.MPLCanvas import MPLCanvas from pyleecan.GUI.Resources import pyleecan_rc [docs] class Ui_PVentUD(object): [docs] def setupUi(self, PVentUD): if not PVentUD.objectName(): PVentUD.setObjectName(u"PVentUD") PVentUD.resize(641, 440) PVentUD.setMinimumSize(QSize(0, 440)) PVentUD.setMaximumSize(QSize(16777215, 16777215)) self.horizontalLayout = QHBoxLayout(PVentUD) self.horizontalLayout.setObjectName(u"horizontalLayout") self.w_viewer = MPLCanvas(PVentUD) self.w_viewer.setObjectName(u"w_viewer") self.horizontalLayout.addWidget(self.w_viewer) self.scrollArea = QScrollArea(PVentUD) self.scrollArea.setObjectName(u"scrollArea") self.scrollArea.setMinimumSize(QSize(300, 0)) self.scrollArea.setMaximumSize(QSize(300, 16777215)) self.scrollArea.setWidgetResizable(True) self.scrollAreaWidgetContents = QWidget() self.scrollAreaWidgetContents.setObjectName(u"scrollAreaWidgetContents") self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 298, 416)) self.verticalLayout = QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout.setObjectName(u"verticalLayout") self.b_dxf = QPushButton(self.scrollAreaWidgetContents) self.b_dxf.setObjectName(u"b_dxf") self.verticalLayout.addWidget(self.b_dxf) self.w_path_json = WPathSelectorV(self.scrollAreaWidgetContents) self.w_path_json.setObjectName(u"w_path_json") sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.w_path_json.sizePolicy().hasHeightForWidth()) self.w_path_json.setSizePolicy(sizePolicy) self.verticalLayout.addWidget(self.w_path_json) self.gridLayout = QGridLayout() self.gridLayout.setObjectName(u"gridLayout") self.in_Zh = QLabel(self.scrollAreaWidgetContents) self.in_Zh.setObjectName(u"in_Zh") self.gridLayout.addWidget(self.in_Zh, 0, 0, 1, 1) self.si_Zh = SpinBox(self.scrollAreaWidgetContents) self.si_Zh.setObjectName(u"si_Zh") self.si_Zh.setMaximum(999999999) self.gridLayout.addWidget(self.si_Zh, 0, 1, 1, 1) self.verticalLayout.addLayout(self.gridLayout) self.verticalSpacer = QSpacerItem( 20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding ) self.verticalLayout.addItem(self.verticalSpacer) self.w_out = WVentOut(self.scrollAreaWidgetContents) self.w_out.setObjectName(u"w_out") self.verticalLayout.addWidget(self.w_out) self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.horizontalLayout.addWidget(self.scrollArea) self.retranslateUi(PVentUD) QMetaObject.connectSlotsByName(PVentUD) # setupUi ``` ```python [docs] def retranslateUi(self, PVentUD): PVentUD.setWindowTitle(QCoreApplication.translate("PVentUD", u"Form", None)) self.b_dxf.setText( QCoreApplication.translate("PVentUD", u"Define Duct from DXF", None) ) self.in_Zh.setText(QCoreApplication.translate("PVentUD", u"Zh :", None)) # retranslateUi ``` -------------------------------- ### Get End Point of Arc1 Source: https://pyleecan.org/_modules/pyleecan/Methods/Geometry/Arc1/get_end.html Returns the complex coordinates of the end point of an Arc1 object. No specific setup is required beyond having an Arc1 object instance. ```python # -*- coding: utf-8 -*- [docs] def get_end(self): """Return the end point of the arc Parameters ---------- self : Arc1 An Arc1 object Returns ------- end: complex Complex coordinates of the end point of the Arc1 """ return self.end ``` -------------------------------- ### DMachineSetup Initialization Source: https://pyleecan.org/_modules/pyleecan/GUI/Dialog/DMachineSetup/DMachineSetup.html Initializes the DMachineSetup GUI, setting up machine configurations and event handlers. ```APIDOC ## DMachineSetup Initialization ### Description Initializes the GUI for machine setup, allowing users to load, edit, and save machine configurations. It handles various machine types and material dictionaries. ### Method __init__ ### Parameters - **machine** (Machine) - Optional - The machine object to edit. - **material_dict** (dict) - Optional - A dictionary of materials. - **machine_path** (str) - Optional - The default path for loading machines. ### Request Example ```python # Example of initializing DMachineSetup setup_gui = DMachineSetup(machine=my_machine, material_dict=materials) ``` ### Response This method does not return a value but initializes the object's state. ``` -------------------------------- ### Get Segment Begin Point Source: https://pyleecan.org/_modules/pyleecan/Methods/Geometry/Segment/get_begin.html Use this method to retrieve the complex number representing the starting point of a Segment object. Ensure a Segment object is initialized before calling. ```python # -*- coding: utf-8 -*- [docs] def get_begin(self): """Return the begin point of the segment Parameters ---------- self : Segment A Segment object Returns ------- begin: complex Begin point of the Segment """ return self.begin ``` -------------------------------- ### Reverse Arc3 Geometry Source: https://pyleecan.org/_modules/pyleecan/Methods/Geometry/Arc3/reverse.html Use this method to reverse the orientation of an Arc3 object by swapping its start and end points and inverting its direction. No specific setup is required beyond having an Arc3 instance. ```python def reverse(self): """Reverse the begin and end point of the Line Parameters ---------- self : Arc3 An Arc3 object Returns ------- """ end = self.end self.end = self.begin self.begin = end self.is_trigo_direction = not self.is_trigo_direction ``` -------------------------------- ### DMachineSetup Class Source: https://pyleecan.org/pyleecan.GUI.Dialog.DMachineSetup.DMachineSetup.html The DMachineSetup class serves as the main window for the Machine Setup Tools in pyleecan. ```APIDOC ## Class DMachineSetup ### Description Main windows of the Machine Setup Tools. ### Parameters - **_machine** (_object_) - Optional - The machine object to initialize with. - **_material_dict** (_dict_) - Optional - A dictionary of materials. - **_machine_path** (_str_) - Optional - The path to the machine file. ### Signals - **machineChanged**: Emitted when the machine is changed. - **rejected**: Emitted when the dialog is rejected. - **save_needed()**: Sets the is_save_needed flag to True. ### Methods #### closeEvent(_event_) ##### Description Display a message before leaving. ##### Parameters - **self** (_DMachineSetup_) – A DMachineSetup object - **event** – The closing event #### reject() #### s_save() ##### Description Slot for saving the current machine to a json file. ##### Parameters - **self** (_DMachineSetup_) – A DMachineSetup object #### s_save_close() ##### Description Signal to save and close. ##### Parameters - **self** (_DMachineSetup_) – A DMachineSetup object #### s_load() ##### Description Slot to load a machine from a .json file (triggered by b_load). ##### Parameters - **self** (_DMachineSetup_) – A DMachineSetup object #### update_nav(_next_step = None_) ##### Description Update the nav list to match the step of the current machine. #### update_enable_nav() #### get_machine_index() ##### Description Get the index corresponding to the current machine in the mach_list. #### set_nav(_index_) ##### Description Select the current widget according to the current machine type and the current nav index. ##### Parameters - **self** (_DMachineSetup_) – A DMachineSetup object - **index** (_int_) – Current index of nav_step #### s_next() ##### Description Signal to set the next step as accessible (and selected). ##### Parameters - **self** (_DMachineSetup_) – A DMachineSetup object #### s_previous() ##### Description Signal to set the previous page of w_page_stack as accessible (and selected). ##### Parameters - **self** (_DMachineSetup_) – A DMachineSetup object ``` -------------------------------- ### Reverse Arc2 Geometry Source: https://pyleecan.org/_modules/pyleecan/Methods/Geometry/Arc2/reverse.html Use this method to reverse the orientation of an Arc2 object by swapping its start and end points and negating its angle. No specific setup is required beyond having an Arc2 instance. ```python def reverse(self): """Reverse the begin and end point of the Line Parameters ---------- self : Arc2 An Arc2 object Returns ------- """ self.begin = self.get_end() self.angle = -self.angle ``` -------------------------------- ### Basic pytest Test Functions Source: https://pyleecan.org/test.contribution.html Demonstrates how to write basic test functions using pytest. Test functions must start with 'test_'. Includes examples of assertions and exception handling. ```python import pytest def test_upper(): assert 'foo'.upper() == 'FOO' def test_isupper(): assert 'FOO'.isupper() assert 'Foo'.isupper() == False def test_split(self): s = 'hello world' assert s.split() == ['hello', 'world'] # check that s.split fails when the separator is not a string with pytest.raises(TypeError): s.split(2) ``` -------------------------------- ### SMHoleMag Initialization and Setup Source: https://pyleecan.org/_modules/pyleecan/GUI/Dialog/DMachineSetup/SMHoleMag/SMHoleMag.html Initializes the SMHoleMag widget, sets up the GUI based on machine type, and manages the list of holes for the machine. ```APIDOC ## SMHoleMag Class ### Description Manages the graphical user interface for setting up holes in an electric machine. It handles the addition, removal, and display of different hole configurations. ### Class Definition ```python class SMHoleMag(Ui_SMHoleMag, QWidget): """Step to set several Holes""" # ... (initialization and methods) ... ``` ### Initialization (`__init__`) Initializes the widget, loads machine data, and sets up the hole list. If no holes are present, it initializes with a default `HoleM50`. **Parameters** - **machine** (Machine): The current machine object being edited. - **material_dict** (dict): Dictionary of available materials. - **is_stator** (bool): Flag to indicate if configuring stator holes (True) or rotor holes (False). ### Methods - **emit_save()**: Emits a `saveNeeded` signal. - **set_hole_pitch(Zh)**: Updates the display of the hole pitch based on the number of slots (Zh). - **s_add(hole=False)**: Adds a new hole configuration to the machine. If `hole` is provided, it initializes the new page with that hole object; otherwise, it creates a new `HoleM50`. - **s_remove(index)**: Removes a hole configuration at the specified index. ``` -------------------------------- ### Get SlotW10 Opening Surface Source: https://pyleecan.org/_modules/pyleecan/Methods/Slot/SlotW10/get_surface_opening.html Returns the list of surfaces defining the opening area of the SlotW10. Returns an empty list if H0 and H1 are both 0. Requires necessary imports and parent object setup. ```python from ....Classes.Segment import Segment from ....Classes.Arc1 import Arc1 from ....Classes.SurfLine import SurfLine from ....Functions.labels import SOP_LAB, DRAW_PROP_LAB [docs] def get_surface_opening(self, alpha=0, delta=0): """Return the list of surfaces defining the opening area of the Slot Parameters ---------- self : SlotW10 A SlotW10 object alpha : float float number for rotation (Default value = 0) [rad] delta : complex complex number for translation (Default value = 0) Returns ------- surf_list : list list of surfaces objects """ # H0=H1=0 no opening H1 = self.get_H1() if self.H0 == 0 and H1 == 0: return [] # Create curve list line_dict = self._comp_line_dict() curve_list = [ line_dict["1-2"], line_dict["2-3"], line_dict["3-4"], line_dict["4-7"], line_dict["7-8"], line_dict["8-9"], line_dict["9-10"], line_dict["10-1"], ] curve_list = [line for line in curve_list if line is not None] # Only the closing arc (10-1) needs to be drawn (in FEMM) for curve in curve_list[:-1]: if curve.prop_dict is None: curve.prop_dict = dict() curve.prop_dict.update({DRAW_PROP_LAB: False}) # Create surface if self.is_outwards(): Zmid = self.get_Rbo() + (self.H0 + H1) / 2 else: Zmid = self.get_Rbo() - (self.H0 + H1) / 2 label = self.parent.get_label() + "_" + SOP_LAB + "_R0-T0-S0" surface = SurfLine(line_list=curve_list, label=label, point_ref=Zmid) # Apply transformation surface.rotate(alpha) surface.translate(delta) return [surface] ``` -------------------------------- ### GUIOption Class Initialization Source: https://pyleecan.org/_modules/pyleecan/Classes/GUIOption.html Demonstrates how to initialize a GUIOption object using different methods: with default values, from a dictionary, or from a file path. ```APIDOC ## GUIOption Initialization ### Description Initializes a GUIOption object. It can be initialized with default values, a dictionary of properties, or from a file path. ### Method `__init__(self, unit=-1, init_dict=None, init_str=None)` ### Parameters - **unit** (int) - Default value is -1, which calls the default constructor for pyleecan types. - **init_dict** (dict) - A dictionary with property names as keys. If provided, it overwrites default values. - **init_str** (str) - A file path to load the object's state from. ### Request Example ```python # Initialize with default values gui_option_default = GUIOption() # Initialize with a dictionary init_data = {"unit": 1} gui_option_dict = GUIOption(init_dict=init_data) # Initialize from a file (assuming 'gui_option.json' exists) gui_option_file = GUIOption(init_str='path/to/gui_option.json') ``` ### Response An initialized GUIOption object. ``` -------------------------------- ### Example Output of Operating Point Matrix and Settings Source: https://pyleecan.org/04_tuto_Operating_point.html This output shows the generated operating point matrix and the original and updated operating points after configuration. It verifies the correct setup of parameters for multi-point simulations. ```text Operating Point matrix: [[2.00000000e+03 1.76776695e+02 1.04719755e+00 7.90000000e+01] [2.00000000e+03 1.76776695e+02 1.22173048e+00 1.25000000e+02] [2.00000000e+03 1.76776695e+02 1.39626340e+00 1.60000000e+02] [2.00000000e+03 1.76776695e+02 1.57079633e+00 1.92000000e+02] [2.00000000e+03 1.76776695e+02 1.74532925e+00 2.37000000e+02] [2.00000000e+03 1.76776695e+02 1.91986218e+00 2.81000000e+02] [2.00000000e+03 1.76776695e+02 2.09439510e+00 3.19000000e+02] [2.00000000e+03 1.76776695e+02 2.26892803e+00 3.43000000e+02] [2.00000000e+03 1.76776695e+02 2.44346095e+00 3.53000000e+02] [2.00000000e+03 1.76776695e+02 2.61799388e+00 3.32000000e+02] [2.00000000e+03 1.76776695e+02 2.79252680e+00 2.66000000e+02] [2.00000000e+03 1.76776695e+02 2.96705973e+00 1.64000000e+02] [2.00000000e+03 1.76776695e+02 3.14159265e+00 2.20000000e+01]] Original Operating point: {'I0': 176.77669529663686, 'Phi0': 2.443460952792061} Updated Operating point: {'I0': 176.77669529663686, 'Phi0': 1.0471975511965976} ``` -------------------------------- ### GET /tutorial/open Source: https://pyleecan.org/_modules/pyleecan/GUI/Dxf/DXF_Hole.html Opens the tutorial video URL associated with the current module in the system's default web browser. ```APIDOC ## GET /tutorial/open ### Description Launches the default web browser to navigate to the tutorial URL defined in the object configuration. ### Method GET ### Endpoint /tutorial/open ``` -------------------------------- ### Install PYLEECAN Dependencies with Pip Source: https://pyleecan.org/prerequisite.html Use this command to install all required packages listed in a requirements.txt file. Ensure pip is installed and updated. ```bash python -m pip install -r requirements.txt ``` -------------------------------- ### Setup UI for DXF_Surf Source: https://pyleecan.org/_modules/pyleecan/GUI/Dxf/Ui_DXF_Surf.html Initializes the UI for the DXF_Surf window. This includes setting the window icon, creating layouts, and adding various widgets like buttons, text browsers, and input fields. ```Python from PySide2.QtCore import * from PySide2.QtGui import * from PySide2.QtWidgets import * from ...GUI.Tools.FloatEdit import FloatEdit from ...GUI.Tools.WPathSelector.WPathSelector import WPathSelector from pyleecan.GUI.Resources import pyleecan_rc [docs] class Ui_DXF_Surf(object): [docs] def setupUi(self, DXF_Surf): if not DXF_Surf.objectName(): DXF_Surf.setObjectName(u"DXF_Surf") DXF_Surf.resize(864, 653) icon = QIcon() icon.addFile( u":/images/images/icon/pyleecan_64.png", QSize(), QIcon.Normal, QIcon.Off ) DXF_Surf.setWindowIcon(icon) self.horizontalLayout_5 = QHBoxLayout(DXF_Surf) self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") self.layout_plot = QVBoxLayout() self.layout_plot.setObjectName(u"layout_plot") self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setObjectName(u"horizontalLayout") self.b_reset = QPushButton(DXF_Surf) self.b_reset.setObjectName(u"b_reset") self.horizontalLayout.addWidget(self.b_reset) self.b_cancel = QPushButton(DXF_Surf) self.b_cancel.setObjectName(u"b_cancel") self.horizontalLayout.addWidget(self.b_cancel) self.b_tuto = QPushButton(DXF_Surf) self.b_tuto.setObjectName(u"b_tuto") self.b_tuto.setEnabled(False) self.horizontalLayout.addWidget(self.b_tuto) self.horizontalSpacer_2 = QSpacerItem( 40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum ) self.horizontalLayout.addItem(self.horizontalSpacer_2) self.layout_plot.addLayout(self.horizontalLayout) self.textBrowser = QTextBrowser(DXF_Surf) self.textBrowser.setObjectName(u"textBrowser") self.textBrowser.setMaximumSize(QSize(16777215, 140)) self.layout_plot.addWidget(self.textBrowser) self.horizontalLayout_5.addLayout(self.layout_plot) self.w_side = QWidget(DXF_Surf) self.w_side.setObjectName(u"w_side") self.w_side.setMinimumSize(QSize(400, 0)) self.w_side.setMaximumSize(QSize(400, 16777215)) self.verticalLayout_2 = QVBoxLayout(self.w_side) self.verticalLayout_2.setObjectName(u"verticalLayout_2") self.g_import = QGroupBox(self.w_side) self.g_import.setObjectName(u"g_import") self.verticalLayout = QVBoxLayout(self.g_import) self.verticalLayout.setObjectName(u"verticalLayout") self.w_path_selector = WPathSelector(self.g_import) self.w_path_selector.setObjectName(u"w_path_selector") sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.w_path_selector.sizePolicy().hasHeightForWidth() ) self.w_path_selector.setSizePolicy(sizePolicy) self.verticalLayout.addWidget(self.w_path_selector) self.is_convert = QCheckBox(self.g_import) self.is_convert.setObjectName(u"is_convert") self.is_convert.setChecked(True) self.verticalLayout.addWidget(self.is_convert) self.horizontalLayout_3 = QHBoxLayout() self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") self.in_tol = QLabel(self.g_import) self.in_tol.setObjectName(u"in_tol") self.horizontalLayout_3.addWidget(self.in_tol) self.lf_tol = FloatEdit(self.g_import) self.lf_tol.setObjectName(u"lf_tol") sizePolicy1 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) sizePolicy1.setHorizontalStretch(0) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth(self.lf_tol.sizePolicy().hasHeightForWidth()) self.lf_tol.setSizePolicy(sizePolicy1) self.horizontalLayout_3.addWidget(self.lf_tol) self.verticalLayout.addLayout(self.horizontalLayout_3) self.verticalLayout_2.addWidget(self.g_import) self.gridLayout = QGridLayout() self.gridLayout.setObjectName(u"gridLayout") self.in_Zh = QLabel(self.w_side) self.in_Zh.setObjectName(u"in_Zh") self.gridLayout.addWidget(self.in_Zh, 0, 0, 1, 1) self.in_per_a = QLabel(self.w_side) self.in_per_a.setObjectName(u"in_per_a") self.gridLayout.addWidget(self.in_per_a, 1, 0, 1, 1) self.si_Zh = QSpinBox(self.w_side) self.si_Zh.setObjectName(u"si_Zh") sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy2.setHorizontalStretch(0) sizePolicy2.setVerticalStretch(0) sizePolicy2.setHeightForWidth(self.si_Zh.sizePolicy().hasHeightForWidth()) self.si_Zh.setSizePolicy(sizePolicy2) ``` -------------------------------- ### Set Linspace Start Value Source: https://pyleecan.org/_modules/pyleecan/GUI/Tools/WImport/WImportLinspace/WImportLinspace.html Updates the 'start' attribute of the data object with the value from the start input field and emits a saveNeeded signal. ```python [docs] def set_start(self): """Change the value according to the widget""" self.data.start = self.lf_start.value() # Notify the machine GUI that the machine has changed self.saveNeeded.emit() ``` -------------------------------- ### Install pytest Source: https://pyleecan.org/_sources/tests_tutorials/how.to.use.pytest.md.txt Command to install the pytest package. ```bash pip install -U pytest ``` -------------------------------- ### Initialize and Configure PMSlot15 UI Source: https://pyleecan.org/_modules/pyleecan/GUI/Dialog/DMachineSetup/SMSlot/PMSlot15/Ui_PMSlot15.html Sets up the main window for PMSlot15, including layout, image display, and text constraints. This is the entry point for the UI setup. ```python from PySide2.QtCore import * from PySide2.QtGui import * from PySide2.QtWidgets import * from ......GUI.Tools.FloatEdit import FloatEdit from ......GUI.Dialog.DMachineSetup.SWSlot.WWSlotOut.WWSlotOut import WWSlotOut from pyleecan.GUI.Resources import pyleecan_rc [docs] class Ui_PMSlot15(object): [docs] def setupUi(self, PMSlot15): if not PMSlot15.objectName(): PMSlot15.setObjectName(u"PMSlot15") PMSlot15.resize(878, 470) PMSlot15.setMinimumSize(QSize(630, 470)) PMSlot15.setMaximumSize(QSize(16777215, 16777215)) self.horizontalLayout = QHBoxLayout(PMSlot15) self.horizontalLayout.setObjectName(u"horizontalLayout") self.verticalLayout_2 = QVBoxLayout() self.verticalLayout_2.setObjectName(u"verticalLayout_2") self.img_slot = QLabel(PMSlot15) self.img_slot.setObjectName(u"img_slot") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.img_slot.sizePolicy().hasHeightForWidth()) self.img_slot.setSizePolicy(sizePolicy) self.img_slot.setMaximumSize(QSize(16777215, 16777215)) self.img_slot.setPixmap( QPixmap(u":/images/images/MachineSetup/WMSlot/SlotM15.png") ) self.img_slot.setScaledContents(False) self.img_slot.setAlignment(Qt.AlignCenter) self.verticalLayout_2.addWidget(self.img_slot) self.txt_constraint = QTextEdit(PMSlot15) self.txt_constraint.setObjectName(u"txt_constraint") sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) sizePolicy1.setHorizontalStretch(0) sizePolicy1.setVerticalStretch(0) sizePolicy1.setHeightForWidth( self.txt_constraint.sizePolicy().hasHeightForWidth() ) self.txt_constraint.setSizePolicy(sizePolicy1) self.txt_constraint.setMaximumSize(QSize(16777215, 50)) self.txt_constraint.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.txt_constraint.setTextInteractionFlags( Qt.TextSelectableByKeyboard | Qt.TextSelectableByMouse ) self.verticalLayout_2.addWidget(self.txt_constraint) self.horizontalLayout.addLayout(self.verticalLayout_2) self.scrollArea = QScrollArea(PMSlot15) self.scrollArea.setObjectName(u"scrollArea") self.scrollArea.setMinimumSize(QSize(270, 0)) self.scrollArea.setMaximumSize(QSize(270, 16777215)) self.scrollArea.setWidgetResizable(True) self.scrollAreaWidgetContents = QWidget() self.scrollAreaWidgetContents.setObjectName(u"scrollAreaWidgetContents") self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 268, 446)) self.verticalLayout = QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout.setObjectName(u"verticalLayout") self.gridLayout = QGridLayout() self.gridLayout.setObjectName(u"gridLayout") self.in_W0 = QLabel(self.scrollAreaWidgetContents) self.in_W0.setObjectName(u"in_W0") self.gridLayout.addWidget(self.in_W0, 0, 0, 1, 1) self.lf_W0 = FloatEdit(self.scrollAreaWidgetContents) self.lf_W0.setObjectName(u"lf_W0") self.gridLayout.addWidget(self.lf_W0, 0, 1, 1, 1) self.unit_W0 = QLabel(self.scrollAreaWidgetContents) self.unit_W0.setObjectName(u"unit_W0") self.gridLayout.addWidget(self.unit_W0, 0, 2, 1, 1) self.in_Wmag = QLabel(self.scrollAreaWidgetContents) self.in_Wmag.setObjectName(u"in_Wmag") self.gridLayout.addWidget(self.in_Wmag, 1, 0, 1, 1) self.lf_Wmag = FloatEdit(self.scrollAreaWidgetContents) self.lf_Wmag.setObjectName(u"lf_Wmag") self.gridLayout.addWidget(self.lf_Wmag, 1, 1, 1, 1) self.unit_Wmag = QLabel(self.scrollAreaWidgetContents) self.unit_Wmag.setObjectName(u"unit_Wmag") self.gridLayout.addWidget(self.unit_Wmag, 1, 2, 1, 1) self.in_H0 = QLabel(self.scrollAreaWidgetContents) self.in_H0.setObjectName(u"in_H0") self.gridLayout.addWidget(self.in_H0, 2, 0, 1, 1) self.lf_H0 = FloatEdit(self.scrollAreaWidgetContents) self.lf_H0.setObjectName(u"lf_H0") self.gridLayout.addWidget(self.lf_H0, 2, 1, 1, 1) self.unit_H0 = QLabel(self.scrollAreaWidgetContents) self.unit_H0.setObjectName(u"unit_H0") self.gridLayout.addWidget(self.unit_H0, 2, 2, 1, 1) self.in_Hmag = QLabel(self.scrollAreaWidgetContents) self.in_Hmag.setObjectName(u"in_Hmag") self.gridLayout.addWidget(self.in_Hmag, 3, 0, 1, 1) self.lf_Hmag = FloatEdit(self.scrollAreaWidgetContents) ```