Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6a9e830
initial testing
jgsdavies May 27, 2025
ce5606c
Geometry and geometrynode outline
aidanc-ansys Jun 23, 2025
93979a8
Base functionality complete
aidanc-ansys Jun 23, 2025
5af4baf
Testing implemented, overall improvements
aidanc-ansys Jun 26, 2025
35bd62e
More testing
aidanc-ansys Jun 27, 2025
81af941
Merge branch 'main' into add_get_set_tree_method
aidanc-ansys Jun 27, 2025
be1f685
Modified testing, changed expected output of mc.get_geometry_tree
aidanc-ansys Jun 27, 2025
f19b51c
Merge branch 'main' into add_get_set_tree_method
aidanc-ansys Jun 27, 2025
d3177d6
Merge branch 'main' into add_get_set_tree_method
aidanc-ansys Jun 27, 2025
a408df5
Merge remote-tracking branch 'origin/add_get_set_tree_method' into ad…
aidanc-ansys Jun 30, 2025
a82f170
Amended tests for coverage and fixed issues in parent reassignment
aidanc-ansys Jun 30, 2025
63d8ca6
fix mistaken change to geometry.py
aidanc-ansys Jul 7, 2025
375c5d4
update get_node to be more flexible
aidanc-ansys Jul 9, 2025
fae774a
Begun implementation of checks for trees
aidanc-ansys Jul 15, 2025
008c039
Fixed error in last push
aidanc-ansys Jul 15, 2025
caab77e
Added missing endcap regiontype
aidanc-ansys Jul 16, 2025
5e5825f
Initial Testing
aidanc-ansys Jul 16, 2025
b991eb3
Merge remote-tracking branch 'origin/main' into python-graphics
aidanc-ansys Jul 22, 2025
b286928
Complete basic functionality for regions, trees, and entities
aidanc-ansys Jul 22, 2025
10a8728
Better comments; updated functions
aidanc-ansys Jul 23, 2025
570ca26
New display methods
aidanc-ansys Jul 23, 2025
724d3f0
Merge branch 'add_get_set_tree_method' into python-graphics
aidanc-ansys Jul 23, 2025
2d4afbf
Better drawing algorithm; basic legend, all around improvements
aidanc-ansys Jul 24, 2025
d111444
Separating drawing changes
aidanc-ansys Jul 25, 2025
3e9c350
Restored mc.set_geometry_tree
aidanc-ansys Jul 25, 2025
ed1b3b6
Restored mc.set_geometry_tree
aidanc-ansys Jul 25, 2025
772fe0c
Restored testing
aidanc-ansys Jul 25, 2025
77e4e1c
More tests for setting geometry and fixing ducts
aidanc-ansys Jul 29, 2025
a288445
Several docstrings
aidanc-ansys Jul 29, 2025
9ab3403
Nodes now have a set _motorcad_instance attribute
aidanc-ansys Jul 29, 2025
8378227
Nodes now have a set _motorcad_instance attribute
aidanc-ansys Jul 29, 2025
32edc9a
Fixed error with motorcad instance left empty for default constructor…
aidanc-ansys Jul 29, 2025
b7087e9
Added regiontypes
aidanc-ansys Jul 30, 2025
10ae26c
Slightly improved testing
aidanc-ansys Jul 30, 2025
890c0b0
Added function to get nodes from supplied region type
aidanc-ansys Jul 30, 2025
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
15 changes: 15 additions & 0 deletions src/ansys/motorcad/core/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class RegionType(Enum):
rotor_pocket = "Rotor Pocket"
pole_spacer = "Pole Spacer"
rotor_slot = "Rotor Slot"
rotor_bar_end_ring = "Rotor Bar End Ring"
coil_separator = "Coil Separator"
damper_bar = "Damper Bar"
wedge_rotor = "Rotor Wedge"
Expand All @@ -75,6 +76,7 @@ class RegionType(Enum):
barrier = "Barrier"
mounting_base = "Base Mount"
mounting_plate = "Plate Mount"
endcap = "Endcap"
banding = "Banding"
sleeve = "Sleeve"
rotor_cover = "Rotor Cover"
Expand All @@ -84,7 +86,9 @@ class RegionType(Enum):
slot_wj_duct_no_detail = "Slot Water Jacket Duct (no detail)"
cowling = "Cowling"
cowling_gril = "Cowling Grill"
cowling_grill_hole = "Cowling Grill Hole"
brush = "Brush"
bearings = "Bearings"
commutator = "Commutator"
airgap = "Airgap"
dxf_import = "DXF Import"
Expand Down Expand Up @@ -1589,6 +1593,17 @@ def get_arc_intersection(self, arc):
"""
return arc.get_line_intersection(self)

def get_coordinate_distance(self, coordinate):
"""Get distance of line with another coordinate."""
normal_angle = self.angle - 90
defining_point = Coordinate.from_polar_coords(1, normal_angle)
normal = Line(Coordinate(0, 0), defining_point)
normal.translate(coordinate.x, coordinate.y)
nearest_point = self.get_line_intersection(normal)
if nearest_point is None:
return None
return sqrt((coordinate.x - nearest_point.x) ** 2 + (coordinate.y - nearest_point.y) ** 2)


class _BaseArc(Entity):
"""Internal class to allow creation of Arcs."""
Expand Down
13 changes: 13 additions & 0 deletions src/ansys/motorcad/core/methods/adaptive_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from warnings import warn

from ansys.motorcad.core.geometry import Region, RegionMagnet
from ansys.motorcad.core.methods.geometry_tree import GeometryTree
from ansys.motorcad.core.rpc_client_core import MotorCADError, is_running_in_internal_scripting


Expand Down Expand Up @@ -304,3 +305,15 @@ def reset_adaptive_geometry(self):
# No need to do this if running internally
if not is_running_in_internal_scripting():
return self.connection.send_and_receive(method)

def get_geometry_tree(self):
"""Fetch a GeometryTree object containing all the defining geometry of the loaded motor."""
method = "GetGeometryTree"
json = self.connection.send_and_receive(method)
return GeometryTree._from_json(json, self)

def set_geometry_tree(self, tree: GeometryTree):
"""Use a GeometryTree object to set the defining geometry of the loaded motor."""
params = [tree._to_json()]
method = "SetGeometryTree"
return self.connection.send_and_receive(method, params)
Loading