| 9774 | win.show(); |
| 9775 | win.focus(); |
| 9776 | } |
| 9777 | dialog.showMessageBox(win && !win.isDestroyed() ? win : undefined, { |
| 9778 | type: 'error', |
| 9779 | title: errorMessage, |
| 9780 | message: errorDetail, |
| 9781 | detail: error.stack ? `Technical details: ${error.stack.substring(0, 200)}...` : '' |
| 9782 | }); |
| 9783 | } |
| 9784 | } |
| 9785 | }); |
| 9786 | } |
| 9787 | |
| 9788 | // Check if any selected files are 3MF files |
| 9789 | const has3MFFiles = filePaths.some(fp => { |
| 9790 | const ext = path.extname(fp).toLowerCase(); |
| 9791 | // Handle zip entries - check the entry path extension |
| 9792 | if (fp.includes('::')) { |
| 9793 | const entryPath = fp.split('::')[1]; |
| 9794 | return path.extname(entryPath).toLowerCase() === '.3mf'; |
| 9795 | } |
| 9796 | return ext === '.3mf'; |
| 9797 | }); |
| 9798 | |
| 9799 | // Add "Pull Metadata" option for 3MF files |
| 9800 | if (has3MFFiles) { |
| 9801 | menuItems.push({ |
| 9802 | label: 'Pull Metadata', |
| 9803 | click: async () => { |
| 9804 | try { |
| 9805 | // Filter to only 3MF files |
| 9806 | const threeMFFiles = filePaths.filter(fp => { |
| 9807 | const ext = path.extname(fp).toLowerCase(); |
| 9808 | if (fp.includes('::')) { |
| 9809 | const entryPath = fp.split('::')[1]; |
| 9810 | return path.extname(entryPath).toLowerCase() === '.3mf'; |
| 9811 | } |
| 9812 | return ext === '.3mf'; |
| 9813 | }); |
| 9814 | |
| 9815 | if (threeMFFiles.length === 0) { |
| 9816 | return; |
| 9817 | } |
| 9818 | |
| 9819 | // Check existing models to see if any have data that will be overwritten |
| 9820 | const modelsWithData = []; |
| 9821 | for (const filePath of threeMFFiles) { |
| 9822 | const model = getModelByFilePath(filePath, { includeThumbnail: true }); |
| 9823 | if (model) { |
| 9824 | const hasData = (model.designer && model.designer.trim()) || |
| 9825 | (model.parentModel && model.parentModel.trim()) || |
| 9826 | (model.notes && model.notes.trim()) || |
| 9827 | (model.license && model.license.trim()); |
| 9828 | if (hasData) { |
| 9829 | modelsWithData.push({ |
| 9830 | filePath, |
| 9831 | fileName: model.fileName || path.basename(filePath), |
| 9832 | designer: model.designer, |
| 9833 | parentModel: model.parentModel, |