Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

generate_svg does nothing #29

Description

@maxschommer

After following the instructions here, and running the following code from the root directory of pcbdl:

import pcbdl as dl

vcc, gnd = dl.Net("vcc"), dl.Net("gnd")
vin = dl.Net("vin")
base = dl.Net("base")

base << dl.C("1000u", to=vin)
base << (
    dl.R("1k", to=vcc),
    dl.R("1k", to=gnd),
)

class Transistor(dl.Part):
    REFDES_PREFIX = "Q"
    PINS = ["B", "C", "E"]

q = Transistor()

q.E << (
    dl.R("100", to=gnd),
    dl.C("100u", to=gnd),
)

q.C << (
    dl.C("100u", to=dl.Net("vout")),
    dl.R("100", "Rc", to=vcc),
)

dl.global_context.autoname()


dl.generate_svg('class_svg'):

Nothing happens. After investigating the generate_svg function, it appears that the function doesn't do anything since it is a generator with a try/except block which yields svg_contents if they exist. However, SVGPage.PageEmpty exception is always raised by n.generate(). After investigating further, it seems that the page is always empty because for some reason in add_parts(), self.should_draw_pin(pin) always returns None or False. I'm guessing that the None return behavior is from returning an empty regex match, but it seems that the return type should be uniform. After setting should_draw_pin to the following:

def should_draw_pin(self, pin):
    return True

then the following produces an SVG:

svg_arr = []
for svg in dl.generate_svg('class_svg'):
    svg_arr.append(svg)

However, it doesn't write the SVG file as documented, and instead seems to produce the raw SVG data.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions