From a43e323df8b8b5bbc195402b48ab0f5945cab85f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 15 Oct 2020 18:52:24 +0000 Subject: [PATCH] DataBeam : - altre correzioni per fori inclinati (fronte/sopra) - corretta gestione ingombro ghiera portautensili su fori inclinati con punte - gestione distanza da pezzo successivo per ribassi con sega a catena. --- LuaLibs/BeamExec.lua | 5 +-- LuaLibs/MachiningLib.lua | 10 ++++-- LuaLibs/ProcessDrill.lua | 19 +++++----- LuaLibs/ProcessLapJoint.lua | 69 +++++++++++++++++++++++++++++++------ 4 files changed, 79 insertions(+), 24 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index f388f61..1bd41ec 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,4 +1,4 @@ --- BeamExec.lua by Egaltech s.r.l. 2020/10/07 +-- BeamExec.lua by Egaltech s.r.l. 2020/10/15 -- Libreria esecuzione lavorazioni per Travi -- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- 2019/09/04 Corretto controllo feature di testa e coda con sovramateriale di testa elevato. @@ -17,6 +17,7 @@ -- 2020/07/25 Ricalcolati flag head e tail della prima parte del foro dopo lo split. -- 2020/07/27 Modifica a ordinamento fori. -- 2020/10/07 Aggiunta distanza libera dietro il pezzo (BDST) scritta nel suo grezzo. +-- 2020/10/15 Per foro sdoppiato ricalcolo anche flag Head oltre a Tail . -- Tabella per definizione modulo local BeamExec = {} @@ -379,7 +380,7 @@ local function CollectFeatures( PartId, b3Raw, dCurrOvmH) Proc2.Box = BBox3d( Proc.Box) Proc2.Fct = Proc.Fct Proc2.Diam = Proc.Diam - Proc2.Head = Proc.Head + Proc2.Head = Drill.IsHeadFeature( Proc2, b3Raw, dCurrOvmH) Proc2.Tail = Drill.IsTailFeature( Proc2, b3Raw, dCurrOvmH) Proc2.Fcs = Proc.Fce Proc2.Fce = Proc.Fcs diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 49ddbdb..50ca513 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -1,4 +1,4 @@ --- MachiningLib.lua by Egaltech s.r.l. 2020/09/15 +-- MachiningLib.lua by Egaltech s.r.l. 2020/10/14 -- Libreria ricerca lavorazioni per Travi -- Tabella per definizione modulo @@ -89,9 +89,12 @@ function MachiningLib.FindDrilling( dDiam, dDepth) local dMaxToolLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) local dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) local dDiamTh = EgtTdbGetCurrToolThDiam() + local dLenTh = 72 + if EgtTdbGetCurrToolThLength then dLenTh = EgtTdbGetCurrToolThLength() end + local dFreeLen = EgtTdbGetCurrToolParam( MCH_TP.LEN) - dLenTh - EgtMdbGetGeneralParam( MCH_GP.MAXDEPTHSAFE) if dTDiam < dDiam + 10 * GEO.EPS_SMALL and dTDiam > dDiam - BD.DRILL_TOL - 10 * GEO.EPS_SMALL then if not dDepth or dTMaxMat > dDepth - GEO.EPS_SMALL then - return Drilling.Name, Drilling.Type, dTMaxMat, dMaxToolLength, dToolDiam, dDiamTh + return Drilling.Name, Drilling.Type, dTMaxMat, dMaxToolLength, dToolDiam, dDiamTh, dFreeLen end end end @@ -105,9 +108,10 @@ function MachiningLib.FindDrilling( dDiam, dDepth) local dMaxToolLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) local dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) local dDiamTh = EgtTdbGetCurrToolThDiam() + local dFreeLen = dMaxToolLength if dTDiam < dDiam - 10 * GEO.EPS_SMALL then if not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL then - return Drilling.Name, Drilling.Type, dTMaxDepth, dMaxToolLength, dToolDiam, dDiamTh + return Drilling.Name, Drilling.Type, dTMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dFreeLen end end end diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index 02adcc8..4d87599 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -1,4 +1,4 @@ --- ProcessDrill.lua by Egaltech s.r.l. 2020/09/24 +-- ProcessDrill.lua by Egaltech s.r.l. 2020/10/14 -- Gestione calcolo forature per Travi -- Tabella per definizione modulo @@ -133,7 +133,7 @@ function ProcessDrill.Classify( Proc, b3Raw) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) local ptCen = EgtCP( AuxId, GDB_RT.GLOB) -- se lavorato in doppio, devo considerare il lato più sfavorevole - if Proc.Flg == 2 or Proc.Flg == -2 then + if Proc.Flg == -2 or ( BD.ROT90 and Proc.Flg == 2) then if vtExtr:getZ() > 0 then vtExtr = - vtExtr ptCen = ptCen + vtExtr * dLen @@ -144,7 +144,7 @@ function ProcessDrill.Classify( Proc, b3Raw) return false, false, false end local bOpen = ( Proc.Fce ~= 0) - local bFaceDown = ( ptCen:getZ() < b3Raw:getMin():getZ() + 2 and not Proc.Head and not Proc.Tail) + local bFaceDown = ( ptCen:getZ() < b3Raw:getMin():getZ() + 2 and (( not Proc.Head and not Proc.Tail) or ( BD.ROT90 and ( Proc.Flg == 2 or Proc.Flg == -2)))) -- verifico se il foro è sotto e quindi va spostato o sopra o sul fianco if (( vtExtr:getZ() < BD.DRILL_VZ_MIN or bFaceDown) and ( not bOpen or Proc.Flg ~= 1)) then if not bOpen then @@ -196,7 +196,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) dCheckDepth = nil end -- recupero la lavorazione - local sDrilling, nType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh = ML.FindDrilling( dDiam, dCheckDepth) + local sDrilling, nType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, dCheckDepth) if not sDrilling then -- se non ho passato altezza di taglio utensile allora non è stato trovato utensile if not dCheckDepth then @@ -206,7 +206,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) -- altrimenti rifaccio la ricerca foratura senza passare altezza utensile else dCheckDepth = nil - sDrilling, nType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh = ML.FindDrilling( dDiam) + sDrilling, nType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam) if not sDrilling then local sErr = 'Error : drilling not found in library' EgtOutLog( sErr) @@ -215,7 +215,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) end end -- se la lunghezza utensile massima supera il valore limite del BeamData e la componente Z supera i 10 gradi - -- allore ricerco un utensile senza lunghezza massima + -- allora ricerco un utensile senza lunghezza massima 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 -- se non ho passato altezza di taglio utensile allora la lunghezza utensile non è idonea per il taglio if not dCheckDepth then @@ -224,7 +224,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) return false, sErr -- rifaccio ricerca lavorazione senza specificare la profondità (dovrebbe trovare l'utensile più corto) else - sDrilling, nType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh = ML.FindDrilling( dDiam) + sDrilling, nType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam) if not sDrilling then local sErr = 'Error : drilling not found in library' EgtOutLog( sErr) @@ -243,7 +243,8 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) local dSubL2 = 0 local dSubL3 = 0 -- se foro non su testa o coda e inclinato, limito il massimo affondamento - if not ( ( Proc.Fcs == 5 or Proc.Fcs == 6) or ( bToInvert and ( Proc.Fce == 5 or Proc.Fce == 6))) then + local bInvertFcse = ( bToInvert and Proc.Flg ~= -2) + if ( not bInvertFcse and Proc.Fcs ~= 5 and Proc.Fcs ~= 6) or ( bInvertFcse and Proc.Fce ~= 5 and Proc.Fce ~= 6) then local CosB = abs( vtExtr:getX()) if CosB < BD.DRILL_VX_MAX then local TgA = CosB / sqrt( 1 - CosB * CosB) @@ -274,7 +275,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) end local dSubL = max( dSubL1, dSubL2, dSubL3) if dMaxDepth > 0 then - dMaxDepth = dMaxDepth - dSubL + dMaxDepth = min( dMaxDepth, dToolFreeLen - dSubL) end -- inserisco la lavorazione local sName = 'Drill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index a0d8210..7c12c6f 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2020/10/14 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/10/15 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. @@ -1874,6 +1874,10 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, dDepthCham, b3FacesUsed) local bOrthoFaces local sWarn + -- ingombro del grezzo + local b3Raw = EgtGetRawPartBBox( nRawId) + -- ottengo la distanza tra la fine del pezzo e il pezzo successivo + local dDistToNextPiece = EgtGetInfo( nRawId, 'BDST', 'd') or 5.4 if b3FacesUsed then -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa local nFacInd1, dFacElev1, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId, b3FacesUsed) @@ -1935,6 +1939,7 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, -- Determino se estremi aperti o chiusi local bOpenStart = false local bOpenEnd = false + local vtNS, vtNE -- se non ho la faccia di fondo ( che comporta essere una fessura) verifico se ho lati aperti if not nBottomFace then local vAdj2 = EgtSurfTmFacetAdjacencies( Proc.Id, nFacAdj)[1] @@ -1947,12 +1952,20 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, i = EgtIf( i > 1, i - 1, #vAdj2) end bOpenStart = ( vAdj2[i] < 0) + -- se è chiusa acquisisco vettore faccia tappo + if not bOpenStart and vAdj2[i] >= 0 then + _, vtNS = EgtSurfTmFacetCenter( Proc.Id, vAdj2[i], GDB_ID.ROOT) + end -- Se non esiste faccia adiacente a lato successivo -> fine aperto local k = EgtIf( j < #vAdj2, j + 1, 1) while vAdj2[k] == nFacInd do k = EgtIf( k < #vAdj2, k + 1, 1) end bOpenEnd = ( vAdj2[k] < 0) + -- se è chiusa acquisisco vettore faccia tappo + if not bOpenEnd and vAdj2[k] >= 0 then + _, vtNE = EgtSurfTmFacetCenter( Proc.Id, vAdj2[k], GDB_ID.ROOT) + end end end end @@ -1993,8 +2006,6 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, end -- Calcolo uso faccia local nFaceUse = BL.GetNearestOrthoOpposite( rfFac:getVersZ()) - -- ingombro del grezzo - local b3Raw = EgtGetRawPartBBox( nRawId) -- Eseguo i tagli local nStep = ceil( ( dV - 10 * GEO.EPS_SMALL) / dSawThick) local dStep = 0 @@ -2006,6 +2017,14 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, nFacAdj, sCutting, dSawDiam, nFaceUse, -0.01, 0, BD.CUT_SIC, dOffs, 0, nil, b3Raw) if not bOk then return bOk, sErr end end + -- in base all'elevazione calcolo l'impronta della lama + local dUsedBladeLen = sqrt( ((dSawDiam / 2)*(dSawDiam / 2)) - ( ( (dSawDiam / 2) - dElev) * ( (dSawDiam / 2) - dElev))) + -- controllo direzione taglio e se il minimo della feature sborda in coda + if not Proc.Tail and abs( vtN:getX()) < GEO.EPS_SMALL and abs( b3Solid:getMin():getX() - Proc.Box:getMin():getX()) < 100 * GEO.EPS_SMALL and dDistToNextPiece < dUsedBladeLen then + -- do avviso che la lama può sbordare nel pezzo successivo + sWarn = 'Warning on saw cut : Cut machining can damage next piece' + EgtOutLog( sWarn .. ' (process ' .. tostring( Proc.Id) .. ')') + end -- altrimenti con sega a catena else -- Recupero la lavorazione @@ -2067,9 +2086,29 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, EgtSetMachiningGeometry( {{ Proc.Id, nFacAdj}}) -- imposto uso faccia EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) - -- imposto accorciamento iniziale/finale per estremi aperti/chiusi - EgtSetMachiningParam( MCH_MP.STARTADDLEN, EgtIf( bOpenStart, 0, - dSawWidth / 2)) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, EgtIf( bOpenEnd, 0, - dSawWidth / 2)) + -- controllo direzione taglio e se il minimo della feature sborda in coda + if not Proc.Tail and abs( vtN:getX()) < GEO.EPS_SMALL and abs( b3Solid:getMin():getX() - Proc.Box:getMin():getX()) < 100 * GEO.EPS_SMALL then + -- se ho lato partenza aperto e lato uscita chiuso e direzione lato chiuso è negativa, allora controllo uscita lama + if bOpenStart and not bOpenEnd and vtNE:getX() < -0.99 and dDistToNextPiece < (dSawWidth / 2) then + -- imposto accorciamento iniziale per estremi aperti/chiusi + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dDistToNextPiece - 1 - (dSawWidth / 2)) + else + -- imposto accorciamento iniziale per estremi aperti/chiusi + EgtSetMachiningParam( MCH_MP.STARTADDLEN, EgtIf( bOpenStart, 0, - dSawWidth / 2)) + end + -- se ho lato uscita aperto e lato partenza chiuso e direzione lato partenza è negativa, allora controllo uscita lama + if bOpenEnd and not bOpenStart and vtNS:getX() < -0.99 and dDistToNextPiece < (dSawWidth / 2) then + -- imposto accorciamento finale per estremi aperti/chiusi + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dDistToNextPiece - 1 - (dSawWidth / 2)) + else + -- imposto accorciamento finale per estremi aperti/chiusi + EgtSetMachiningParam( MCH_MP.ENDADDLEN, EgtIf( bOpenEnd, 0, - dSawWidth / 2)) + end + else + -- imposto accorciamento iniziale/finale per estremi aperti/chiusi + EgtSetMachiningParam( MCH_MP.STARTADDLEN, EgtIf( bOpenStart, 0, - dSawWidth / 2)) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, EgtIf( bOpenEnd, 0, - dSawWidth / 2)) + end -- imposto angolo 3° asse rot EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, 'A=' .. EgtNumToString( d3RotAng)) -- imposto offset radiale @@ -3244,8 +3283,17 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa elseif abs( vtN:getX()) > 0.707 or abs( vtN:getY()) > 0.707 or abs( vtN:getZ()) > 0.707 then dCollSic = 5 * BD.COLL_SIC end + -- settaggio voluto da Alessandro local sMchFind = EgtIf( bSinglePart, 'Pocket', 'OpenPocket') local nUseRoughTool = EgtIf( bSinglePart, 0, 1) + -- fino a che nelle svuotature non si può decidere il punto di inizio faccio delle valutazioni + -- se ho passi multipli controllo il numero delle facce + if not bSinglePart then + -- se ho 3 o più facce allora re-imposto il tipo di svuotatura + if ( Proc.Fct == 3 and bIsU) or Proc.Fct > 3 then + sMchFind = 'Pocket' + end + end local dDiam = min( dH, dV) local dDiamMax local nUseRT @@ -3264,7 +3312,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa end end -- verifico dalla forma se non posso prendere utensile grande - if ( Proc.Fct == 3 and bIsU) or ( Proc.Fct == 2 and bIsL) or Proc.Fct == 1 then + if ( Proc.Fct == 3 and bIsU and bSinglePart) or ( Proc.Fct == 2 and bIsL) or Proc.Fct == 1 then --ottengo un diametro utensile opportuno dDiam, sMchFind, nUseRoughTool, dDiamMax = CheckDiamToolByFaces( Proc, nFacInd, dH, dV, bIsU, bIsL, ( dFacElev + dCollSic), nUseRoughTool) if not dDiam and nUseRoughTool == 0 then @@ -3381,6 +3429,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa return false, sErr elseif nOk > 0 then bTryWithBlades = false + sWarn = sErr end bOk = true end @@ -3399,9 +3448,9 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa if not bOk and sStat == 'MNF' then sPocketing = ML.FindPocketing( sMchFind, dDiam) if not sPocketing then - local sErr = 'Error : pocketing not found in library' - EgtOutLog( sErr) - return false, sErr + local sErr2 = 'Error : pocketing not found in library' + EgtOutLog( sErr2) + return false, sErr2 end else return bOk, sWarn