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

Fixed plugin for KiCad 7 #41

Merged
merged 4 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
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
31 changes: 16 additions & 15 deletions round_tracks/round_trk.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import sys
import os
from pcbnew import *
from builtins import abs
import wx
import pcbnew
import math
Expand Down Expand Up @@ -218,8 +219,8 @@ def create_Track(pcb,p1,p2,lyr=None,w=None,Nn=None,Ts=None):
else:
new_shape = PCB_SHAPE()
new_line = PCB_TRACK(new_shape)
new_line.SetStart(p1)
new_line.SetEnd(p2)
new_line.SetStart(VECTOR2I(p1))
new_line.SetEnd(VECTOR2I(p2))
if w is None:
new_line.SetWidth(FromUnits(1.5)) #FromUnits(int(mask_width)))
else:
Expand Down Expand Up @@ -266,9 +267,9 @@ def create_Arc(pcb,p1,p2,mp,lyr=None,w=None,Nn=None,Ts=None):
#new_arc = PCB_ARC(new_shape)
new_trk = PCB_TRACK(pcb)
new_arc = PCB_ARC(new_trk)
new_arc.SetStart(p1)
new_arc.SetEnd(p2)
new_arc.SetMid(mp)
new_arc.SetStart(VECTOR2I(p1))
new_arc.SetEnd(VECTOR2I(p2))
new_arc.SetMid(VECTOR2I(mp))
if w is None:
new_arc.SetWidth(FromUnits(1.5)) #FromUnits(int(mask_width)))
else:
Expand Down Expand Up @@ -297,8 +298,8 @@ def create_Draw(pcb,p1,p2,lyr=None,w=None):
else:
new_line = PCB_SHAPE()
#new_line = pcbnew.TRACK(pcb)
new_line.SetStart(p1)
new_line.SetEnd(p2)
new_line.SetStart(VECTOR2I(p1))
new_line.SetEnd(VECTOR2I(p2))
if w is None:
new_line.SetWidth(FromUnits(1.5)) #FromUnits(int(mask_width)))
else:
Expand Down Expand Up @@ -806,19 +807,19 @@ def Connect_Segments(pcb):
wxLogDebug('dp1,pi)'+str(distance(wxPoint(x1,y1),pi)),debug2)
wxLogDebug('dp3,pi)'+str(distance(wxPoint(x3,y3),pi)),debug2)
if distance(wxPoint(x1,y1),pi) > distance(wxPoint(x3,y3),pi):
tracks[0].SetStart(wxPoint(x1,y1))
tracks[0].SetEnd(pi)
tracks[0].SetStart(VECTOR2I(wxPoint(x1,y1)))
tracks[0].SetEnd(VECTOR2I(pi))
else:
tracks[0].SetStart(wxPoint(x3,y3))
tracks[0].SetEnd(pi)
tracks[0].SetStart(VECTOR2I(wxPoint(x3,y3)))
tracks[0].SetEnd(VECTOR2I(pi))
wxLogDebug('dp2,pi)'+str(distance(wxPoint(x2,y2),pi)),debug2)
wxLogDebug('dp4,pi)'+str(distance(wxPoint(x4,y4),pi)),debug2)
if distance(wxPoint(x2,y2),pi) > distance(wxPoint(x4,y4),pi):
tracks[1].SetStart(wxPoint(x2,y2))
tracks[1].SetEnd(pi)
tracks[1].SetStart(VECTOR2I(wxPoint(x2,y2)))
tracks[1].SetEnd(VECTOR2I(pi))
else:
tracks[1].SetStart(wxPoint(x4,y4))
tracks[1].SetEnd(pi)
tracks[1].SetStart(VECTOR2I(wxPoint(x4,y4)))
tracks[1].SetEnd(VECTOR2I(pi))
pcbnew.Refresh()
else:
wxLogDebug(u'\u2718 you must select two tracks only',not debug)
Expand Down
30 changes: 15 additions & 15 deletions taper_fz/taper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import os
import sys
from math import cos, acos, sin, asin, tan, atan2, sqrt, pi, degrees, radians, copysign
from pcbnew import ToMM, FromMM, wxPoint, GetBoard, ZONE_SETTINGS
from pcbnew import ToMM, FromMM, wxPoint, GetBoard, ZONE_SETTINGS, VECTOR2I
from pcbnew import ZONE_FILLER
import pcbnew
import wx
Expand Down Expand Up @@ -56,7 +56,7 @@ def __Zone(board, points, track):
z.SetMinThickness(25400) # The minimum
z.SetPadConnection(2) # 2 -> solid
z.SetIsFilled(True)
z.SetPriority(MAGIC_TAPER_ZONE_ID) # MAGIC_TEARDROP_ZONE_ID)
z.SetAssignedPriority(MAGIC_TAPER_ZONE_ID) # MAGIC_TEARDROP_ZONE_ID)
ol = z.Outline()
ol.NewOutline()

Expand Down Expand Up @@ -234,7 +234,7 @@ def __ComputePoints(track, pad, segs):
bdelta = FromMM(0.01)
backoff=0
while backoff<radius:
np = start + wxPoint( vecT[0]*backoff, vecT[1]*backoff )
np = start + VECTOR2I(wxPoint( vecT[0]*backoff, vecT[1]*backoff ))
if __PointDistance(np, pad.GetPosition()) >= radius: # via[0]) >= radius:
break
backoff += bdelta
Expand All @@ -254,14 +254,14 @@ def __ComputePoints(track, pad, segs):
vpercent = ToMM(vpercent*n/targetLength + minVpercent*(1-n/targetLength))

# find point on the track, sharp end of the teardrop
pointB = start + wxPoint( vecT[0]*n +vecT[1]*w , vecT[1]*n -vecT[0]*w )
pointA = start + wxPoint( vecT[0]*n -vecT[1]*w , vecT[1]*n +vecT[0]*w )
pointB = start + VECTOR2I(wxPoint( vecT[0]*n +vecT[1]*w , vecT[1]*n -vecT[0]*w ))
pointA = start + VECTOR2I(wxPoint( vecT[0]*n -vecT[1]*w , vecT[1]*n +vecT[0]*w ))
#pointB = wxPoint(int(start.x-0.15*radius),int(start.y-0.15*radius)) + wxPoint( vecT[0]*n +vecT[1]*w , vecT[1]*n -vecT[0]*w )
# Introduce a last point in order to cover the via centre.
# If not, the zone won't be filled or not connected
internal_delta_multiplier = 0.15
idm = internal_delta_multiplier
pointF = start + wxPoint(int(vecT[0]*+idm*w), int(vecT[1]*+idm*w))
pointF = start + VECTOR2I(wxPoint(int(vecT[0]*+idm*w), int(vecT[1]*+idm*w)))

# In some cases of very short, eccentric tracks the points can end up
# inside the teardrop. If this happens just cancel adding it
Expand Down Expand Up @@ -305,8 +305,8 @@ def __ComputePoints(track, pad, segs):
vecC = [vec[0]*cos(dC)+vec[1]*sin(dC), -vec[0]*sin(dC)+vec[1]*cos(dC)]
vecE = [vec[0]*cos(dE)+vec[1]*sin(dE), -vec[0]*sin(dE)+vec[1]*cos(dE)]

