Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add template list #147

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/ansys/motorcad/core/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,55 @@
y = coordinates_complex.imag

return x, y


def template_list(self):
"""Return List of templates available in Motor-CAD.

Individual template information is in dictionary format
for example
[{'Template': 'a1',
'Sector': 'Aerospace',
' Machine_Type': ' Surface PM',
'Application': ' Generator',
'Winding_Type': ' Concentrated',
'Max_Speed(rpm)': ' 10,000',
'Power(kW)': ' 14',
' Cooling': 'Oil cooled',
' Drive_Type': 'Sine'},]
"""
import os

Check warning on line 70 in src/ansys/motorcad/core/geometry.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/motorcad/core/geometry.py#L70

Added line #L70 was not covered by tests

# Motor-CAD installation directory in PC
mcad_install_dir = self.get_variable("CurrentExeDir_MotorLAB")
directory = mcad_install_dir + r"Motor-CAD Data\templates"
template_list1 = []
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
if filename.endswith(".mtt"):
with open(f, "r") as file:
print(filename)
for l_no, line in enumerate(file):

Check warning on line 81 in src/ansys/motorcad/core/geometry.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/motorcad/core/geometry.py#L73-L81

Added lines #L73 - L81 were not covered by tests
# search string
if "Data_File_Notes[1]" in line:
print("string found in a file")
print("Line Number:", l_no)
print("Line:", line)

Check warning on line 86 in src/ansys/motorcad/core/geometry.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/motorcad/core/geometry.py#L83-L86

Added lines #L83 - L86 were not covered by tests
# don't look for next lines
list1 = line.split(";")
list1[0] = list1[0][19:]
dict1 = {

Check warning on line 90 in src/ansys/motorcad/core/geometry.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/motorcad/core/geometry.py#L88-L90

Added lines #L88 - L90 were not covered by tests
"Template": filename.split(".")[0],
"Sector": list1[0],
"Machine_Type": list1[1],
"Application": list1[2],
"Winding_Type": list1[3],
"Max_Speed(rpm)": list1[4],
"Power(kW)": list1[5],
"Cooling": list1[6],
"Drive_Type": list1[7],
}
template_list1.append(dict1)
break

Check warning on line 102 in src/ansys/motorcad/core/geometry.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/motorcad/core/geometry.py#L101-L102

Added lines #L101 - L102 were not covered by tests

return template_list1

Check warning on line 104 in src/ansys/motorcad/core/geometry.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/motorcad/core/geometry.py#L104

Added line #L104 was not covered by tests