Pneumatic Circuit to Parts List Generator

Use this tool to generate a comprehensive parts list from your pneumatic circuit diagram. Manually enter each component, its quantity, and a brief description. The tool will then compile a summarized list.

Please ensure all components have a selected type and a valid positive quantity.

'; downloadPdfButton.style.display = 'none'; return; } const sortedCompiledParts = Array.from(compiledParts.values()).sort((a, b) => { // Sort by type, then by description if (a.type < b.type) return -1; if (a.type > b.type) return 1; if (a.description < b.description) return -1; if (a.description > b.description) return 1; return 0; }); let partsListTableHtml = ` `; sortedCompiledParts.forEach(part => { partsListTableHtml += ` `; }); partsListTableHtml += `
Component Type Description Total Quantity
${part.type} ${part.description || 'N/A'} ${part.count}
`; // Display results resultArea.style.display = 'block'; resultArea.innerHTML = `

Generated Parts List:

${partsListTableHtml} `; downloadPdfButton.style.display = 'block'; // Show PDF button // Store compiled and raw data for PDF generation resultArea.dataset.compiledParts = JSON.stringify(sortedCompiledParts); resultArea.dataset.rawComponentData = JSON.stringify(rawComponentData); } /** * Clears all component inputs, results, and hides the PDF button. */ function clearAll() { const componentInputSection = document.getElementById('componentInputSection'); if (componentInputSection) { componentInputSection.innerHTML = ''; // Remove all component rows } addComponentRow(); // Add back one empty row for usability clearResultArea(); } /** * Helper function to clear and hide the result area. */ function clearResultArea() { const resultArea = document.getElementById('resultArea'); const downloadPdfButton = document.getElementById('downloadPdfButton'); if (resultArea) { resultArea.style.display = 'none'; resultArea.innerHTML = ''; // Clear stored data for PDF delete resultArea.dataset.compiledParts; delete resultArea.dataset.rawComponentData; } if (downloadPdfButton) { downloadPdfButton.style.display = 'none'; } } /** * Generates a PDF report of the compiled parts list. */ function generatePdf() { // Check if jsPDF library is loaded if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') { console.error('jsPDF library not loaded. Cannot generate PDF.'); const resultArea = document.getElementById('resultArea'); if (resultArea) { resultArea.innerHTML = '

PDF generation failed. Library not loaded.

'; } return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); const resultArea = document.getElementById('resultArea'); // Retrieve stored data for PDF const compiledParts = JSON.parse(resultArea.dataset.compiledParts || '[]'); const rawComponentData = JSON.parse(resultArea.dataset.rawComponentData || '[]'); const generationDate = new Date().toLocaleString(); let yOffset = 20; // Title doc.setFontSize(24); doc.setTextColor(44, 62, 80); doc.text("Pneumatic Circuit Parts List Report", 105, yOffset, { align: 'center' }); yOffset += 20; // Summary of Parts List doc.setFontSize(16); doc.setTextColor(46, 204, 113); /* Green */ doc.text("Compiled Parts List:", 20, yOffset); yOffset += 10; const compiledTableHeaders = ["Component Type", "Description", "Total Quantity"]; const compiledTableRows = compiledParts.map(part => [ part.type, part.description || 'N/A', part.count ]); // Add compiled parts table doc.autoTable({ startY: yOffset, head: [compiledTableHeaders], body: compiledTableRows, theme: 'grid', styles: { fontSize: 10, cellPadding: 2, fillColor: [255, 255, 255] }, headStyles: { fillColor: [209, 236, 241], textColor: [12, 84, 96], fontStyle: 'bold' }, alternateRowStyles: { fillColor: [242, 242, 242] }, margin: { left: 20, right: 20 }, didDrawPage: function(data) { // Footer for each page doc.setFontSize(9); doc.setTextColor(150, 150, 150); doc.text(`Report Generated: ${generationDate}`, 20, doc.internal.pageSize.height - 15); doc.text("Pneumatic Parts List Tool", doc.internal.pageSize.width - 20, doc.internal.pageSize.height - 15, { align: 'right' }); } }); yOffset = doc.autoTable.previous.finalY + 20; // Update yOffset after the table // Raw Component Data (as entered) doc.setFontSize(14); doc.setTextColor(51, 51, 51); doc.text("Raw Component Data (as entered):", 20, yOffset); yOffset += 10; const rawTableHeaders = ["Component Type", "Quantity", "Description"]; const rawTableRows = rawComponentData.map(data => [ data.type, data.quantity, data.description || 'N/A' ]); doc.autoTable({ startY: yOffset, head: [rawTableHeaders], body: rawTableRows, theme: 'grid', styles: { fontSize: 10, cellPadding: 2, fillColor: [255, 255, 255] }, headStyles: { fillColor: [209, 236, 241], textColor: [12, 84, 96], fontStyle: 'bold' }, alternateRowStyles: { fillColor: [242, 242, 242] }, margin: { left: 20, right: 20 }, didDrawPage: function(data) { // Footer for each page doc.setFontSize(9); doc.setTextColor(150, 150, 150); doc.text(`Report Generated: ${generationDate}`, 20, doc.internal.pageSize.height - 15); doc.text("Pneumatic Parts List Tool", doc.internal.pageSize.width - 20, doc.internal.pageSize.height - 15, { align: 'right' }); } }); doc.save("Pneumatic_Parts_List_Report.pdf"); }
Scroll to Top