Skip to content

Commit

Permalink
Fix get_coordinate_from_distance where if a value of 0 was assigned t…
Browse files Browse the repository at this point in the history
…o a named parameter, it is ignored. (#436)
  • Loading branch information
james-packer authored Nov 27, 2024
1 parent a73cff3 commit 25a1512
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/ansys/motorcad/core/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,20 +1248,20 @@ def get_coordinate_from_distance(
Coordinate
Coordinate at distance along Line.
"""
if not distance and not fraction and not percentage:
if (distance is None) and (fraction is None) and (percentage is None):
raise Exception("You must provide either a distance, fraction or percentage.")

if distance and fraction:
if (distance is not None) and (fraction is not None):
warn("Both distance and fraction provided. Using distance.", UserWarning)
if distance and percentage:
if (distance is not None) and (percentage is not None):
warn("Both distance and percentage provided. Using distance.", UserWarning)

if not distance:
if fraction and percentage:
if distance is None:
if (fraction is not None) and (percentage is not None):
warn("Both fraction and percentage provided. Using fraction.", UserWarning)
if fraction:
if fraction is not None:
distance = self.length * fraction
elif percentage:
elif percentage is not None:
distance = self.length * (percentage / 100)

if ref_coordinate == self.end:
Expand Down Expand Up @@ -1450,20 +1450,20 @@ def get_coordinate_from_distance(
Coordinate
Coordinate at distance along Arc.
"""
if not distance and not fraction and not percentage:
if (distance is None) and (fraction is None) and (percentage is None):
raise Exception("You must provide either a distance, fraction or percentage.")

if distance and fraction:
if (distance is not None) and (fraction is not None):
warn("Both distance and fraction provided. Using distance.", UserWarning)
if distance and percentage:
if (distance is not None) and (percentage is not None):
warn("Both distance and percentage provided. Using distance.", UserWarning)

if not distance:
if fraction and percentage:
if distance is None:
if (fraction is not None) and (percentage is not None):
warn("Both fraction and percentage provided. Using fraction.", UserWarning)
if fraction:
if fraction is not None:
distance = self.length * fraction
elif percentage:
elif percentage is not None:
distance = self.length * (percentage / 100)

ref_coordinate_angle = atan2(
Expand Down

0 comments on commit 25a1512

Please sign in to comment.