electronics made easy
This is the old fritzing discussion forum. Search it for valuable information from 2009 to 2015.
I'm working on a custom part with four terminals. I edited the part to move the connectors to the right place in the breadboard view (which is a custom .svg designed in Inkscape). I save the part, but it moves the connectors to somewhere else in the image (off to the side of the image). I tried deleting all the connectors and creating them from scratch, no dice.
I read a few threads with similar sounding problems but I couldn't figure out the final outcome -- seems like some people tried editing the XML files. Is there a guide to how the XML files work, specifically how the connectors are specified and how they correspond to the .svg image files?
Specifically: do the .svg files need to contain special elements that correspond to connectors, or can the connector rectangles be placed in arbitrary positions?
Well, I hope you're not mad at us.
The part format is described here, though the document is somewhat out of date. The basic idea is that there is a list of connectors in the metadata file (.fzp) and each connector is given an 'svgId'. Then in each view's svg file, a graphical element (circle, rect, etc) is given an 'id' attribute that matches the 'svgId' in the fzp file. These IDs usually have the form 'connectorNpin' or 'connectorNpad' where N ranges from zero to the number of connectors on the part (minus 1). You can see plenty of examples if you go into the Fritzing parts folder and open up a part, like a capacitor, from parts/core (fzp) and parts/svg/breadboard/core (svg).
But in answer to your question, as long as the IDs match between metadata and svg--for each connector--everything should be hunky dory. Connector rectangles (or whatever the shape is in the svg file) can be placed in arbitrary positions.
But notice I said "for each connector". One common problem is when the svg has two elements with the same ID; another common problem is when an svgId is specified in the metadata file, and there is no corresponding element with that id in the svg file.
The parts editor will try to match connector ids in the svg files it loads with svgIds in the metadata file, but I have noticed that any number of activities can confuse it, including editing (then saving) an svg multiple times in Inkscape (because Inkscape often modifies element IDs). It is also the case that the parts editor is barely keeping up with all the changes lately, so there could be bugs there as well.
If you're still stuck, then email the files to info .at. fritzing .dot. org and we'll take a look. From Fritzing, elect your custom part and choose Export from the Part menu, and send us the resulting .fzpz file. It also can help if you include the individual svg files you're working on.
Great, that should be enough to go on for a bit. I'll write back when I get something working or stuck again.
PS - Overall, I'm very impressed w/ Fritzing, for an open, free, alpha, it's pretty awesome.
Ok, I see what happened.
To make the schematic for my custom part, I hacked the svg together from existing svgs from other parts. Turns out those files already had rectangles named connectorN and connectorNterminal. So fritzing was confused when they didn't correspond to anything in my breadboard svg.
Ok, progress -- when I deleted all the connector rectangles from my schematic and started fresh, it almost worked -- except I bumped into the "all connectors are shifted horizontally by an offset" problem. I saw this in another thread, I'll hunt it down. Maybe a problem with the way I exported the svg from Inkscape?
Could be several possibilities for the shift. Well-formed Fritzing svgs have three attributes in the <svg> element (the top level element in the svg file): 'width', 'height', and 'viewBox'. Width and height are actual real-world measures, typically with units such as inches or cm. Sometimes you will see no units, or 'px' units. For most of the svg world (including Inkscape) this means a unit of 1/90th inch.
The viewBox should always be of the form '0 0 x y' and is related to the width and height proportionally, and the rest of the svg file's coordinates should be expressed in values that range from 0 to x (or 0 to y). For example, you might have a part with width='2in' height='1in' viewBox='0 0 2000 1000'. Meaning that all the other coordinates in the file can be intpreted as having units of 1/1000 inch.
This is a long way of saying that if you cobbled your svg from multiple places, it may be that there are different units being tossed around. Or it may be that things are shifted from the 0,0 position of the viewbox.
Another thing to look for, especially from Inkscape, is that a lot of transforms get thrown around. So something could just be shifted unexpectedly by a transform. Fritzing has gotten better about these, but it still chokes occasionally, particularly when something gets scaled. Another bug I see occasionally is if you have a transform element outside a view indicator. This is a little hard to explain. You might have
<g id='copper0' >
in which case Fritzing might miss the outer transform.