def SetTeardrops(hpercent=30, vpercent=70, segs=10, pcb=None): """Set teardrops on a teardrop free board""" if pcb is None: pcb = GetBoard() vias = __GetAllVias(pcb)[0] + __GetAllPads(pcb, [PAD_ATTRIB_STANDARD])[0] vias_selected = __GetAllVias(pcb)[1] +\ __GetAllPads(pcb, [PAD_ATTRIB_STANDARD])[1] if len(vias_selected) > 0: vias = vias_selected teardrops = __GetAllTeardrops(pcb) count = 0 for track in [t for t in pcb.GetTracks() if type(t) == TRACK]: for via in [v for v in vias if track.IsPointOnEnds(v[0], v[1] / 2)]: if (track.GetLength() < __TeardropLength(track, via, hpercent)) or\ (track.GetWidth() >= via[1] * vpercent / 100): continue found = False if track.GetNetname() in teardrops.keys(): for teardrop in teardrops[track.GetNetname()]: if __DoesTeardropBelongTo(teardrop, track, via): found = True break if not found: coor = __ComputePoints(track, via, hpercent, vpercent, segs) pcb.Add(__Zone(pcb, coor, track)) count += 1 print('{0} teardrops inserted'.format(count)) return count
def SetTeardrops(hpercent=30, vpercent=70, segs=10, pcb=None, use_smd=False, discard_in_same_zone=True): """Set teardrops on a teardrop free board""" if pcb is None: pcb = GetBoard() pad_types = [PAD_ATTRIB_STANDARD] + [PAD_ATTRIB_SMD] * use_smd vias = __GetAllVias(pcb)[0] + __GetAllPads(pcb, pad_types)[0] vias_selected = __GetAllVias(pcb)[1] + __GetAllPads(pcb, pad_types)[1] if len(vias_selected) > 0: vias = vias_selected teardrops = __GetAllTeardrops(pcb) count = 0 for track in [t for t in pcb.GetTracks() if type(t) == TRACK]: for via in [ v for v in vias if track.IsPointOnEnds(v[0], int(v[1] / 2)) ]: if (track.GetLength() < __TeardropLength(track, via, hpercent)) or\ (track.GetWidth() >= via[1] * vpercent / 100): continue found = False if track.GetNetname() in teardrops.keys(): for teardrop in teardrops[track.GetNetname()]: if __DoesTeardropBelongTo(teardrop, track, via): found = True break # Discard case where pad and track are on different layers, or the pad have no copper at all (paste pads). if (via[3] == "none"): continue if (via[3] == "front") and (not track.IsOnLayer(0)): continue if (via[3] == "back") and track.IsOnLayer(0): continue # Discard case where pad/via is within a zone with the same netname # WARNING: this can severly reduce performances if discard_in_same_zone and \ __IsViaAndTrackInSameNetZone(pcb, via, track): continue if not found: coor = __ComputePoints(track, via, hpercent, vpercent, segs) pcb.Add(__Zone(pcb, coor, track)) count += 1 RebuildAllZones(pcb) print('{0} teardrops inserted'.format(count)) return count
def SetTeardrops(hpercent=30, vpercent=70, segs=10, pcb=None, use_smd=False): """Set teardrops on a teardrop free board""" if pcb is None: pcb = GetBoard() pad_types = [PAD_ATTRIB_STANDARD] + [PAD_ATTRIB_SMD] * use_smd vias = __GetAllVias(pcb)[0] + __GetAllPads(pcb, pad_types)[0] vias_selected = __GetAllVias(pcb)[1] + __GetAllPads(pcb, pad_types)[1] if len(vias_selected) > 0: vias = vias_selected teardrops = __GetAllTeardrops(pcb) count = 0 for track in [t for t in pcb.GetTracks() if type(t) == TRACK]: for via in [ v for v in vias if track.IsPointOnEnds(v[0], int(v[1] / 2)) ]: if (track.GetLength() < __TeardropLength(track, via, hpercent)) or\ (track.GetWidth() >= via[1] * vpercent / 100): continue found = False if track.GetNetname() in teardrops.keys(): for teardrop in teardrops[track.GetNetname()]: if __DoesTeardropBelongTo(teardrop, track, via): found = True break # Discard case where pad and track are not on the same layer if (via[3] == "front") and (not track.IsOnLayer(0)): continue if (via[3] == "back") and track.IsOnLayer(0): continue if not found: coor = __ComputePoints(track, via, hpercent, vpercent, segs) pcb.Add(__Zone(pcb, coor, track)) count += 1 RebuildAllZones(pcb) print('{0} teardrops inserted'.format(count)) return count
def SetTeardrops(hpercent=50, vpercent=90, segs=10, pcb=None, use_smd=False, discard_in_same_zone=True, follow_tracks=True): """Set teardrops on a teardrop free board""" if pcb is None: pcb = GetBoard() pad_types = [PAD_ATTRIB_STANDARD] + [PAD_ATTRIB_SMD]*use_smd vias = __GetAllVias(pcb)[0] + __GetAllPads(pcb, pad_types)[0] vias_selected = __GetAllVias(pcb)[1] + __GetAllPads(pcb, pad_types)[1] if len(vias_selected) > 0: vias = vias_selected trackLookup = {} if follow_tracks: for t in pcb.GetTracks(): if type(t) == TRACK: net = t.GetNetname() layer = t.GetLayer() if layer not in trackLookup: trackLookup[layer] = {} if net not in trackLookup[layer]: trackLookup[layer][net]=[] trackLookup[layer][net].append(t) teardrops = __GetAllTeardrops(pcb) count = 0 for track in [t for t in pcb.GetTracks() if type(t)==TRACK]: for via in [v for v in vias if track.IsPointOnEnds(v[0], int(v[1]/2))]: if (track.GetWidth() >= via[1] * vpercent / 100): continue if track.IsPointOnEnds(via[0], int(via[1]/2))==STARTPOINT|ENDPOINT: # both start and end are within the via continue found = False if track.GetNetname() in teardrops.keys(): for teardrop in teardrops[track.GetNetname()]: if __DoesTeardropBelongTo(teardrop, track, via): found = True break # Discard case where pad and track are on different layers, or the # pad have no copper at all (paste pads). if (via[3] != -1) and (via[3] != track.GetLayer()): continue # Discard case where pad/via is within a zone with the same netname # WARNING: this can severely reduce performance if discard_in_same_zone and \ __IsViaAndTrackInSameNetZone(pcb, via, track): continue if not found: coor = __ComputePoints(track, via, hpercent, vpercent, segs, follow_tracks, trackLookup) pcb.Add(__Zone(pcb, coor, track)) count += 1 RebuildAllZones(pcb) print('{0} teardrops inserted'.format(count)) return count