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

fix: Handle Undefined 'first_diode' Variable to Prevent Plugin Crash #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all 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
15 changes: 8 additions & 7 deletions kle_placer_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def check(key):
first_diode = self.get_footprint(diode_format.format(1), required=False) or None

# Make sure there is a first diode if relative diode is enabled
if not first_diode and relative_diode_mode:
if not first_diode and move_diodes:
raise Exception("First key requires a diode!")

# DEFAULTS
Expand Down Expand Up @@ -395,13 +395,14 @@ def check(key):
else:
diode_offset_x = self.nm_to_mm(first_diode.GetPosition().x - first_key.GetPosition().x)
diode_offset_y = self.nm_to_mm(first_diode.GetPosition().y - first_key.GetPosition().y)

first_diode_rotation = first_diode.GetOrientationDegrees()
if first_key_already_rotated:
first_diode_rotation += self.layout.keys[0].rotation_angle

# Set the default diode rotation to that of the first diode's
default_diode_rotation = first_diode_rotation
if move_diodes:
first_diode_rotation = first_diode.GetOrientationDegrees()
if first_key_already_rotated:
first_diode_rotation += self.layout.keys[0].rotation_angle

# Set the default diode rotation to that of the first diode's
default_diode_rotation = first_diode_rotation

# Start placement of keys
for key in self.layout.keys:
Expand Down