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
3 changes: 2 additions & 1 deletion lib/svg-serialization/serialize-altium-sheet-to-svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ function renderSchematicRecord(
) {
if (record.getBoolean("ISHIDDEN") && !options.showHidden) return undefined
if (options.showText === false) return undefined
const location = getSchematicLocation(record)
const location = getSchematicLocationIfPresent(record)
if (!location) return undefined
const x = viewport.toX(location.x)
const y = viewport.toY(location.y)
const sourceText =
Expand Down
17 changes: 0 additions & 17 deletions tests/svg/__snapshots__/sample-schematic-sheet.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions tests/svg/__snapshots__/schematic-locationless-text.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions tests/svg/schematic-locationless-text.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect, test } from "bun:test"
import { parseAltiumSchDoc, serializeAltiumSheetToSvg } from "../../lib"

test("does not render locationless simulation-model parameters", async () => {
const document = parseAltiumSchDoc(
[
"|HEADER=Protel for Windows - Schematic Capture Ascii File Version 5.0",
"|RECORD=31|FONTIDCOUNT=1|SIZE1=10|FONTNAME1=Arial|CUSTOMX=240|CUSTOMY=160",
"|RECORD=1|CURRENTPARTID=1|LOCATION.X=120|LOCATION.Y=80",
"|RECORD=44|OWNERINDEX=1|OWNERPARTID=-1",
"|RECORD=45|OWNERINDEX=2|OWNERPARTID=-1",
"|RECORD=48|OWNERINDEX=3|OWNERPARTID=-1",
'|RECORD=41|OWNERINDEX=4|INDEXINSHEET=-1|OWNERPARTID=-1|FONTID=1|TEXT=@DESIGNATOR %1 %2 @VALUE ?"INITIAL VOLTAGE"|NAME=Netlist',
"|RECORD=25|LOCATION.X=120|LOCATION.Y=80|FONTID=1|TEXT=Visible annotation",
].join("\n"),
)
const svg = serializeAltiumSheetToSvg(document)

expect(svg).toContain("Visible annotation")
expect(svg).not.toContain("INITIAL VOLTAGE")
await expect(svg).toMatchSvgSnapshot(import.meta.path)
})
Loading