Closed qu1ck closed 5 years ago
May use as hyperlink in a existent column at generated iBOM.
@qu1ck Would you consider adding the "Datasheet" field in the list of fields since the format update in KiCad V6 doesn't differentiate it from other properties?
(property "Value" "CAP-000008-00" (id 1) (at 0 -15.24 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Footprint" "Capacitors:C0402" (id 2) (at 0 -22.86 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "http://xyz.com/" (id 3) (at 0 -13.97 0)
(effects (font (size 1.27 1.27)) hide)
)
It is stored similarly to other properties in the schematic but ibom doesn't read schematic file. It reads either netlist or pcb file. Datasheet field is not exported to the pcb so you have to generate netlist file if you want to use datasheet field.
@qu1ck Yes it does work exporting the netlist. Follow-up question: can certain field be treated as hyperlink inside the HTML table?
In summary I would like this:
To become:
I could do a simple regex on the HTML, but I wonder if this feature is built-in somewhere?
Actually never mind on the Regex... I didn't realize the data was compressed.
You can do any kind of postprocessing you want using customization.
Thanks, I'll take a look!
Alright figured it out, even with my poor JS skills :sweat_smile:
For anyone looking to add datasheet links to the BOM table, using KiCad V6:
user.js
file inside folder "web/user-file-examples" to the "web" folder, along with other *.js
files
function urlify(text) {
var urlRegex = /(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))/g;
return text.replace(urlRegex, function(url) {
return '<a href="' + url + '" target="_blank">' + url + '</a>';
})
}
function urlify_bomtable() { var table = document.getElementById("bomtable");
for (var i = 0; i < table.rows.length; i++) {
table.rows[i].innerHTML = urlify(table.rows[i].innerHTML)
}
}
EventHandler.registerCallback(IBOM_EVENT_TYPES.BOM_BODY_CHANGE_EVENT, urlify_bomtable);
6. Go back to KiCad layout, open InteractiveHTMLBOM plugin, select "Fields" tab, click "Show" checkmark next to `Datasheet` field (`Datasheet` field should be present in the list, else you've missed step 1).
7. Click "Generate BOM"
8. Enjoy hyperlinks!
@qu1ck Would you mind adding a link to this comment to this section of the doc, if you find it useful?https://github.com/openscopeproject/InteractiveHtmlBom/wiki/Customization#examples
Your code will work only once when page is loaded. Any time bom table is changed (with filtering or display mode or checkbox change) your links will disappear because the table is regenerated.
You should add a listener to BOM_BODY_CHANGE_EVENT, see user.js example.
Thanks, I have updated my code snapshot above to make it a callback instead :+1:
Added to wiki.
For anyone looking to add datasheet links to the BOM table, using KiCad V6:
How do I get this working with easyeda? also more than data sheet i want to create clickable url for references or values which takes to that specific product buy link.? any work around or suggestions?
Urls are detected automatically now since 39fc0c466cf1bd98464efae56c9713aaddbeb5a3 as long as it's the only thing in your field.
But extra fields are not supported in easyeda. I see that they now added support to put custom fields in each component but there is no convenient way to bulk edit all components because BOM table doesn't show custom fields.
If anyone wants to add support to parse custom fields in easyeda parser I'll review it but I don't have time to add it right now.
If anyone wants to add support to parse custom fields in easyeda parser I'll review it but I don't have time to add it right now.
thanks alot. please update me when you get it working.
I filed #348 to keep track of it.
Datasheet field is a built in and needs special handling because it's stored differently.