diff --git a/LuaLibs/ProcessLongCut.lua b/LuaLibs/ProcessLongCut.lua index 0b2b682..c2c0ea3 100644 --- a/LuaLibs/ProcessLongCut.lua +++ b/LuaLibs/ProcessLongCut.lua @@ -1,4 +1,4 @@ --- ProcessLongCut.lua by Egaltech s.r.l. 2021/11/08 +-- ProcessLongCut.lua by Egaltech s.r.l. 2022/03/07 -- Gestione calcolo taglio longitudinale per Travi -- 2021/02/03 Corretto FaceUse con fresa orizzontale su taglio orizzontale. -- 2021/05/18 Possibile taglio con lama anche di fianco su macchina con testa da sotto. @@ -9,6 +9,7 @@ -- 2021/10/29 Aggiunta opzione tipo lavorazione 'LongCut'. -- 2021/11/04 Migliorata gestione sicurezza aggiuntiva in fresate di fianco (distinzione tra larga come tutta la faccia o meno). -- 2021/11/08 Se con lama e flag BD.USE_LONGCUT si lavora in direzione contraria allo standard. +-- 2022/03/07 Razionalizzata gestione casi con fresa di fianco. Aggiunta gestione Long2Cut anche con testa sotto. -- Tabella per definizione modulo local ProcessLongCut = {} @@ -354,34 +355,37 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus bLimXmax = true end end - -- Verifico lato di lavorazione (limite di lato a 45deg per pinze che schiacciano) - -- 14.07.2021 su richieste di alcuni clienti, se taglio di lato (assegnazione +/- 2) fare lo stesso con la lama lasciando il cordone centrale + -- Verifico lato di lavorazione (limite di lato a 45deg per FAST e 36deg per PF) local nSide = 1 if vtN:getZ() < - 0.5 then nSide = -1 - elseif vtN:getY() < -0.7072 then + elseif vtN:getY() < - EgtIf( BD.C_SIMM, 0.588, 0.7072) then nSide = -2 - elseif vtN:getY() > 0.7072 then + elseif vtN:getY() > EgtIf( BD.C_SIMM, 0.588, 0.7072) then nSide = 2 end -- Verifico se largo come faccia local bLarghAsFace = false if nSide == 1 or nSide == -1 then - bLarghAsFace = ( Proc.Box:getDimY() > b3Solid:getDimY() - 10) + bLarghAsFace = ( Proc.Box:getDimY() > b3Solid:getDimY() - 20) else - bLarghAsFace = ( Proc.Box:getDimZ() > b3Solid:getDimZ() - 10) + bLarghAsFace = ( Proc.Box:getDimZ() > b3Solid:getDimZ() - 20) end + -- Determino se parte da sopra + local bTopStart = ( Proc.Box:getMax():getZ() > b3Solid:getMax():getZ() - 20) + -- Determino se parte da sotto + local bBottomStart = ( Proc.Box:getMin():getZ() < b3Solid:getMin():getZ() + 20) -- determino se lavorazione da davanti o da dietro local bFront = ( vtN:getY() < 0) -- ottengo la distanza tra la fine del pezzo e il pezzo successivo - local dDistToNextPiece = EgtGetInfo( nRawId, 'BDST', 'd') or 5.4 + local dDistToNextPiece = EgtGetInfo( nRawId, 'BDST', 'd') or BD.OVM_MID local bForcedLim local sWarn ---------------------------------------------------------------------------------------------------------------------------------------- -- 2020/09/15 Fabio Squaratti: se sono attivi entrambe i Q05 (lavorare con lama) e Q07 (lavorare con fresa di fianco anche da sopra) -- allora vince il Q7, cioè si utilizza la fresa di fianco ( per i tagli da sopra) - -- 2020/09/17 Fabio Squaratti: se lavorazione con fresa di fianco e se ci sono delle facce laterali, l'utensile deve arrivare - -- fino al punto più vicino della faccia laterale (prima l'arretramento era sempre del rggio utensile). + -- 2020/09/17 Fabio Squaratti: se lavorazione con fresa di fianco e se ci sono delle facce terminali, l'utensile deve arrivare + -- fino al punto più vicino della faccia terminale (prima l'arretramento era sempre del raggio utensile). -- Questo viene fatto se Q07=1 o fresa da sotto ---------------------------------------------------------------------------------------------------------------------------------------- local nUseBlade = EgtIf( bCustUseBlade, 1, EgtGetInfo( Proc.Id, 'Q05', 'i') or 0) @@ -756,31 +760,6 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus dAddExtraPerp = Proc.Box:getMin():getZ() - b3Solid:getMin():getZ() end dLioPerp = dLioPerp + dAddExtraPerp - ------------------------------------------------------------------------------------------------------- - -- disabilito questo calcolo dell'attacco perpendicolare perchè in alcune condizioni genera extra corsa - ------------------------------------------------------------------------------------------------------- - --[[ - -- parametri di attacco/uscita - local nOrthoOpposite = nFaceUse2 - local b3Box = BBox3d( b3Raw) - b3Box:expand( BD.CUT_SIC) - -- linea o bilinea di lavorazione (qui uso nOrthoOpposite per ripetere esattamente il calcolo del Mach) - local ptP1, ptPm, ptP2, vtV1, vtV2, dLen, dWidth2 = EgtSurfTmFacetOppositeSide( Proc.Id, 0, BL.GetVersRef( nOrthoOpposite), GDB_ID.ROOT) - vtV1 = - vtV1 - local bInvert = ( ptP2:getZ() < ptP1:getZ() - 100 * GEO.EPS_SMALL) - if bInvert then - ptP1, ptP2 = ptP2, ptP1 - vtV1, vtV2 = vtV2, vtV1 - end - local vtTg = ptP2 - ptP1 ; vtTg:normalize() - -- Versore di riferimento - local vtRef = Vector3d( vtTg) - local dCutExtra = 0 - vtRef:rotate( vtN, EgtIf( bInvert, -90, 90)) - local ptP1act = ptP1 - local ptP2act = ptP2 - _, dLioPerp, _, _ = Fbs.CalcLeadInOutPerpGeom( ptP1act, ptP2act, vtV1, vtV2, vtN, dToolDiam/2, vtRef, dCutExtra, b3Box) - ]]-- end -- inserisco le parti di lavorazione nM = nM + 1 @@ -822,16 +801,6 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus if ( not bFront and k == 1) or ( bFront and k == 2) then dSal, dEal = dEal, dSal end - -- se faccia da sotto inverto direzione utensile e profondità - -- if nSide == -1 then - -- if k == 1 and abs( vtN:getY()) > 0.01 and abs( vtN:getY()) <= 0.866 and abs( vtN:getY()) > 0.707 then - -- -- imposto lato di correzione - -- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - -- else - -- EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - -- EgtSetMachiningParam( MCH_MP.DEPTH, dThick) - -- end - -- end if bCanUseBlade and bCanUseUnderBlade then EgtSetMachiningParam( MCH_MP.INVERT, true) @@ -884,14 +853,16 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus end end end + -- se non è sotto e non uso fresa di fianco: lavorazione Long2Cut - elseif nSide ~= - 1 and nUseMillOnSide == 0 then + elseif ( nSide ~= - 1 or BD.DOWN_HEAD) and nUseMillOnSide == 0 then -- determino la massima elevazione local dElev = BL.GetFaceElevation( Proc.Id, 0, nPartId) -- recupero la lavorazione - local sMilling = ML.FindMilling( 'Long2Cut', dElev) + local sMchType = EgtIf( nSide ~= - 1, 'Long2Cut', 'Long2Cut_H2') + local sMilling = ML.FindMilling( sMchType, dElev) if not sMilling then - local sErr = 'Error : milling Long2Cut not found in library' + local sErr = 'Error : milling '..sMchType..' not found in library' EgtOutLog( sErr) return false, sErr end @@ -1081,9 +1052,9 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus nCountMilHead = nCountMilHead + 1 end end - -- altrimenti è da sotto ( lavorazione Long2CutDown) o abilitata lavorazione con fresa di fianco ( lavorazione Long2CutSide) + + -- altrimenti è con fresa di fianco (Long2CutSide) o da sotto (Long2CutDown) else - -- da Analisi con Fabio Squaratti 15/09/2020 -- variabile che indica se ripassare sul raggio rimasto dalla lavorazione di fianco local bRemoveToolRadius -- se nExtendMach = 0 la lavorazione rimane arretrata dalla fine della faccia del raggio utensile @@ -1091,12 +1062,12 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus -- se nExtendMach = 2 la lavorazione viene estesa ma arretra per non segnare il pezzo successivo (se non ha facce limite) local nExtendMach -- recupero la lavorazione - local sMilling - local sMillingDn - local sPrefix - local sPrefixDn + local sMchType, sMchTypeDn + local sMilling, sMillingDn + local sPrefix, sPrefixDn if nSide ~= - 1 then - sMilling = ML.FindMilling( 'Long2CutSide') + sMchType = 'Long2CutSide' + sMilling = ML.FindMilling( sMchType) sPrefix = 'L2CS_' nExtendMach = nUseMillOnSide if nUseMillOnSide == 2 then @@ -1104,30 +1075,33 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus end -- se testa da sotto if nSide ~= 1 and BD.DOWN_HEAD then - sMillingDn = ML.FindMilling( 'Long2CutSide_H2') + sMchTypeDn = 'Long2CutSide_H2' + sMillingDn = ML.FindMilling( sMchTypeDn) sPrefixDn = 'L2CSH2_' end -- lavorazione da sotto - else - sMilling = ML.FindMilling( 'Long2CutDown') + else + sMchType = 'Long2CutDown' + sMilling = ML.FindMilling( sMchType) sPrefix = 'L2CD_' nExtendMach = 1 if nUseMillOnSide ~= 1 then - nExtendMach = 2 -- arretro il minimo indispensabile per non segnare il pezzo successivo (se non ha facce limite) + nExtendMach = 2 -- arretro il minimo indispensabile per non segnare il pezzo successivo (se non ha facce limite) end -- se testa da sotto if BD.DOWN_HEAD then - sMillingDn = ML.FindMilling( 'Long2CutDown_H2') + sMchTypeDn = 'Long2CutDown_H2' + sMillingDn = ML.FindMilling( sMchTypeDn) sPrefixDn = 'L2CDH2_' end end - if not sMilling then - local sErr = 'Error : milling Long2CutSide or Long2CutDown not found in library' + if not sMilling and ( nSide == 1 or not BD.DOWN_HEAD) then + local sErr = 'Error : milling '..sMchType..' not found in library' EgtOutLog( sErr) return false, sErr end - if nSide ~= 1 and BD.DOWN_HEAD and not sMillingDn then - local sErr = 'Error : milling Long2CutSide_H2 or Long2CutDown_H2 not found in library' + if not sMilling and not sMillingDn then + local sErr = 'Error : milling '..sMchType..' and '..sMchTypeDn..' not found in library' EgtOutLog( sErr) return false, sErr end @@ -1137,9 +1111,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus local dMaxDepth = 0 local dThDiam = 0 local dThLen = 0 - local dExtraForSafety = EgtIf( BD.DOWN_HEAD, 8.5, 6.5) -- corrisponde al doppio valore di sicurezza dell'mlpe + 0.5 --- local dExtraForSafetyDn = 8.5 -- 8.5 -- corrisponde al doppio valore di sicurezza dell'mlpe + 0.5 - if EgtMdbSetCurrMachining( sMilling) then + if sMilling and EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam @@ -1155,7 +1127,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus local dMaxDepthDn = 0 local dThDiamDn = 0 local dThLenDn = 0 - if nSide ~= 1 and BD.DOWN_HEAD and EgtMdbSetCurrMachining( sMillingDn) then + if sMillingDn and EgtMdbSetCurrMachining( sMillingDn) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dToolDiamDn = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiamDn @@ -1165,19 +1137,17 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus dThLenDn = EgtTdbGetCurrToolThLength() or dThLenDn end end - - local dDistToEnd = dToolDiam / 2 + -- distanza dalle eventuali facce estreme + local dDistToEnd = dToolDiam / 2 local dDistToEndDn = dToolDiamDn / 2 -- calcolo l'elevazione della faccia principale local dFacElev = BL.GetFaceElevation( Proc.Id, 0, nPartId) - -- se fresa di fianco o da sotto calcolo quanto l'utensile può andare vicino al limite se l'elevazione della faccia è minore del raggio utensile - if nUseMillOnSide <= 1 or nSide == -1 then - if dFacElev < dDistToEnd then - dDistToEnd = sqrt( ( ( dToolDiam / 2) * ( dToolDiam / 2)) - ( ( dToolDiam / 2 - dFacElev) * (dToolDiam / 2 - dFacElev))) - end - if dFacElev < dDistToEndDn then - dDistToEndDn = sqrt( ( ( dToolDiamDn / 2) * ( dToolDiamDn / 2)) - ( ( dToolDiamDn / 2 - dFacElev) * (dToolDiamDn / 2 - dFacElev))) - end + -- se fresa di fianco o da sotto calcolo quanto l'utensile può andare vicino all'estremo con l'elevazione della faccia minore del raggio utensile + if ( nUseMillOnSide <= 1 or nSide == -1) and dFacElev < dToolDiam / 2 then + dDistToEnd = sqrt( dFacElev * ( dToolDiam - dFacElev)) + end + if nUseMillOnSide <= 1 and dFacElev < dToolDiamDn / 2 then + dDistToEndDn = sqrt( dFacElev * ( dToolDiamDn - dFacElev)) end -- se la fine è già limitata allora setto per arretrare del raggio utensile if bLimXmin then @@ -1252,123 +1222,134 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus dEndAccDist = 0 end end - -- verifico se posso farlo da due parti opposte o da solo una parte - local dCollSic - local dCollSicMin - local dCollSicDn - local dCollSicMinDn - local dDepth - local dDepthDn - local dDepth2 - local dDepth2Dn - local nPass = 1 - local dNz = EgtIf( abs(nSide) == 1, vtN:getY(), vtN:getZ()) - local dNzMin = EgtIf( abs(vtN:getY()) >= abs(vtN:getZ()), vtN:getY(), vtN:getZ()) - -- se faccia da sopra e angolo 45° o faccia da sotto e angolo 40° (con singola testa ) o faccia non da sopra e testa da sotto - -- permette di eseguire due lavorazioni opposte - if ( nSide == 1 and abs(vtN:getY()) <= 0.7072) or ( nSide == -1 and not BD.DOWN_HEAD and abs(vtN:getY()) < 0.6428) or ( nSide ~= 1 and BD.DOWN_HEAD) then - -- verifico massimo affondamento (tengo conto dell'inclinazione utensile e della pinza con estremità conica) - -- 08/09/2020 tolti i 3mm ( per la ghiera smussata) perchè nella verifica collisione vine creato un cilindro non smussato che rileva la collisione - local dSicOnRad - local dSicOnLegth - if ( abs(nSide) == 1 and abs(vtN:getZ()) >= abs(vtN:getY())) or ( abs(nSide) == 2 and abs(vtN:getY()) >= abs(vtN:getZ())) then - dSicOnRad = ( dThDiam + dExtraForSafety - dToolDiam) / 2 - dSicOnLegth = 0 - else - dSicOnRad = ( dThDiam - dToolDiam) / 2 - dSicOnLegth = dExtraForSafety / 2 + -- verifico se posso farlo da una sola parte o se necessario da due parti + local dMaxDepthZ = dMaxDepth + local dMaxDepthDnZ = dMaxDepthDn + local CosA = abs( vtN:getZ()) + if CosA >= 0.05 then + local SinA = sqrt( 1 - CosA * CosA) + local dRad = dThDiam / 2 - dToolDiam / 2 + BD.COLL_SIC + dMaxDepthZ = dMaxDepthZ - ( dRad * CosA / SinA) + if sMillingDn then + local dRadDn = dThDiamDn / 2 - dToolDiamDn / 2 + dMaxDepthDnZ = dMaxDepthDnZ - ( dRadDn * CosA / SinA) end - dCollSicMin = max( BD.COLL_SIC, ( dThDiam - dToolDiam) / 2 * abs( EgtIf( abs(vtN:getY()) >= abs(vtN:getZ()), vtN:getZ(), vtN:getY()) / dNzMin)) - if bLarghAsFace then - dCollSic = max( BD.COLL_SIC, dSicOnRad * abs( EgtIf( abs(vtN:getY()) >= abs(vtN:getZ()), vtN:getZ(), vtN:getY()) / dNzMin) + dSicOnLegth) - else - dCollSic = max( BD.COLL_SIC, dSicOnRad * EgtIf( abs(dNz) < GEO.EPS_SMALL, 1, abs( EgtIf( abs(nSide) == 1, vtN:getZ(), vtN:getY()) / dNz)) + dSicOnLegth) + end + local dMaxDepthY = dMaxDepth + local dMaxDepthDnY = dMaxDepthDn + local SinA = abs( vtN:getZ()) + if SinA >= 0.05 then + local CosA = sqrt( 1 - SinA * SinA) + local dRad = dThDiam / 2 - dToolDiam / 2 + BD.COLL_SIC + dMaxDepthY = dMaxDepthY - ( dRad * CosA / SinA) + if sMillingDn then + local dRadDn = dThDiamDn / 2 - dToolDiamDn / 2 + dMaxDepthDnY = dMaxDepthDnY - ( dRadDn * CosA / SinA) end - if nSide ~= 1 and BD.DOWN_HEAD then - local dSicOnRadDn - local dSicOnLegthDn - if ( abs(nSide) == 1 and abs(vtN:getZ()) >= abs(vtN:getY())) or ( abs(nSide) == 2 and abs(vtN:getY()) >= abs(vtN:getZ())) then - dSicOnRadDn = ( dThDiamDn + dExtraForSafety - dToolDiamDn) / 2 - dSicOnLegthDn = 0 + end + local nPass = 0 + local vdMaxD = { 0, 0} + local vnHead = { 0, 0} + -- con testa da sopra + if nSide == 1 or ( sMilling and abs( nSide) == 2 and ( bTopStart or abs( vtN:getY()) < 0.866)) or not sMillingDn then + vnHead = { 1, 1} + -- se faccia sopra + if nSide == 1 then + vdMaxD[1] = EgtIf( bLarghAsFace, dMaxDepthY, dMaxDepthZ) + if dWidth + dAgg <= vdMaxD[1] then + nPass = 1 else - dSicOnRadDn = ( dThDiamDn - dToolDiamDn) / 2 - dSicOnLegthDn = dExtraForSafety / 2 + nPass = 2 + dAgg = BD.CUT_EXTRA_MIN + vdMaxD[2] = dMaxDepthY end - dCollSicMinDn = max( BD.COLL_SIC, ( dThDiamDn - dToolDiamDn) / 2 * abs( EgtIf( abs(vtN:getY()) >= abs(vtN:getZ()), vtN:getZ(), vtN:getY()) / dNzMin)) - if bLarghAsFace then - dCollSicDn = max( BD.COLL_SIC, dSicOnRadDn * abs( EgtIf( abs(vtN:getY()) >= abs(vtN:getZ()), vtN:getZ(), vtN:getY()) / dNzMin) + dSicOnLegthDn) + -- se altrimenti faccia sotto + elseif nSide == -1 then + if dWidth + dAgg <= dMaxDepthY or abs( vtN:getY()) > EgtIf( BD.C_SIMM, 0.588, 0.7072) then + nPass = 1 + vdMaxD[1] = dMaxDepthY else - dCollSicDn = max( BD.COLL_SIC, dSicOnRadDn * EgtIf( abs(dNz) < GEO.EPS_SMALL, 1, abs( EgtIf( abs(nSide) == 1, vtN:getZ(), vtN:getY()) / dNz)) + dSicOnLegthDn) - end - if dWidth + dAgg > dMaxDepth - dCollSic then nPass = 2 - dAgg = 1 - if ( 0.5 * dWidth) + dAgg > dMaxDepth - dCollSic then - sWarn = 'Warning in LongCut : depth is bigger than max tool depth' - end - end - if nPass == 1 and dWidth + dAgg > dMaxDepthDn - dCollSicDn then - nPass = 2 - dAgg = 1 - if ( 0.5 * dWidth) + dAgg > dMaxDepthDn - dCollSicDn then - sWarn = 'Warning in LongCut_2 : depth is bigger than max tool depth' + vdMaxD[1] = dMaxDepthY + local dDelta = b3Solid:getDimY() - Proc.Box:getDimY() + if bLarghAsFace then + vdMaxD[2] = min( dMaxDepthY, dMaxDepth - dDelta * abs( vtN:getZ()) - BD.COLL_SIC) + else + vdMaxD[2] = min( dMaxDepthZ, dToolLength - 5 - dDelta / abs( vtN:getZ()) - BD.COLL_SIC) end + if vdMaxD[2] < 0 then nPass = 1 end + if nPass == 2 then dAgg = BD.CUT_EXTRA_MIN end end + -- altrimenti faccia di fianco else - if dWidth + dAgg > dMaxDepth - dCollSic then - nPass = 2 - dAgg = 1 - if ( 0.5 * dWidth) + dAgg > dMaxDepth - dCollSic then - sWarn = 'Warning in LongCut : depth is bigger than max tool depth' - end + nPass = 1 + local dDelta = b3Solid:getMax():getZ() - Proc.Box:getMax():getZ() + if abs( vtN:getY()) < 0.866 then + vdMaxD[1] = dMaxDepthY + elseif bTopStart then + vdMaxD[1] = min( dMaxDepthZ, dMaxDepth - dDelta * abs( vtN:getY()) - BD.COLL_SIC) + else + vdMaxD[1] = min( dMaxDepthY, dToolLength - 5 - dDelta * abs( vtN:getY()) - BD.COLL_SIC) end + if vdMaxD[1] < 0 then nPass = 0 end end + -- eventuale errore per lavorazione saltata + if nPass == 0 then + local sErr = 'Error in '..sMchType..' : impossible machining' + EgtOutLog( sErr) + return false, sErr + end + -- eventuale avviso per lavorazione incompleta + if dWidth + nPass * dAgg > vdMaxD[1] + vdMaxD[2] then + sWarn = 'Warning in '..sMchType..' : depth is bigger than max tool depth' + end + -- con testa da sotto else - -- verifico massimo affondamento (tengo conto dell'inclinazione utensile e della pinza con estremità conica) - -- 08/09/2020 tolti i 3mm ( per la ghiera smussata) perchè nella verifica collisione vine creato un cilindro non smussato che rileva la collisione - local dSicOnRad - local dSicOnLegth - if ( abs(nSide) == 1 and abs(vtN:getZ()) >= abs(vtN:getY())) or ( abs(nSide) == 2 and abs(vtN:getY()) >= abs(vtN:getZ())) then - dSicOnRad = ( dThDiam + dExtraForSafety - dToolDiam) / 2 - dSicOnLegth = 0 + vnHead = { 2, 2} + -- se faccia sotto + if nSide == -1 then + vdMaxD[1] = EgtIf( bLarghAsFace, dMaxDepthDnY, dMaxDepthDnZ) + if dWidth + dAgg <= vdMaxD[1] then + nPass = 1 + else + nPass = 2 + dAgg = BD.CUT_EXTRA_MIN + vdMaxD[2] = dMaxDepthDnY + end + -- altrimenti faccia di fianco else - dSicOnRad = ( dThDiam - dToolDiam) / 2 - dSicOnLegth = dExtraForSafety / 2 + nPass = 1 + local dDelta = Proc.Box:getMin():getZ() - b3Solid:getMin():getZ() + if bBottomStart then + vdMaxD[1] = min( dMaxDepthDnZ, dMaxDepthDn - dDelta * abs( vtN:getY()) - BD.COLL_SIC) + else + vdMaxD[1] = min( dMaxDepthDnY, dToolLengthDn - 5 - dDelta * abs( vtN:getY()) - BD.COLL_SIC) + end + if vdMaxD[1] < 0 then nPass = 0 end end - dCollSicMin = max( BD.COLL_SIC, ( dThDiam - dToolDiam) / 2 * abs( EgtIf( abs(vtN:getY()) >= abs(vtN:getZ()), vtN:getZ(), vtN:getY()) / dNzMin)) --- dCollSic = max( BD.COLL_SIC, dSicOnRad * EgtIf( abs(dNz) < GEO.EPS_SMALL, 1, abs( EgtIf( abs(nSide) == 1, vtN:getY(), vtN:getZ()) / dNz)) + dSicOnLegth) - dCollSic = max( BD.COLL_SIC, dSicOnRad * abs( EgtIf( abs(vtN:getY()) >= abs(vtN:getZ()), vtN:getZ(), vtN:getY()) / dNzMin) + dSicOnLegth) - if dWidth + dAgg > dMaxDepth - dCollSic then - sWarn = 'Warning in LongCut : depth is bigger than max tool depth' - end - end - -- profondità prima passata - dDepth = min( dMaxDepth - dCollSicMin, dWidth + dAgg) - -- profondità seconda passata - dDepth2 = dWidth + dAgg - dDepth - if not BD.DOWN_HEAD then - if nPass == 2 and dDepth2 < dAgg then - dDepth = min( dMaxDepth - dCollSicMin, dWidth + dAgg) / 2 - dDepth2 = dWidth + dAgg - dDepth - end - end - if nSide ~= 1 and BD.DOWN_HEAD then - dDepthDn = min( dMaxDepthDn - dCollSicMinDn, dWidth + dAgg) - dDepth2Dn = dWidth + dAgg - EgtIf( abs(nSide) == 2, dDepth, dDepthDn) - if nPass == 2 and dDepth2Dn < dAgg then - dDepthDn = min( dMaxDepthDn - dCollSicMinDn, dWidth + dAgg) / 2 - dDepth2Dn = dWidth + dAgg - EgtIf( abs(nSide) == 2, dDepth, dDepthDn) + -- eventuale errore per lavorazione saltata + if nPass == 0 then + local sErr = 'Error in '..sMchType..' : impossible machining' + EgtOutLog( sErr) + return false, sErr + end + -- eventuale avviso per lavorazione incompleta + if dWidth + nPass * dAgg > vdMaxD[1] + vdMaxD[2] then + sWarn = 'Warning in '..sMchType..' : depth is bigger than max tool depth' end end + -- profondità passate + local vdDepth = {} + vdDepth[1] = min( dWidth + dAgg, vdMaxD[1]) + vdDepth[2] = min( dWidth + dAgg - vdDepth[1], vdMaxD[2]) -- ciclo sulle parti local nM = 0 local bMakeMillHeadEnd local bMakeMillHeadStart local dLioPerp1 = dFacElev + BD.COLL_SIC --- local dLioPerp2 = dWidth + BD.COLL_SIC - local dLioPerp2 = dWidth * EgtIf( abs(dNz) < GEO.EPS_SMALL, 1, sqrt( 1 - dNz * dNz) / abs( dNz)) + BD.COLL_SIC + local dLioPerp2 = dWidth * EgtIf( abs( vtN:getZ()) < GEO.EPS_SMALL, 1, sqrt( 1 - vtN:getZ() * vtN:getZ()) / abs( vtN:getZ())) + BD.COLL_SIC -- valore sovrapposizione tra passate - local dOverLapExtend = 2 + local dOverLapExtend = 2 * BD.CUT_EXTRA_MIN for j = 1, nC do -- Limitazioni della lavorazione local nPos = EgtIf( bFront, j, nC - j + 1) @@ -1376,11 +1357,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus local dEal = EgtIf( nPos == nC, -dStartDist, -dStartAccDist - ( nC - nPos - 1) * dC + dOverLapExtend) -- Posizione braccio portatesta local nSCC - local dExtraElev_1st = 0 - local dExtraElevDn_1st = 0 for k = 1, nPass do - --- if EgtIf( k == 1, bFront, not bFront) then if bFront then nSCC = EgtIf( ( BD.C_SIMM or j == 1 or j == nC - 1), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) else @@ -1388,31 +1365,19 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus end -- inserisco le parti di lavorazione nM = nM + 1 - local sNameF - local nMchFId - if BD.DOWN_HEAD and k == 2 and nSide ~= 1 then - sNameF = sPrefixDn .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM) - nMchFId = EgtAddMachining( sNameF, sMillingDn) - if not nMchFId then - local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMillingDn - EgtOutLog( sErr) - return false, sErr - end - else - sNameF = sPrefix .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM) - nMchFId = EgtAddMachining( sNameF, sMilling) - if not nMchFId then - local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling - EgtOutLog( sErr) - return false, sErr - end + local sNameF = EgtIf( vnHead[k] ~= 2, sPrefix, sPrefixDn) .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM) + local nMchFId = EgtAddMachining( sNameF, EgtIf( vnHead[k] ~= 2, sMilling, sMillingDn)) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMillingDn + EgtOutLog( sErr) + return false, sErr end -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, 0}}) -- imposto posizione braccio porta testa per non ingombrare agli estremi EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- imposto uso faccia - local nUseFace = MCH_MILL_FU.PARAL_DOWN + local nUseFace = EgtIf( vnHead[k] ~= 2, MCH_MILL_FU.PARAL_DOWN, MCH_MILL_FU.PARAL_TOP) if AreSameOrOppositeVectorApprox( vtN, Z_AX()) then nUseFace = MCH_MILL_FU.PARAL_BACK end EgtSetMachiningParam( MCH_MP.FACEUSE, nUseFace) -- imposto lato di lavoro e inversione @@ -1429,185 +1394,8 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) -- assegno affondamento - local dExtraElev = 0 - local dExtraElevDn = 0 - - if not BD.DOWN_HEAD then - -- se prima lavorazione non da sotto o seconda lavorazione da sotto e componente Y <= 60° e > 0 - if ( ( k == 1 and nSide ~= -1) or ( k == 2 and nSide == -1)) and abs(vtN:getY()) <= 0.866 and abs(vtN:getY()) > GEO.EPS_SMALL then - -- verifico se può collidere in base alle dimensione del portapezzo - local dDistToolTh = (dToolLength - EgtIf( k == 1, dDepth, ( dDepth2 + dExtraElev_1st)) - dThLen) / abs(vtN:getZ()) - local dDistRadTh = dDistToolTh * abs(vtN:getY()) - local dDistSurf = EgtIf( bFront, b3Solid:getMax():getY() - Proc.Box:getMax():getY(), Proc.Box:getMin():getY() - b3Solid:getMin():getY()) - -- raggio portautensile e raggio utensile allora calcolo un arretramento profondità - if dDistSurf > dDistToolTh and dDistRadTh < (( dThDiam - dToolDiam) / 2) then - -- se devo premiare extra sicurezza su lunghezza utensile - if abs(vtN:getY()) > abs(vtN:getZ()) then - dExtraElev = ((( dThDiam - dToolDiam) / 2) - dDistRadTh) * abs(vtN:getZ()) / abs(vtN:getY()) + ( 0.5 * dExtraForSafety) / abs(vtN:getY()) - -- altrimenti premio extra sicurezza su raggio utensile - else - dExtraElev = ((( dThDiam + dExtraForSafety - dToolDiam) / 2) - dDistRadTh) * abs(vtN:getZ()) / abs(vtN:getY()) - end - elseif abs(dDistSurf) > GEO.EPS_SMALL then - if nSide ~= -1 then - dDistSurf = b3Solid:getMax():getZ() - Proc.Box:getMax():getZ() - else - dDistSurf = Proc.Box:getMin():getZ() - b3Solid:getMin():getZ() - end - if dDistSurf * abs(vtN:getZ()) > (( dThDiam + dToolDiam) * 0.5) then - dExtraElev = dDistSurf * abs(vtN:getY()) - end - end - -- altrimenti prima lavorazione di fianco con componente Z negativa - elseif k == 1 and abs(nSide) == 2 and vtN:getZ() > -0.866 and vtN:getZ() < - GEO.EPS_SMALL then - -- verifico se può collidere in base alle dimensione del portapezzo - local dDistToolTh = (dToolLength - dDepth - dThLen) / abs(vtN:getY()) - local dDistRadTh = dDistToolTh * abs(vtN:getZ()) - local dDistSurf = b3Solid:getMax():getZ() - Proc.Box:getMax():getZ() - -- raggio portautensile e raggio utensile allora calcolo un arretramento profondità - if dDistSurf > dDistToolTh and dDistRadTh < (( dThDiam - dToolDiam) / 2) then - -- se devo premiare extra sicurezza su lunghezza utensile - if abs(vtN:getY()) > abs(vtN:getZ()) then - dExtraElev = ((( dThDiam - dToolDiam) / 2) - dDistRadTh) * abs(vtN:getY()) / abs(vtN:getZ()) + ( 0.5 * dExtraForSafety) / abs(vtN:getZ()) - -- altrimenti premio extra sicurezza su raggio utensile - else - dExtraElev = ((( dThDiam + dExtraForSafety - dToolDiam) / 2) - dDistRadTh) * abs(vtN:getY()) / abs(vtN:getZ()) - end - elseif abs( dDistSurf) < GEO.EPS_SMALL then - if bFront then - dDistSurf = Proc.Box:getMin():getY() - b3Solid:getMin():getY() - else - dDistSurf = b3Solid:getMax():getY() - Proc.Box:getMax():getY() - end - if dDistSurf * abs(vtN:getY()) > (( dThDiam + dToolDiam) * 0.5) then - dExtraElev = dDistSurf * abs(vtN:getZ()) - end - end - end - -- altrimenti con testa da sotto - else - -- se prima lavorazione non da sotto e componente y <= 60° e > 0 - if ( k == 1 and nSide ~= -1) and abs(vtN:getY()) <= 0.866 and abs(vtN:getY()) > GEO.EPS_SMALL then - -- verifico se può collidere in base alle dimensione del portapezzo - local dDistToolTh = (dToolLength - dDepth - dThLen) / abs(vtN:getZ()) - local dDistRadTh = dDistToolTh * abs(vtN:getY()) - local dDistSurf = EgtIf( bFront, b3Solid:getMax():getY() - Proc.Box:getMax():getY(), Proc.Box:getMin():getY() - b3Solid:getMin():getY()) - -- raggio portautensile e raggio utensile allora calcolo un arretramento profondità - if dDistSurf > dDistToolTh and dDistRadTh < (( dThDiam - dToolDiam) * 0.5) then - -- se devo premiare extra sicurezza su lunghezza utensile - if abs(vtN:getZ()) > abs(vtN:getY()) then - dExtraElev = ((( dThDiam - dToolDiam) * 0.5) - dDistRadTh) * abs(vtN:getZ()) / abs(vtN:getY()) + ( 0.5 * dExtraForSafety) / abs(vtN:getY()) - -- altrimenti premio extra sicurezza su raggio utensile - else - dExtraElev = ((( dThDiam + dExtraForSafety - dToolDiam) * 0.5) - dDistRadTh) * abs(vtN:getZ()) / abs(vtN:getY()) - end - elseif abs(dDistSurf) < GEO.EPS_SMALL then - dDistSurf = b3Solid:getMax():getZ() - Proc.Box:getMax():getZ() - if dDistSurf * vtN:getZ() > (( dThDiam + dToolDiam) * 0.5) then - dExtraElev = dDistSurf * abs(vtN:getY()) - end - end - -- se seconda lavorazione sopra e componente Z > 0 - elseif k == 2 and nSide == 1 and vtN:getZ() > GEO.EPS_SMALL then - local dDistToolTh = (dToolLength - ( dDepth2 + dExtraElev_1st) - dThLen) / abs(vtN:getY()) - local dDistRadTh = dDistToolTh * abs(vtN:getZ()) - local dDistSurf = Proc.Box:getMin():getZ() - b3Solid:getMin():getZ() - -- raggio portautensile e raggio utensile allora calcolo un arretramento profondità - if dDistSurf > dDistToolTh and dDistRadTh < (( dThDiam - dToolDiam) * 0.5) then - -- premio extra sicurezza su lunghezza utensile - if abs(vtN:getZ()) > abs(vtN:getY()) then - dExtraElev = ((( dThDiam - dToolDiam) * 0.5) - dDistRadTh) * abs(vtN:getY()) / abs(vtN:getZ()) + ( 0.5 * dExtraForSafety) / vtN:getZ() - -- altrimenti premio extra sicurezza su raggio utensile - else - dExtraElev = ((( dThDiam + dExtraForSafety - dToolDiam) * 0.5) - dDistRadTh) * abs(vtN:getY()) / abs(vtN:getZ()) - end - end - -- se prima lavorazione di fianco e componente Z > 0 - elseif k == 1 and abs(nSide) == 2 and vtN:getZ() < GEO.EPS_SMALL then - local dDistToolTh = (dToolLength - dDepth - dThLen) / abs(vtN:getY()) - local dDistRadTh = dDistToolTh * abs(vtN:getZ()) - local dDistSurf = b3Solid:getMax():getZ() - Proc.Box:getMax():getZ() - -- raggio portautensile e raggio utensile allora calcolo un arretramento profondità - if dDistSurf > dDistToolTh and dDistRadTh < (( dThDiam - dToolDiam) * 0.5) then - -- se devo premiare extra sicurezza su lunghezza utensile - if abs(vtN:getY()) > abs(vtN:getZ()) then - dExtraElev = (dDistSurf - dDistToolTh + ( 0.5 * dExtraForSafety)) / abs(vtN:getY()) - -- altrimenti premio extra sicurezza su raggio utensile - else - dExtraElev = (( dThDiam - dToolDiam) * 0.5) * abs(vtN:getY()) / abs(vtN:getZ()) - (dToolLength - dDepth - dThLen) + ( 0.5 * dExtraForSafety) / abs(vtN:getZ()) - end - elseif abs(dDistSurf) < GEO.EPS_SMALL then - if bFront then - dDistSurf = Proc.Box:getMin():getY() - b3Solid:getMin():getY() - else - dDistSurf = b3Solid:getMax():getY() - Proc.Box:getMax():getY() - end - if dDistSurf * abs(vtN:getY()) > (( dThDiam + dToolDiam) * 0.5) then - dExtraElev = dDistSurf * abs(vtN:getZ()) - end - end - -- se seconda lavorazione di fianco e componente Z > 0 - elseif k == 2 and abs(nSide) == 2 and vtN:getZ() > GEO.EPS_SMALL then - local dDistToolThDn = (dToolLengthDn - ( dDepth2Dn + dExtraElevDn_1st) - dThLenDn) / abs(vtN:getY()) - local dDistRadThDn = dDistToolThDn * abs(vtN:getZ()) - local dDistSurfDn = Proc.Box:getMin():getZ() - b3Solid:getMin():getZ() - -- raggio portautensile e raggio utensile allora calcolo un arretramento profondità - if dDistSurfDn > dDistToolThDn and dDistRadThDn < (( dThDiamDn - dToolDiamDn) * 0.5) then - -- se devo premiare extra sicurezza su lunghezza utensile - if abs(vtN:getY()) > abs(vtN:getZ()) then - dExtraElevDn = ((( dThDiamDn - dToolDiamDn) * 0.5) - dDistRadThDn) * abs(vtN:getY()) / abs(vtN:getZ()) + ( 0.5 * dExtraForSafety) / vtN:getZ() - -- altrimenti premio extra sicurezza su raggio utensile - else - dExtraElevDn = ((( dThDiamDn + dExtraForSafety - dToolDiamDn) * 0.5) - dDistRadThDn) * abs(vtN:getY()) / abs(vtN:getZ()) - end - elseif abs(dDistSurfDn) < GEO.EPS_SMALL then - if bFront then - dDistSurfDn = Proc.Box:getMin():getY() - b3Solid:getMin():getY() - else - dDistSurfDn = b3Solid:getMax():getY() - Proc.Box:getMax():getY() - end - if dDistSurfDn * abs(vtN:getY()) > (( dThDiamDn + dToolDiamDn) * 0.5) then - dExtraElevDn = dDistSurfDn * abs(vtN:getZ()) - end - end - -- se seconda lavorazione da sotto a componente Y < 60° e Y > 0 - elseif ( k == 2 and nSide == -1) and abs(vtN:getY()) <= 0.866 and abs(vtN:getY()) > GEO.EPS_SMALL then - -- verifico se può collidere in base alle dimensione del portapezzo - local dDistToolThDn = (dToolLengthDn - ( dDepth2Dn + dExtraElevDn_1st) - dThLenDn) / abs(vtN:getY()) - local dDistRadThDn = dDistToolThDn * abs(vtN:getZ()) - local dDistSurfDn = EgtIf( bFront, b3Solid:getMax():getY() - Proc.Box:getMax():getY(), Proc.Box:getMin():getY() - b3Solid:getMin():getY()) - -- raggio portautensile e raggio utensile allora calcolo un arretramento profondità - if dDistSurfDn > dDistToolThDn and dDistRadThDn < (( dThDiamDn - dToolDiamDn) * 0.5) then - -- se devo premiare extra sicurezza su lunghezza utensile - if abs(vtN:getZ()) > abs(vtN:getY()) then - dExtraElevDn = ((( dThDiamDn - dToolDiamDn) * 0.5) - dDistRadThDn) * abs(vtN:getY()) / abs(vtN:getZ()) + ( 0.5 * dExtraForSafety) / abs(vtN:getY()) - -- altrimenti premio extra sicurezza su raggio utensile - else - dExtraElevDn = ((( dThDiamDn + dExtraForSafety - dToolDiamDn) * 0.5) - dDistRadThDn) * abs(vtN:getY()) / abs(vtN:getZ()) - end - elseif abs(dDistSurfDn) < GEO.EPS_SMALL then - dDistSurfDn = Proc.Box:getMin():getZ() - b3Solid:getMin():getZ() - if dDistSurfDn * abs(vtN:getZ()) > (( dThDiamDn + dToolDiamDn) * 0.5) then - dExtraElevDn = dDistSurfDn * abs(vtN:getY()) - end - end - end - end - - if BD.DOWN_HEAD and k == 2 and nSide ~= 1 then - EgtSetMachiningParam( MCH_MP.DEPTH, dDepth2Dn - dExtraElevDn) - dExtraElevDn_1st = dExtraElevDn - if dExtraElevDn > 0 and sWarn and #sWarn < 1 then - sWarn = 'Warning in LongCut_2 : depth is bigger than max tool depth' - end - else - EgtSetMachiningParam( MCH_MP.DEPTH, EgtIf( k == 1, dDepth, dDepth2) - dExtraElev) - dExtraElev_1st = dExtraElev - if dExtraElev > 0 and sWarn and #sWarn < 1 then - sWarn = 'Warning in LongCut : depth is bigger than max tool depth' - end - end - -- assegbo attacco perpendicolare + EgtSetMachiningParam( MCH_MP.DEPTH, vdDepth[k]) + -- assegno attacco perpendicolare EgtSetMachiningParam( MCH_MP.LIPERP, dLioPerp1) EgtSetMachiningParam( MCH_MP.LOPERP, dLioPerp1) -- eseguo diff --git a/LuaLibs/ProcessSawCut.lua b/LuaLibs/ProcessSawCut.lua index ca43ccd..807f995 100644 --- a/LuaLibs/ProcessSawCut.lua +++ b/LuaLibs/ProcessSawCut.lua @@ -1,4 +1,4 @@ --- ProcessSawCut.lua by Egaltech s.r.l. 2021/01/15 +-- ProcessSawCut.lua by Egaltech s.r.l. 2022/03/07 -- Gestione calcolo taglio di lama per Travi -- Tabella per definizione modulo @@ -31,7 +31,7 @@ function ProcessSawCut.Classify( Proc, b3Raw) if not AuxId then return false end AuxId = AuxId + Proc.Id local vtDir = EgtSV( AuxId, GDB_ID.ROOT) - return true, ( vtDir:getZ() <= - 0.088) + return true, ( vtDir:getZ() <= - 0.5) end ---------------------------------------------------------------------