Closed akshaybabloo closed 1 year ago
hey @akshaybabloo thank you for the suggestion! Do you have an example of what you mean?
@alixander Certainly. Consider the following example of a circuit diagram (made with Autodesk Fusion 365):
Is shows that a 9v battery connected to a resistor to step down the voltage to light up the LED
The only difference between
US
andNON-US
is how the resistor is denoted.
I tried to do this via D2, and this is what I got:
direction: right
classes: {
resistor: {
shape: rectangle
height: 10
}
}
9v -> 350k -> led -> 9v
350k.class: resistor
I think for this we would need the following:
Digital icons can be added later once you have a proof of concept
direction: right
classes: {
resistor: {
shape: image
height: 30
width: 60
icon: https://b2523400.smushcdn.com/2523400/wp-content/uploads/2020/11/image19.png?lossy=1&strip=1&webp=1
}
}
US: {
style: {
fill: transparent
stroke-dash: 2
}
9v -> 350k -> led -> 9v
350k.class: resistor
}
it's pretty close. this type of diagram cannot be done in elk or dagre btw, because they only do hierarchical diagrams.
i think implementing ports is all that's needed: https://github.com/terrastruct/d2/issues/628
@akshaybabloo are there any comparable tools that you can create circuit diagrams with text?
Not that I know of @alixander
Also, the ends are not really connected to the resistor there, it's just hovering. It would be nice to have some internal icons that can do that.
just need ports (can then specify to only route through the left and right sides of the icon)
Tools to create schematics, off the top of my head:
can you generate with text in any of these? @BarryNolte
I think what you want is a 'net list'. https://en.wikipedia.org/wiki/Netlist. They all probably produce a net list; some might read them. I don't think it's a super well-defined standard, otherwise there wouldn't be a lot of discussion on converting files from one EDA package to another, which is the evergreen topic on electronics message boards.
Most of them use a combination of XML and binary
sorry i meant are any of these tools text-to-circuit-diagram. not whether they can export to text.
could be a good opportunity to expand d2 with no much more extra work if a comparable solution doesn't exist yet and there's demand for it
I think there are some netlist -> html/svg projects around.
oh interesting, yeah: https://github.com/nturley/netlistsvg#examples
looks like they use ELK too.
Yup, just found that one too.
Verilog
For scripted schematic image generation, there's this library: https://github.com/cdelker/schemdraw
that one seems quite good. i'm going to close this then as not something D2 should focus on.
It will be good to have a way to create circuit diagrams using D2.