Package: inventree-wireviz-plugin
inventree-wirevizTheinventree-wirevizplugin provides direct integration forwireviz, a text-based wiring harness specification tool.FunctionalityThe plugin provides a number of key functions:Harness Diagram GenerationThis plugin provides server-side generation of a wiring harness diagram from a.wirevizfile. Uploading a simpleharness fileresults in the generation of a wiring diagram:NoteRefer to thewireviz syntax guidefor a full description of the file format.The generated harness diagram is available as a.svgfile.BOM ExtractionBill of Materials (BOM) information can be extracted directly from the harness description file, allowing for a harness assembly to be fully qualified from the template file.Report GenerationThe generated.svgcan be used in report templates, for example as a reference diagram in a Build Order ReportInstallationInstallation RequirementsYou must havegraphvizinstalled, and accessible by the InvenTree server.e.g.apt-get install graphvizIf installing in a container environment (e.g. Docker), the dockerfile will need to be extended to install thegraphvizbinariesPlugin InstallationThe plugin is availablevia PIP. Follow theInvenTree plugin installation guideto install the plugin on your systemConfigurationOnce the plugin is installed, it needs to be enabled before it is available for use. Again, refer to the InvenTree docs for instructions on how to enable the plugin. After the plugin is enabled, the following configuration options are available:SettingDescriptionWireviz Upload PathDirectory where wireviztemplatefiles can be uploaded, and referenced by wireviz. This is anadvancedoption. Refer to the wireviz docs for more information on templates.Delete Old FilesRemove old harness diagram files when a new.wirevizfile is uploadedExtract BOM DataExtract BOM data from harness file and generate new BOM entriesClear BOM DataRemove existing BOM entries first, before creating new onesAdd Part ImageWhere available, embed part images in the generated harness diagramAdditionally, you must ensure that theEnable event integrationsetting is enabled in thePlugin Settingsview:OperationUploading Wireviz FileTo generate a wiring harness diagram for a specific Part, upload a (valid) wireviz yaml file. The file *musthave the.wirevizextension to be recognized by the plugin.When the file is uploaded to the server, the plugin is notified and begins the process of generating the harness diagram. If successful, a.svgfile is attached to the part instance:Harness Diagram PanelWhen a Part has a valid harness diagram (i.e. generated without any critical errors), theHarness Diagrampanel will be available for that part. This panel displays the diagram image, and a simple Bill of Materials (as defined in the uploaded.wirevizfile):NoteYou may need to reload the page before this panel is visibleWarningAny warnings or errors which were raised during the process will be displayed hereBOM ExtractionIf enabled, the plugin will attempt to generate a linked Bill of Materials based on the data provided in the file. Part linking is performed based on thepn(part number) attribute in the wireviz BOM.For each line item in the uploaded BOM, the plugin attempts to match thepnfield to an existing part in the InvenTree database. If a matching part is not found, this is marked with a warning in the simplified BOM table in theharness diagram panel.ReportsThe generated diagram can be used in certain reports (such as the Build Order Report). If a wiring harness diagram is available for a Part, it is included in the report context as a variable namedwireviz_svg_file.NoteThe provided variable refers to thefilenameof the.svgimage - not the file itself.
Use the{% encode_svg_image %}template tag to render the image file.A very simple example is shown below:{% extends "report/inventree_build_order_base.html" %}

{% load report %}

{% block style %}
{{ block.super }}

.harness {
    border: 1px solid #AAA; 
    width: 100%;
    display: inline-block;
}

{% endblock %}

{% block page_content %}

{{ block.super }}

{% if wireviz_svg_file %}<h4>Harness Drawing</h4><imgclass='harness'src='{% encode_svg_image wireviz_svg_file %}'>{% endif %}

{% endblock page_content %}The resulting report is rendered as below:Wireviz DocumentationDocumentation on the capabilities of wireviz itself:https://github.com/formatc1702/WireViz/blob/master/docs/README.mdhttps://github.com/formatc1702/WireViz/blob/master/docs/syntax.md