-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve output of diagram + BOM as technical drawing #74
Conversation
7534300
to
0cef5e3
Compare
Hi @formatc1702 I just found your project, and I really like what you have done here! Is there any progress on this particular branch, with particular regard to adding document metadata and title block information? This addition, and also PDF output, would make this tool extremely useful to me (and many others, I'm sure) in a professional setting.
I'd love to help out if I can. I see a lot of value in this project :) |
About the YAML metadata input, see also PR #214, where I've added a few basic metadata attributes based on #158 (comment) and other comments about the same issue. |
Nice, I'd like to also see features like:
|
Thanks!
I plan on resuming work on this branch soon, should not be a big deal. I will then welcome subsequent PRs for, among other things:
No, this is an area where I am very open to input. As mentioned above, I will split PDF generation as a separate issue/PR. |
- `simple.html` is similar to the previous built-in HTML output - `din-6771.html` is a technical drawing with title block and BOM
342ed12
to
b6761a9
Compare
Test files: Modified `demo01.yml`metadata:
title: WireViz Demo 01
pn: 123-456-789
authors:
Created:
name: D. Rojas
date: 2020-05-20
Approved:
name: D. Rojas
date: 2020-05-20
template:
name: din-6771
sheetsize: A4
connectors:
X1:
type: D-Sub
subtype: female
pinlabels: [DCD, RX, TX, DTR, GND, DSR, RTS, CTS, RI]
X2:
type: Molex KK 254
subtype: female
pinlabels: [GND, RX, TX]
cables:
W1:
gauge: 0.25 mm2
length: 0.2
color_code: DIN
wirecount: 3
shield: true
connections:
-
- X1: [5,2,3]
- W1: [1,2,3]
- X2: [1,3,2]
-
- X1: 5
- W1: s
Modified `demo02.yml`metadata:
title: WireViz Demo 02
pn: 123-456-789
authors:
Created:
name: D. Rojas
date: 2020-05-20
Approved:
name: D. Rojas
date: 2020-05-20
revisions:
01:
changelog: Add ferrules
name: D. Rojas
date: 2020-06-14
02:
changelog: Add ferrules
name: D. Rojas
date: 2020-06-14
template:
name: din-6771
sheetsize: A3
templates: # defining templates to be used later on
- &molex_f
type: Molex KK 254
subtype: female
- &con_i2c
pinlabels: [GND, +5V, SCL, SDA]
- &wire_i2c
category: bundle
gauge: 0.14 mm2
colors: [BK, RD, YE, GN]
connectors:
X1:
<<: *molex_f # copying items from the template
pinlabels: [GND, +5V, SCL, SDA, MISO, MOSI, SCK, N/C]
X2:
<<: *molex_f
<<: *con_i2c # it is possible to copy from more than one template
X3:
<<: *molex_f
<<: *con_i2c
X4:
<<: *molex_f
pinlabels: [GND, +12V, MISO, MOSI, SCK]
ferrule_crimp:
style: simple
autogenerate: true
type: Crimp ferrule
subtype: 0.25 mm²
color: YE
cables:
W1:
<<: *wire_i2c
length: 0.2
show_equiv: true
W2:
<<: *wire_i2c
length: 0.4
show_equiv: true
W3:
category: bundle
gauge: 0.14 mm2
length: 0.3
colors: [BK, BU, OG, VT]
show_equiv: true
W4:
gauge: 0.25 mm2
length: 0.3
colors: [BK, RD]
show_equiv: true
connections:
-
- X1: [1-4]
- W1: [1-4]
- X2: [1-4]
-
- X1: [1-4]
- W2: [1-4]
- X3: [1-4]
-
- X1: [1,5-7]
- W3: [1-4]
- X4: [1,3-5]
-
- ferrule_crimp
- W4: [1,2]
- X4: [1,2]
I want to keep the actual demo files unchanged for simplicity. |
elif isinstance(value, Dict): # useful for authors, revisions | ||
for index, (category, entry) in enumerate(value.items()): | ||
if isinstance(entry, Dict): | ||
html = html.replace(f'<!-- %{item}_{index+1}% -->', str(category)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using {index+1}
instead of {category}
here to be able to use more generic labels in the HTML template.
This way, for example, <!-- %revisions_1_changelog% -->
and <!-- %authors_1_name% -->
are always replaced correctly, no matter if the user tracks revisions using numbers, letters (A, B, C, ...) or other, or if they use a different authorsship scheme instead of the Created
and Approved
that I have used in my examples.
ab32e8b
to
6f56fcd
Compare
@formatc1702 If it were me, I'd use an html template engine (Jinja2 comes to mind) instead of writing your own here. It allows a lot of nice features and gives the template creator a bunch of tools.
I would be curious if you have any issues with this approach, it does require yet another module to be included of course, which would by my only issue. Thanks for the great tool BTW, I'm using this at work now, and it's awesome. I just don't like my workflow step of importing the PNG into another tool for the title block for obvious reasons. Edit: Here's an example of one of my other tools using Jinja to create a PDF using PDFKit, a wrapper for wkhtmltopdf: template_loader = jinja2.FileSystemLoader([path.join(path.dirname(__file__), 'templates')])
template_env = jinja2.Environment(loader=template_loader)
template_file = "moduleQATemplate.j2"
template = template_env.get_template(template_file)
output_text = template.render(
serialnum=serial,
dt=testdate,
bankV=bankV,
bank_OCV=bank_OCV,
bank_ESR=bank_ESR,
module_ESR=round(module_ESR, 3),
loaded_deltav=loaded_deltav,
testername=self.inputs.get('testername'),
moduleV=module_OCV,
esrloadcurrent=self.esrloadcurrent,
temps=start_temps,
passfail=self.passing,
notes=notes,
logo=logoimage,
images=images,
testlog=self.testlog
)
if path.isdir("N:\\"):
pdf_path = path.join("N:\\", "Battery","Test","ModuleReports",f"Module_{serial}_{testdatesafe}.pdf")
else:
pdf_path = path.join(environ["HOMEPATH"], "Desktop", F"Module_{serial}_{testdatesafe}.pdf")
options = {
'page-size': 'Letter',
'margin-top': '0.35in',
'margin-right': '0.75in',
'margin-bottom': '0.75in',
'margin-left': '0.75in',
'encoding': "UTF-8",
'no-outline': None,
'enable-local-file-access': None,
'quiet': False
}
self.logHeader(f"Writing report to: {pdf_path}")
config = pdfkit.configuration(wkhtmltopdf="C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe")
pdfkit.from_string(output_text, pdf_path, options=options, configuration=config) |
The latest development of such a feature is moved to PR #239, and this PR is closed. I therefore suggest you rather make your comments to that new PR. I like your idea, and I hope the author considers it. |
Closes #32.