pointC = pad.GetPosition() + wxPoint(int(vecC[0] * nsx/2), int(vecC[1] * nsx/2)) #radius)) # - wxPoint(int(vec[0]*-0.25*nsy), int(vec[1]*-0.25*nsy))
pointE = pad.GetPosition() + wxPoint(int(vecE[0] * nsx/2), int(vecE[1] * nsx/2)) #radius)) # - wxPoint(int(vec[0]*-0.25*nsy), int(vec[1]*-0.25*nsy))
pointC = pad.GetPosition() + VECTOR2I(wxPoint(int(vecC[0] * nsx/2), int(vecC[1] * nsx/2))) #radius)) # - wxPoint(int(vec[0]*-0.25*nsy), int(vec[1]*-0.25*nsy))
pointE = pad.GetPosition() + VECTOR2I(wxPoint(int(vecE[0] * nsx/2), int(vecE[1] * nsx/2))) #radius)) # - wxPoint(int(vec[0]*-0.25*nsy), int(vec[1]*-0.25*nsy))
# pointC = via[0] + wxPoint(int(vecC[0] * radius), int(vecC[1] * radius))
# pointE = via[0] + wxPoint(int(vecE[0] * radius), int(vecE[1] * radius))
#pointC2 = pointC + wxPoint(int(cos(padAngle)*vec[0]*invx*nsx*0.5), int(-sin(padAngle)*vec[1]*invy*nsx*0.5))
Expand All @@ -315,13 +315,13 @@ def __ComputePoints(track, pad, segs):
signx = copysign (1, vec[0])
signy = copysign (1, vec[1])

shiftP = wxPoint(int(invx*signx*nsy*0.25), int(invy*signy*nsy*0.25))
shiftP = VECTOR2I(wxPoint(int(invx*signx*nsy*0.25), int(invy*signy*nsy*0.25)))
pointC2 = pointC + shiftP #wxPoint(int(invx*signx*nsy*0.25), int(invy*signy*nsy*0.25))
pointE2 = pointE + shiftP #wxPoint(int(invx*signx*nsy*0.25), int(invy*signy*nsy*0.25))

# Introduce a last point in order to cover the via centre.
# If not, the zone won't be filled
shiftD= wxPoint(int(vec[0]*-0.12*radius), int(vec[1]*-0.12*radius))
shiftD= VECTOR2I(wxPoint(int(vec[0]*-0.12*radius), int(vec[1]*-0.12*radius)))
pointD = pad.GetPosition() + shiftD
# pointD = via[0] + wxPoint(int(vec[0]*-0.5*radius), int(vec[1]*-0.5*radius))

Expand Down Expand Up @@ -589,10 +589,10 @@ def SetTaper_Zone(pcb=None):
# it will be used a base vector pointing in the track direction
vecT = __NormalizeVector(end - start)
# find point on the track, sharp end of the teardrop
pointB = start + wxPoint( vecT[0]*n +vecT[1]*w , vecT[1]*n -vecT[0]*w )
pointA = start + wxPoint( vecT[0]*n -vecT[1]*w , vecT[1]*n +vecT[0]*w )
pointD = start - wxPoint( vecT[0]*n +vecT[1]*w , vecT[1]*n -vecT[0]*w )
pointC = start - wxPoint( vecT[0]*n -vecT[1]*w , vecT[1]*n +vecT[0]*w )
pointB = start + VECTOR2I(wxPoint( vecT[0]*n +vecT[1]*w , vecT[1]*n -vecT[0]*w ))
pointA = start + VECTOR2I(wxPoint( vecT[0]*n -vecT[1]*w , vecT[1]*n +vecT[0]*w ))
pointD = start - VECTOR2I(wxPoint( vecT[0]*n +vecT[1]*w , vecT[1]*n -vecT[0]*w ))
pointC = start - VECTOR2I(wxPoint( vecT[0]*n -vecT[1]*w , vecT[1]*n +vecT[0]*w ))
points = [pointA,pointB,pointC,pointD]
pcb.Add(__Zone(pcb, points, track))
RebuildAllZones(pcb)
Expand Down Expand Up @@ -637,7 +637,7 @@ def __GetAllTapers(board):
"""Just retrieves all teardrops of the current board classified by net"""
tapers_zones = {}
for zone in [board.GetArea(i) for i in range(board.GetAreaCount())]:
if zone.GetPriority() == MAGIC_TAPER_ZONE_ID:
if zone.GetAssignedPriority() == MAGIC_TAPER_ZONE_ID:
netname = zone.GetNetname()
if netname not in tapers_zones.keys():
tapers_zones[netname] = []
Expand Down
8 changes: 4 additions & 4 deletions trace_clearance/trace_clearance.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def poly_points(track_start, track_end, track_width, clearance):

delta_x = delta * -dy_norm
delta_y = delta * dx_norm
pt_delta = pcbnew.wxPoint(delta_x, delta_y)
pt_delta = pcbnew.VECTOR2I(pcbnew.wxPoint(delta_x, delta_y))

pts = []
pts.append(track_start + pt_delta)
Expand All @@ -198,7 +198,7 @@ def poly_points(track_start, track_end, track_width, clearance):
for pt in semicircle_points(track_end, delta, theta, False):
pts.append(pt)
pts.append(track_end + pt_delta)
return pcbnew.wxPoint_Vector(pts)
return pcbnew.VECTOR_VECTOR2I(pts)


def semicircle_points(circle_center, radius, angle_norm, is_start=True):
Expand Down Expand Up @@ -230,6 +230,6 @@ def semicircle_points(circle_center, radius, angle_norm, is_start=True):
# )
pts.append(
circle_center
+ pcbnew.wxPoint(radius * math.cos(ang), radius * math.sin(ang))
+ pcbnew.VECTOR2I(pcbnew.wxPoint(radius * math.cos(ang), radius * math.sin(ang)))
)
return pcbnew.wxPoint_Vector(pts)
return pcbnew.VECTOR_VECTOR2I(pts)
6 changes: 3 additions & 3 deletions via_fence_generator/viafence_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def createVias(self, viaPoints, viaDrill, viaSize, netCode):
newVia.SetTimeStamp(ts) # adding a unique number as timestamp to mark this via as generated by this script
self.boardObj.Add(newVia)

newVia.SetPosition(pcbnew.wxPoint(viaPoint[0], viaPoint[1]))
newVia.SetPosition(pcbnew.VECTOR2I(pcbnew.wxPoint(viaPoint[0], viaPoint[1])))
newVia.SetWidth(viaSize)
newVia.SetDrill(viaDrill)
if hasattr(pcbnew, 'VIA_THROUGH'):
Expand Down Expand Up @@ -171,7 +171,7 @@ def checkPads(self):
viaPos[1] - local_offset*expansion)
size_rect = pcbnew.wxSize(2 * expansion * local_offset, 2 * expansion * local_offset)
wxLogDebug(str(pcbnew.ToMM(start_rect))+'::'+str(pcbnew.ToMM(size_rect)),debug)
if pad.HitTest(pcbnew.EDA_RECT(start_rect, size_rect), False):
if pad.HitTest(pcbnew.BOX2I(pcbnew.VECTOR2I(start_rect), pcbnew.VECTOR2I(size_rect)), False):
#rectangle[x][y] = self.REASON_PAD
wxLogDebug('Hit on Pad: viaPos:'+str(viaPos),debug)
#self.viaPointsSafe.pop(i)
Expand Down Expand Up @@ -259,7 +259,7 @@ def checkTracks(self):
#wxLogDebug('here',True)
#if track.HitTest(pcbnew.EDA_RECT(start_rect, size_rect), False):
aContained=False;aAccuracy=0
if track.HitTest(pcbnew.EDA_RECT(start_rect, size_rect), aContained, aAccuracy):
if track.HitTest(pcbnew.BOX2I(pcbnew.VECTOR2I(start_rect), pcbnew.VECTOR2I(size_rect)), aContained, aAccuracy):
#rectangle[x][y] = self.REASON_PAD
wxLogDebug('Hit on Track: viaPos:'+str(viaPos),debug)
#self.viaPointsSafe.pop(i)
Expand Down