From 031ad00966741fd5566e43e70e7d5f4f4ab803f2 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 22 Feb 2021 10:56:12 +0000 Subject: [PATCH] DataBeam : - aggiunto controllo file macchina mlde per ricalcolo - modifiche per PF1250. --- BatchProcess.lua | 6 +- BatchProcessNew.lua | 3 +- LuaLibs/FacesBySaw.lua | 21 +-- LuaLibs/ProcessCut.lua | 324 +++++++++++++++++++++++++++++------ LuaLibs/ProcessDoubleCut.lua | 54 +++--- LuaLibs/ProcessDtTenon.lua | 4 + 6 files changed, 321 insertions(+), 91 deletions(-) diff --git a/BatchProcess.lua b/BatchProcess.lua index b07ff62..386c191 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -1,4 +1,4 @@ --- BatchProcess.lua by Egaltech s.r.l. 2021/02/14 +-- BatchProcess.lua by Egaltech s.r.l. 2021/02/22 -- Gestione calcolo batch disposizione e lavorazioni per Travi -- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- 2019/07/16 Aggiunta gestione modalità oltre 10 per impostazione macchina e uscita. @@ -18,6 +18,7 @@ -- 2020/06/12 Si esegue sempre Processing se parametri macchina TS3 successivi al btl. -- 2021/02/04 Se necessario ricalcolo allora si aggiorna anche l'attrezzaggio. -- 2021/02/14 Modifica per macchine senza BD.MAX_WIDTH2 e BD.MAX_HEIGHT2. +-- 2021/02/22 Aggiunto anche controllo su file macchina mlde per aggiornare calcoli. -- Intestazioni require( 'EgtBase') @@ -166,7 +167,8 @@ if bBtl and string.find( sTitle, 'Bar_', 1, true) and EgtExistsFile( sNgeFile) t bToProcess = false -- se cambiata configurazione macchina da ultima elaborazione, devo riprocessare if EgtCompareFilesLastWriteTime( sOriFile, sMachDir .. '\\Beam\\TS3Data.lua') == -1 or - EgtCompareFilesLastWriteTime( sOriFile, sMachDir .. '\\Tools\\Tools.data') == -1 then + EgtCompareFilesLastWriteTime( sOriFile, sMachDir .. '\\Tools\\Tools.data') == -1 or + EgtCompareFilesLastWriteTime( sOriFile, sMachDir .. '\\' .. sMachine ..'.mlde') == -1 then bToRecalc = true end end diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 9165a1a..0eb5351 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -147,7 +147,8 @@ if bBtl and string.find( sTitle, 'Bar_', 1, true) and EgtExistsFile( sNgeFile) t bToProcess = false -- se cambiata configurazione macchina da ultima elaborazione, devo aggiornare if EgtCompareFilesLastWriteTime( sOriFile, sMachDir .. '\\Beam\\TS3Data.lua') == -1 or - EgtCompareFilesLastWriteTime( sOriFile, sMachDir .. '\\Tools\\Tools.data') == -1 then + EgtCompareFilesLastWriteTime( sOriFile, sMachDir .. '\\Tools\\Tools.data') == -1 or + EgtCompareFilesLastWriteTime( sOriFile, sMachDir .. '\\' .. sMachine ..'.mlde') == -1 then bToRecalc = true end end diff --git a/LuaLibs/FacesBySaw.lua b/LuaLibs/FacesBySaw.lua index 5d99c4b..4420860 100644 --- a/LuaLibs/FacesBySaw.lua +++ b/LuaLibs/FacesBySaw.lua @@ -16,7 +16,7 @@ local BD = require( 'BeamData') local ML = require( 'MachiningLib') --------------------------------------------------------------------- -function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutName, bUpdateIng) +function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutType, bUpdateIng, bDownHead) -- bUpdateIng : parametro opzionale con default true if bUpdateIng == nil then bUpdateIng = true end -- recupero l'ingombro del grezzo di appartenenza @@ -25,13 +25,13 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutName, local Ls = EgtGetFirstNameInGroup( nPartId, 'Box') local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD) if not b3Solid then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' part box not found' + local sErr = 'Error : part box not found' EgtOutLog( sErr) return false, sErr end -- verifico il numero di facce della tacca if Proc.Fct < 2 then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' TwoFacesBySaw facet number not supported' + local sErr = 'Error : TwoFacesBySaw facet number not supported' EgtOutLog( sErr) return false, sErr end @@ -44,15 +44,15 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutName, local bFaceOk = {} bFaceOk[1] = ( vtN[1]:getZ() >= BD.NZ_MINB) bFaceOk[2] = ( vtN[2]:getZ() >= BD.NZ_MINB) - if not bFaceOk[1] and not bFaceOk[2] then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' TwoFacesBySaw from bottom impossible' + if not bDownHead and not bFaceOk[1] and not bFaceOk[2] then + local sErr = 'Error : TwoFacesBySaw from bottom impossible' EgtOutLog( sErr) return false, sErr end -- recupero dati su giunzione tra facce local bTouch, ptT1, ptT2, dAngT = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) if not bTouch then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' TwoFacesBySaw faces not touching' + local sErr = 'Error : TwoFacesBySaw faces not touching' EgtOutLog( sErr) return false, sErr end @@ -80,7 +80,7 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutName, nUpInd = nBigInd end -- recupero la lavorazione - local sCutting = ML.FindCutting( sCutName) + local sCutting = ML.FindCutting( sCutType) if not sCutting then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library' EgtOutLog( sErr) @@ -108,7 +108,7 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutName, -- recupero gruppo per geometria addizionale local nAddGrpId = BL.GetAddGroup( nPartId) if not nAddGrpId then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' + local sErr = 'Error : missing AddGroup' EgtOutLog( sErr) return false, sErr end @@ -166,9 +166,4 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutName, return true end ---------------------------------------------------------------------- -function FacesBySaw.MakeThree( Proc, nPhase, nRawId, nPartId, sCutName) - return false -end - return FacesBySaw \ No newline at end of file diff --git a/LuaLibs/ProcessCut.lua b/LuaLibs/ProcessCut.lua index 15d4888..892f32f 100644 --- a/LuaLibs/ProcessCut.lua +++ b/LuaLibs/ProcessCut.lua @@ -1,4 +1,4 @@ --- ProcessCut.lua by Egaltech s.r.l. 2021/02/05 +-- ProcessCut.lua by Egaltech s.r.l. 2021/02/21 -- Gestione calcolo singoli tagli di lama per Travi -- Tabella per definizione modulo @@ -25,6 +25,11 @@ end --------------------------------------------------------------------- -- Classificazione della feature function ProcessCut.Classify( Proc, b3Raw) + -- se PF con testa da sotto, ammessa qualunque orientazione + if BD.C_SIMM and BD.DOWN_HEAD then + return true + end + -- recupero i dati del taglio local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) if vtN:getZ() <= - 0.5 and abs( vtN:getY()) > 0.1 then local _, DimH, DimV = BL.GetFaceHvRefDim( Proc.Id, 0) @@ -176,8 +181,38 @@ local function MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead) end --------------------------------------------------------------------- --- Applicazione della lavorazione -function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, bCustDiceCut) +-- Aggiornamento ingombro +local function UpdateEncumbrance( Proc, vtN, dOvmHead, nRawId, b3Solid, b3Raw) + -- eventuale segnalazione ingombro di testa o coda (se non chiamata da altre feature) + local dMinHIng = min( 0.5 * BD.VICE_MINH, 0.5 * b3Raw:getDimZ()) + if ProcessCut.Identify( Proc) and Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < b3Raw:getMin():getZ() + dMinHIng then + if Proc.Head then + local dOffs = b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX() + if vtN:getZ() > 0.5 then + dOffs = dOffs - 0.6 * Proc.Box:getDimX() + elseif vtN:getZ() < -0.5 then + dOffs = dOffs - 0.2 * Proc.Box:getDimX() + elseif ( abs( vtN:getY()) > 0.9 and vtN:getZ() > 0.2) then + dOffs = dOffs - 0.3 * Proc.Box:getDimX() + end + BL.UpdateHCING( nRawId, dOffs) + elseif Proc.Tail then + local dOffs = Proc.Box:getMax():getX() - b3Solid:getMin():getX() + if vtN:getZ() > 0.5 then + dOffs = dOffs - 0.6 * Proc.Box:getDimX() + elseif vtN:getZ() < -0.5 then + dOffs = dOffs - 0.2 * Proc.Box:getDimX() + elseif ( abs( vtN:getY()) > 0.9 and vtN:getZ() > 0.2) then + dOffs = dOffs - 0.3 * Proc.Box:getDimX() + end + BL.UpdateTCING( nRawId, dOffs) + end + end +end + +--------------------------------------------------------------------- +-- Applicazione della lavorazione con testa da sopra +local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, bCustDiceCut) -- ingombro del grezzo local b3Raw = EgtGetRawPartBBox( nRawId) -- ingombro del pezzo @@ -195,23 +230,6 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, if not BD.C_SIMM and abs( vtN:getX()) < 0.5 then dNzLimDwnUp = -0.707 end local bDownCut = ( vtN:getZ() <= dNzLimDwnUp) if bFromBottom == nil then bFromBottom = ( b3Solid:getDimX() < BD.LEN_SHORT_PART and vtN:getX() < 0 and vtN:getZ() > 0.25) end - -- se taglio di testa - if Proc.Head then - -- se coincide con il taglio di separazione precedente, non va fatto - if AreSameVectorApprox( vtN, X_AX()) and abs( ptC:getX() - b3Raw:getMax():getX() + dOvmHead) < 10 * GEO.EPS_SMALL then - return true - end - -- altrimenti taglio di coda - else - -- se coincide con taglio di separazione, non va fatto - if AreSameVectorApprox( vtN, - X_AX()) and abs( ptC:getX() - b3Raw:getMin():getX()) < BD.OVM_MID + 10 * GEO.EPS_SMALL then - return true - end - end - -- se coincide con un taglio frontale non va fatto - if Proc.CutFront then - return true - end -- verifico se da considerare taglio lungo ( non da sotto, inclinato meno di 21.56deg, largo come la trave e abbastanza lungo) local bLongCut = ( not bDownCut and vtN:getZ() > 0.93 and Proc.Box:getDimY() > b3Solid:getDimY() - 10 * GEO.EPS_SMALL and @@ -270,13 +288,6 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, local bOkc, sErrC = MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead) if not bOkc then return bOkc, sErrC end end - -- recupero la lavorazione - local sCutting = ML.FindCutting( EgtIf( Proc.Head, 'HeadSide', 'TailSide')) - if not sCutting then - local sErr = 'Error : cutting not found in library' - EgtOutLog( sErr) - return false, sErr - end -- recupero i dati dell'utensile local dSawDiam = 400 local dSawThick = 2 @@ -293,7 +304,6 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, -- determino la direzione di taglio preferenziale local _, dCutH, dCutV = BL.GetFaceHvRefDim( Proc.Id, 0) local bHorizCut = ( dCutV < dMaxVertDepth - BD.CUT_EXTRA and not bDownCut) - --local bHorizCut = (( dCutV < dMaxVertDepth - BD.CUT_EXTRA and dCutH > dMaxDepth - BD.CUT_EXTRA) and not bDownCut) -- verifico se necessari tagli supplementari EgtOutLog( string.format( 'MaxDepth=%.1f MaxVertDepth=%.1f CutH=%.1f CutV=%.1f', dMaxDepth, dMaxVertDepth, dCutH, dCutV), 3) local vCuts = {} @@ -468,33 +478,241 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, return bOk, sErr end end - -- eventuale segnalazione ingombro di testa o coda (se non chiamata da altre feature) - local dMinHIng = min( 0.5 * BD.VICE_MINH, 0.5 * b3Raw:getDimZ()) - if ProcessCut.Identify( Proc) and Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < b3Raw:getMin():getZ() + dMinHIng then - if Proc.Head then - local dOffs = b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX() - if vtN:getZ() > 0.5 then - dOffs = dOffs - 0.6 * Proc.Box:getDimX() - elseif vtN:getZ() < -0.5 then - dOffs = dOffs - 0.2 * Proc.Box:getDimX() - elseif ( abs( vtN:getY()) > 0.9 and vtN:getZ() > 0.2) then - dOffs = dOffs - 0.3 * Proc.Box:getDimX() - end - BL.UpdateHCING( nRawId, dOffs) - elseif Proc.Tail then - local dOffs = Proc.Box:getMax():getX() - b3Solid:getMin():getX() - if vtN:getZ() > 0.5 then - dOffs = dOffs - 0.6 * Proc.Box:getDimX() - elseif vtN:getZ() < -0.5 then - dOffs = dOffs - 0.2 * Proc.Box:getDimX() - elseif ( abs( vtN:getY()) > 0.9 and vtN:getZ() > 0.2) then - dOffs = dOffs - 0.3 * Proc.Box:getDimX() - end - BL.UpdateTCING( nRawId, dOffs) - end - end + -- Aggiornamento ingombro + UpdateEncumbrance( Proc, vtN, dOvmHead, nRawId, b3Solid, b3Raw) return true end +--------------------------------------------------------------------- +-- Applicazione della lavorazione con testa da sotto +local function MakeFromDown( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead) + -- ingombro del grezzo + local b3Raw = EgtGetRawPartBBox( nRawId) + -- ingombro del pezzo + local Ls = EgtGetFirstNameInGroup( nPartId, 'Box') + local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD) + if not b3Solid then + local sErr = 'Error : part box not found' + EgtOutLog( sErr) + return false, sErr + end + -- dati geometrici del taglio + local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) + -- se vero taglio, eventuale inserimento smussi + if Proc.Prc == 10 then + local bOkc, sErrC = MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead) + if not bOkc then return bOkc, sErrC end + end + -- recupero i dati dell'utensile + local dSawDiam = 400 + local dSawThick = 2 + local dMaxDepth = 0 + if EgtMdbSetCurrMachining( sCutting) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam + dSawThick = EgtTdbGetCurrToolParam(MCH_TP.THICK) or dSawThick + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end + local dMaxVertDepth = dMaxDepth + -- determino la direzione di taglio preferenziale + local _, dCutH, dCutV = BL.GetFaceHvRefDim( Proc.Id, 0) + local bHorizCut = ( dCutV < dMaxVertDepth - BD.CUT_EXTRA) + -- verifico se necessari tagli supplementari + EgtOutLog( string.format( 'MaxDepth=%.1f MaxVertDepth=%.1f CutH=%.1f CutV=%.1f', dMaxDepth, dMaxVertDepth, dCutH, dCutV), 3) + local vCuts = {} + if dCutH > dMaxDepth - BD.CUT_EXTRA - 3 * BD.COLL_SIC or dCutV > dMaxVertDepth - BD.CUT_EXTRA - 3 * BD.COLL_SIC then + local ptExtra, vtExtra + local bAutoCalcSurf = true + if bFillAreaPiece or bFillTail then + local ptMiddle = ( b3Solid:getMin() + b3Solid:getMax()) / 2 + ptExtra = Point3d( b3Solid:getMin():getX() + 5*GEO.EPS_SMALL, ptMiddle:getY(), ptMiddle:getZ()) + vtExtra = X_AX() + bAutoCalcSurf = false + end + vCuts = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC, vtN, bAutoCalcSurf, ptExtra, vtExtra, dMaxDepth - BD.CUT_EXTRA) + end + --DC.PrintOrderCut( vCuts) + if #vCuts > 0 then + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error : missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end + -- sistemo posizione nel DB e nome + local bOrthInv = false + for i = 1, #vCuts do + for j = 1, #vCuts[i] do + EgtRelocateGlob( vCuts[i][j], nAddGrpId) + EgtSetName( vCuts[i][j], 'AddCut_' .. tostring( Proc.Id)) + EgtSetInfo( vCuts[i][j], 'TASKID', Proc.TaskId) + if ( i % 2) == 1 then + local vtO = EgtSurfTmFacetNormVersor( vCuts[i][j], 0, GDB_ID.ROOT) + if ( vtN:getY() > 0.707 and vtO:getY() < -0.05) or + ( vtN:getY() < -0.707 and vtO:getY() > 0.05) then + EgtInvertSurf( vCuts[i][j]) + bOrthInv = true + end + end + end + end + -- eseguo + for i = 1, #vCuts do + -- determino il modo di tagliare + local vtOrthoO + local bNoPerpCuts = false + if i % 2 == 1 then + vtOrthoO = Vector3d( vtN) + else + local vtO + if #vCuts[i-1] > 0 then + vtO = EgtSurfTmFacetNormVersor( vCuts[i-1][1], 0, GDB_ID.ROOT) + elseif vCuts[i+1] and #vCuts[i+1] > 0 then + -- lunghezza faccia nell'eventuale direzione ortogonale + local asseX = EgtSurfTmFacetNormVersor( vCuts[i+1][1], 0, GDB_ID.ROOT) + local asseY = asseX ^ vtN + local Frame = Frame3d( ptC, ptC + asseX, ptC + asseY) + local b3Fac = EgtGetBBoxRef( vCuts[i][1], GDB_BB.STANDARD, Frame) + -- se lunghezza inferiore al limite, accetto la direzione + if b3Fac:getDimX() < dMaxDepth - BD.CUT_EXTRA then + vtO = asseX + else + bNoPerpCuts = true + end + else + bNoPerpCuts = true + end + if vtO then + vtOrthoO = Vector3d( vtO) * EgtIf( bOrthInv, -1, 1) + else + if bHorizCut then + vtOrthoO = Z_AX() + elseif vtN:getY() > -0.02 then + if not Proc.Head then + vtOrthoO = -Y_AX() + else + vtOrthoO = Y_AX() + end + else + vtOrthoO = -Y_AX() + end + end + end + -- lavoro la faccia + for j = 1, #vCuts[i] do + -- in generale sta sollevato di pochissimo + local dExtraCut = -0.1 + -- se tagli paralleli + if ( i % 2) == 0 then + -- se non ci sono tagli ortogonali devo affondare + if bNoPerpCuts then + dExtraCut = BD.CUT_EXTRA + -- se altrimenti tagli ortogonali invertiti, devo approfondire dello spessore lama + elseif bOrthInv then + dExtraCut = dSawThick + -- se ultimo taglio, devo affondare + elseif j == #vCuts[i] then + dExtraCut = BD.CUT_EXTRA + end + end + -- taglio (limite Vz Down Up messo a -2 per non farlo mai intervenire) + local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, -2, dExtraCut, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then + return bOk, sErr + end + end + end + -- altrimenti tagli diretti della faccia + else + -- lavoro la faccia + local vtOrthoO + if bHorizCut and ( b3Solid:getDimX() > BD.LEN_SHORT_PART or vtN:getX() > 0) then + vtOrthoO = Z_AX() + elseif b3Solid:getDimX() < BD.LEN_SHORT_PART and abs( vtN:getY()) > 0.259 and vtN:getZ() > -0.174 and abs( vtN:getY()) > abs( vtN:getZ()) and dCutH < dMaxDepth + 10 * GEO.EPS_SMALL then + if Proc.Head then + vtOrthoO = X_AX() + else + vtOrthoO = -X_AX() + end + elseif abs( vtN:getY()) > 0.259 and abs( vtN:getY()) > abs( vtN:getZ()) and dCutH < dMaxDepth + 10 * GEO.EPS_SMALL then + if Proc.Head then + vtOrthoO = X_AX() + else + vtOrthoO = -X_AX() + end + elseif vtN:getY() > -0.02 then + if Proc.Head then + vtOrthoO = -Y_AX() + else + vtOrthoO = Y_AX() + end + else + if Proc.Head then + vtOrthoO = Y_AX() + else + vtOrthoO = -Y_AX() + end + end + -- taglio (limite Vz Down Up messo a -2 per non farlo mai intervenire) + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, vtOrthoO, -2, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then + return bOk, sErr + end + end + -- Aggiornamento ingombro + UpdateEncumbrance( Proc, vtN, dOvmHead, nRawId, b3Solid, b3Raw) + return true +end + +--------------------------------------------------------------------- +-- Applicazione della lavorazione +function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, bCustDiceCut) + -- ingombro del grezzo + local b3Raw = EgtGetRawPartBBox( nRawId) + -- dati geometrici del taglio + local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) + -- se taglio di testa + if Proc.Head then + -- se coincide con il taglio di separazione precedente, non va fatto + if AreSameVectorApprox( vtN, X_AX()) and abs( ptC:getX() - b3Raw:getMax():getX() + dOvmHead) < 10 * GEO.EPS_SMALL then + return true + end + -- altrimenti taglio di coda + else + -- se coincide con taglio di separazione, non va fatto + if AreSameVectorApprox( vtN, - X_AX()) and abs( ptC:getX() - b3Raw:getMin():getX()) < BD.OVM_MID + 10 * GEO.EPS_SMALL then + return true + end + end + -- se coincide con un taglio frontale non va fatto + if Proc.CutFront then + return true + end + -- abilitazione lavorazione da sotto (testa da sotto e direzione normale sotto -20deg) + local bTopHead = ( BD.DOWN_HEAD and vtN:getZ() > -0.342) + local bDownHead = ( BD.DOWN_HEAD and vtN:getZ() < -0.342) + -- recupero la lavorazione + local sCutType = EgtIf( Proc.Head, 'HeadSide', 'TailSide') + local sCutting = ML.FindCutting( sCutType .. EgtIf( bDownHead, '_H2', '')) + if not sCutting and bTopHead then + sCutting = ML.FindCutting( sCutType) + bDownHead = false + end + if not sCutting then + local sErr = 'Error : cutting not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- se taglio con testa da sopra + if not bDownHead then + return MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, bCustDiceCut) + else + return MakeFromDown( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, bCustDiceCut) + end +end + --------------------------------------------------------------------- return ProcessCut diff --git a/LuaLibs/ProcessDoubleCut.lua b/LuaLibs/ProcessDoubleCut.lua index 403c228..95790cd 100644 --- a/LuaLibs/ProcessDoubleCut.lua +++ b/LuaLibs/ProcessDoubleCut.lua @@ -1,4 +1,4 @@ --- ProcessDoubleCut.lua by Egaltech s.r.l. 2021/22/02 +-- ProcessDoubleCut.lua by Egaltech s.r.l. 2021/02/22 -- Gestione calcolo doppi tagli di lama per Travi -- Tabella per definizione modulo @@ -28,6 +28,10 @@ end function ProcessDoubleCut.Classify( Proc, b3Raw) --se una faccia, uso la classificazione dei tagli singoli if Proc.Fct == 1 then return Cut.Classify( Proc, b3Raw) end + -- se PF con testa da sotto, ammessa qualunque orientazione + if BD.C_SIMM and BD.DOWN_HEAD then + return true + end -- verifico se convesso local bAdj, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) local bConvex = ( not bAdj or ( dAng > 0)) @@ -180,23 +184,6 @@ function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- inserimento smussi local bOkc, sErrC = MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead) if not bOkc then return bOkc, sErrC end - -- recupero la lavorazione - local sCutting = ML.FindCutting( EgtIf( bHead, 'HeadSide', 'TailSide')) - if not sCutting then - local sErr = 'Error : cutting not found in library' - EgtOutLog( sErr) - return false, sErr - end - -- recupero i dati dell'utensile - local dSawDiam = 400 - local dMaxDepth = 0 - if EgtMdbSetCurrMachining( sCutting) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth - end - end -- recupero gruppo per geometria addizionale local nAddGrpId = BL.GetAddGroup( nPartId) if not nAddGrpId then @@ -237,6 +224,31 @@ function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- altrimenti concavo else + -- abilitazione lavorazione da sotto (testa da sotto e direzione normale sotto -30deg) + local bTopHead = ( BD.DOWN_HEAD and vtNm:getZ() > -0.5) + local bDownHead = ( BD.DOWN_HEAD and vtNm:getZ() < -0.5) + -- recupero la lavorazione + local sCutType = EgtIf( bHead, 'HeadSide', 'TailSide') + local sCutting = ML.FindCutting( sCutType .. EgtIf( bDownHead, '_H2', '')) + if not sCutting and bTopHead then + sCutting = ML.FindCutting( sCutType) + bDownHead = false + end + if not sCutting then + local sErr = 'Error : cutting not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + local dSawDiam = 400 + local dMaxDepth = 0 + if EgtMdbSetCurrMachining( sCutting) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end -- verifico se necessari tagli supplementari local vCuts = DC.GetDice( nAddGrpId, b3Solid, ptC[nBigInd], vtN[nBigInd], false, ptC[nSmaInd], vtN[nSmaInd]) --DC.PrintOrderCut( vCuts) @@ -266,14 +278,12 @@ function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- altrimenti, tagli diretti delle facce else - local bOk, sErr = Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, EgtIf( bHead, 'HeadSide', 'TailSide'), false) + local bOk, sErr = Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutType .. EgtIf( bDownHead, '_H2', ''), false, bDownHead) if not bOk then return bOk, sErr end end - end - -- eventuale segnalazione ingombro di testa o coda (se non convesso, altrimenti già fatto nei tagli singoli) - if not bConvex then + -- segnalazione ingombro di testa o coda if Proc.Head then -- intersezioni con linee a metà altezza appena dentro dal davanti e dal dietro local ptRef = b3Raw:getCenter() - 0.5 * b3Raw:getDimX() * X_AX() diff --git a/LuaLibs/ProcessDtTenon.lua b/LuaLibs/ProcessDtTenon.lua index 912a31e..7c0c2e7 100644 --- a/LuaLibs/ProcessDtTenon.lua +++ b/LuaLibs/ProcessDtTenon.lua @@ -18,6 +18,10 @@ local ML = require( 'MachiningLib') --------------------------------------------------------------------- local function VerifyOrientation( Proc, vtN, b3Raw) + -- se PF con testa da sotto, ammessa qualunque orientazione + if BD.C_SIMM and BD.DOWN_HEAD then + return true + end -- se trave molto bassa if b3Raw:getDimZ() <= 120 then -- se tenone praticamente in asse, accetto fino a -45 deg