From 3593be43b5bd52f93f5bfadccf9a97dec0fc7932 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Fri, 20 Mar 2026 12:37:59 -0400 Subject: [PATCH] normalize dxf import dialog --- src/kiri/app/platform.js | 68 +++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/src/kiri/app/platform.js b/src/kiri/app/platform.js index 2ef9ee30..1860a932 100644 --- a/src/kiri/app/platform.js +++ b/src/kiri/app/platform.js @@ -1146,28 +1146,52 @@ function loadSVGDialog(doit) { * @private */ function loadDXFDialog(doit) { - const opt = {pre: [ - "
", - "

Import DXF

", - "

", - " Extrude a 3D model from a 2D DXF.", - " Supports POLYLINE, LWPOLYLINE, LINE, CIRCLE, ARC, and SPLINE entities.", - "

", - "
", - " ", - " ", - " ", - " ", - "
z height in mm
arc segment size in mm
minimum arc segments
nest shapes
", - "
" - ]}; - api.uc.confirm(undefined, {convert:true, cancel:false}, undefined, opt).then((ok) => { - let depth = Math.max(0.1, parseFloat($('dxf-depth').value)); - let segmentSize = Math.max(0.01, parseFloat($('dxf-seg').value)); - let minSegments = Math.max(3, parseInt($('dxf-min').value)); - let soup = $('dxf-nest').checked; - ok && doit({ soup, depth, segmentSize, minSegments }); - }); + const rnd = Date.now().toString(36); + const host = $('mod-any'); + host.innerHTML = [ + `
`, + `

Import DXF

`, + `

`, + ` Extrude a 3D model from a 2D DXF.`, + ` Supports POLYLINE, LWPOLYLINE, LINE, CIRCLE, ARC, and SPLINE entities.`, + `

`, + `
`, + ` `, + ` `, + ` `, + ` `, + `
z height in mm
arc segment size in mm
minimum arc segments
nest shapes
`, + `
`, + ` `, + ` `, + `
`, + `
` + ].join(''); + + const depth = $(`dxf-depth-${rnd}`); + const segmentSize = $(`dxf-seg-${rnd}`); + const minSegments = $(`dxf-min-${rnd}`); + const nest = $(`dxf-nest-${rnd}`); + const okBtn = $(`dxf-convert-ok-${rnd}`); + const cancelBtn = $(`dxf-convert-cancel-${rnd}`); + + okBtn.onclick = () => { + api.modal.hide(); + setTimeout(() => { + doit({ + soup: nest.checked, + depth: Math.max(0.1, parseFloat(depth.value)), + segmentSize: Math.max(0.01, parseFloat(segmentSize.value)), + minSegments: Math.max(3, parseInt(minSegments.value)) + }); + }, 50); + }; + cancelBtn.onclick = () => api.modal.hide(); + depth.onkeypress = (ev) => { + if (ev.key === 'Enter' || ev.charCode === 13) okBtn.click(); + }; + api.modal.show('any'); + setTimeout(() => depth.focus(), 0); } /**