diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 884a700..e240285 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -260,7 +260,7 @@ if bToProcess then -- Assegno lunghezza della barra dBarLen = vBeam[1].Box:getDimX() + 10 if dBarLen < 2200 then - dBarLen = dBarLen + 1600 + dBarLen = dBarLen + 1800 end -- Assegno posizione prima ed unica trave vBeam[1].PosX = 10 diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index b1d3f92..7e94afe 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -483,12 +483,12 @@ local function OrderFeatures( vProc, b3Raw) if abs( B2.Box:getDimX() - b3Raw:getDimX()) < 0.2 * b3Raw:getDimX() then return B1.Box:getMax():getZ() > B2.Box:getMax():getZ() else - return B1.Box:getMin():getX() + 50 > B2.Box:getCenter():getX() + return B2.Tail or B1.Box:getMin():getX() + 20 > B2.Box:getCenter():getX() end end -- se secondo è taglio longitudinale completo o altra lav. lunga, dopo tutte le altre feature non di coda if abs( B2.Box:getDimX() - b3Raw:getDimX()) < 0.2 * b3Raw:getDimX() then - return B1.Box:getCenter():getX() > B2.Box:getMin():getX() + 50 + return not ( B1.Tail or B2.Box:getMin():getX() + 20 > B1.Box:getCenter():getX()) end -- se primo è foro e l'altro no, lo penalizzo if B1.Prc == 40 and B2.Prc ~= 40 then diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index 3c14306..91805c7 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -1,7 +1,8 @@ --- ProcessDrill.lua by Egaltech s.r.l. 2021/05/03 +-- ProcessDrill.lua by Egaltech s.r.l. 2021/09/19 -- Gestione calcolo forature per Travi -- 2021/04/14 DS Corretta gestione Invert con testa da sotto. Migliorato calcolo ingombro portautensile. -- 2021/05/03 DS Su macchina con testa da sotto aggiunta possibilità di fare fori verticali metà sopra e l'altra sotto. +-- 2021/09/19 DS Si premia il più possibile ricerca punta con adeguato affondamento. -- Tabella per definizione modulo local ProcessDrill = {} @@ -111,9 +112,6 @@ function ProcessDrill.Split( Proc, b3Raw) if not bTrySplit then return false end - -- recupero la lavorazione - local sDrilling, _, dMaxMat = ML.FindDrilling( dDiam, 0, bDrillDown) - if not sDrilling then dMaxMat = 0 end -- restituisco se va fatto in doppio (solo fori orizzontali) local bHoriz = ( abs( vtExtr:getZ()) < abs( BD.DRILL_VZ_MIN) and ( abs( vtExtr:getY()) * b3Raw:getDimZ() > abs( vtExtr:getZ()) * b3Raw:getDimY() or Proc.Fce == 5 or Proc.Fce == 6)) @@ -191,12 +189,12 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) EgtOutLog( sErr) return false, sErr end - -- se il foro può non essere passante (bOpen vale false) inverto + -- se il foro è cieco all'inizio, lo inverto if Proc.Fcs == 0 then bToInvert = true end if bToInvert then vtExtr = - vtExtr end -- se foro è splittato ed è la parte opposta, inverto if Proc.Flg == -2 then bToInvert = true end - -- profondità geometria foro + -- profondità geometrica del foro local dDepth = dLen local dDepth2 = dLen if Proc.Flg == 2 or Proc.Flg == -2 then @@ -205,37 +203,28 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) local dCheckDepth = dDepth local dCheckDepth2 = dDepth2 local nErrorCode = 0 - -- se troppo inclinata sulla X o Y va troppo dietro o Z va in negativo o se il foro è splittato, - -- annullo il valore della profondità nella ricerca utensile - if abs(vtExtr:getX()) > 0.707 or vtExtr:getY() > 0.5 or vtExtr:getZ() < BD.DRILL_VZ_MIN or abs(Proc.Flg) == 2 then - dCheckDepth = nil - dCheckDepth2 = nil - end -- abilitazione foratura da sotto local bDrillDown = ( BD.DOWN_HEAD and ( Proc.Down or vtExtr:getZ() < -0.1 or vtExtr:getZ() < 0.259)) local bDrillUp = ( BD.DOWN_HEAD and vtExtr:getZ() > -0.259) - -- primo gruppo di controlli con lunghezza utensile calcolata + -- primo gruppo di controlli con lunghezza utensile pari a metà foro se passante -- recupero la lavorazione local sDrilling, sType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, dCheckDepth, bDrillDown) - if not sDrilling then - -- se ho passato altezza di taglio utensile allora rifaccio la ricerca senza passare altezza utensile - if dCheckDepth then - sDrilling, sType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, 0, bDrillDown) - if sDrilling then dCheckDepth = nil end - end - if not sDrilling and bDrillUp then - sDrilling, sType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, dCheckDepth) - if not sDrilling and dCheckDepth then - sDrilling, sType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, 0) - if sDrilling then dCheckDepth = nil end - end - end - if not sDrilling then - nErrorCode = 1 - end + if not sDrilling and bDrillUp then + sDrilling, sType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, dCheckDepth) end - -- se esiste la lavorazione e la lunghezza utensile massima supera il valore limite del BeamData e la componente Z supera i 10 gradi - -- allora ricerco un utensile senza lunghezza massima + if not sDrilling and dCheckDepth then + sDrilling, sType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, 0, bDrillDown) + if sDrilling then dCheckDepth = nil end + end + if not sDrilling and bDrillUp and dCheckDepth then + sDrilling, sType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, 0) + if sDrilling then dCheckDepth = nil end + end + if not sDrilling then + nErrorCode = 1 + end + -- se trovata la lavorazione e la lunghezza massima utensile supera il valore limite del BeamData e inclinato più di 10 gradi da Z + -- allora ricerco un utensile senza imporre minima capacità di taglio if nErrorCode == 0 and dMaxToolLength > ( BD.MAX_TOOL_LEN_FOR_HOR_MACH or 300) and abs( vtExtr:getZ()) < ( BD.DRILL_VZ_MIN_LONG_TOOL or cos(10)) then -- se non ho passato altezza di taglio utensile allora la lunghezza utensile non è idonea per il taglio if not dCheckDepth then @@ -248,37 +237,32 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) end if not sDrilling then nErrorCode = 1 - end - -- ultimo controllo sulla lunghezza utensile - if dMaxToolLength > ( BD.MAX_TOOL_LEN_FOR_HOR_MACH or 300) and abs( vtExtr:getZ()) < ( BD.DRILL_VZ_MIN_LONG_TOOL or cos(10)) then + elseif dMaxToolLength > ( BD.MAX_TOOL_LEN_FOR_HOR_MACH or 300) and abs( vtExtr:getZ()) < ( BD.DRILL_VZ_MIN_LONG_TOOL or cos(10)) then nErrorCode = 2 end end end - -- secondo gruppo di controlli con lunghezza utensile calcolata + -- secondo gruppo di controlli con lunghezza richiesta pari all'intero foro -- recupero la lavorazione local sDrilling2, sType2, dMaxDepth2, dMaxToolLength2, dToolDiam2, dDiamTh2, dToolFreeLen2 if dDepth2 > dDepth + BD.DRILL_OVERLAP then sDrilling2, sType2, dMaxDepth2, dMaxToolLength2, dToolDiam2, dDiamTh2, dToolFreeLen2 = ML.FindDrilling( dDiam, dCheckDepth2, bDrillDown) - if not sDrilling2 then - -- se ho passato altezza di taglio utensile allora rifaccio la ricerca senza passare altezza utensile - if dCheckDepth2 then - sDrilling2, sType2, dMaxDepth2, dMaxToolLength2, dToolDiam2, dDiamTh2, dToolFreeLen2 = ML.FindDrilling( dDiam, 0, bDrillDown) - if sDrilling2 then dCheckDepth2 = nil end - end - if not sDrilling2 and bDrillUp then - sDrilling2, sType2, dMaxDepth2, dMaxToolLength2, dToolDiam2, dDiamTh2, dToolFreeLen2 = ML.FindDrilling( dDiam, dCheckDepth2) - if not sDrilling2 and dCheckDepth2 then - sDrilling2, sType2, dMaxDepth2, dMaxToolLength2, dToolDiam2, dDiamTh2, dToolFreeLen2 = ML.FindDrilling( dDiam, 0) - if sDrilling2 then dCheckDepth2 = nil end - end - end - if not sDrilling2 then - nErrorCode = 1 - end + if not sDrilling2 and bDrillUp then + sDrilling2, sType2, dMaxDepth2, dMaxToolLength2, dToolDiam2, dDiamTh2, dToolFreeLen2 = ML.FindDrilling( dDiam, dCheckDepth2) end - -- se esiste la lavorazione e la lunghezza utensile massima supera il valore limite del BeamData e la componente Z supera i 10 gradi - -- allora ricerco un utensile senza lunghezza massima + if not sDrilling2 and dCheckDepth2 then + sDrilling2, sType2, dMaxDepth2, dMaxToolLength2, dToolDiam2, dDiamTh2, dToolFreeLen2 = ML.FindDrilling( dDiam, 0, bDrillDown) + if sDrilling2 then dCheckDepth2 = nil end + end + if not sDrilling2 and bDrillUp and dCheckDepth2 then + sDrilling2, sType2, dMaxDepth2, dMaxToolLength2, dToolDiam2, dDiamTh2, dToolFreeLen2 = ML.FindDrilling( dDiam, 0) + if sDrilling2 then dCheckDepth2 = nil end + end + if not sDrilling2 then + nErrorCode = 1 + end + -- se trovata la lavorazione e la lunghezza massima utensile supera il valore limite del BeamData e inclinato più di 10 gradi da Z + -- allora ricerco un utensile senza imporre minima capacità di taglio if nErrorCode == 0 and dMaxToolLength2 > ( BD.MAX_TOOL_LEN_FOR_HOR_MACH or 300) and abs( vtExtr:getZ()) < ( BD.DRILL_VZ_MIN_LONG_TOOL or cos(10)) then -- se non ho passato altezza di taglio utensile allora la lunghezza utensile non è idonea per il taglio if not dCheckDepth2 then @@ -291,9 +275,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) end if not sDrilling2 then nErrorCode = 1 - end - -- ultimo controllo sulla lunghezza utensile - if dMaxToolLength2 > ( BD.MAX_TOOL_LEN_FOR_HOR_MACH or 300) and abs( vtExtr:getZ()) < ( BD.DRILL_VZ_MIN_LONG_TOOL or cos(10)) then + elseif dMaxToolLength2 > ( BD.MAX_TOOL_LEN_FOR_HOR_MACH or 300) and abs( vtExtr:getZ()) < ( BD.DRILL_VZ_MIN_LONG_TOOL or cos(10)) then nErrorCode = 2 end end diff --git a/LuaLibs/ProcessLongDoubleCut.lua b/LuaLibs/ProcessLongDoubleCut.lua index b7f97cc..92d87d3 100644 --- a/LuaLibs/ProcessLongDoubleCut.lua +++ b/LuaLibs/ProcessLongDoubleCut.lua @@ -1,4 +1,4 @@ --- ProcessLongDoubleCut.lua by Egaltech s.r.l. 2021/09/08 +-- ProcessLongDoubleCut.lua by Egaltech s.r.l. 2021/09/14 -- Gestione calcolo doppio taglio longitudinale per Travi -- 2021/05/18 Possibile taglio con lama anche di fianco su macchina con testa da sotto. -- 2021/06/29 Corretta gestione caso equivalente a due smussi. @@ -204,6 +204,79 @@ local function MakeByPocketing( Proc, nPhase, nRawId, nPartId, nSide, nFacInd, d return true, sWarn end +--------------------------------------------------------------------- +local function CalcBladeUse( bUseBlade, bDown_Head, nSide, vtN1, vtN2, bConvex, nOrd, bFront, dCustomAngle) + + local bCanUseBlade = false + local bCanUseUnderBlade = false + + -- se lama abilitata e faccia da sopra + if bUseBlade and nSide == 1 then + bCanUseBlade = true + end + -- se lama abilitata e non c'è testa da sotto + if bUseBlade and not bDown_Head then + if nSide >= 0 then + if nSide > 0 and ( ( vtN1 and vtN1:getZ() >= -0.0157) or ( vtN2 and vtN2:getZ() >= -0.0157)) then + bCanUseBlade = true + elseif nSide == 0 then + if ( ( vtN1 and vtN1:getZ() >= -0.0157) or ( vtN2 and vtN2:getZ() >= -0.0157)) then + bCanUseBlade = true + elseif not bConvex and nOrd and (( nOrd == 1 and bFront) or ( nOrd == 2 and not bFront)) and ( vtN1 and vtN1:getZ() >= -0.0157) then + bCanUseBlade = true + elseif not bConvex and nOrd and (( nOrd == 2 and bFront) or ( nOrd == 1 and not bFront)) and ( vtN1 and vtN1:getZ() >= -0.5) then + bCanUseBlade = true + elseif bConvex and ( vtN1 and vtN1:getZ() >= -0.0157) then + bCanUseBlade = true + end + end + else + if bConvex then + if vtN1 and vtN2 then + if vtN1:getZ() >= -0.5 then + if vtN2:getZ() >= -0.5 then + bCanUseBlade = true + end + else + if vtN2:getZ() >= -0.0157 then + bCanUseBlade = true + end + end + else + if ( vtN1 and vtN1:getZ() >= EgtIf( dCustomAngle, dCustomAngle, -0.5)) then + bCanUseBlade = true + end + end + else + if ( vtN1 and vtN1:getZ() >= EgtIf( dCustomAngle, dCustomAngle, -0.5)) or ( vtN2 and vtN2:getZ() >= -0.5) then + bCanUseBlade = true + end + end + end + end + -- se lama abilitata e c'è testa da sotto + if bUseBlade and bDown_Head then + -- se faccia da sotto o di lato ma con versore Z negativo che supera i 30° da Z- + if nSide <= 0 and ( ( vtN1 and vtN1:getZ() <= -0.5) or ( vtN2 and vtN2:getZ() <= -0.5)) then + bCanUseUnderBlade = true + end + -- se faccia da sotto o di lato ma con versore Z negativo abilito la lavorazione con lame mixate + if nSide <= 0 and ( ( vtN1 and vtN1:getZ() <= 0.0175) or ( vtN2 and vtN2:getZ() <= 0.0175)) then + bCanUseUnderBlade = true + end + -- se faccia da sopra o di lato ma con versore Z negativo verifico che abbia un angolo compatibile per non avere extracorsa + if nSide >= 0 and ( ( vtN1 and vtN1:getZ() > -0.4695) or ( vtN2 and vtN2:getZ() > -0.4695)) then + bCanUseBlade = true + end + -- se faccia da sotto ma con versore Z negativo verifico che abbia un angolo compatibile per non avere extracorsa + if nSide < 0 and ( ( vtN1 and vtN1:getZ() > -0.4695) or ( vtN2 and vtN2:getZ() > -0.4695)) then + bCanUseBlade = true + end + end + + return bCanUseBlade, bCanUseUnderBlade +end + --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster, nUseSideToolMaster) @@ -215,9 +288,9 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster -- verifico posizione (+1=sopra, -1=sotto, 0=sui lati) local nSide = 0 - if vtN[1]:getZ() > -10 * GEO.EPS_SMALL and vtN[2]:getZ() > -10 * GEO.EPS_SMALL then + if vtN[1]:getZ() > 10 * GEO.EPS_SMALL and vtN[2]:getZ() > 10 * GEO.EPS_SMALL then nSide = 1 - elseif vtN[1]:getZ() < 10 * GEO.EPS_SMALL and vtN[2]:getZ() < 10 * GEO.EPS_SMALL then + elseif vtN[1]:getZ() < -10 * GEO.EPS_SMALL and vtN[2]:getZ() < -10 * GEO.EPS_SMALL then nSide = -1 end @@ -287,64 +360,149 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster -- se entrambe i Q sono attivi, disabilito lama if nUseMillOnSide > 0 then bUseBlade = false end + -- verifico se posso usare lame + local bCanUseBlade, bCanUseUnderBlade = CalcBladeUse( bUseBlade, BD.DOWN_HEAD, nSide, vtN[1], vtN[2], bConvex) + -- introduco messaggi di errore in caso sia settata la lama ma impossibile utilizzarla + -- se si toglie questa parte il processo continua utilizzandi però la fresa ma per il vincolo del parametro Q non è possibile + if bUseBlade and not BD.DOWN_HEAD and not bCanUseBlade then + local sErr = 'Error, impossible use blade on too negative face' + EgtOutLog( sErr) + return false, sErr +-- elseif bUseBlade and not bCanUseBlade then +-- local sErr = 'Error, impossible use blade' +-- EgtOutLog( sErr) +-- return false, sErr + elseif bUseBlade and BD.DOWN_HEAD and not bCanUseBlade and not bCanUseUnderBlade then + local sErr = 'Error, impossible use blade' + EgtOutLog( sErr) + return false, sErr + end -- Se senza facce limitanti, da sopra o ( da tutte i lati con testa da sotto) e taglio di lama e lunghezza facce maggiore del parametro lunghezza minima - if nFaceLimit == 0 and ( nSide == 1 or ( abs(nSide) >= 0 and BD.DOWN_HEAD)) and bUseBlade and b3Solid:getDimX() > dLimMinPiece - 1 then - -- recupero la lavorazione +-- if nFaceLimit == 0 and ( nSide == 1 or ( abs(nSide) >= 0 and BD.DOWN_HEAD)) and bUseBlade and Proc.Box:getDimX() > dLimMinPiece - 1 then + if nFaceLimit == 0 and ( bCanUseUnderBlade or bCanUseBlade) and bUseBlade and Proc.Box:getDimX() > dLimMinPiece - 1 then + local sCutting - if nSide == -1 and BD.DOWN_HEAD then - sCutting = ML.FindCutting( 'HeadSide_H2') - else - sCutting = ML.FindCutting( 'HeadSide') - end - if not sCutting then - local sErr = 'Error : HeadSide not found in library' - EgtOutLog( sErr) - return false, sErr - end - -- recupero i dati dell'utensile local dToolDiam = 0 - local dMaxDepth = 0 local dToolThick = 0 - if EgtMdbSetCurrMachining( sCutting) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth - dToolThick = EgtTdbGetCurrToolParam(MCH_TP.THICK) or dToolThick + local dMaxDepth = 0 + local sCuttingDn + local dToolDiamDn = 0 + local dToolThickDn = 0 + local dMaxDepthDn = 0 + -- recupero la lavorazione + if bCanUseUnderBlade then + sCuttingDn = ML.FindCutting( 'HeadSide_H2') + if not sCuttingDn then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' sawing underneath not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + if EgtMdbSetCurrMachining( sCuttingDn) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dToolDiamDn = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiamDn + dToolThickDn = EgtTdbGetCurrToolParam(MCH_TP.THICK) or dToolThickDn + dMaxDepthDn = EgtTdbGetCurrToolMaxDepth() or dMaxDepthDn + end + end + end + if bCanUseBlade then + sCutting = ML.FindCutting( 'HeadSide') + if not sCutting then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' sawing not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + if EgtMdbSetCurrMachining( sCutting) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam + dToolThick = EgtTdbGetCurrToolParam(MCH_TP.THICK) or dToolThick + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end end end -- se la distanza dal pezzo successivo è inferiore della metà lama, do un warning - if dDistToNextPiece < dToolDiam/2 then + if ( bCanUseBlade or bCanUseUnderBlade) and ( dDistToNextPiece < dToolDiam/2 or dDistToNextPiece < dToolDiamDn/2) then sWarn = 'Warning : Cut machining can damage next piece' EgtOutLog( sWarn) end + -- determino gli estremi + local dStartAccDist + local dEndAccDist + local dStartAccDistUp = BD.LONGCUT_ENDLEN + local dEndAccDistUp = BD.LONGCUT_ENDLEN + local dStartAccDistDn = BD.LONGCUT_ENDLEN + local dEndAccDistDn = BD.LONGCUT_ENDLEN + local nC + local dC + + local nCUp + local dCUp -- determino numero di parti - local dStartAccDist = BD.LONGCUT_ENDLEN - local dEndAccDist = BD.LONGCUT_ENDLEN - local nC = ceil( ( dLen - dStartAccDist - dEndAccDist) / BD.LONGCUT_MAXLEN) - local dC = 0 - if nC > 0 then - dC = ( dLen - dStartAccDist - dEndAccDist) / nC - if dC < min( dStartAccDist, dEndAccDist) then - dC = dLen / ( nC + 2) - dStartAccDist = dC - dEndAccDist = dC - end - nC = nC + 2 - else - if dLen > min( dStartAccDist, dEndAccDist) then - nC = 2 - dStartAccDist = dLen / 2 - dEndAccDist = dStartAccDist + if bCanUseBlade then + nCUp = ceil( ( dLen - dStartAccDistUp - dEndAccDistUp) / BD.LONGCUT_MAXLEN) + dCUp = 0 + if nCUp > 0 then + dCUp = ( dLen - dStartAccDistUp - dEndAccDistUp) / nCUp + if dCUp < min( dStartAccDistUp, dEndAccDistUp) then + dCUp = dLen / ( nCUp + 2) + dStartAccDistUp = dCUp + dEndAccDistUp = dCUp + end + nCUp = nCUp + 2 else - nC = 1 - dStartAccDist = 0 - dEndAccDist = 0 + if dLen > min( dStartAccDistUp, dEndAccDistUp) then + nCUp = 2 + dStartAccDistUp = dLen / 2 + dEndAccDistUp = dStartAccDistUp + else + nCUp = 1 + dStartAccDistUp = 0 + dEndAccDistUp = 0 + end end end + local nCDn + local dCDn + if bCanUseUnderBlade then + nCDn = ceil( ( dLen - dStartAccDistDn - dEndAccDistDn) / BD.LONGCUT_MAXLEN) + dCDn = 0 + if nCDn > 0 then + dCDn = ( dLen - dStartAccDistDn - dEndAccDistDn) / nCDn + if dCDn < min( dStartAccDistDn, dEndAccDistDn) then + dCDn = dLen / ( nCDn + 2) + dStartAccDistDn = dCDn + dEndAccDistDn = dCDn + end + nCDn = nCDn + 2 + else + if dLen > min( dStartAccDistDn, dEndAccDistDn) then + nCDn = 2 + dStartAccDistDn = dLen / 2 + dEndAccDistDn = dStartAccDistDn + else + nCDn = 1 + dStartAccDistDn = 0 + dEndAccDistDn = 0 + end + end + end + -- prendo il valore minimo di passi + if nCUp then + nC = nCUp + dC = dCUp + elseif nCDn then + nC = nCDn + dC = dCDn + end - local dDimStrip = EgtIf( nSide ~= 0, BD.DIM_STRIP_SMALL, BD.DIM_STRIP) + -- disabilitato la selezione del codolo, prende sempre quello più piccolo. Non cancellare quello disabiliato in caso di ripristino +-- local dDimStrip = EgtIf( nSide ~= 0, BD.DIM_STRIP_SMALL, BD.DIM_STRIP) + local dDimStrip = BD.DIM_STRIP_SMALL * EgtIf( nSide == -1, -1, 1) local nM = 0 -- se convesso lavoro ogni faccia in due metà lasciando attaccata la parte centrale if bConvex then @@ -355,27 +513,106 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster if not BD.C_SIMM then nSCC = EgtIf( ( i == 1 or i == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) end + local nCountToShift = 0 -- ciclo sulle due facce for j = 1, #vOrd do + local nIdPrev + local nIdNext + nCountToShift = nCountToShift + 1 -- determino se lavorazione da davanti o da dietro local bFront = ( vtN[vOrd[j]]:getY() < 0) - -- determino l'utilizzo della faccia - local nFaceUse = EgtIf( abs( vtN[vOrd[j]]:getY()) > 0.01, MCH_MILL_FU.ORTHO_TOP, EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)) - local nFaceUse2 = EgtIf( abs( vtN[vOrd[j]]:getY()) > 0.01, MCH_MILL_FU.ORTHO_DOWN, EgtIf( bFront, MCH_MILL_FU.ORTHO_FRONT, MCH_MILL_FU.ORTHO_BACK)) - -- ciclo sulle passate - local dOffset = ( vWidth[vOrd[j]] + dDimStrip) / 2 ; - local dLioTang = 0 - local dLioPerp = ( vWidth[vOrd[j]] - dDimStrip) / 2 + BD.CUT_SIC ; - for k = 1, 2 do - -- inserisco le parti di lavorazione - nM = nM + 1 - local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM) .. '_' .. tostring(j) - local nMchFId = EgtAddMachining( sNameF, sCutting) - if not nMchFId then - local sErr = 'Error adding machining ' .. sNameF .. '-' .. sCutting + -- determino se posso usare lame sulla faccia specifica + bCanUseBlade, bCanUseUnderBlade = CalcBladeUse( bUseBlade, BD.DOWN_HEAD, nSide, vtN[vOrd[j]], nil, bConvex, j, bFront) + if not bCanUseUnderBlade and not bCanUseBlade then + local sErr = 'Error, impossible use blade on too negative face' + EgtOutLog( sErr) + return false, sErr + end + local nFaceUse + local nFaceUse2 + -- se ho solo lama da sotto + if bCanUseUnderBlade and not bCanUseBlade then + -- determino l'utilizzo della faccia + nFaceUse = EgtIf( abs( vtN[vOrd[j]]:getY()) > 0.01, MCH_MILL_FU.ORTHO_TOP, EgtIf( bFront, MCH_MILL_FU.ORTHO_FRONT, MCH_MILL_FU.ORTHO_BACK)) + nFaceUse2 = EgtIf( abs( vtN[vOrd[j]]:getY()) > 0.01, MCH_MILL_FU.ORTHO_DOWN, EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)) + else + -- determino l'utilizzo della faccia + nFaceUse = EgtIf( abs( vtN[vOrd[j]]:getY()) > 0.01, MCH_MILL_FU.ORTHO_TOP, EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)) + nFaceUse2 = EgtIf( abs( vtN[vOrd[j]]:getY()) > 0.01, MCH_MILL_FU.ORTHO_DOWN, EgtIf( bFront, MCH_MILL_FU.ORTHO_FRONT, MCH_MILL_FU.ORTHO_BACK)) + end + -- se lama da sotto verifico se la componente Y della profondità di taglio supera la capacità della lama + if nSide <= 0 and bCanUseUnderBlade then + if (( vWidth[vOrd[j]] - dDimStrip) / 2) > dMaxDepthDn then + local sErr = 'Error, side depth is bigger than underneath blade cut depth' EgtOutLog( sErr) return false, sErr end + end + local dOffset = ( vWidth[vOrd[j]] + dDimStrip) / 2 ; + local dLioTang = 0 + local nFaceSide = 0 + if vtN[vOrd[j]]:getZ() > 0.707 then + nFaceSide = 1 + elseif vtN[vOrd[j]]:getZ() < -0.707 then + nFaceSide = -1 + end + -- ricavo boc della faccia + local b3Fac = EgtSurfTmGetFacetBBoxGlob( Proc.Id, vOrd[j]-1, GDB_BB.STANDARD) + -- ciclo sulle passate + for k = 1, 2 do + local dLioPerp = ( vWidth[vOrd[j]] - dDimStrip) / 2 + BD.CUT_SIC + local bAddOpposite = true + local dAddExtraPerp = 0 + if ( nFaceSide == -1 and abs(vtN[vOrd[j]]:getY()) >= 0.2079) or ( nFaceSide == 0 and abs(vtN[vOrd[j]]:getZ()) >= 0.2588) then + bAddOpposite = false + end + if nFaceSide == 1 or ( nFaceSide == -1 and k == 1) then + bAddOpposite = false + end + if bAddOpposite then + -- controllo se devo aggiungere un extra all'attacco perpendicolare + if nFaceSide == -1 then + if vtN[vOrd[j]]:getY() > 0 then + dAddExtraPerp = b3Fac:getMin():getY() - b3Solid:getMin():getY() + elseif vtN[vOrd[j]]:getY() < 0 then + dAddExtraPerp = b3Solid:getMax():getY() - b3Fac:getMax():getY() + end + elseif nFaceSide == 0 then + if ( vtN[vOrd[j]]:getZ() >= 0 and k == 1) or ( vtN[vOrd[j]]:getZ() < 0 and k == 2) then + dAddExtraPerp = b3Fac:getMin():getZ() - b3Solid:getMin():getZ() + else + dAddExtraPerp = b3Solid:getMax():getZ() - b3Fac:getMax():getZ() + end + end + dLioPerp = dLioPerp + dAddExtraPerp + end + -- inserisco le parti di lavorazione + nM = nM + 1 + local sNameF + local nMchFId + if ( k == 1 and bCanUseBlade) or ( k == 2 and ( bCanUseBlade and not bCanUseUnderBlade)) then + sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring(j) .. '_' .. tostring( nM) + nMchFId = EgtAddMachining( sNameF, sCutting) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sCutting + EgtOutLog( sErr) + return false, sErr + end + -- setto le variabili delle distanze dagli estremi + dEndAccDist = dEndAccDistUp + dStartAccDist = dStartAccDistUp + elseif ( k == 2 and bCanUseUnderBlade) or ( k == 1 and ( bCanUseUnderBlade and not bCanUseBlade)) then + sNameF = 'L2CD_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring(j) .. '_' .. tostring( nM) + nMchFId = EgtAddMachining( sNameF, sCuttingDn) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sCuttingDn + EgtOutLog( sErr) + return false, sErr + end + -- setto le variabili delle distanze dagli estremi + dEndAccDist = dEndAccDistDn + dStartAccDist = dStartAccDistDn + end -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, vOrd[j]-1}}) -- limito opportunamente la lavorazione @@ -384,17 +621,35 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster if ( not bFront and k == 1) or ( bFront and k == 2) then dSal, dEal = dEal, dSal end - if nSide == -1 and BD.DOWN_HEAD then - EgtSetMachiningParam( MCH_MP.STARTADDLEN, dEal) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, dSal) - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - EgtSetMachiningParam( MCH_MP.INVERT, false) + if bCanUseBlade and bCanUseUnderBlade then + if bCanUseBlade and nSide == -1 then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + else + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + dSal, dEal = dEal, dSal + end + -- imposto uso della faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( k == 1, nFaceUse2, nFaceUse)) + elseif bCanUseUnderBlade then + if nSide ~= 0 then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + end + -- imposto uso della faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( k == 1, nFaceUse, nFaceUse2)) else - EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) + -- imposto uso della faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( k == 1, nFaceUse, nFaceUse2)) + if bCanUseBlade and nSide == -1 then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + end end + + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) + -- imposto offset radiale - EgtSetMachiningParam( MCH_MP.OFFSR, dOffset) + EgtSetMachiningParam( MCH_MP.OFFSR, EgtIf( nSide == -1, -dOffset, dOffset)) -- imposto attacco/uscita EgtSetMachiningParam( MCH_MP.LITANG, dLioTang) EgtSetMachiningParam( MCH_MP.LIPERP, dLioPerp) @@ -410,6 +665,19 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster EgtSetOperationMode( nMchFId, false) return false, sErr end + -- se sono alla seconda faccia scambio le ultime due lavorazione per ottimizzare i percorosi + if nCountToShift == 2 then + -- se prima porzione di faccia memorizzo l'id della lavorazione + if k == 1 then + nIdPrev = nMchFId + else + nIdNext = nMchFId + end + -- se alla fine della seconda porzione della seconda faccia sposta la prima dopo la econda + if nIdPrev and nIdNext and k == 2 then + EgtRelocateGlob( nIdPrev, nIdNext, GDB_IN.AFTER) + end + end end end end @@ -426,15 +694,31 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster for j = 1, #vOrd do -- determino se lavorazione da davanti o da dietro local bFront = ( vtN[vOrd[j]]:getY() < 0) - local nFaceUse - local nFaceUse2 - if abs( nSide) == 1 then - -- determino l'utilizzo della faccia - nFaceUse = EgtIf( abs( vtN[vOrd[j]]:getY()) > 0.01, MCH_MILL_FU.ORTHO_TOP, EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)) - nFaceUse2 = EgtIf( abs( vtN[vOrd[j]]:getY()) > 0.01, MCH_MILL_FU.ORTHO_DOWN, EgtIf( bFront, MCH_MILL_FU.ORTHO_FRONT, MCH_MILL_FU.ORTHO_BACK)) - else - nFaceUse = EgtIf( abs( vtN[vOrd[j]]:getY()) > 0.01, MCH_MILL_FU.ORTHO_TOP, EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)) - nFaceUse2 = vFaceUse[vOrd[j]] + local OthFace = abs(j-3) + local dSinLimit + -- se faccia da sotto e Z centro faccia è minore del centro altra faccia, segno il limite angolare da passare + -- dovrebbe essere il limite angolare della testa 1 in sottosquadra + if nSide == -1 and not BD.DOWN_HEAD then + if ptC[vOrd[j]]:getZ() < ptC[vOrd[OthFace]]:getZ() then + dSinLimit = -0.0157 + else + dSinLimit = -0.5 + end + end + -- determino se posso usare lame sulla faccia specifica + bCanUseBlade, bCanUseUnderBlade = CalcBladeUse( bUseBlade, BD.DOWN_HEAD, nSide, vtN[vOrd[j]], nil, bConvex, j, bFront, dSinLimit) + if not bCanUseUnderBlade and not bCanUseBlade then + local sErr = 'Error, impossible use blade on too negative face' + EgtOutLog( sErr) + return false, sErr + end + -- se lama da sotto verifico se la componente Y della profondità di taglio supera la capacità della lama + if nSide <= 0 and bCanUseUnderBlade then + if ( vWidth[vOrd[j]] / 2) > dMaxDepthDn then + local sErr = 'Error, side depth is bigger than underneath blade cut depth' + EgtOutLog( sErr) + return false, sErr + end end -- ciclo sulle passate local dOffset @@ -452,20 +736,38 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster dLioPerp = vWidth[vOrd[j]] - dOffset + BD.CUT_SIC end local dLioTang = 0 - - local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring(j) - local nMchFId = EgtAddMachining( sNameF, sCutting) - if not nMchFId then - local sErr = 'Error adding machining ' .. sNameF .. '-' .. sCutting - EgtOutLog( sErr) - return false, sErr + local sNameF + local nMchFId + nM = nM + 1 + if bCanUseBlade then + sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring(j) .. '_' .. tostring( nM) + nMchFId = EgtAddMachining( sNameF, sCutting) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sCutting + EgtOutLog( sErr) + return false, sErr + end + -- setto le variabili delle distanze dagli estremi + dEndAccDist = dEndAccDistUp + dStartAccDist = dStartAccDistUp + elseif bCanUseUnderBlade then + sNameF = 'L2CD_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring(j) .. '_' .. tostring( nM) + nMchFId = EgtAddMachining( sNameF, sCuttingDn) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sCuttingDn + EgtOutLog( sErr) + return false, sErr + end + -- setto le variabili delle distanze dagli estremi + dEndAccDist = dEndAccDistDn + dStartAccDist = dStartAccDistDn end -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, vOrd[j]-1}}) -- limito opportunamente la lavorazione local dSal = EgtIf( i == nC, 0, - dEndAccDist - ( nC - i - 1) * dC) local dEal = EgtIf( i == 1, 0, - dStartAccDist - ( i - 2) * dC) - if ( bFront and abs( nSide) == 1) or j == 2 then + if j == 2 then dSal, dEal = dEal, dSal end if nSide == -1 and BD.DOWN_HEAD then @@ -484,12 +786,8 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster EgtSetMachiningParam( MCH_MP.LOPERP, dLioPerp) -- imposto posizione braccio porta testa per non ingombrare agli estremi EgtSetMachiningParam( MCH_MP.SCC, nSCC) - -- imposto uso della faccia - if nSide == -1 and BD.DOWN_HEAD then - EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) - else - EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse2) - end + -- determino e imposto l'utilizzo della faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, vFaceUse[vOrd[j]]) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() diff --git a/LuaLibs/ProcessProfCamb.lua b/LuaLibs/ProcessProfCamb.lua index 98b9166..15473e2 100644 --- a/LuaLibs/ProcessProfCamb.lua +++ b/LuaLibs/ProcessProfCamb.lua @@ -1,7 +1,8 @@ --- ProcessProfCamb.lua by Egaltech s.r.l. 2021/06/28 +-- ProcessProfCamb.lua by Egaltech s.r.l. 2021/09/15 -- Gestione calcolo profilo caudato per Travi -- 2021/05/03 Aggiunta gestione smusso da sopra e sotto per macchina con testa da sotto. -- 2021/06/28 Per macchine con testa sotto, smussi di lato con questa testa se non c'è lav.ne da sopra. +-- 2021/09/15 Estesa gestione di testa da sotto, se presente. -- Tabella per definizione modulo local ProcessProfCamb = {} @@ -233,6 +234,8 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) elseif vtN:getZ() < -0.1 then nSide = -1 end + -- abilitazione lavorazione da sotto + local bMillDown = ( BD.DOWN_HEAD and nSide == -1) -- recupero gruppo per geometria addizionale local nAddGrpId = BL.GetAddGroup( nPartId) if not nAddGrpId then @@ -282,7 +285,11 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end -- leggo anticipatamente i parametri utensile fresa per dare un valore opportuno all'elevazione della lama -- recupero la lavorazione di fresatura - sMilling = ML.FindMilling( 'Prof') + local sMillType = 'Prof' + sMilling = ML.FindMilling( sMillType .. EgtIf( bMillDown, '_H2', '')) + if not sMilling then + sMilling = ML.FindMilling( sMillType) + end if not sMilling then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library' EgtOutLog( sErr) @@ -298,9 +305,13 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end -- se non da sotto e abilitato dal parametro Q aggiungo taglio di lama - if nSide ~= -1 and nLastFacet and EgtGetInfo( Proc.Id, sEnableExtraBladeUpperFace, 'i') == 1 then + if ( nSide ~= -1 or bMillDown) and nLastFacet and EgtGetInfo( Proc.Id, sEnableExtraBladeUpperFace, 'i') == 1 then -- recupero la lavorazione - local sCutting = ML.FindCutting( 'HeadSide') + local sCutType = 'HeadSide' + local sCutting = ML.FindCutting( sCutType .. EgtIf( bMillDown, '_H2', '')) + if not sCutting then + sCutting = ML.FindCutting( sCutType) + end if not sCutting then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' sawing not found in library' EgtOutLog( sErr) @@ -318,7 +329,8 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) dToolThick = EgtTdbGetCurrToolParam(MCH_TP.THICK) or dToolThick end end - local vtOrthoO = Vector3d(vtN) + local vtOrthoO = Vector3d( vtN) + local dVzLimDwnUp = EgtIf( bMillDown, -2, nil) local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, nLastFacet, sCutting, dToolDiam, vtOrthoO, nil, -((dMillDiam/2)+1), BD.CUT_SIC, 0, 0, 0, nil, b3Raw) end end @@ -336,7 +348,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) - -- se lavorazione da sopra o da sotto + -- se profilo sopra o sotto (lavorazioni di fianco) if nSide ~= 0 then bDoubleCham = true -- se lavorazione a destra di fronte o sinistra da dietro, inverto @@ -345,7 +357,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) EgtSetMachiningParam( MCH_MP.INVERT, true) end - -- altrimenti lavorazione dal davanti o dal dietro + -- altrimenti profilo davanti o dietro (lavorazioni da sopra e/o sotto) else bDoubleCham = BD.DOWN_HEAD -- se fresa verso il basso, la porto verso l'alto @@ -620,7 +632,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end -- se non da sotto e parametro Q abilitato, inserisco lavorazione finitura angolo - if nSide ~= -1 and EgtGetInfo( Proc.Id, sEnableExtraMillUpperFace, 'i') == 1 then + if ( nSide ~= -1 or bMillDown) and EgtGetInfo( Proc.Id, sEnableExtraMillUpperFace, 'i') == 1 then sName = 'ProfV_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchVId = EgtAddMachining( sName, sMilling) if not nMchVId then @@ -637,8 +649,8 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.STEP, 0) EgtSetMachiningParam( MCH_MP.OFFSR, -0.5) -- imposto tipo uso faccia - local nFaceUse = MCH_MILL_FU.ORTHO_DOWN - if nSide ~= 1 then + local nFaceUse = EgtIf( bMillDown, MCH_MILL_FU.ORTHO_TOP, MCH_MILL_FU.ORTHO_DOWN) + if nSide == 0 then nFaceUse = EgtIf( vtN:getY() > 0.1, MCH_MILL_FU.ORTHO_FRONT, MCH_MILL_FU.ORTHO_BACK) end EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse)