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
15 changes: 4 additions & 11 deletions lib/components/primitive-components/Via.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { createNetsFromProps } from "lib/utils/components/createNetsFromProps"
import { getViaSpanLayers } from "lib/utils/getViaSpanLayers"
import { getViaDiameterDefaultsWithOverrides } from "lib/utils/pcbStyle/getViaDiameterDefaults"
import { getViaTenting } from "lib/utils/getViaTenting"
import { z } from "zod"
import { PrimitiveComponent } from "../base-components/PrimitiveComponent"
import { Net } from "./Net"
import { Port } from "./Port"
Expand All @@ -19,12 +18,6 @@ export class Via extends PrimitiveComponent<typeof viaProps> {
source_trace_id: string | null = null
subcircuit_connectivity_map_key: string | null = null

constructor(props: z.input<typeof viaProps>) {
super(props)
const layers = this._getLayers()
;(this._parsedProps as any).layers = layers
this.initPorts()
}
get config() {
return {
componentName: "Via",
Expand Down Expand Up @@ -86,16 +79,16 @@ export class Via extends PrimitiveComponent<typeof viaProps> {
}
_getLayers(): LayerRef[] {
const { fromLayer = "top", toLayer = "bottom" } = this._parsedProps
// Before the via is attached to the tree (constructor/port init) the board
// layer count is unknown — fall back to 2, which yields [fromLayer, toLayer].
// Unattached layer queries do not yet know the board's layer count.
const layerCount = this.parent
? this.getSubcircuit()._getSubcircuitLayerCount()
: 2
return getViaSpanLayers({ fromLayer, toLayer, layerCount })
}

initPorts() {
const layers = (this._parsedProps as any).layers as LayerRef[]
doInitialInitializePortsFromChildren(): void {
const layers = this._getLayers()
;(this._parsedProps as any).layers = layers
for (const layer of layers) {
const port = new Port({ name: layer, layer })
port.registerMatch(this)
Expand Down
Loading
Loading