Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export const insertNetLabelsForPortsMissingTrace = ({
}) => {
const { db } = group.root!

// Track which nets already have a label placed to avoid duplicates
// When multiple ports share the same net (e.g., C1.pin1 and C2.pin1 both connected to GND),
// we only want to place one label, not one per port
const netsWithLabels = new Set<string>()

// Create net labels for ports connected only to a net (no trace connected)
for (const schOrSrcPortId of Array.from(
allSourceAndSchematicPortIdsInScope,
Expand All @@ -38,6 +43,10 @@ export const insertNetLabelsForPortsMissingTrace = ({
continue
}

// Check if this net already has a label placed
const netId = sourceNet.source_net_id || sourceNet.name || key
if (netsWithLabels.has(netId)) continue

// Avoid duplicate labels at this port anchor position
// Use a larger tolerance to account for placement discrepancy between
// different net label algorithms (solver vs port-based placement)
Expand Down Expand Up @@ -73,5 +82,8 @@ export const insertNetLabelsForPortsMissingTrace = ({
? { source_net_id: sourceNet.source_net_id }
: {}),
})

// Mark this net as having a label placed
netsWithLabels.add(netId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export function insertNetLabelsForTracesExcludedFromRouting(args: {
} = args
const { db } = group.root!

// Track which nets already have a label placed to avoid duplicates
// When multiple traces share the same net, we only want to place one label
const netsWithLabels = new Set<string>()

for (const trace of displayLabelTraces as any[]) {
const label = trace._parsedProps?.schDisplayLabel
if (!label) continue
Expand All @@ -36,6 +40,9 @@ export function insertNetLabelsForTracesExcludedFromRouting(args: {
text: label,
})

// Check if this net already has a label placed
if (netsWithLabels.has(label)) continue

// // Deduplicate: if a label with the same text is already at this anchor position, skip
const alreadyExists = db.schematic_net_label.list().some((nl) => {
const ap = nl.anchor_position
Expand All @@ -57,6 +64,9 @@ export function insertNetLabelsForTracesExcludedFromRouting(args: {
? { source_trace_id: trace.source_trace_id }
: {}),
})

// Mark this net as having a label placed
netsWithLabels.add(label)
}
} catch {}
}
Expand Down