@tscircuit/checks 0.0.171 → 0.0.173
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +17 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1967,6 +1967,11 @@ function checkCopperToBoardEdgeClearance(circuitJson) {
|
|
|
1967
1967
|
if (!boardPolygon) return [];
|
|
1968
1968
|
const requiredClearance = getBoardDrcValue(board, "min_board_edge_clearance") ?? jlcMinTolerances.min_board_edge_clearance;
|
|
1969
1969
|
if (requiredClearance === void 0) return [];
|
|
1970
|
+
const allowedOffBoardComponentIds = new Set(
|
|
1971
|
+
circuitJson.filter(
|
|
1972
|
+
(element) => element.type === "pcb_component"
|
|
1973
|
+
).filter((component) => component.is_allowed_to_be_off_board).map((component) => toPcbComponentId(component.pcb_component_id))
|
|
1974
|
+
);
|
|
1970
1975
|
const copperElements = circuitJson.filter(
|
|
1971
1976
|
(element) => element.type === "pcb_via" || element.type === "pcb_smtpad" || element.type === "pcb_plated_hole" || element.type === "pcb_copper_pour"
|
|
1972
1977
|
);
|
|
@@ -1980,6 +1985,11 @@ function checkCopperToBoardEdgeClearance(circuitJson) {
|
|
|
1980
1985
|
);
|
|
1981
1986
|
const errors = [];
|
|
1982
1987
|
for (const element of copperElements) {
|
|
1988
|
+
if ((element.type === "pcb_smtpad" || element.type === "pcb_plated_hole") && element.pcb_component_id && allowedOffBoardComponentIds.has(
|
|
1989
|
+
toPcbComponentId(element.pcb_component_id)
|
|
1990
|
+
)) {
|
|
1991
|
+
continue;
|
|
1992
|
+
}
|
|
1983
1993
|
const geometry = getCopperGeometry(element, componentCcwRotationsById);
|
|
1984
1994
|
if (!geometry) continue;
|
|
1985
1995
|
const { isInside, clearance } = measureClearance(boardPolygon, geometry);
|
|
@@ -3605,6 +3615,7 @@ function checkViaPadClearance(circuitJson, {
|
|
|
3605
3615
|
|
|
3606
3616
|
// lib/check-vias-in-pads.ts
|
|
3607
3617
|
import { getPrimaryId as getPrimaryId7 } from "@tscircuit/circuit-json-util";
|
|
3618
|
+
import { getFullConnectivityMapFromCircuitJson as getFullConnectivityMapFromCircuitJson12 } from "circuit-json-to-connectivity-map";
|
|
3608
3619
|
function checkViasInPads(circuitJson) {
|
|
3609
3620
|
const board = getPcbBoard(circuitJson);
|
|
3610
3621
|
if (board && "is_via_in_pad_allowed" in board && board.is_via_in_pad_allowed === true) {
|
|
@@ -3615,6 +3626,7 @@ function checkViasInPads(circuitJson) {
|
|
|
3615
3626
|
);
|
|
3616
3627
|
const pads = getPads(circuitJson);
|
|
3617
3628
|
if (vias.length === 0 || pads.length === 0) return [];
|
|
3629
|
+
const connMap = getFullConnectivityMapFromCircuitJson12(circuitJson);
|
|
3618
3630
|
const padOrdinals = new Map(
|
|
3619
3631
|
pads.map((pad, index) => [getPrimaryId7(pad), index])
|
|
3620
3632
|
);
|
|
@@ -3625,18 +3637,14 @@ function checkViasInPads(circuitJson) {
|
|
|
3625
3637
|
});
|
|
3626
3638
|
const errors = [];
|
|
3627
3639
|
for (const via of vias) {
|
|
3628
|
-
const nearbyPads = padIndex.getObjectsInBounds(
|
|
3629
|
-
minX: via.x,
|
|
3630
|
-
minY: via.y,
|
|
3631
|
-
maxX: via.x,
|
|
3632
|
-
maxY: via.y
|
|
3633
|
-
});
|
|
3640
|
+
const nearbyPads = padIndex.getObjectsInBounds(getPadBounds(via));
|
|
3634
3641
|
for (const pad of nearbyPads) {
|
|
3642
|
+
const padId = getPrimaryId7(pad);
|
|
3635
3643
|
const viaLayers = getLayersOfPcbElement(via);
|
|
3636
3644
|
const padLayers = getLayersOfPcbElement(pad);
|
|
3637
3645
|
if (!viaLayers.some((layer) => padLayers.includes(layer))) continue;
|
|
3638
|
-
if (
|
|
3639
|
-
|
|
3646
|
+
if (connMap.areIdsConnected(via.pcb_via_id, padId)) continue;
|
|
3647
|
+
if (getPadToPadGap(via, pad) > 0) continue;
|
|
3640
3648
|
const padOrdinal = padOrdinals.get(padId) ?? 0;
|
|
3641
3649
|
const padName = getReadableNameForFootprintPad(
|
|
3642
3650
|
circuitJson,
|
|
@@ -3647,7 +3655,7 @@ function checkViasInPads(circuitJson) {
|
|
|
3647
3655
|
type: "pcb_placement_error",
|
|
3648
3656
|
pcb_placement_error_id: `via_in_pad_${via.pcb_via_id}_${padId}`,
|
|
3649
3657
|
error_type: "pcb_placement_error",
|
|
3650
|
-
message: `Via at (${via.x.toFixed(2)}mm, ${via.y.toFixed(2)}mm)
|
|
3658
|
+
message: `Via copper at (${via.x.toFixed(2)}mm, ${via.y.toFixed(2)}mm) overlaps ${padName}`,
|
|
3651
3659
|
subcircuit_id: via.subcircuit_id ?? pad.subcircuit_id
|
|
3652
3660
|
});
|
|
3653
3661
|
}
|