How do I add a variant to a core part?

“gorn” is an attribute added by Inkscape. It is not part of the svg specification, and gets ignored by (probably) everything exception Inkscape. There are other application specific attributes as well. There are tools around to remove those, but they can sometimes be more aggressive than wanted.

Not “everything” is imperial, and those units are being set in the svg (by Inkscape or other). In a generic svg, lots of times inches is not the correct choice. Even if “usually” it is correct for Fritzing.

I will remove gorn from all my SVGs then.
Thank you.

If the editor you are using supports regular expressions, then
' gorn="\d+(\.\d+)*"' will match all of them. a simple global replace with an empty string will clean all of them up at once.

If you are using inkscape for some of the editing, you can use File » Save As… » Optimized SVG to get access to a tool to do multiple cleanup steps while saving. I check as a base (across the various tabs)

  • Convert CSS attributes to XML attributes
  • Collapse Groups
  • Work around renderer bugs
  • Remove metadata
  • Format output with line-breaks and indentation
  • Strip the “xml:space” attribute from the root SVG element
  • Remove unused IDs
  • Preserve the following IDS: “breadboard,schematic,copper0,copper1,silkscreen”
  • Preserve IDs starting with: “connector”

You may want to adjust that based on your own patterns.

I use Inkscape and Notepad++ for editing SVGs. I tried searching for gorn="\d+(.\d+)*" in Notepad, but it didn’t find any of the gorns in the file.

My Inkscape (ver1.1) hasn’t got a Save As…Optimized SVG. I usually Save As… Plain SVG after editing.

that regex works for me in Visual Studio code. I used Notepad++ years ago. The regex appears valid according to this RegEx Cheat Sheet for notepad++. I will guess that either the quote characters are messing things up, or you need to switch to regex mode instead of simple search. I don’t remember how np++ does it.

I have Inkscape 1.1.2 (on Fedora linux). With that, when clicking “Save As…”, the file requester that comes up has a drop down at the bottom that can select file type options. Plain SVG and Optimized SVG are a couple of the entries in that list.

I believe gorn is actually a Fritzing attribute for something (I don’t know what though.) However Fritzing will add it back in when the svg is loaded so it can be safely removed from svgs.

Peter

@vanepp
I do not put gorn attributes in my manually created svg files. They do not exist in the created part files. I have not seen them in parts files exported from Fritzing, if the original part did not have them. I have only seen them added after saving from Inkscape, without using the “customized” filtering.

I was told that a long time ago by someone familiar with Fritzing. A quick search of the source indicates Fritzing is adding them under some circumstances and paying attention to them:

/cygdrive/d/repos/fritzing-app-cur
$ grep -R gorn .
./src/partseditor/pecommands.cpp: QString(" vid:%1 id:%2, terminalid:%3, oldgorn:%4, oldgornterminal:%5, newgorn:%6, newgornterminal:%7")
./src/partseditor/pemainwindow.cpp: bool hasGorn = element.hasAttribute(“gorn”);
./src/partseditor/pemainwindow.cpp: element.removeAttribute(“gorn”);
./src/partseditor/pemainwindow.cpp: DebugDialog::debug(QString(“remove gorn failure: %1 %2 %3 %4”).arg(errorStr).arg(errorLine).arg(errorColumn).arg(svg));
./src/partseditor/pemainwindow.cpp: TextUtils::gornTree(svgDocument);
./src/partseditor/pemainwindow.cpp: QString newGorn = pegi->element().attribute(“gorn”);
./src/partseditor/pemainwindow.cpp: QDomElement newGornElement = TextUtils::findElementWithAttribute(svgRoot, “gorn”, newGorn);
./src/partseditor/pemainwindow.cpp: QString oldGorn = oldGornElement.attribute(“gorn”);
./src/partseditor/pemainwindow.cpp: oldGornTerminal = element.attribute(“gorn”);
./src/partseditor/pemainwindow.cpp: if (newGornElement.attribute(“gorn”).compare(oldGornElement.attribute(“gorn”)) == 0) {
./src/partseditor/pemainwindow.cpp: QDomElement oldGornElement = TextUtils::findElementWithAttribute(svgRoot, “gorn”, oldGorn);
./src/partseditor/pemainwindow.cpp: oldGornTerminalElement = TextUtils::findElementWithAttribute(svgRoot, “gorn”, oldGornTerminal);
./src/partseditor/pemainwindow.cpp: QDomElement newGornElement = TextUtils::findElementWithAttribute(svgRoot, “gorn”, newGorn);
./src/partseditor/pemainwindow.cpp: newGornTerminalElement = TextUtils::findElementWithAttribute(svgRoot, “gorn”, newGornTerminal);
./src/partseditor/pemainwindow.cpp: if (element.attribute(“gorn”).compare(newGorn) == 0) {
./src/partseditor/pemainwindow.cpp: else if (element.attribute(“gorn”).compare(oldGorn) == 0) {
./src/partseditor/pemainwindow.cpp: if (terminalElement.attribute(“gorn”).isEmpty()) {
./src/partseditor/pemainwindow.cpp: QString gorn = svgConnectorElement.attribute(“gorn”);
./src/partseditor/pemainwindow.cpp: int ix = gorn.lastIndexOf(".");
./src/partseditor/pemainwindow.cpp: gorn.truncate(ix);

so I think they are a part of Fritzing.

Peter

My bet is that that code was modelled on a file created by Inkscape. That is also all in Parts Editor, which is not required to run Fritzing itself, and did not exist when Fritzing was created. It does not look like Fritzing itself ever references the attribute.

I’ve reworked the G6E relay files. The PCB and breadboard footprint are correct now. I’ve tried to standardise the svg files and get rid of all the "gorn"s too.

G6E-134P - Relay.fzpz (4.8 KB)

If this checks out OK, I’ll submit the part.

Looks fine to me!

Peter

I hope this topic is not too old to comment on. Fritzing is at version 1.0.2 when I’m writing this.

When I Export as SVG from the Parts Editor the SVG file has a Fritzing watermark added to it. In Inkscape I’m able to delete the Watermark so it isn’t there when I load the SVG back into Fritzing.

I’m wondering if you can just use the SVG file that Fritzing saves in the D:\Documents\Fritzing\parts\svg\user\pcb folder to edit and then load back in via the Parts Editor?

Probably. That should be a copy of the pcb svg.

Peter