-- -- EEEEEEEEEE GGGGGG wwww wwww -- EEEEEEEEEE GGGGGGGGGG wwww wwww -- EEEE GGGG GGGG wwww wwww wwww -- EEEE GGGG wwww wwww wwww -- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww -- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww -- EEEE GGGG GGGG wwww wwwwwwww wwww -- EEEE GGGG GGGG wwww wwww wwww wwww -- EEEEEEEEEE GGGGGGGGGG wwwwwwww wwwwwwww -- EEEEEEEEEE GGGGGG wwwwwww wwwwwww -- -- EdgePullMortiseCyl.lua by EgalWare s.r.l. 2016.06.14 -- Autore: Filippo Monchi -- edge pull tipo mortise o cilindrica -- 2016.09.21 V1.011 FM add warning messages -- 2017.08.30 V1.012 FM Add flag for not rotate Face on bevel profile -- 2018.04.05 V1.013 FM Manage info (KeepBackSet) for adjust probe on Z -- 2018.10.17 V1.014 FM Add parameter to show into message 402 -- 2018.10.22 V1.015 FM Manage better the big radius fillet parameter -- 2018.10.22 V1.015 FM Add new parameter D_XE to move all geometries -- 2019.10.10 V1.016 FM Manage steel option (disable to generate pocket paths, mortise) -- 2019.10.18 V2.000 FM Manage use Materials -- 2019.10.25 V2.001 FM Add clean corner geometries -- 2019.12.18 V2.002 FM Use new parameter DGC.Eah that allow insert template also on bullnose ans convex profiles -- 2019.12.20 V2.003 FM fix a bug on clean corner direction path in case main path turn reverse -- 2020.04.29 V2.004 FM Update for aluminum material -- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false -- 2021.11.24 V3.001 FM Manage side probe option if variable DGC.Pms > 2 -- 2022.07.27 V3.002 FM Modification to use compiled code -- 2024.07.19 V3.003 FM Set note 'NotCheckDir' to pocketing and antisplint paths -- 2024.09.17 V3.004 FM Fix error on not assigned parameters: H2 and D_X -- 2024.10.03 V3.005 FM Manage probe geometry and their offset position when template is disposed -- 2024.10.29 V3.006 FM Manage new DGC.Fpd CurrDoorCustomData variable to force shuttle probe geometry to stay horizontal -- Tavola per definizione modulo (serve ma non usata) local EdgePullMortiseCyl = {} -- Intestazioni require( 'EgtBase') EgtEnableDebug( false) -- per messaggi -- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') -- Valori limite local DgMin = 4. -- valore minimo diametro utensile local PtMin = 0.1 local PtMax = 1.0 local dExtraH = 0.5 local function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) local EgtDoorsMsg = require( 'EgtDoorsMsg') local sMessage = '' if dOriDiamTool then if nErrorId == -1 then -- lavorazione non presente in tabella sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -5 then -- diametro utensile non trovato sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -6 then -- nome geometria non presente in tabella sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -7 then -- altezza massima utensile non trovata sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -8 then -- tabella non presente nelle note sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) end elseif nErrorId == -1 then -- lavorazione non presente in tabella sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) elseif nErrorId == -2 then -- errore nel settare la lavorazione sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -5 then -- diametro utensile non trovato sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -6 then -- nome geometria non presente in tabella sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) elseif nErrorId == -7 then -- altezza massima utensile non trovata sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -8 then -- tabella non presente nelle note sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) end return sMessage end -- Funzione di sistemazione parametri function EdgePullMortiseCyl.AdjustParams( tMhPar) tMhPar.invG = 1 local EgtDoorsMsg = require( 'EgtDoorsMsg') local dMaxMat0 local dMaxMat1 local dMaxMat2 local dMaxMat3 local dNumMessage local dNumLog = 0 local sMessToOut = '' local nTempT0 local nTempT1 local nTempT2 local nTempT3 local nTempT4 local sMchngName0 local sMchngName1 local sMchngName2 local sMchngName3 local sMchngName4 local dOffset = DGD.OFFSET or 0 -- do errore se profilo tipo bullnose e convesso e non è ammesso if not DGC.Eah and ( DGD.tProfs.lockedge.trimming == 'CV' or DGD.tProfs.lockedge.trimming == '1B' or DGD.tProfs.lockedge.trimming == '2B' or DGD.tProfs.lockedge.trimming == '3B' or DGD.tProfs.lockedge.trimming == '4B' or DGD.tProfs.lockedge.trimming == '5B' or DGD.tProfs.lockedge.trimming == '6B' or DGD.tProfs.lockedge.trimming == '7B' or DGD.tProfs.lockedge.trimming == '8B') then return tMhPar, 1999, string.format(EgtDoorsMsg[431], tMhPar.Nome, DGD.tProfs.lockedge.trimming) end -- se profilo bevel disabilito la giunzione tra face e mortise if DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BU' or DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB' then tMhPar.jnb = false -- setto il flag che indica profilo bevel tMhPar.bev = true else tMhPar.jnb = true end -- se serratura su lato destro setto il flag per invertire i percorsi if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end tMhPar.SL = DGD.Lock if tMhPar.dl and tMhPar.H and tMhPar.T and tMhPar.T > 0 and not tMhPar.jnb then -- se non ruoto face risetto il flag che impedisce il chain tra face e mortise tMhPar.jnb = true -- ricalcolo la profondità per avere spessore minomo = al valore di .T tMhPar.T = tMhPar.T + EgtIf( DGC.Bwd and DGC.Bwd == 2, 0, (( tMhPar.H/2) * TAN3)) -- ricalcolo anche lo spessore seconda cava, se presente if tMhPar.T2nd and tMhPar.T2nd > 0 then tMhPar.T2nd = tMhPar.T2nd + EgtIf( DGC.Bwd and DGC.Bwd == 2, 0, (( tMhPar.H/2) * TAN3)) end else tMhPar.dl = false end -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava if not tMhPar.sf or abs(tMhPar.sf) < GEO.EPS_SMALL then tMhPar.sf = tMhPar.T end -- se non ho il parametro lo setto disattivato if not tMhPar.ech then tMhPar.ech = false end -- se non c'è la variabile suffisso if not tMhPar.CH then tMhPar.CH = '_Chisel' end -- se c'è la variabile CurrCamInfo che indica che la porta è disposta con il lato lock sul lato navetta -- e il template non è sui lati top e bottom if DGD.SDF and DGD.SDF > 1 then -- calcolo la posizione del centro foro sullo spessore porta if dOffset > 0 then if DGD.Push then tMhPar.posh = (DGD.dT/2) - dOffset else tMhPar.posh = -(DGD.dT/2) + dOffset end else tMhPar.posh = 0 end if tMhPar.bev and not tMhPar.dl and not DGC.Fpd then tMhPar.posh = tMhPar.posh / cos( 3) end end -- se non ho il parametro di arrotondamento lati lo setto disabilitato if not tMhPar.cl then tMhPar.cl = 0 end -- se arrotondo entrambe le estremità disabilito il chisel e il cleancorner if tMhPar.cl == 3 then tMhPar.ech = false tMhPar.clc = nil tMhPar.CLC = nil end if not tMhPar.rf then tMhPar.rf = 0 if tMhPar.cl > 0 and tMhPar.H then tMhPar.rf = tMhPar.H/2 end end -- Assegno parametri da dati utensili in macchina local MB = require( 'MachiningBase') local sLM local nLMi = 1 local sLA local nLAi = 1 local sLA3 local nLA3i = 1 local sLGH local nLGHi = 1 local sLG local nLGi = 1 -- se porta steel o aluminum disabilito l'antischeggia, la svuotatura, il chisel e modifico il nome geometria if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then tMhPar.LM = nil tMhPar.LA = nil tMhPar.LA3 = nil tMhPar.ech = false tMhPar.CH = nil tMhPar.est = true tMhPar.d2 = nil tMhPar.d3 = nil else tMhPar.est = nil end -- devo considerare il profilo serratura e se eventualmente è opposto a quello cerniere if DGD.tProfs.lockedge.trimming == 'BU' or DGD.tProfs.lockedge.trimming == 'BUEB' then -- profilo serrratura bevel up -- se lato cerniere opposto mi troverò il bevel al contrario perché comanda il lato cerniere if DGD.bBothOppoBevel then nLMi = 3 nLGi = 3 else nLMi = 2 nLGi = 2 end elseif DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BDEB' then -- profilo serrratura bevel dn -- se lato cerniere opposto mi troverò il bevel al contrario perché comanda il lato cerniere if DGD.bBothOppoBevel then nLMi = 2 nLGi = 2 else nLMi = 3 nLGi = 3 end end if tMhPar.est and tMhPar.LG then -- se altro materiale sLG = tMhPar.LG if DGD.MachEn > 0 and tMhPar.d then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end end if tMhPar.LM then sLM = tMhPar.LM if DGD.MachEn > 0 and tMhPar.d then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLM, nLMi) end end if tMhPar.ech and tMhPar.LG then -- se chisel abilitato sLG = tMhPar.LG .. tMhPar.CH tMhPar.d0 = 0 if DGD.MachEn > 0 and tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end end if tMhPar.LA then sLA = tMhPar.LA if DGD.MachEn > 0 and tMhPar.d2 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLA, nLAi) end end if tMhPar.LA3 then sLA3 = tMhPar.LA3 if DGD.MachEn > 0 and tMhPar.d3 then nTempT3, dMaxMat3, sMchngName3 = MB.GetToolDataFromAttrib( sLA3, nLA3i) end end if tMhPar.mh and tMhPar.LGH then sLGH = tMhPar.LGH if DGD.MachEn > 0 then nTempT4, dMaxMat2, sMchngName4 = MB.GetToolDataFromAttrib( sLGH, nLGHi) end end -- se devo disegnare le geometrie di lavorazione if DGD.MachEn > 0 then -- gestisco il risultato della lettura utensili if DGD.bProoduce and tMhPar.est and tMhPar.d and nTempT0 <= 0 then dNumLog = -1988 sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT0, sLG, nLGi, tMhPar.d, dNumLog, sMchngName0) elseif tMhPar.est and nTempT0 then tMhPar.d = nTempT0 end -------------------------------------------------------------------------------- -- se c'è materiale steel faccio in modo che non assegni il diametro utensile -------------------------------------------------------------------------------- -- gestisco il risultato della lettura utensili if DGD.bProoduce and not tMhPar.est and tMhPar.d and nTempT1 and nTempT1 <= 0 then dNumLog = -1990 sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) elseif not tMhPar.est and nTempT1 then tMhPar.d = nTempT1 end if DGD.bProoduce and not tMhPar.est and tMhPar.d2 and nTempT2 and nTempT2 <= 0 then dNumLog = -1990 sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2) elseif not tMhPar.est and nTempT2 then tMhPar.d2 = nTempT2 end if not tMhPar.est and tMhPar.d3 and nTempT3 and nTempT3 <= 0 then if DGD.bProoduce and not tMhPar.jn then -- se non si concatenano i due percorsi dNumLog = -1990 sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLA3, nLA3i, tMhPar.d3, dNumLog, sMchngName3) end elseif not tMhPar.est and nTempT3 then tMhPar.d3 = nTempT3 end if DGD.bProoduce and tMhPar.mh and tMhPar.LGH and not dMaxMat2 then dNumLog = -1989 sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT4, sLGH, nLGHi, nil, dNumLog, sMchngName4) end -- chiseling if tMhPar.ech and tMhPar.d0 and nTempT0 > 0 then tMhPar.d0 = nTempT0 end -- se la profondità della face per steel è maggiore della capacità utensile limito la profondità ed emetto un warning if tMhPar.est and tMhPar.T and dMaxMat0 and tMhPar.T > dMaxMat0 then dNumLog = -1987 dNumMessage = 460 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat0)) tMhPar.T = dMaxMat0 end -- se la profondità della face è maggiore della capacità utensile limito la profondità ed emetto un warning if tMhPar.T and dMaxMat1 and tMhPar.T > dMaxMat1 then dNumLog = -1998 dNumMessage = 460 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) tMhPar.T = dMaxMat1 - 0.05 -- tolgo 0.05 per permettere la lavorazione end -- se la profondità della seconda face è maggiore della capacità utensile limito la profondità ed emetto un warning if tMhPar.T2nd and dMaxMat1 and tMhPar.T2nd > dMaxMat1 then dNumLog = -1997 dNumMessage = 460 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2nd), EgtToUiUnits(dMaxMat1)) tMhPar.T2nd = dMaxMat1 - 0.05 -- tolgo 0.05 per permettere la lavorazione end -- se mortise concatenata a face e la profondità della mortise è maggiore della capacità utensile, -- limito la profondità ed emetto un warning if tMhPar.jn and not tMhPar.mh and tMhPar.jnb and tMhPar.T2 and dMaxMat1 and tMhPar.T2 > dMaxMat1 then dNumLog = -1996 dNumMessage = 461 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat1)) tMhPar.T2 = dMaxMat1 - 0.02 end -- se mortise non concatenata a face e la profondità della mortise è maggiore della capacità utensile, -- limito la profondità ed emetto un warning if ( not tMhPar.jn or tMhPar.mh or not tMhPar.jnb) and tMhPar.T2 and dMaxMat2 and tMhPar.T2 > dMaxMat2 then dNumLog = -1995 if tMhPar.mh then dNumMessage = 463 else dNumMessage = 461 end sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat2)) tMhPar.T2 = dMaxMat2 - 0.02 end -- se tutte le mortise concatenate a face e la profondità della mortise è maggiore della capacità utensile, -- limito la profondità ed emetto un warning if tMhPar.jn and tMhPar.jn2 and not tMhPar.mh and tMhPar.jnb and tMhPar.T2 and dMaxMat1 and tMhPar.T2 > dMaxMat1 then dNumLog = -1994 dNumMessage = 461 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat1)) tMhPar.T2 = dMaxMat1 - 0.02 end -- se tutte le mortise concatenate a face e la profondità della mortise è maggiore della capacità utensile, -- limito la profondità ed emetto un warning if tMhPar.jn and tMhPar.jn2 and not tMhPar.mh and tMhPar.jnb and tMhPar.T3 and dMaxMat1 and tMhPar.T3 > dMaxMat1 then dNumLog = -1993 dNumMessage = 461 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T3), EgtToUiUnits(dMaxMat1)) tMhPar.T3 = dMaxMat1 end -- se solo le mortise concatenate a face e la profondità della seconda mortise è maggiore della capacità utensile, -- limito la profondità ed emetto un warning if not tMhPar.jn and tMhPar.jn2 and not tMhPar.mh and tMhPar.T3 and dMaxMat2 and tMhPar.T3 > dMaxMat2 then dNumLog = -1992 dNumMessage = 461 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T3), EgtToUiUnits(dMaxMat2)) tMhPar.T3 = dMaxMat2 end -- se nessuna mortise è concatenate a face e la profondità della mortise è maggiore della capacità utensile, -- limito la profondità ed emetto un warning if not tMhPar.jn and not tMhPar.jn2 and tMhPar.T3 and dMaxMat2 and tMhPar.T3 > dMaxMat2 then dNumLog = -1991 dNumMessage = 461 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T3), EgtToUiUnits(dMaxMat2)) tMhPar.T3 = dMaxMat2 end -- Raggio: se altro materiale e raggio presente e se raggio minore del diametro utensile + delta, lo annullo if tMhPar.est and tMhPar.rf and tMhPar.rf > 0 and tMhPar.cl > 0 and tMhPar.d and tMhPar.rf < ((tMhPar.d/2)+0.02) then tMhPar.rf = 0 end if tMhPar.CLC and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.H or tMhPar.clc >= tMhPar.L) then tMhPar.clc = nil elseif not tMhPar.CLC then tMhPar.clc = nil end end if dNumLog ~= 0 then return tMhPar, dNumLog, sMessToOut end return tMhPar, 0, '' end -- Funzione di disegno function EdgePullMortiseCyl.Draw( tLckP, bPreview, bRunByCompo, nDrawMach, dThickDoor) -- Assegno le dimensioni geometria local L = tLckP.L -- lunghezza face local H = tLckP.H -- larghezza face local T = tLckP.T -- spessore face local T2nd = tLckP.T2nd -- seconda profondità cava doppia local nPosT2nd = tLckP.nPosT2nd -- posizione cava con profondità maggiorata. solo valori -1 o 1 local d = tLckP.d -- diametro utensile face local p = tLckP.p -- percentuale uso utensile face local sf = tLckP.sf -- passo affondamento face local dl = tLckP.dl -- disponi face come lock, cioè non ruotata su bevel local mh = tLckP.mh -- crea foro: true o mortasa: false local L2 = tLckP.L2 -- lunghezza mortasa (seconda cava) local H2 = tLckP.H2 -- larghezza mortasa o diametro foro local T2 = tLckP.T2 -- profondità mortasa o foro local d2 = tLckP.d2 -- diametro utensile svuotatura mortasa ( non per foro) local p2 = tLckP.p2 -- percentuale uso utensile mortasa local s = tLckP.s -- passo affondamento mortasa local L3 = tLckP.L3 -- lunghezza seconda mortasa ( terza cava) local H3 = tLckP.H3 -- larghezza seconda mortasa ( terza cava) local T3 = tLckP.T3 -- profondità seconda mortasa ( terza cava) local d3 = tLckP.d3 -- diametro utensile svuotatura seconda mortasa local p3 = tLckP.p3 -- percentuale uso utensile seconda mortasa local s3 = tLckP.s3 -- passo affondamento seconda mortasa local cl = tLckP.cl -- arrotonda estremità face, 0: nessun arrotondamento, 1: arrotonda a sinistra, -- 2: arrotonda a destra, 3: arrotonda entrambe i lati local rf = tLckP.rf -- raggio arrotondamento face local clc = tLckP.clc local ccr = tLckP.ccr local ech = tLckP.ech -- abilitazione chisel local est = tLckP.est -- altro materiale trovato local kbs = tLckP.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) local pbs = tLckP.pbs local SL = tLckP.SL -- Assegno i flag local jn = tLckP.jn -- flag per giunzione prima cava face con seconda cava (mortasa) local jn2 = tLckP.jn2 -- flag per giunzione seconda cava (mortasa) con terza cava ( seconda mortasa) local jnb = tLckP.jnb -- flag che indica se profilo tipo bevel o meno -- Inserimento geometrie probe local posh = tLckP.posh -- posizione in Y del foro di tastatura local posp = tLckP.posp -- posizione in X del foro di tastatura -- Disassamento delle 2 cave rispetto alla face local D_X = tLckP.D_X -- disassamento seconda cava (mortasa o foro) da centro lunghezza face local D_X3 = tLckP.D_X3 -- disassamento terza cava (seconda mortasa) da centro lunghezza face -- Disassamento globale local D_XE = tLckP.D_XE -- Extra delta on X pos for all geometries -- gestione inversione percorsi local invG = tLckP.invG -- flag per invertire il senso dei percorsi di lavorazione -- Assegno le label degli attributi fianco porta local LG = tLckP.LG -- nome geometria face: per la doppia face, la prima geometria è LG..'1st' local LG2 = tLckP.LG2 -- nome geometria seconda cava (mortasa) local LG3 = tLckP.LG3 -- nome geometria terza cava (seconda mortasa) local LM = tLckP.LM -- nome geometria lavorazione face: per la doppia face, la prima geometria è LM..'1st' local LA = tLckP.LA -- nome geometria lavorazione seconda cava (mortasa) local LA3 = tLckP.LA3 -- nome geometria lavorazione terza cava (seconda mortasa) local CH = tLckP.CH -- nome suffisso lavorazione chisel local CLC = tLckP.CLC -- nome geometria clean corner -- Assegno le label alla geometria foro profondo di lato local LGH = tLckP.LGH -- nome geometria seconda cava (foro) -- variabile nome geometrie probe local LH = 'Shuttle_Probe' -- variabili per messaggi e settaggi vari local sCompoName = tLckP.Nome local nCompoNpar = tLckP.Npar local sCompoPath = tLckP.Path -- eventuale messaggio errore rilevato nell'adjust local nCodAdj = tLckP.nCod local sCodAdj = tLckP.sCod -- variabili per messaggi di errore local sNamePar1 = tLckP.NPL or 'L' local sNamePar2 = tLckP.NPH or 'H' local sNamePar3 = tLckP.NPT or 'T' local sNamePar13 = tLckP.NPT2nd or 'T2nd' local sNamePar4 = tLckP.NPd or 'd' local sNamePar5 = tLckP.NPp or 'p' local sNamePar7 = tLckP.NL2 or 'L2' local sNamePar8 = tLckP.NT2 or 'T2' local sNamePar9 = tLckP.NPd2 or 'd2' local sNamePar10 = tLckP.NPp2 or 'p2' local sNamePar11 = tLckP.NPS or 's' local sNamePar12 = tLckP.NPH2 or 'H2' local sNamePar14 = tLckP.NL3 or 'L3' local sNamePar15 = tLckP.NL3 or 'H3' local sNamePar16 = tLckP.NT3 or 'T3' local sNamePar17 = tLckP.NPd3 or 'd3' local sNamePar18 = tLckP.NPp3 or 'p3' local sNamePar19 = tLckP.NPS3 or 's3' local sNamePar20 = tLckP.NPD_X or 'D_X' local sNamePar21 = tLckP.NPD_X3 or 'D_X3' local sNamePar48 = tLckP.NPSF or 'sf' local sNamePar49 = tLckP.NPRF or 'rf' local sNamePar50 = tLckP.N50 or 'clc' local sNamePar51 = tLckP.N51 or 'ccr' -- RunByComponetInterface local RC = true -- Messaggi codice errori local EM = ' ' local EC = 0 local ErrorBase = 1900 -- variabili che abilitano la creazione della geometria local bMakeFaceGeom = true local bMakeMortGeom = true local bMakeMortGeom2nd = true if not bRunByCompo then RC = false end -- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi if not L or not H then bMakeFaceGeom = false jn = false -- disattivo il join tra face e mortasa clc = nil CLC = nil end -- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili if bMakeFaceGeom then if L >= H then if rf > (H/2) then rf = (H/2) end else if rf > (L/2) then rf = (L/2) end end end -- se rilevato profilo bevel disattivo il join tra face e mortasa if not jnb then jn = false end if not T then T = 0 end if not D_X then D_X = 0 end if not D_XE then D_XE = 0 end if mh then if not H2 then bMakeMortGeom = false end -- disattivo i join sul foro jn = false jn2 = false else if not L2 or not H2 then bMakeMortGeom = false -- disattivo i join jn = false jn2 = false end end if not T2 then T2 = 0 end if not L3 or not H3 then bMakeMortGeom2nd = false end if not T3 then T3 = 0 end if est then bMakeMortGeom = false bMakeMortGeom2nd = false -- disattivo i join jn = false jn2 = false -- jnb = false end -- se prima e seconda cava giuntate assegno il diametro della seconda cava uguale alla prima if jn and bMakeFaceGeom and bMakeMortGeom then d2 = d p2 = p end -- se seconda e terza cava giuntate assegno il diametro della terza cava uguale alla seconda if jn2 and bMakeMortGeom and bMakeMortGeom2nd then d3 = d2 p3 = p2 s3 = s end -- se non definita o parametri relativi alla definizione dei percorsi sono mancanti, la setto per non creare geometria di lavorazione if not nDrawMach then nDrawMach = 0 end local EgtDoorsMsg = require( 'EgtDoorsMsg') -- Verifica delle dimensioni, alcune condizioni vengono verificate solo se è abilitata la creazione dei percorsi di lavorazione if bMakeFaceGeom and L <= 0 then EC = 1 EM = string.format(EgtDoorsMsg[401],sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L' deve essere > 0 L = d*2 elseif bMakeMortGeom and not mh and L2 < 0 then EC = 2 EM = string.format(EgtDoorsMsg[404],sNamePar7,EgtToUiUnits(L2), sCompoPath) -- il parametro 'L2' deve essere >= 0 L2 = d2*2 elseif bMakeMortGeom2nd and L3 < 0 then EC = 3 EM = string.format(EgtDoorsMsg[404],sNamePar14,EgtToUiUnits(L3), sCompoPath) -- il parametro 'L3' deve essere >= 0 L3 = d3*2 elseif bMakeFaceGeom and H <= 0 then EC = 4 EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0 H = d elseif bMakeMortGeom and H2 <= 0 then EC = 5 EM = string.format(EgtDoorsMsg[401],sNamePar12,EgtToUiUnits(H2), sCompoPath) -- il parametro 'H2' deve essere > 0 H2 = d2 elseif bMakeMortGeom2nd and H3 <= 0 then EC = 6 EM = string.format(EgtDoorsMsg[401],sNamePar15,EgtToUiUnits(H3), sCompoPath) -- il parametro 'H3' deve essere > 0 H3 = d3 elseif bMakeFaceGeom and T < 0 then EC = 7 EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 T = 0 elseif bMakeMortGeom and T2 <= 0 then EC = 8 EM = string.format(EgtDoorsMsg[401],sNamePar8,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T2' deve essere > 0 T2 = 0.1 elseif bMakeMortGeom2nd and T3 <= 0 then EC = 9 EM = string.format(EgtDoorsMsg[401],sNamePar16,EgtToUiUnits(T3), sCompoPath) -- il parametro 'T3' deve essere > 0 T3 = 0.1 elseif bMakeFaceGeom and T2nd and T2nd < 0 then EC = 10 EM = string.format(EgtDoorsMsg[404],sNamePar13,EgtToUiUnits(T2nd), sCompoPath) -- il parametro 'T2nd' deve essere >= 0 T2nd = 0 elseif bMakeFaceGeom and nDrawMach > 0 and L <= d then if DGD.bProoduce then EC = 11 EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar4,EgtToUiUnits(d), sCompoPath) -- il parametro 'L' deve essere maggiore al diametro utensile L = d + 0.002 else d = L - 0.002 end elseif bMakeMortGeom and nDrawMach > 0 and not mh and L2 <= d2 then if DGD.bProoduce then EC = 12 EM = string.format(EgtDoorsMsg[402],sNamePar7,EgtToUiUnits(L2),sNamePar9,EgtToUiUnits(d2), sCompoPath) -- il parametro 'L2' deve essere maggiore al diametro utensile L2 = d2 + 0.002 else d2 = L2 - 0.002 end elseif bMakeMortGeom2nd and nDrawMach > 0 and L3 <= d3 then if DGD.bProoduce then EC = 13 EM = string.format(EgtDoorsMsg[402],sNamePar7,EgtToUiUnits(L2),sNamePar9,EgtToUiUnits(d2), sCompoPath) -- il parametro 'L2' deve essere maggiore al diametro utensile L3 = d3 + 0.002 else d3 = L3 - 0.002 end elseif bMakeFaceGeom and nDrawMach > 0 and H < d then if DGD.bProoduce then EC = 14 EM = string.format(EgtDoorsMsg[405],sNamePar2,EgtToUiUnits(H),EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere >= del diametro utensile H = d else d = H - 0.002 end elseif bMakeMortGeom and nDrawMach > 0 and not mh and H2 < d2 then if DGD.bProoduce then EC = 15 EM = string.format(EgtDoorsMsg[405],sNamePar12,EgtToUiUnits(H2),EgtToUiUnits(d2), sCompoPath) -- il parametro 'H2' deve essere >= del diametro utensile H2 = d2 else d2 = H2 - 0.002 end elseif bMakeMortGeom2nd and nDrawMach > 0 and H3 < d3 then if DGD.bProoduce then EC = 16 EM = string.format(EgtDoorsMsg[405],sNamePar15,EgtToUiUnits(H3),EgtToUiUnits(d2), sCompoPath) -- il parametro 'H3' deve essere >= del diametro utensile H3 = d3 else d3 = H3 - 0.002 end elseif bMakeFaceGeom and nDrawMach > 0 and d < DgMin then EC = 17 EM = string.format(EgtDoorsMsg[400],sNamePar4, EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di d = DgMin elseif bMakeMortGeom and nDrawMach > 0 and not mh and d2 < DgMin then EC = 18 EM = string.format(EgtDoorsMsg[400],sNamePar9, EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di d2 = DgMin elseif bMakeMortGeom2nd and nDrawMach > 0 and d3 < DgMin then EC = 19 EM = string.format(EgtDoorsMsg[400],sNamePar17, EgtToUiUnits(d3),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di d3 = DgMin elseif bMakeFaceGeom and nDrawMach > 0 and ( p < PtMin or p > PtMax) then EC = 20 EM = string.format(EgtDoorsMsg[403],sNamePar5,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra p = 0.8 elseif bMakeMortGeom and nDrawMach > 0 and not mh and ( p2 < PtMin or p2 > PtMax) then EC = 21 EM = string.format(EgtDoorsMsg[403],sNamePar10,p2,PtMin,PtMax, sCompoPath) -- il parametro 'p2' deve essere compreso tra p2 = 0.8 elseif bMakeMortGeom2nd and nDrawMach > 0 and ( p3 < PtMin or p3 > PtMax) then EC = 22 EM = string.format(EgtDoorsMsg[403],sNamePar18,p3,PtMin,PtMax, sCompoPath) -- il parametro 'p3' deve essere compreso tra p3 = 0.8 elseif bMakeFaceGeom and bMakeMortGeom and not mh and L2 >= L then EC = 23 EM = string.format(EgtDoorsMsg[406],sNamePar7,EgtToUiUnits(L2),sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L2' deve essere < 'L' L2 = L - 0.1 -- elseif bMakeMortGeom and bMakeMortGeom2nd and not mh and L3 >= L2 then -- EC = 24 -- EM = string.format(EgtDoorsMsg[406],sNamePar14,EgtToUiUnits(L3),sNamePar7,EgtToUiUnits(L2), sCompoPath) -- il parametro 'L3' deve essere < 'L2' -- L3 = L2 - 0.1 elseif bMakeFaceGeom and bMakeMortGeom and H2 > H then EC = 25 EM = string.format(EgtDoorsMsg[456],sNamePar12,EgtToUiUnits(H2),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H2' deve essere <= 'H' H2 = H elseif bMakeMortGeom and bMakeMortGeom2nd and H3 > H2 then EC = 26 EM = string.format(EgtDoorsMsg[456],sNamePar15,EgtToUiUnits(H3),sNamePar12,EgtToUiUnits(H2), sCompoPath) -- il parametro 'H3' deve essere <= 'H2' H3 = H2 elseif bMakeFaceGeom and bMakeMortGeom and T2 <= T then EC = 27 EM = string.format(EgtDoorsMsg[407],sNamePar8,EgtToUiUnits(T2),sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T2' deve essere > 'T' T2 = T + 0.1 elseif bMakeFaceGeom and bMakeMortGeom and T2nd and T2 <= T2nd then EC = 28 EM = string.format(EgtDoorsMsg[407],sNamePar8,EgtToUiUnits(T2),sNamePar13,EgtToUiUnits(T2nd), sCompoPath) -- il parametro 'T2' deve essere > 'T2nd' T2 = T2nd + 0.1 elseif bMakeMortGeom and bMakeMortGeom2nd and T3 <= T2 then EC = 29 EM = string.format(EgtDoorsMsg[407],sNamePar16,EgtToUiUnits(T3),sNamePar8,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T3' deve essere > 'T2' T3 = T2 + 0.1 elseif bMakeMortGeom and nDrawMach > 0 and not mh and s and s <= 0 then EC = 30 EM = string.format(EgtDoorsMsg[401],sNamePar11,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 s = d2 elseif bMakeMortGeom2nd and nDrawMach > 0 and s3 and s3 <= 0 then EC = 31 EM = string.format(EgtDoorsMsg[401],sNamePar19,EgtToUiUnits(s3), sCompoPath) -- il parametro 's3' deve essere > 0 s3 = d3 elseif bMakeFaceGeom and bMakeMortGeom and not mh and D_X and abs(2*D_X) > (L-L2) then -- se il decentramento è troppo altro e fa sbordare la cava2 dalla 1 EC = 32 EM = string.format(EgtDoorsMsg[423],sNamePar20,EgtToUiUnits(D_X),EgtToUiUnits((L-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: D_X = 0 elseif bMakeFaceGeom and bMakeMortGeom and mh and D_X and abs(2*D_X) > (L-H2) then -- se il decentramento è troppo altro e fa sbordare la cava2 dalla 1 EC = 33 EM = string.format(EgtDoorsMsg[423],sNamePar20,EgtToUiUnits(D_X),EgtToUiUnits((L-H2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: D_X = 0 -- elseif bMakeMortGeom and bMakeMortGeom2nd and not mh and D_X and D_X3 and abs(2*(D_X-D_X3)) > (L2-L3) then -- se il decentramento è troppo altro e fa sbordare la cava3 dalla 2 -- EC = 34 -- EM = string.format(EgtDoorsMsg[423],sNamePar21,EgtToUiUnits(D_X3),EgtToUiUnits(((L2-L3)/2)-D_X), sCompoPath) -- il parametro 'D_X3' é troppo grande, max valore: -- D_X3 = 0 -- elseif bMakeFaceGeom and bMakeMortGeom2nd and D_X3 and abs(2*D_X3) > (L-L3) then -- se il decentramento è troppo altro e fa sbordare la cava3 dalla 1 -- EC = 35 -- EM = string.format(EgtDoorsMsg[423],sNamePar21,EgtToUiUnits(D_X3),EgtToUiUnits((L-L3)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: -- D_X3 = 0 elseif bMakeFaceGeom and nDrawMach > 0 and sf and sf <= 0 then EC = 36 EM = string.format(EgtDoorsMsg[401],sNamePar48,EgtToUiUnits(sf), sCompoPath) -- il parametro 'sf' deve essere > 0 sf = d elseif bMakeFaceGeom and cl and cl > 0 and rf < 0 then EC = 37 EM = string.format(EgtDoorsMsg[404],sNamePar49,EgtToUiUnits(rf), sCompoPath) -- il parametro 'rf' deve essere >= 0 rf = H/2 elseif bMakeFaceGeom and CLC and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then EC = 38 EM = string.format(EgtDoorsMsg[407],sNamePar50,EgtToUiUnits(clc),'',EgtToUiUnits(2*(ccr*sin(45))), sCompoPath) -- il parametro 'clc' deve essere > 'crc' clc = (2*(ccr*sin(45)))+0.2 end if not bPreview and EC ~= 0 then return (ErrorBase+EC), EM end -- Se Preview cancello tutto if bPreview then EgtNewFile() EgtSetDefaultMaterial( BLACK()) end -- Pezzo e Layer local Pz if bPreview then Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo else if not RC then Pz = EgtGetCurrPart() -- pezzo corrente end if not Pz then Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo end end local Lg local bMakeTwinFace = false -- variabili dei percorsi geometrici local nGeomFace, nGeom1st, nGeom1, nGeom2, nGeom3 local nPkToJoin1st, nPkToJoin1, nPkToJoin2, nPkToJoin3 local nPkJoin, nPkJoin1 local nPosFace = 0 local nPos1st = 0 local nPos2nd = 0 local bMakeSecondFace = false local dFirstface = {} local dSecondface = {} local nForceMakeFace = nDrawMach Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer principale EgtSetName(Lg,sCompoName) -- verifico le condizioni necessarie per creare la doppia face if jnb and H and H2 and abs(H - H2) < GEO.EPS_SMALL and not mh and bMakeFaceGeom and cl == 0 then bMakeTwinFace = true end if bMakeFaceGeom then -- se posizione cava profondità maggiorata non è definita o con valori non idonei, -- la setto di default a -1 ( inserimento a sinistra) if not nPosT2nd or ( nPosT2nd ~= -1 and nPosT2nd ~= 1) then nPosT2nd = -1 end -- se seconda profondità non definita o nulla la setto uguale alla profondità generale if not T2nd or T2nd < GEO.EPS_SMALL then T2nd = T end if bMakeTwinFace then -- se doppia cava face preparo la relativa tabella con i parametri -- in base agli arrotondamenti calcolo lo spostamento per posizionare la cava in centro if cl == 1 then -- se arrotondamento a sinistra nPosFace = H/4 elseif cl == 2 then -- se arrotondamento a destra nPosFace = -H/4 else nPosFace = 0 end -- se contorno più percorsi lavorazione, faccio fare solo contorno if nDrawMach > 1 then nForceMakeFace = 0 end -- cava face solo contorno -- assegno i valori coerenti con la tabella del componente dFirstface.L = L dFirstface.H = H dFirstface.T = T dFirstface.d = d dFirstface.p = p dFirstface.sf = sf dFirstface.jn = false -- disattivo il join della prima cava face dFirstface.L2 = L2 dFirstface.H2 = H2 dFirstface.cl = cl dFirstface.rf = rf dFirstface.est = est dFirstface.invG = invG dFirstface.LG = LG dFirstface.LM = LM dFirstface.Nome = sCompoName dFirstface.D_X = 0 -- annullo lo spostamento della mortasa dFirstface.smr = 0 -- così il latch non crea i raccordini per evitare il chiseling -- lancio il primo componente base con settato il parametro per disegnare solamente il contorno esterno -- senza lavorazione MHgen = require( '_Latch') nGeomFace = MHgen.Draw( EC, EM, dFirstface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) -- riassegno il valore impostazione originario nForceMakeFace = nDrawMach -- prima semi-cava face completa -- assegno i valori coerenti con la tabella del componente dFirstface.L = ((L-L2)/2) + ( D_X * nPosT2nd) + (d/2) + dExtraH if est then dFirstface.smr = 0 -- così il latch non crea i raccordini per evitare il chiseling else dFirstface.smr = -nPosT2nd -- crea i raccordini in base alla posizione cava end -- se ho abilitato il chiseling modifico il nome geometria if ech then dFirstface.LG = LG .. '_1st' .. CH -- se ho abilitato solo le geometrie di lavorazione, abilito la generazione di entrambe per il contorno chisel if nDrawMach == 1 then nForceMakeFace = 2 end else dFirstface.LG = LG .. '_1st' end if LM then dFirstface.LM = LM .. '_1st' else dFirstface.LM = nil end nPos1st = ( dFirstface.L - L)/2 * nPosT2nd -- lancio il primo componente base per disegnare prima semi-face MHgen = require( '_Latch') nGeom1st, nPkToJoin1st = MHgen.Draw( EC, EM, dFirstface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) -- seconda semi-cava face bMakeSecondFace = true -- assegno i valori coerenti con la tabella del componente dSecondface.L = ((L-L2)/2) - ( D_X * nPosT2nd) + (d/2) + dExtraH dSecondface.H = H dSecondface.T = T2nd dSecondface.d = d dSecondface.p = p dSecondface.sf = sf dSecondface.jn = jn dSecondface.L2 = L2 dSecondface.H2 = H2 dSecondface.cl = cl dSecondface.rf = rf dSecondface.est = est dSecondface.invG = invG if est then dSecondface.smr = 0 -- così il latch non crea i raccordini per evitare il chiseling else dSecondface.smr = nPosT2nd -- crea i raccordini in base alla posizione cava end -- se ho abilitato il chiseling modifico il nome geometria if ech then dSecondface.LG = LG .. CH else dSecondface.LG = LG end dSecondface.LM = LM dSecondface.Nome = sCompoName nPos2nd = (L - dSecondface.L)/2 * nPosT2nd -- calcolo la posizione dal centro cava 2nd face al centro della mortasa dSecondface.D_X = D_X - nPos2nd -- lancio il primo componente base per disegnare seconda semi-face MHgen = require( '_Latch') nGeom1, nPkToJoin1 = MHgen.Draw( EC, EM, dSecondface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) else -- altrimenti cava face completa -- verifico se è fattibile la seconda semi-cava if abs(T2nd-T) > GEO.EPS_SMALL and ( ( ( cl == 0 or cl == 2) and nPosT2nd < 0) or ( ( cl == 0 or cl == 1) and nPosT2nd > 0)) then bMakeSecondFace = true else T2nd = T -- se non faccio la semicava secondaria rimetto lo spessore della face intera end -- in base agli arrotondamenti calcolo lo spostamento per posizionare la cava in centro if cl == 1 then -- se arrotondamento a sinistra nPos1st = rf/2 elseif cl == 2 then -- se arrotondamento a destra nPos1st = -(rf/2) else nPos1st = 0 end -- prima cava face completa -- assegno i valori coerenti con la tabella del componente dFirstface.L = L dFirstface.H = H dFirstface.T = T dFirstface.d = d dFirstface.p = p dFirstface.sf = sf -- se c'è la seconda cava disattivo il join if bMakeSecondFace then dFirstface.jn = false -- disattivo il join della prima cava face else dFirstface.jn = jn end dFirstface.L2 = L2 dFirstface.H2 = H2 dFirstface.cl = cl dFirstface.rf = rf dFirstface.est = est dFirstface.invG = invG dFirstface.smr = 0 -- così il latch non crea i raccordini per evitare il chiseling -- se ho abilitato il chiseling modifico il nome geometria if ech then dFirstface.LG = LG .. '_1st' .. CH -- se ho abilitato solo le geometrie di lavorazione, abilito la generazione di entrambe per il contorno chisel if nDrawMach == 1 then nForceMakeFace = 2 end else dFirstface.LG = LG .. '_1st' end if LM then dFirstface.LM = LM .. '_1st' else dFirstface.LM = nil end dFirstface.Nome = sCompoName dFirstface.D_X = -nPos1st + D_X nPos2nd = 0 -- lancio il primo componente base per disegnare la face completa MHgen = require( '_Latch') nGeom1st, nPkToJoin1st = MHgen.Draw( EC, EM, dFirstface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) -- se seconda profondità face differisce dalla profondita generale face -- e non ci sono raccordi, creo la seconda semi-cava if bMakeSecondFace then -- seconda semi-cava face -- assegno i valori coerenti con la tabella del componente dSecondface.L = ((L-L2)/2) - ( D_X * nPosT2nd) + (d/2) + dExtraH dSecondface.H = H dSecondface.T = T2nd dSecondface.d = d dSecondface.p = p dSecondface.sf = sf dSecondface.jn = jn dSecondface.L2 = L2 dSecondface.H2 = H2 dSecondface.cl = 0 -- faccio solo semi-cava rettangolare dSecondface.rf = rf dSecondface.invG = invG if est then dSecondface.smr = 0 -- così il latch non crea i raccordini per evitare il chiseling else dSecondface.smr = nPosT2nd -- crea i raccordini in base alla posizione cava end -- se ho abilitato il chiseling modifico il nome geometria if ech then dSecondface.LG = LG .. CH else dSecondface.LG = LG end dSecondface.LM = LM dSecondface.Nome = sCompoName nPos2nd = (L - dSecondface.L)/2 * nPosT2nd -- calcolo la posizione dal centro cava 2nd face al centro della mortasa dSecondface.D_X = D_X - nPos2nd -- lancio il primo componente base MHgen = require( '_Latch') nGeom1, nPkToJoin1 = MHgen.Draw( EC, EM, dSecondface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) end end -- setto le note che indicano su che lato della porta devono essere messe le geometrie local sSide = EgtIf( dl, 'Lock', 'Side') -- Clean corner if nDrawMach >= 0 then -- se abilitata geometria if cl ~= 3 or ( cl == 3 and rf > 0) then -- se c'è almeno un lato senza raccordo if CLC and clc and clc > 0 and clc < H and clc < L then local CLC1 = MakeClcPath( clc, ccr, CLC, Lg, -T, (invG == -1)) if CLC1 then -- se mantiene backset if kbs and kbs > 0 then EgtSetInfo( CLC1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( CLC1, 'ProbeSide', '1') end EgtSetInfo( CLC1,'SideDoor',sSide) if cl <= 1 or cl == 3 then -- angolo x+y+ local CLC2 = EgtCopyGlob( CLC1, Lg) EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) EgtMove( CLC2, Point3d((L/2),(H/2),0) - ORIG()) -- angolo x+y- local CLC3 = EgtCopyGlob( CLC1, Lg) EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) EgtMove( CLC3, Point3d((L/2),-(H/2),0) - ORIG()) if cl == 1 then EgtErase(CLC1) end end if cl == 0 or cl >= 2 then -- angolo x-y- local CLC4 = EgtCopyGlob( CLC1, Lg) EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) EgtMove( CLC4, Point3d(-(L/2),-(H/2),0) - ORIG()) -- angolo x-y+ EgtMove( CLC1, Point3d(-(L/2),(H/2),0) - ORIG()) end end end end end if nGeomFace then EgtSetInfo(nGeomFace,'SideDoor',sSide) -- se mantiene centro spessore anche su face if kbs and kbs > 0 then EgtSetInfo( nGeomFace, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( nGeomFace, 'ProbeSide', '1') end end if nGeom1st then EgtSetInfo(nGeom1st,'SideDoor',sSide) -- se mantiene centro spessore anche su face if kbs and kbs > 0 then EgtSetInfo( nGeom1st, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( nGeom1st, 'ProbeSide', '1') end end if nPkToJoin1st then EgtSetInfo(nPkToJoin1st,'SideDoor',sSide) -- se mantiene centro spessore anche su face if kbs and kbs > 0 then EgtSetInfo( nPkToJoin1st, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( nPkToJoin1st, 'ProbeSide', '1') end end if nGeom1 then EgtSetInfo(nGeom1,'SideDoor',sSide) -- se mantiene centro spessore anche su face if kbs and kbs > 0 then EgtSetInfo( nGeom1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( nGeom1, 'ProbeSide', '1') end end if nPkToJoin1 then EgtSetInfo(nPkToJoin1,'SideDoor',sSide) -- se mantiene centro spessore anche su face if kbs and kbs > 0 then EgtSetInfo( nPkToJoin1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( nPkToJoin1, 'ProbeSide', '1') end end end if bMakeMortGeom then -- se seconda cava abilitata if mh then -- se devo fare il foro nGeom2 = EgtCircle( Lg, Point3d(0,0,0), H2/2 , GDB_RT.LOC) EgtModifyCurveThickness( nGeom2, -T2) EgtSetName( nGeom2, LGH) -- se mantiene centro spessore su mortise if kbs and kbs > 0 then EgtSetInfo( nGeom2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( nGeom2, 'ProbeSide', '1') end else -- cava mortasa local dMortise = {} -- assegno i valori coerenti con la tabella del componente if jn then dMortise.T = T2nd else dMortise.T = T end dMortise.L2 = L2 dMortise.H2 = H2 dMortise.T2 = T2 dMortise.s = s dMortise.d = d2 dMortise.p = p2 dMortise.jn = jn dMortise.d3 = d2 dMortise.p3 = p2 dMortise.invG = invG dMortise.mkrev = false -- disabilito la creazione del percorso in senso contrario dMortise.L3 = L3 dMortise.H3 = H3 dMortise.LGM = LG2 dMortise.LMM = LA dMortise.Nome = sCompoName dMortise.jne = jn2 -- calcolo la posizione dal centro seconda cava (mortasa) al centro della cava successiva if jn2 then dMortise.D_X = (D_X3-D_X) end -- lancio il secondo componente base MHgen = require('_Mortise') nGeom2, nPkToJoin2 = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) end -- setto le note che indicano su che lato della porta devono essere messe le geometrie if nGeom2 then EgtSetInfo(nGeom2,'SideDoor','Lock') end if nPkToJoin2 then EgtSetInfo(nPkToJoin2,'SideDoor','Lock') end end if bMakeMortGeom2nd then -- se terza cava abilitata -- cava mortasa local dMortise = {} -- assegno i valori coerenti con la tabella del componente dMortise.T = T2 dMortise.L2 = L3 dMortise.H2 = H3 dMortise.T2 = T3 dMortise.s = s3 dMortise.d = d3 dMortise.p = p3 dMortise.jn = jn2 dMortise.d3 = d3 dMortise.p3 = p3 dMortise.invG = invG dMortise.mkrev = false -- disabilito la creazione del percorso in senso contrario dMortise.jne = false -- non ci sono ulteriori cave, disabilito il join alla successiva dMortise.LGM = LG3 dMortise.LMM = LA3 dMortise.Nome = sCompoName -- calcolo la posizione dal centro seconda cava (mortasa) al centro della cava successiva dMortise.D_X = 0 -- lancio il secondo componente base MHgen = require('_Mortise') nGeom3, nPkToJoin3 = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) -- setto le note che indicano su che lato della porta devono essere messe le geometrie if nGeom3 then EgtSetInfo(nGeom3,'SideDoor','Lock') end if nPkToJoin3 then EgtSetInfo(nPkToJoin3,'SideDoor','Lock') end end if EC == 0 and nGeomFace and abs(nPosFace) > GEO.EPS_SMALL then -- se esiste solo la geometria face EgtMove( nGeomFace, Point3d(nPosFace,0,0) - ORIG()) end if EC == 0 and ( nGeom1st or nPkToJoin1st) and abs(nPos1st) > GEO.EPS_SMALL then -- se esiste la prima face if nGeom1st then EgtMove( nGeom1st, Point3d(nPos1st,0,0) - ORIG()) end if nPkToJoin1st then EgtMove( nPkToJoin1st, Point3d(nPos1st,0,0) - ORIG()) end end if EC == 0 and ( nGeom1 or nPkToJoin1) and abs(nPos2nd) > GEO.EPS_SMALL then -- se esiste la seconda face if nGeom1 then EgtMove( nGeom1, Point3d(nPos2nd,0,0) - ORIG()) end if nPkToJoin1 then EgtMove( nPkToJoin1, Point3d(nPos2nd,0,0) - ORIG()) end end if EC == 0 and mh and nGeom2 and abs(D_X) > GEO.EPS_SMALL then -- se esiste il secondo foro EgtMove( nGeom2, Point3d(D_X,0,0) - ORIG()) end if EC == 0 and not mh and ( nGeom2 or nPkToJoin2) and abs(D_X) > GEO.EPS_SMALL then -- se esiste la seconda cava if nGeom2 then EgtMove( nGeom2, Point3d(D_X,0,0) - ORIG()) end if nPkToJoin2 then EgtMove( nPkToJoin2, Point3d(D_X,0,0) - ORIG()) end end if EC == 0 and ( nGeom3 or nPkToJoin3) and abs(D_X3) > GEO.EPS_SMALL then -- se esiste la terza cava if nGeom3 then EgtMove( nGeom3, Point3d(D_X3,0,0) - ORIG()) end if nPkToJoin3 then EgtMove( nPkToJoin3, Point3d(D_X3,0,0) - ORIG()) end end -- se percorsi fatti con lo stesso utensile, li concateno if bMakeSecondFace then -- se doppia cava face if jn and EC == 0 and nPkToJoin1 and nPkToJoin2 then nPkJoin = EgtCurveCompo( Lg, {nPkToJoin1,nPkToJoin2}, true) if nPkJoin then EgtSetName( nPkJoin, LM) EgtSetInfo( nPkJoin, 'NotCheckDir', '1') -- se concatenata con la seconda cava (mortasa), forzo la posizione a Lock ( non segue angolo del profilo bevel) EgtSetInfo( nPkJoin, 'SideDoor', 'Lock') -- se mantiene centro spessore anche su face if kbs and kbs > 0 then EgtSetInfo( nPkJoin, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore EgtSetInfo( nGeom2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( nPkJoin, 'ProbeSide', '1') EgtSetInfo( nGeom2, 'ProbeSide', '1') end else EC = ErrorBase + 40 EM = string.format(EgtDoorsMsg[426], sCompoPath) end elseif not jn and EC == 0 and nPkToJoin2 then -- se mantiene centro spessore su mortise if kbs and kbs > 0 then EgtSetInfo( nPkToJoin2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore EgtSetInfo( nGeom2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( nPkToJoin2, 'ProbeSide', '1') EgtSetInfo( nGeom2, 'ProbeSide', '1') end end else -- seconda semi-cava non presente if not bMakeTwinFace then -- creata face completa if jn and EC == 0 and nPkToJoin1st and nPkToJoin2 then nPkJoin = EgtCurveCompo( Lg, {nPkToJoin1st,nPkToJoin2}, true) if nPkJoin then EgtSetName( nPkJoin, LM) EgtSetInfo( nPkJoin, 'NotCheckDir', '1') -- se concatenata con la seconda cava (mortasa), forzo la posizione a Lock ( non segue angolo del profilo bevel) EgtSetInfo( nPkJoin, 'SideDoor', 'Lock') -- se mantiene centro spessore anche su face if kbs and kbs > 0 then EgtSetInfo( nPkJoin, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore EgtSetInfo( nGeom2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( nPkJoin, 'ProbeSide', '1') EgtSetInfo( nGeom2, 'ProbeSide', '1') end else EC = ErrorBase + 41 EM = string.format(EgtDoorsMsg[426], sCompoPath) end elseif not jn and EC == 0 and nPkToJoin2 then -- se mantiene centro spessore su mortise if kbs and kbs > 0 then EgtSetInfo( nPkToJoin2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore EgtSetInfo( nGeom2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( nPkToJoin2, 'ProbeSide', '1') EgtSetInfo( nGeom2, 'ProbeSide', '1') end end end end if jn2 and EC == 0 and nDrawMach > 0 then if nPkJoin then -- se riuscito primo concatenamento nPkJoin1 = EgtCurveCompo( Lg, {nPkJoin,nPkToJoin3}, true) else nPkJoin1 = EgtCurveCompo( Lg, {nPkToJoin2,nPkToJoin3}, true) end if nPkJoin1 then if nPkJoin then EgtSetName( nPkJoin1, LM) -- se mantiene centro spessore anche su face if kbs and kbs > 0 then EgtSetInfo( nPkJoin1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore if nGeom3 then EgtSetInfo( nGeom3, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( nPkJoin1, 'ProbeSide', '1') if nGeom3 then EgtSetInfo( nGeom3, 'ProbeSide', '1') end end else EgtSetName( nPkJoin1, LA) -- se mantiene centro spessore su mortise if kbs and kbs > 0 then EgtSetInfo( nPkJoin1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore if nGeom3 then EgtSetInfo( nGeom3, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( nPkJoin1, 'ProbeSide', '1') if nGeom3 then EgtSetInfo( nGeom3, 'ProbeSide', '1') end end end EgtSetInfo( nPkJoin1, 'SideDoor', 'Lock') EgtSetInfo( nPkJoin1, 'NotCheckDir', '1') else EC = ErrorBase + 42 EM = string.format(EgtDoorsMsg[426], sCompoPath) end elseif not jn2 and EC == 0 and nDrawMach > 0 then -- altrimenti se non devo concatenare -- se mantiene centro spessore su mortise if kbs and kbs > 0 then if nPkToJoin3 then EgtSetInfo( nPkToJoin3, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end if nGeom3 then EgtSetInfo( nGeom3, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore end end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then if nPkToJoin3 then EgtSetInfo( nPkToJoin3, 'ProbeSide', '1') end if nGeom3 then EgtSetInfo( nGeom3, 'ProbeSide', '1') end end end -- aggiungo foro probe if EC == 0 and nDrawMach > 0 and posh and L then local dPosProbe = 0 local sPositiveSuffixProbe = '' local sNegativeSuffixProbe = '' if posp and posp > 0 then dPosProbe = (L/2) + posp if ( SL == 'R' and DGD.Push) or ( SL == 'L' and not DGD.Push) then sPositiveSuffixProbe = '_NEG' sNegativeSuffixProbe = '_POS' else sPositiveSuffixProbe = '_POS' sNegativeSuffixProbe = '_NEG' end end local pCentr = Point3d( dPosProbe, posh, 0) local hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) -- verifico se devo forzare direzione orizzontale o seguire il profilo local sSideDoorInfo if DGC.Fpd then sSideDoorInfo = 'Lock' else sSideDoorInfo = EgtIf( dl, 'Lock', 'Side') end if hintPr then EgtModifyCurveThickness( hintPr, -10) EgtSetName( hintPr, LH..sPositiveSuffixProbe) EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) end if dPosProbe > 0 then pCentr = Point3d( -dPosProbe, posh, 0) hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) if hintPr then EgtModifyCurveThickness( hintPr, -10) EgtSetName( hintPr, LH..sNegativeSuffixProbe) EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) end end end if EC == 0 and D_XE and D_XE ~= 0 then EgtMove( Lg, Point3d(0,D_XE,0) - ORIG()) end -- Se non Preview if not bPreview and EC == 0 then if bRunByCompo then -- scrivo i parametri nelle info del pezzo WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) end -- scrivo note nel layer della cerniera EgtSetInfo( Lg, 'Type' ,'EdgePullMortiseCyl') EgtSetInfo( Lg, 'Nome' ,sCompoName) EgtSetInfo( Lg, 'L' ,L) EgtSetInfo( Lg, 'H' ,H) EgtSetInfo( Lg, 'T' ,T) EgtSetInfo( Lg, 'T2nd' ,T2nd) EgtSetInfo( Lg, 'nPosT2nd' ,nPosT2nd) EgtSetInfo( Lg, 'd' ,d) EgtSetInfo( Lg, 'p' ,p) EgtSetInfo( Lg, 'sf' ,sf) EgtSetInfo( Lg, 'dl' ,dl) EgtSetInfo( Lg, 'mh' ,mh) EgtSetInfo( Lg, 'L2' ,L2) EgtSetInfo( Lg, 'H2' ,H2) EgtSetInfo( Lg, 'T2' ,T2) EgtSetInfo( Lg, 'd2' ,d2) EgtSetInfo( Lg, 'p2' ,p2) EgtSetInfo( Lg, 's' ,s) EgtSetInfo( Lg, 'L3' ,L3) EgtSetInfo( Lg, 'H3' ,H3) EgtSetInfo( Lg, 'T3' ,T3) EgtSetInfo( Lg, 'd3' ,d3) EgtSetInfo( Lg, 'p3' ,p3) EgtSetInfo( Lg, 's3' ,s3) EgtSetInfo( Lg, 'cl' ,cl) EgtSetInfo( Lg, 'rf' ,rf) EgtSetInfo( Lg, 'clc' ,clc) EgtSetInfo( Lg, 'ccr' ,ccr) EgtSetInfo( Lg, 'jn' ,jn) EgtSetInfo( Lg, 'jn2' ,jn2) EgtSetInfo( Lg, 'jnb' ,jnb) EgtSetInfo( Lg, 'D_X' ,D_X) EgtSetInfo( Lg, 'D_X3' ,D_X3) EgtSetInfo( Lg, 'D_XE' ,D_XE) EgtSetInfo( Lg, 'invG' ,invG) EgtSetInfo( Lg, 'posh' ,posh) EgtSetInfo( Lg, 'posp' ,posp) EgtSetInfo( Lg, 'ech' ,ech) EgtSetInfo( Lg, 'est' ,est) EgtSetInfo( Lg, 'kbs' ,kbs) EgtSetInfo( Lg, 'pbs' ,pbs) EgtSetInfo( Lg, 'LG' ,LG) EgtSetInfo( Lg, 'LG2' ,LG2) EgtSetInfo( Lg, 'LG3' ,LG3) EgtSetInfo( Lg, 'LM' ,LM) EgtSetInfo( Lg, 'LA' ,LA) EgtSetInfo( Lg, 'LA3' ,LA3) EgtSetInfo( Lg, 'CLC' ,CLC) EgtSetInfo( Lg, 'LGH' ,LGH) EgtSetInfo( Lg, 'LH' ,LH) EgtSetInfo( Lg, 'CH' ,CH) EgtSetInfo( Lg, 'Path' ,sCompoPath) end if EC == 0 and nCodAdj and nCodAdj < 0 then EC = nCodAdj EM = sCodAdj end return EC, EM, Lg end return EdgePullMortiseCyl