diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index 04d512a..a7e2b36 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -392,36 +392,96 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) nSCC = MCH_SCC.NONE end EgtSetMachiningParam( MCH_MP.SCC, nSCC) + + ----------------------------------------- -- aggiusto l'affondamento - local sMyWarn +-- local sMyWarn +-- local dMaxElev = dDepth +-- local dToolAddLength = 0 +-- -- se c'è un taglio precedente di testa o coda posso impostare MaxElev per allungare il percorso +-- -- considero solo i fori "entranti" in testa o coda +-- if ( Proc.MachineAfterHeadCutId and vtExtr:getX() > 0) or ( Proc.MachineAfterTailCutId and vtExtr:getX() < 0) then +-- local ptCen = EgtCP( AuxId, GDB_RT.GLOB) +-- local bIntersectionOk, _, vDistance = EgtLineSurfTmInters( ptCen, -vtExtr, Proc.MachineAfterHeadCutId or Proc.MachineAfterTailCutId, GDB_RT.GLOB) +-- dHoleToCutDistance = vDistance[1] +-- -- il segno della distanza data dalla funzione di intersezione mi indica dove sia la geometria del foro +-- if bIntersectionOk then +-- if dHoleToCutDistance > 0 then +-- dMaxElev = dLen - dHoleToCutDistance +-- elseif dHoleToCutDistance < 0 then +-- dMaxElev = -dHoleToCutDistance +-- end +-- dToolAddLength = dLen - dMaxElev +-- end +-- end +-- if dDepth - dToolAddLength > dMaxDepth + 10 * GEO.EPS_SMALL then +-- sMyWarn = 'Warning in drill : depth (' .. EgtNumToString( dDepth - dToolAddLength, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' +-- if dMaxDepth == 0 or dToolAddLength == 0 then +-- dDepth = dMaxDepth +-- dMaxElev = dDepth +-- elseif abs( dMaxElev - dDepth) > GEO.EPS_SMALL then +-- dDepth = dLen +-- end +-- EgtOutLog( sMyWarn) +-- end + ------------------------------------------ + + -- aggiusto affondamento e MaxElev local dMaxElev = dDepth - local dToolAddLength = 0 - -- se c'è un taglio precedente di testa o coda posso impostare MaxElev per allungare il percorso - -- considero solo i fori "entranti" in testa o coda - if ( Proc.MachineAfterHeadCutId and vtExtr:getX() > 0) or ( Proc.MachineAfterTailCutId and vtExtr:getX() < 0) then - local ptCen = EgtCP( AuxId, GDB_RT.GLOB) - local bIntersectionOk, _, vDistance = EgtLineSurfTmInters( ptCen, -vtExtr, Proc.MachineAfterHeadCutId or Proc.MachineAfterTailCutId, GDB_RT.GLOB) - dHoleToCutDistance = vDistance[1] - -- il segno della distanza data dalla funzione di intersezione mi indica dove sia la geometria del foro - if bIntersectionOk then - if dHoleToCutDistance > 0 then - dMaxElev = dLen - dHoleToCutDistance - elseif dHoleToCutDistance < 0 then - dMaxElev = -dHoleToCutDistance + local sMyWarn + if dDepth > dMaxDepth + 10 * GEO.EPS_SMALL then + -- se c'è un taglio precedente di testa o coda posso impostare MaxElev per allungare il percorso + -- considero solo i fori "entranti" in testa o coda + if (( Proc.MachineAfterHeadCutId and vtExtr:getX() > 0) or ( Proc.MachineAfterTailCutId and vtExtr:getX() < 0)) and dMaxDepth ~= 0 then + local ptCen = EgtCP( AuxId, GDB_RT.GLOB) + local bIntersectionOk, _, vDistance = EgtLineSurfTmInters( ptCen, -vtExtr, Proc.MachineAfterHeadCutId or Proc.MachineAfterTailCutId, GDB_RT.GLOB) + dHoleToCutDistance = vDistance[1] + -- setto MaxElev + -- il segno della distanza data dalla funzione di intersezione mi indica dove sia la geometria del foro + if bIntersectionOk then + if dHoleToCutDistance > 0 then + dMaxElev = dLen - dHoleToCutDistance + elseif dHoleToCutDistance < 0 then + dMaxElev = -dHoleToCutDistance + end + local dToolAddLength = dLen - dMaxElev + -- se l'utensile è comunque troppo corto lavoro il massimo possibile + if dDepth - dToolAddLength > dMaxDepth + 10 * GEO.EPS_SMALL then + sMyWarn = 'Warning in drill : depth (' .. EgtNumToString( dDepth - dToolAddLength, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' + dDepth = dLen + else + dMaxElev = dMaxElev - dLen + dDepth + end + -- se per qualche motivo fallisce l'intersezione torno al caso standard + else + sMyWarn = 'Warning in drill : depth (' .. EgtNumToString( dDepth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' + dDepth = dMaxDepth + dMaxElev = dMaxDepth end - dToolAddLength = dLen - dMaxElev - end - end - if dDepth - dToolAddLength > dMaxDepth + 10 * GEO.EPS_SMALL then - sMyWarn = 'Warning in drill : depth (' .. EgtNumToString( dDepth - dToolAddLength, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' - if dMaxDepth == 0 or dToolAddLength == 0 then + -- caso standard + else + sMyWarn = 'Warning in drill : depth (' .. EgtNumToString( dDepth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' dDepth = dMaxDepth - dMaxElev = dDepth - elseif abs( dMaxElev - dDepth) > GEO.EPS_SMALL then - dDepth = dLen + dMaxElev = dMaxDepth + end + if sMyWarn then + EgtOutLog( sMyWarn) end - EgtOutLog( sMyWarn) end + + + + + + + + + + + + + + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) -- Note utente con dichiarazione nessuna generazione sfridi per Vmill local sUserNotes = 'VMRS=0;'