-- -- 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 -- -- _Mortise.lua by EgalWare s.r.l. 2016.06.14 -- Autore: Filippo Monchi -- Mortise, componente di secondo livello, non può essere chiamato direttamente da un lua dei -- componenti di interfaccia -- 2019.10.18 V2.000 FM Manage use Materials -- 2021.05.10 V2.001 FM Spliet case 3 pocket in 2 (now there are 5 cases) with better optimization for central line pocket -- 2021.12.01 V2.002 FM Manage side probe option if variable DGC.Pms > 2 -- 2024.04.29 V2.003 FM Verify step value (parameter 's') <> 0 -- 2024.07.19 V2.004 FM Set note 'NotCheckDir' to pocketing paths -- Tavola per definizione modulo (serve ma non usata) local _Mortise = {} -- Intestazioni require( 'EgtBase') EgtEnableDebug( false) -- per messaggi -- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') -- EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2) local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) if idTable then table.insert( idTable, nLine) end if bPrev then if bDrawFirst then local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) EgtSetColor(nCircle1, cColor1) end if bDrawLast then local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) EgtSetColor(nCircle2, cColor2) end end return nLine end local function DrawAddCircleDrawCircle( pCenter, dRadius, dAngIni, dAngCen, nGroup, idTable, bPrev, nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar) local nCircle = EgtArc( nGroup, pCenter, dRadius, dAngIni, dAngCen, 0, GDB_RT.LOC) local nNumCircle if idTable then table.insert( idTable, nCircle) -- se devo inserire una variazione nell'entità if sMVar then nNumCircle = #idTable end end if bPrev then if bDrawFirst then local nCircle1 = EgtCircle( nGroupCirc, EgtSP( nCircle), nRad , GDB_RT.LOC) EgtSetColor( nCircle1, cColor1) end if bDrawLast then local nCircle2 = EgtCircle( nGroupCirc, EgtEP( nCircle), nRad , GDB_RT.LOC) EgtSetColor( nCircle2, cColor2) end end return nCircle, nNumCircle, sMVar end -- Funzione di disegno function _Mortise.Draw( EC, EM, tMortiseParam, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) -- Assegno le dimensioni local T = tMortiseParam.T local L2 = tMortiseParam.L2 local H2 = tMortiseParam.H2 local T2 = tMortiseParam.T2 local s = tMortiseParam.s local d = tMortiseParam.d local p = tMortiseParam.p local jn = tMortiseParam.jn local d2 = tMortiseParam.d3 local p2 = tMortiseParam.p3 local invG = tMortiseParam.invG local mkrev = tMortiseParam.mkrev local jne = tMortiseParam.jne local jnt = tMortiseParam.jnt local L3 = tMortiseParam.L3 local H3 = tMortiseParam.H3 local TE = tMortiseParam.TE local D_X = tMortiseParam.D_X local smr = tMortiseParam.smr local pbs = tMortiseParam.pbs -- Assegno i nomi dei layer local LGM = tMortiseParam.LGM local LMM = tMortiseParam.LMM local DM = 'DUMMY' -- variabili per messaggi e settaggi vari local sCompoName = tMortiseParam.Nome -- RunByComponetInterface local RC = true -- Variabili per risalita distaccata local nDeltaMovX = 2 local nDeltaMovY = 2 if not bRunByCompo then RC = false end if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione nDrawMach = 0 end if not smr then smr = 0 end if not TE then TE = T end -- Layer local Dm if not Lg then Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale EgtSetName(Lg,sCompoName) end if nDrawMach > 0 then -- se abilitata geometria lavorazione Dm = EgtGroup(Pz,GDB_RT.LOC) -- layer disegni cerchi rappresentatte il diametro utensile EgtSetName(Dm,DM) end local tHint = {} local hint1, hint2, hint3, hint4, hint5 local hint_2, hintPk2, hintPk2_r local pIni, pEnd, pCen local invGy = 1 if nDrawMach ~= 1 and LGM then -- se abilitata geometria esterna -- Costruzione della geometria pIni = Point3d(0,(H2/2),0) if smr > 0 then pEnd = Point3d((L2/2)-0.5,(H2/2),0) else pEnd = Point3d(L2/2,(H2/2),0) end DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd if smr > 0 then pEnd = Point3d((L2/2),(H2/2)-0.5,0) pCen = Point3d((L2/2)-0.5,(H2/2)-0.5,0) DrawAddCircleDrawCircle( pCen, 0.5, 90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd pEnd = Point3d((L2/2),-(H2/2)+0.5,0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd pEnd = Point3d((L2/2)-0.5,-(H2/2),0) pCen = Point3d((L2/2)-0.5,-(H2/2)+0.5,0) DrawAddCircleDrawCircle( pCen, 0.5, 0,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd else pEnd = Point3d((L2/2),-(H2/2),0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd end if smr < 0 then pEnd = Point3d(-(L2/2)+0.5,-(H2/2),0) else pEnd = Point3d(-(L2/2),-(H2/2),0) end DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd if smr < 0 then pEnd = Point3d(-(L2/2),-(H2/2)+0.5,0) pCen = Point3d(-(L2/2)+0.5,-(H2/2)+0.5,0) DrawAddCircleDrawCircle( pCen, 0.5, -90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd pEnd = Point3d(-(L2/2),(H2/2)-0.5,0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd pEnd = Point3d(-(L2/2)+0.5,(H2/2),0) pCen = Point3d(-(L2/2)+0.5,(H2/2)-0.5,0) DrawAddCircleDrawCircle( pCen, 0.5, 180,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd else pEnd = Point3d(-(L2/2),(H2/2),0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd end pEnd = Point3d(0,(H2/2),0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) hint_2 = EgtCurveCompo( Lg, tHint, true) EgtModifyCurveThickness(hint_2, -T2) EgtSetName(hint_2,LGM) if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( hint_2, 'ProbeSide', '1') end end ---------------------------------------------- ---------------------------------------------- -- Costruzione delle geometrie di lavorazione ---------------------------------------------- ---------------------------------------------- local nOrigInvG = invG local nOrigInvGy = invGy if nDrawMach > 0 and LMM and s then -- se abilitata geometria lavorazione if not Lg then Lg = EgtGroup(Pz,GDB_RT.LOC) EgtSetName(Lg,sCompoName) end local tPocket2 = {} local tPocket2_r = {} local pIni_r, pEnd_r local pEnd2, pEnd2_r local nCase local nCaseNext local dZedStart local dZedWork local dZedStartTw --------------------------------------- -- geometria svuotatura giro interno --------------------------------------- local nStep local dStep local dPerim local nDirVers local nPass if jn then -- svuotature unite calcolo il numero di passi in Z -- individuo in che caso sono if abs(H2-d) < 0.03 then -- solo 1 passaggio in centro nCase = 1 elseif (H2-d) <= ( d*0.98) then -- solo passaggio di contornatura nCase = 2 elseif ((H2-d) > ( d*0.98)) and ( (H2-d) <= (d*(1+p))) then -- passaggio di contornatura + un passaggio centrale -- se sfrido rimenente è <= 1 lo tolgo alla fine if ((H2-d) <= ( d*1.10)) or ( H2 - (2*d)) <= 2 then nCase = 3 else nCase = 4 end elseif (H2-d) > (d*(1+p)) then -- passaggio di contornatura + passaggi zig zag nCase = 5 end dPerim = 2*( H2 + L2 -(2*d)) -- step face: per compatibilità con tutti i componenti, se non è definito lo setto = alla profondità cava if not s or abs(s) <= GEO.EPS_SMALL then s = T2-T end nStep = ceil((T2-T)/s) -- numero di passate dStep = ((T2-T)/nStep) -- passo ricalcolato dZedStart = -T dZedStartTw = -TE else -- svuotature separate ricalcolo i casi e il numero di passi in Z -- individuo in che caso sono if abs(H2-d2) < 0.03 then -- solo 1 passaggio in centro nCase = 1 elseif (H2-d2) <= ( d2*0.98) then -- solo passaggio di contornatura nCase = 2 elseif ((H2-d2) > ( d2*0.98)) and ( (H2-d2) <= (d2*(1+p2))) then -- passaggio di contornatura + un passaggio centrale -- se sfrido rimenente è <= 1 lo tolgo alla fine if ((H2-d2) <= ( d2*1.10)) or ( H2 - (2*d2)) <= 2 then nCase = 3 else nCase = 4 end elseif (H2-d2) > (d2*(1+p2)) then -- passaggio di contornatura + passaggi zig zag nCase = 5 end dPerim = 2*( H2 + L2 -(2*d2)) -- step face: per compatibilità con tutti i componenti, se non è definito lo setto = alla profondità cava if not s or abs(s) <= GEO.EPS_SMALL then s = T2 end nStep = ceil(T2/s) -- numero di passate dStep = (T2/nStep) -- passo ricalcolato dZedStart = 0 dZedStartTw = 0 end if jn then -- svuotature unite if nCase == 1 then -- solo 1 passaggio in centro nPass = 1 nDirVers = 1 local nDoubleStep = nStep * 2 pEnd = Point3d(-((L2-d)/2)*invG,0,dZedStart) if mkrev then -- se abilitato anche il percorso inverso pEnd_r = Point3d(((L2-d)/2)*invG,0,dZedStart) end while nPass <= nDoubleStep do -- primo mezzo passo nDirVers = - nDirVers pIni = pEnd dZedWork = dZedStart - ((dStep * nPass)/2) if nPass == nDoubleStep then dZedWork = -T2 end pEnd = Point3d((-nDirVers*((L2-d)/2))*invG,0,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d((nDirVers*((L2-d)/2))*invG,0,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end nPass = nPass + 1 end -- ultimo mezzo passo nDirVers = - nDirVers pIni = pEnd dZedWork = -T2 pEnd = Point3d((-nDirVers*((L2-d)/2))*invG,0,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d((nDirVers*((L2-d)/2))*invG,0,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end pIni = pEnd if jne then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria if jnt then -- se ho cava doppia e devo risalire in Z if ( nDeltaMovX > (L2-d)) then nDeltaMovX = (L2-d) end -- Uscita in Z inizio dZedWork = dZedStartTw pEnd = Point3d(-nDirVers*(((L2-d)/2)-nDeltaMovX)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) pIni = pEnd if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(nDirVers*(((L2-d)/2)-nDeltaMovX)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) end end -- calcolo in che caso sono con la prossima geometria if abs(H3-d) < 0.03 then -- solo 1 passaggio in centro nCaseNext = 1 else nCaseNext = 0 end if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta pEnd = Point3d((-(((L3-d)/2)*invG)+D_X),0,dZedWork) else pEnd = Point3d(((((L3-d)/2)*invG)+D_X),((H3-d)/2)*invGy,dZedWork) end DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta pEnd_r = Point3d(((((L3-d)/2)*invG)+D_X),0,dZedWork) else pEnd_r = Point3d((-(((L3-d)/2)*invG)+D_X),((H3-d)/2)*invGy,dZedWork) end DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end else -- Uscita in Z0 dZedWork = 0 if ( nDeltaMovX > (L2-d)) then nDeltaMovX = (L2-d) end pEnd = Point3d(-nDirVers*(((L2-d)/2)-nDeltaMovX)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(nDirVers*(((L2-d)/2)-nDeltaMovX)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) end end -- solo contornatura or contornatura + un passaggio centrale or contornatura + passaggi svuotatura elseif ( nCase == 2) or ( nCase == 3) or ( nCase == 4) or ( nCase == 5) then nPass = 1 pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedStart) if mkrev then -- se abilitato anche il percorso inverso pEnd_r = Point3d(-((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedStart) end while nPass <= nStep do if nCase > 2 then -- se ho la svuotatura centrale scendo direttamente al passo -- prima linea discendente pIni = pEnd dZedWork = dZedStart - dStep if nPass == nStep then dZedWork = -T2 end pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end end -- prima linea contorno pIni = pEnd if nCase == 2 then dZedWork = dZedStart - ( dStep*((H2-d)/dPerim)) end pEnd = Point3d(((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- seconda linea contorno pIni = pEnd if nCase == 2 then dZedWork = dZedStart - ( dStep*((H2+L2-(2*d))/dPerim)) end pEnd = Point3d(-((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- terza linea contorno pIni = pEnd if nCase == 2 then dZedWork = dZedStart - ( dStep*(((2*H2)+L2-(3*d))/dPerim)) end pEnd = Point3d(-((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- quarta linea contorno pIni = pEnd if nCase == 2 then dZedWork = dZedStart - dStep if nPass == nStep then dZedWork = -T2 end end pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- Se passaggio di contornatura e sono all'ultimo passo, faccio ancora un giro di contorno if nCase == 2 and nPass == nStep then -- passaggio di contornatura pIni = pEnd pEnd = Point3d(((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- seconda linea contorno pIni = pEnd pEnd = Point3d(-((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- terza linea contorno pIni = pEnd pEnd = Point3d(-((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- quarta linea contorno pIni = pEnd pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) if ( nDeltaMovX > ((L2-d)/2)) then -- se delta più grande di metà cava in X nDeltaMovX = (L2-d)/2 end if ( nDeltaMovY > ((H2-d)/2)) then -- se delta più grande di metà cava in Y nDeltaMovY = (H2-d)/2 end pEnd2 = Point3d((((L2-d)/2)-nDeltaMovX)*invG,(((H2-d)/2)-nDeltaMovY)*invGy, EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d)/2)*invG,((H2-d)/2),dZedWork) pEnd2_r = Point3d(-(((L2-d)/2)-nDeltaMovX)*invG,(((H2-d)/2)-nDeltaMovY)*invGy, EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end end -- Se passaggio di contornatura e sono all'ultimo passo, faccio il passaggio centrale if nCase == 3 and nPass == nStep then -- passaggio di contornatura centrale finale -- quinta linea posizionamento passata centrale pIni = pEnd pEnd = Point3d((((L2*2)-(d*3))/4)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, LIME(), LIME()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-(((L2*2)-(d*3))/4)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) end -- sesta linea passata centrale pIni = pEnd pEnd = Point3d(-(((L2*2)-(d*3))/4)*invG,0,dZedWork) pEnd2 = Point3d(-(((L2*2)-(d*3))/4)*invG,0, EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, LIME(), LIME()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d((((L2*2)-(d*3))/4)*invG,0,dZedWork) pEnd2_r = Point3d((((L2*2)-(d*3))/4)*invG,0, EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) end end if nCase == 4 then -- passaggio di contornatura + un passaggio centrale e inverto la direzione -- quinta linea posizionamento passata centrale pIni = pEnd pEnd = Point3d((((L2*2)-(d*3))/4)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, LIME(), LIME()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-(((L2*2)-(d*3))/4)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) end -- sesta linea passata centrale pIni = pEnd pEnd = Point3d(-(((L2*2)-(d*3))/4)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, LIME(), LIME()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d((((L2*2)-(d*3))/4)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) end -- settima linea ritorno a posizione iniziale -- pIni = pEnd -- pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2),dZedWork) -- cambio il posizionamento della posizione iniziale pIni = pEnd invG = -invG -- setto per cambiare la posizione del percorso di inizio invGy = -invGy -- setto per cambiare il senso di direzione della svuotatura pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) if ( nDeltaMovX > ((L2-d)/2)) then -- se delta più grande di metà cava in X nDeltaMovX = (L2-d)/2 end if ( nDeltaMovY > ((H2-d)/2)) then -- se delta più grande di metà cava in Y nDeltaMovY = (H2-d)/2 end pEnd2 = Point3d((((L2-d)/2)-nDeltaMovX)*invG,(((H2-d)/2)-nDeltaMovY)*invGy, EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) pEnd2_r = Point3d(-(((L2-d)/2)-nDeltaMovX)*invG,(((H2-d)/2)-nDeltaMovY)*invGy, EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end elseif nCase == 5 then -- passaggio di contornatura + passaggi svuotatura nDirVers = -1 local nDistYcentr = (d*p) local nPosYcentr = ((H2-d)/2) - nDistYcentr local bContinue = nPosYcentr > -(((H2-d)/2)-(d/2)) -- linea posizionamento passaggi svuotatura pIni = pEnd pEnd = Point3d((-nDirVers * (((L2*2)-(d*3))/4))*invG,nPosYcentr,dZedWork) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d((nDirVers * (((L2*2)-(d*3))/4))*invG,nPosYcentr,dZedWork) end -- ciclo passate svuotatura while bContinue do -- linea affondamento in Y DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) if mkrev then -- se abilitato anche il percorso inverso DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) end -- linea passata in X pIni = pEnd pEnd = Point3d((nDirVers * (((L2*2)-(d*3))/4))*invG,nPosYcentr,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d((-nDirVers * (((L2*2)-(d*3))/4))*invG,nPosYcentr,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) end -- calcolo nuovo passo in Y e indice direzione nPosYcentr = nPosYcentr - nDistYcentr bContinue = nPosYcentr > -(((H2-d)/2)-(d/2)) -- calcolo prossimo punto solo se sono ancora dentro l'area if bContinue then nDirVers = -nDirVers -- ricalcolo punti per linea successiva pIni = pEnd pEnd = Point3d((-nDirVers * (((L2*2)-(d*3))/4))*invG,nPosYcentr,dZedWork) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-(-nDirVers * (((L2*2)-(d*3))/4))*invG,nPosYcentr,dZedWork) end end end -- ultima linea ritorno a posizione iniziale pIni = pEnd pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2),dZedWork) if ( nDeltaMovX > ((L2-d)/2)) then -- se delta più grande di metà cava in X nDeltaMovX = (L2-d)/2 end if ( nDeltaMovY > ((H2-d)/2)) then -- se delta più grande di metà cava in Y nDeltaMovY = (H2-d)/2 end pEnd2 = Point3d((((L2-d)/2)-nDeltaMovX)*invG,(((H2-d)/2)-nDeltaMovY), EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d)/2)*invG,((H2-d)/2),dZedWork) pEnd2_r = Point3d(-(((L2-d)/2)-nDeltaMovX)*invG,(((H2-d)/2)-nDeltaMovY), EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end end nPass = nPass + 1 dZedStart = dZedStart - dStep end pIni = pEnd if jne then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria if jnt then -- se ho cava doppia e devo risalire in Z -- Uscita in Z0 dZedWork = dZedStartTw DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket2, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) pIni = pEnd2 if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r DrawAddLineDrawCircle( pIni_r, pEnd2_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) pEnd_r = pEnd2_r end end -- calcolo in che caso sono con la prossima geometria if abs(H3-d) < 0.03 then -- solo 1 passaggio in centro nCaseNext = 1 else nCaseNext = 0 end -- se sono nel caso che ho continuato ad invertire le posizionei if nCase == 4 then invG = nOrigInvG invGy = nOrigInvGy end if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta pEnd = Point3d((-(((L3-d)/2)*invG)+D_X),0,dZedWork) else pEnd = Point3d(((((L3-d)/2)*invG)+D_X),((H3-d)/2)*invGy,dZedWork) end DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta pEnd_r = Point3d(((((L3-d)/2)*invG)+D_X),0,dZedWork) else pEnd_r = Point3d((-(((L3-d)/2)*invG)+D_X),((H3-d)/2)*invGy,dZedWork) end DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end else -- Uscita in Z0 DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket2, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r DrawAddLineDrawCircle( pIni_r, pEnd2_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) end end end else -- svuotature separate if nCase == 1 then -- solo 1 passaggio in centro nPass = 1 nDirVers = 1 dZedStart = 0 pEnd = Point3d((-nDirVers*((L2-d2)/2))*invG,0,dZedStart) -- nuovo punto finale hint3 = EgtCircle( Dm, pEnd, (d2/2) , GDB_RT.LOC) EgtSetColor(hint3,PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pEnd_r = Point3d((nDirVers*((L2-d2)/2))*invG,0,dZedStart) -- nuovo punto finale end local nDoubleStep = nStep * 2 while nPass <= nDoubleStep do -- primo mezzo passo nDirVers = - nDirVers pIni = pEnd dZedWork = dZedStart - ((dStep * nPass)/2) if nPass == nDoubleStep then dZedWork = -T2 end pEnd = Point3d((-nDirVers*((L2-d2)/2))*invG,0,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d((nDirVers*((L2-d2)/2))*invG,0,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end nPass = nPass + 1 end -- ultimo mezzo passo nDirVers = - nDirVers pIni = pEnd dZedWork = -T2 pEnd = Point3d((-nDirVers*((L2-d2)/2))*invG,0,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d((nDirVers*((L2-d2)/2))*invG,0,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end pIni = pEnd if jne then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria if jnt then -- se ho cava doppia e devo risalire in Z if ( nDeltaMovX > (L2-d2)) then nDeltaMovX = (L2-d2) end -- Uscita in Z0 dZedWork = dZedStartTw pEnd = Point3d(-nDirVers*(((L2-d2)/2)-nDeltaMovX)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, GREEN(), GREEN()) pIni = pEnd if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(nDirVers*(((L2-d2)/2)-nDeltaMovX)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) end end -- calcolo in che caso sono con la prossima geometria if abs(H3-d) < 0.03 then -- solo 1 passaggio in centro nCaseNext = 1 else nCaseNext = 0 end if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta pEnd = Point3d((-(((L3-d)/2)*invG)+D_X),0,dZedWork) else pEnd = Point3d(((((L3-d)/2)*invG)+D_X),((H3-d)/2),dZedWork) end DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta pEnd_r = Point3d(((((L3-d)/2)*invG)+D_X),0,dZedWork) else pEnd_r = Point3d((-(((L3-d)/2)*invG)+D_X),((H3-d)/2),dZedWork) end DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end else -- Uscita in Z0 dZedWork = 0 if ( nDeltaMovX > (L2-d2)) then nDeltaMovX = (L2-d2) end pEnd = Point3d(-nDirVers*(((L2-d2)/2)-nDeltaMovX)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, GREEN(), GREEN()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(nDirVers*(((L2-d2)/2)-nDeltaMovX)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) end end -- solo contornatura or contornatura + un passaggio centrale or contornatura + passaggi svuotatura elseif ( nCase == 2) or ( nCase == 3) or ( nCase == 4) or ( nCase == 5) then nPass = 1 nDirVers = 1 dZedStart = 0 pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedStart) -- nuovo punto finale hint3 = EgtCircle( Dm, pEnd, (d2/2) , GDB_RT.LOC) EgtSetColor(hint3,PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pEnd_r = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedStart) -- nuovo punto finale end while nPass <= nStep do if nCase > 2 then -- se ho la svuotatura centrale scendo direttamente al passo -- prima linea discendente pIni = pEnd dZedWork = dZedStart - dStep if nPass == nStep then dZedWork = -T2 end pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end end -- prima linea contorno pIni = pEnd if nCase == 2 then dZedWork = dZedStart - ( dStep*((H2-d2)/dPerim)) end pEnd = Point3d(((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- seconda linea contorno pIni = pEnd if nCase == 2 then dZedWork = dZedStart - ( dStep*((H2+L2-(2*d2))/dPerim)) end pEnd = Point3d(-((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- terza linea contorno pIni = pEnd if nCase == 2 then dZedWork = dZedStart - ( dStep*(((2*H2)+L2-(3*d2))/dPerim)) end pEnd = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- quarta linea contorno pIni = pEnd if nCase == 2 then dZedWork = dZedStart - dStep if nPass == nStep then dZedWork = -T2 end end pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- Se passaggio di contornatura e sono all'ultimo passo, faccio ancora un giro di contorno if nCase == 2 and nPass == nStep then -- passaggio di contornatura -- prima linea contorno pIni = pEnd pEnd = Point3d(((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- seconda linea contorno pIni = pEnd pEnd = Point3d(-((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- terza linea contorno pIni = pEnd pEnd = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end -- quarta linea contorno pIni = pEnd pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) if ( nDeltaMovX > ((L2-d2)/2)) then -- se delta più grande di metà cava in X nDeltaMovX = (L2-d2)/2 end if ( nDeltaMovY > ((H2-d2)/2)) then -- se delta più grande di metà cava in Y nDeltaMovY = (H2-d2)/2 end pEnd2 = Point3d((((L2-d2)/2)-nDeltaMovX)*invG,(((H2-d2)/2)-nDeltaMovY)*invGy,EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2),dZedWork) pEnd2_r = Point3d(-(((L2-d2)/2)-nDeltaMovX)*invG,(((H2-d2)/2)-nDeltaMovY)*invGy,EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end end -- Se passaggio di contornatura e sono all'ultimo passo, faccio il passaggio centrale if nCase == 3 and nPass == nStep then -- passaggio di contornatura centrale finale -- quinta linea posizionamento passata centrale pIni = pEnd pEnd = Point3d((((L2*2)-(d2*3))/4)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, LIME(), LIME()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-(((L2*2)-(d2*3))/4)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) end -- sesta linea passata centrale pIni = pEnd pEnd = Point3d(-(((L2*2)-(d2*3))/4)*invG,0,dZedWork) pEnd2 = Point3d(-(((L2*2)-(d2*3))/4)*invG,0, EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, LIME(), LIME()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d((((L2*2)-(d2*3))/4)*invG,0,dZedWork) pEnd2_r = Point3d((((L2*2)-(d2*3))/4)*invG,0, EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) end end if nCase == 4 then -- passaggio di contornatura + un passaggio centrale e inverto la direzione -- quinta linea posizionamento passata centrale pIni = pEnd pEnd = Point3d((((L2*2)-(d2*3))/4)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, LIME(), LIME()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-(((L2*2)-(d2*3))/4)*invG,0,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) end -- sesta linea passata centrale pIni = pEnd pEnd = Point3d(-(((L2*2)-(d2*3))/4)*invG,0,dZedWork) pEnd2 = Point3d(-(((L2*2)-(d2*3))/4)*invG,0, EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, LIME(), LIME()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d((((L2*2)-(d2*3))/4)*invG,0,dZedWork) pEnd2_r = Point3d((((L2*2)-(d2*3))/4)*invG,0, EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) end -- settima linea ritorno a posizione iniziale -- pIni = pEnd -- pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2),dZedWork) pIni = pEnd invG = -invG -- setto per cambiare la posizione del percorso di inizio invGy = -invGy -- setto per cambiare il senso di percorrenza del percorso pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) if ( nDeltaMovX > ((L2-d2)/2)) then -- se delta più grande di metà cava in X nDeltaMovX = (L2-d2)/2 end if ( nDeltaMovY > ((H2-d2)/2)) then -- se delta più grande di metà cava in Y nDeltaMovY = (H2-d2)/2 end pEnd2 = Point3d((((L2-d2)/2)-nDeltaMovX)*invG,(((H2-d2)/2)-nDeltaMovY)*invGy,EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) pEnd2_r = Point3d(-(((L2-d2)/2)-nDeltaMovX)*invG,(((H2-d2)/2)-nDeltaMovY)*invGy,EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end elseif nCase == 5 then -- passaggio di contornatura + passaggi svuotatura nDirVers = -1 local nDistYcentr = (d2*p2) local nPosYcentr = ((H2-d2)/2) - nDistYcentr local bContinue = nPosYcentr > -(((H2-d2)/2)-(d2/2)) -- linea posizionamento passaggi svuotatura pIni = pEnd pEnd = Point3d((-nDirVers * (((L2*2)-(d2*3))/4))*invG,nPosYcentr,dZedWork) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d((nDirVers * (((L2*2)-(d2*3))/4))*invG,nPosYcentr,dZedWork) end -- ciclo passate svuotatura while bContinue do -- linea affondamento in Y DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, YELLOW(), YELLOW()) if mkrev then -- se abilitato anche il percorso inverso DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) end -- linea passata in X pIni = pEnd pEnd = Point3d((nDirVers * (((L2*2)-(d2*3))/4))*invG,nPosYcentr,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, YELLOW(), YELLOW()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d((-nDirVers * (((L2*2)-(d2*3))/4))*invG,nPosYcentr,dZedWork) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) end -- calcolo nuovo passo in Y e indice direzione nPosYcentr = nPosYcentr - nDistYcentr bContinue = nPosYcentr > -(((H2-d2)/2)-(d2/2)) -- calcolo prossimo punto solo se sono ancora dentro l'area if bContinue then nDirVers = -nDirVers -- ricalcolo punti per linea successiva pIni = pEnd pEnd = Point3d((-nDirVers * (((L2*2)-(d2*3))/4))*invG,nPosYcentr,dZedWork) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d((nDirVers * (((L2*2)-(d2*3))/4))*invG,nPosYcentr,dZedWork) end end end -- ultima linea ritorno a posizione iniziale pIni = pEnd pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2),dZedWork) if ( nDeltaMovX > ((L2-d2)/2)) then -- se delta più grande di metà cava in X nDeltaMovX = (L2-d2)/2 end if ( nDeltaMovY > ((H2-d2)/2)) then -- se delta più grande di metà cava in Y nDeltaMovY = (H2-d2)/2 end pEnd2 = Point3d((((L2-d2)/2)-nDeltaMovX)*invG,(((H2-d2)/2)-nDeltaMovY),EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r pEnd_r = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2),dZedWork) pEnd2_r = Point3d(-(((L2-d2)/2)-nDeltaMovX)*invG,(((H2-d2)/2)-nDeltaMovY),EgtIf(jnt,dZedStartTw,0)) DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end end nPass = nPass + 1 dZedStart = dZedStart - dStep end pIni = pEnd if jne then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria if jnt then -- se ho cava doppia e devo risalire in Z -- Uscita in Z0 dZedWork = dZedStartTw DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, GREEN(), GREEN()) pIni = pEnd2 if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r DrawAddLineDrawCircle( pIni_r, pEnd2_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) pEnd_r = pEnd2_r end end -- calcolo in che caso sono con la prossima geometria if abs(H3-d) < 0.03 then -- solo 1 passaggio in centro nCaseNext = 1 else nCaseNext = 0 end -- se sono nel caso che ho continuato ad invertire le posizionei if nCase == 4 then invG = nOrigInvG invGy = nOrigInvGy end if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta pEnd = Point3d((-(((L3-d)/2)*invG)+D_X),0,dZedWork) else pEnd = Point3d(((((L3-d)/2)*invG)+D_X),((H3-d)/2)*invGy,dZedWork) end DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta pEnd_r = Point3d(((((L3-d)/2)*invG)+D_X),0,dZedWork) else pEnd_r = Point3d((-(((L3-d)/2)*invG)+D_X),((H3-d)/2)*invGy,dZedWork) end DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) end else -- Uscita in Z0 DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, GREEN(), GREEN()) if mkrev then -- se abilitato anche il percorso inverso pIni_r = pEnd_r DrawAddLineDrawCircle( pIni_r, pEnd2_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) end end end end -- trasformo in geometria composita i/il percorsi/o di svuotatura -- secondo percorso if ( #tPocket2 > 0) then hintPk2 = EgtCurveCompo( Lg, tPocket2, true) if hintPk2 then EgtModifyCurveThickness(hintPk2, 0) EgtSetName(hintPk2,LMM) if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( hintPk2, 'ProbeSide', '1') end end end if ( #tPocket2_r > 0) then hintPk2_r = EgtCurveCompo( Lg, tPocket2_r, true) if hintPk2_r then EgtModifyCurveThickness(hintPk2_r, 0) EgtSetName(hintPk2_r,(LMM..'_R')) if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( hintPk2_r, 'ProbeSide', '1') end end end end -- cambio colore alla geometria if bPreview then if EC == 0 then if hint_2 then EgtSetColor(hint_2,AQUA()) end if hintPk2 then EgtSetColor(hintPk2,AQUA()) end if hintPk2_r then EgtSetColor(hintPk2_r,AQUA()) end else if hint_2 then EgtSetColor(hint_2,ORANGE()) end if hintPk2 then EgtSetColor(hintPk2,ORANGE()) end if hintPk2_r then EgtSetColor(hintPk2_r,ORANGE()) end end else -- altrimenti non Preview -- cancello le parti ausiliarie se disegnate if Dm then EgtErase( Dm) end -- assegno nota su percorsi svuotatura if hintPk2 then EgtSetInfo( hintPk2, 'NotCheckDir', '1') end if hintPk2_r then EgtSetInfo( hintPk2_r, 'NotCheckDir', '1') end end return hint_2, hintPk2, hintPk2_r end return _Mortise