diff --git a/BatchProcess.lua b/BatchProcess.lua index 6a8d81a..0d2567c 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -1,10 +1,11 @@ --- BatchProcess.lua by Egaltech s.r.l. 2019/08/29 +-- BatchProcess.lua by Egaltech s.r.l. 2019/10/04 -- 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. -- 2019/07/19 Aggiunta gestione collisioni. -- 2019/07/24 Aggiunta gestione extra-corse. -- 2019/08/29 Aggiunta possibilità di processare file NGE. +-- 2019/10/04 Migliorato log dei parametri ricevuti. -- Intestazioni require( 'EgtBase') @@ -21,7 +22,19 @@ EgtEnableDebug( false) local bVerifyCollision = true -- Log dati di generazione -local sLog = 'BatchProcess : ' .. BEAM.FILE .. ', ' .. BEAM.MACHINE .. ', ' .. tostring( BEAM.FLAG) +local sFlag = '' +if BEAM.FLAG == 0 then + sFlag = 'GENERATE' +elseif BEAM.FLAG == 1 then + sFlag = 'MODIFY' +elseif BEAM.FLAG == 2 then + sFlag = 'SIMULATE' +elseif BEAM.FLAG == 3 then + sFlag = 'CHECK' +else + sFlag = 'FLAG='..tostring( BEAM.FLAG) +end +local sLog = 'BatchProcess : ' .. BEAM.FILE .. ', ' .. BEAM.MACHINE .. ', ' .. sFlag EgtOutLog( sLog) -- Cancello file di log specifico @@ -222,7 +235,7 @@ if #vBeamErr > 0 then return end --- Verifico sezione barra +-- Verifico sezione barra non troppo grande if dRawW > BD.MAX_WIDTH + 10 * GEO.EPS_SMALL or dRawH > BD.MAX_HEIGHT + 10 * GEO.EPS_SMALL then local sOut = 'Sezione (' .. EgtNumToString( dRawW, 2) .. ' x ' .. EgtNumToString( dRawH, 2) .. ') ' .. 'oltre i limiti della macchina (' .. EgtNumToString( BD.MAX_WIDTH, 2) .. ' x ' .. EgtNumToString( BD.MAX_HEIGHT, 2) .. ')' @@ -233,6 +246,16 @@ if dRawW > BD.MAX_WIDTH + 10 * GEO.EPS_SMALL or dRawH > BD.MAX_HEIGHT + 10 * GEO return end + -- Verifico sezione barra non troppo piccola + if dRawW < BD.MIN_WIDTH - 10 * GEO.EPS_SMALL or dRawH < BD.MIN_HEIGHT - 10 * GEO.EPS_SMALL then + local sOut = 'Sezione (' .. EgtNumToString( dRawW, 2) .. ' x ' .. EgtNumToString( dRawH, 2) .. ') ' .. + 'sotto i limiti della macchina (' .. EgtNumToString( BD.MIN_WIDTH, 2) .. ' x ' .. EgtNumToString( BD.MIN_HEIGHT, 2) .. ')' + BEAM.ERR = 17 + BEAM.MSG = sOut + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) + PostErrView( BEAM.ERR, BEAM.MSG) + end + -- Lunghezza della barra local dRawL = EgtGetInfo( EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or GDB_ID.NULL, 'BARLEN', 'd') or 12000 -- Sovramateriale di testa diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index c3939b9..e4b419b 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,4 +1,4 @@ --- BeamExec.lua by Egaltech s.r.l. 2019/09/25 +-- BeamExec.lua by Egaltech s.r.l. 2019/10/03 -- 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. @@ -360,7 +360,12 @@ local function OrderFeatures( vProc, b3Raw) end -- se primo è taglio longitudinale completo o altra lav. lunga, dopo tutte le altre feature non di coda if abs( B1.Box:getDimX() - b3Raw:getDimX()) < 0.2 * b3Raw:getDimX() then - return B1.Box:getMin():getX() + 50 > B2.Box:getCenter():getX() + -- se anche l'altra è lunga, faccio prima quello a Zmax + 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() + 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 diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 1e9baf1..c5334d4 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1,4 +1,4 @@ --- BeamLib.lua by Egaltech s.r.l. 2019/09/04 +-- BeamLib.lua by Egaltech s.r.l. 2019/10/03 -- Libreria globale per Travi -- Tabella per definizione modulo @@ -363,8 +363,8 @@ function BeamLib.GetFaceWithMostAdj( nSurfId, nPartId) end -- recupero le facce non in sottosquadra e con il maggior numero di adiacenze local nFacInd = {} - local nMaxAdj = 0 - local nSupAdj = 0 + local nMaxAdj = -1 + local nSupAdj = -1 for i = 1, nFacCnt do if not vUcut[i] then if vAdj[i] > nMaxAdj then @@ -412,19 +412,6 @@ function BeamLib.GetFaceWithMostAdj( nSurfId, nPartId) return nFacOpt, dMinElev, nFacOpt2, dMinElev2 end ---------------------------------------------------------------------- -function BeamLib.GetFaceBox( nSurfId, nFacet) - -- estraggo la faccia temporaneamente - local FacId = EgtCopySurfTmFacet( nSurfId, nFacet, EgtGetParent( nSurfId)) - if not FacId then return end - -- determino l'ingombro in globale - local b3Glob = EgtGetBBoxGlob( FacId, GDB_BB.STANDARD) - -- cancello la faccia temporanea - EgtErase( FacId) - -- restituisco il bounding box - return b3Glob -end - --------------------------------------------------------------------- function BeamLib.GetFaceHvRefDim( nSurfId, nFacet) -- recupero centro e normale della faccia diff --git a/LuaLibs/ProcessCut.lua b/LuaLibs/ProcessCut.lua index 1fbbf58..e92efc6 100644 --- a/LuaLibs/ProcessCut.lua +++ b/LuaLibs/ProcessCut.lua @@ -47,9 +47,10 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) EgtOutLog( sErr) return false, sErr end + local dNzLimDwnUp = EgtIf( b3Raw:getDimZ() < 300, -0.5, -0.258) -- dati geometrici del taglio local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) - local bDownCut = (vtN:getZ() <= - 0.5) + local bDownCut = ( vtN:getZ() <= dNzLimDwnUp) -- se taglio di testa if Proc.Head then -- se coincide con il taglio di separazione precedente, non va fatto @@ -134,7 +135,7 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if i % 2 == 0 and #vCuts[i] <= 2 then -- il primo elemento prende la direzione prevista, il secondo quella opposta local vtNewOrthoO = Vector3d( vtOrthoO) - local dVzLimDwnUp = -0.5 + local dVzLimDwnUp = dNzLimDwnUp if j ~= 1 then vtNewOrthoO = -vtOrthoO dVzLimDwnUp = -0.72 @@ -147,7 +148,7 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- tutti gli altri casi vengono saltati -- caso generale else - local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, nil, -0.5, BD.CUT_SIC, 0, 0, nil, b3Raw) + local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, dNzLimDwnUp, -0.5, BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sErr end @@ -165,7 +166,7 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) else vtOrthoO = -Y_AX() end - local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, vtOrthoO, nil, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, nil, b3Raw) + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, vtOrthoO, dNzLimDwnUp, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sErr end diff --git a/LuaLibs/ProcessDtTenon.lua b/LuaLibs/ProcessDtTenon.lua index b04a688..357f69f 100644 --- a/LuaLibs/ProcessDtTenon.lua +++ b/LuaLibs/ProcessDtTenon.lua @@ -18,11 +18,20 @@ local ML = require( 'MachiningLib') --------------------------------------------------------------------- local function VerifyOrientation( Proc, vtN, b3Raw) + -- se trave molto bassa + if b3Raw:getDimZ() <= 120 then + -- se tenone praticamente in asse, accetto fino a -45 deg + if abs( vtN:getY()) < 0.04 then + return ( vtN:getZ() >= -0.7072) + -- altrimenti accetto fino a -30deg + else + return ( vtN:getZ() >= -0.51) + end -- se trave bassa - if b3Raw:getDimZ() <= 200 then + elseif b3Raw:getDimZ() <= 200 then -- se tenone praticamente in asse, accetto fino a -30 deg if abs( vtN:getY()) < 0.04 then - return ( vtN:getZ() >= -0.5) + return ( vtN:getZ() >= -0.51) -- altrimenti accetto fino a -20deg else return ( vtN:getZ() >= -0.343) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 6214b00..cd619b9 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2019/09/30 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2019/10/05 -- Gestione calcolo mezzo-legno per Travi -- Tabella per definizione modulo @@ -302,15 +302,8 @@ local function MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId) -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, nFacInd}}) -- imposto uso faccia e lato correzione - if vtN[nOthInd+1]:getX() > 0.1 then - EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_LEFT) - elseif vtN[nOthInd+1]:getX() < -0.1 then - EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_RIGHT) - elseif vtN[nOthInd+1]:getZ() < -0.1 then - EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_TOP) - else - EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_DOWN) - end + local nFaceUse = BL.GetNearestOrthoOpposite( vtN[nOthInd+1]) + EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) -- imposto lato di correzione EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) -- imposto posizione braccio porta testa @@ -360,6 +353,95 @@ local function MakePreCuts( Proc, nPhase, nRawId, nPartId, b3Raw) return true end +--------------------------------------------------------------------- +local function MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dElev) + -- Recupero le facce adiacenti alla principale + local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1] + if not vAdj or #vAdj == 0 then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' main face without adjacencies' + EgtOutLog( sErr) + return false, sErr + end + EgtOutLog( 'Adjac=' .. table.concat( vAdj, ','), 3) + -- Riordino le dimensioni per avere dH > dV + if dH < dV then + dH, dV = dV, dH + end + -- Cerco una faccia adiacente alla principale sul lato lungo + local nFacAdj + for i = 1, #vAdj do + if vAdj[i] >= 0 then + local _, ptP1, ptP2, _ = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) + local dLen = dist( ptP1, ptP2) + if dLen > 0.5 * dH then + nFacAdj = vAdj[i] + EgtOutLog( string.format( 'Adjac=%d Len=%.3f H=%.3f V=%.3f', vAdj[i], dLen, dH, dV), 3) + break + end + end + end + -- Determino se estremi aperti o chiusi + local bOpenStart = false + local bOpenEnd = false + local vAdj2 = EgtSurfTmFacetAdjacencies( Proc.Id, nFacAdj)[1] + EgtOutLog( 'Adj2=' .. table.concat( vAdj2, ' ,')) + for j = 1, #vAdj2 do + if vAdj2[j] == nFacInd then + -- Se non esiste faccia adiacente a lato precedente -> inizio aperto + local i = EgtIf( j > 1, j - 1, #vAdj2) + while vAdj2[i] == nFacInd do + i = EgtIf( i > 1, i - 1, #vAdj2) + end + bOpenStart = ( vAdj2[i] < 0) + -- 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) + end + end + -- Recupero la lavorazione di fresa + local sMilling = ML.FindMilling( 'LongSmallCut') + if not sMilling then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + local dTDiam = 50 + if EgtMdbSetCurrMachining( sMilling) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam + end + end + -- Calcolo uso faccia + local nFaceUse = BL.GetNearestParalOpposite( rfFac:getVersZ()) + -- inserisco la lavorazione di fresatura + local sName = 'Mill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchFId = EgtAddMachining( sName, sMilling) + if not nMchFId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + 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( bOpenEnd, 0, - dTDiam / 2)) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, EgtIf( bOpenStart, 0, - dTDiam / 2)) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + return true +end + --------------------------------------------------------------------- local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dElev) -- Recupero le facce adiacenti alla principale @@ -518,7 +600,11 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) local b3Raw = EgtGetRawPartBBox( nRawId) -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId) - assert( ( nFacInd and nFacInd >= 0), 'Error : MakeMoreFaces could not find reference face') + if not nFacInd or nFacInd < 0 then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' MakeMoreFaces could not find reference face' + EgtOutLog( sErr) + return false, sErr + end -- dati della faccia local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) -- se orientata verso il basso, verifico l'alternativa @@ -542,15 +628,21 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) return false, sErr end end - -- verifico se tre facce a L con una faccia di terminazione - local bIsL = TestElleShape( Proc) - -- recupero la lavorazione ( se L posso accettare utensili un poco più grandi) - local dDiam = min( dH, dV) * EgtIf( bIsL, 1.4, 1) + -- recupero la lavorazione + local dDiam = min( dH, dV) EgtOutLog( 'Mortise Find Diam =' .. EgtNumToString( dDiam)) - local sPocketing = ML.FindPocketing( 'Mortise', dDiam) - -- se non trova una svuotatura adatta, provo con la sega a catena o lama + local sPocketing = ML.FindPocketing( 'Mortise', dDiam, dFacElev) + -- se non trova una svuotatura adatta if not sPocketing then - return MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev) + -- verifico se due o tre facce a L con una faccia di terminazione + local bIsL = ( Proc.Fct == 2 or TestElleShape( Proc)) + -- se due facce o tre a L provo con contornatura + if bIsL then + return MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev) + -- altrimenti provo con la sega a catena o lama + else + return MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev) + end end -- recupero i dati dell'utensile local dMaxDepth = 0 @@ -592,9 +684,13 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) -- eseguo if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr + -- provo ad allargare leggermente la tasca + EgtSetMachiningParam( MCH_MP.OFFSR, -0.1) + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end end return true, sWarn end @@ -639,7 +735,7 @@ local function MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId) return bOk, sErr end end - return true + return true, sErr end --------------------------------------------------------------------- diff --git a/LuaLibs/ProcessLongCut.lua b/LuaLibs/ProcessLongCut.lua index 86119c9..f9111f0 100644 --- a/LuaLibs/ProcessLongCut.lua +++ b/LuaLibs/ProcessLongCut.lua @@ -1,4 +1,4 @@ --- ProcessLongCut.lua by Egaltech s.r.l. 2019/09/30 +-- ProcessLongCut.lua by Egaltech s.r.l. 2019/10/06 -- Gestione calcolo taglio longitudinale per Travi -- Tabella per definizione modulo @@ -35,9 +35,49 @@ function ProcessLongCut.Classify( Proc) return true, false end +--------------------------------------------------------------------- +local function MakeSideFace( nId, nFac, nSide, sMilling, dToolDiam) + -- inserisco la lavorazione + local sNameF = 'L2C_' .. ( EgtGetName( nId) or tostring( nId)) .. '_' .. tostring( nFac) + local nMchFId = EgtAddMachining( sNameF, sMilling) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ nId, nFac}}) + -- lato di lavoro e inversione + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + -- uso della faccia + local nFaceUse = MCH_MILL_FU.PARAL_DOWN + if nSide == -2 then + nFaceUse = MCH_MILL_FU.PARAL_BACK + elseif nSide == 2 then + nFaceUse = MCH_MILL_FU.PARAL_FRONT + end + EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) + -- annullo offset radiale + EgtSetMachiningParam( MCH_MP.OFFSR, 0) + -- attacco e uscita + EgtSetMachiningParam( MCH_MP.LIPERP, 0) + EgtSetMachiningParam( MCH_MP.LITANG, dToolDiam / 2 + 30) + EgtSetMachiningParam( MCH_MP.LOPERP, 0) + EgtSetMachiningParam( MCH_MP.LOTANG, dToolDiam / 2 + 30) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end +end + --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) + -- recupero l'ingombro del grezzo di appartenenza + local b3Raw = EgtGetRawPartBBox( nRawId) -- dati della faccia local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) local dLen = Proc.Box:getDimX() @@ -66,6 +106,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) nSide = 2 end + local sWarn -- Se non è sotto : lavorazione Long2Cut if nSide ~= - 1 then -- recupero la lavorazione @@ -75,14 +116,24 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) EgtOutLog( sErr) return false, sErr end - -- recupero il diametro dell'utensile + -- recupero i dati dell'utensile local dToolDiam = 0 + local dMaxDepth = 0 if EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth end end + -- determino la massima elevazione + local dElev = 0 + local ptT1 = b3Raw:getMax() + local dDist1 = ( ptT1 - ptC) * vtN + dElev = max( dElev, dDist1) + local ptT2 = ptT1 - Y_AX() * b3Raw:getDimY() + local dDist2 = ( ptT2 - ptC) * vtN + dElev = max( dElev, dDist2) -- determino se lavorazione da davanti o da dietro local bFront = ( vtN:getY() < 0) -- determino gli estremi @@ -144,6 +195,13 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) -- si percorre il lato basso della faccia local nM = 0 for i = 1, nC do + -- Posizione braccio portatesta + local nSCC + if bFront then + nSCC = EgtIf( ( i == 1 or i == nC - 1), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + else + nSCC = EgtIf( ( i == 1 or i == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) + end -- ciclo sulle passate local nO = 1 local dStep = 0 @@ -170,10 +228,18 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) local dEal = EgtIf( i == nC, -dEndDist, - dEndAccDist - ( nC - i - 1) * dC) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) - -- imposto offset radiale (nullo se concavo) + -- imposto offset radiale EgtSetMachiningParam( MCH_MP.OFFSR, ( k - 1) * dStep - BD.CUT_EXTRA) + -- imposto posizione braccio porta testa per non ingombrare agli estremi + EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- imposto uso della faccia EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) + -- verifico massimo affondamento rispetto ad elevazione + if dElev > dMaxDepth - BD.COLL_SIC then + sWarn = 'Warning in LongCut : depth (' .. EgtNumToString( dElev, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth - BD.COLL_SIC, 1) .. ')' + end + local dDepth = min( 0, dMaxDepth - BD.COLL_SIC - dElev ) + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -181,40 +247,26 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) return false, sErr end end + -- eventuale lavorazione della faccia limitante l'inizio + if i == 1 and not bStartFixed then + local vtIni = EgtIf( bFront, X_AX(), -X_AX()) + for i = 1, Proc.Fct - 1 do + local _, vtN = EgtSurfTmFacetCenter( Proc.Id, i, GDB_ID.ROOT) + if vtIni * vtN > 0 then + MakeSideFace( Proc.Id, i, nSide, sMilling, dToolDiam) + end + end + end end - -- se ci sono le facce limitanti - for i = 1, Proc.Fct - 1 do - -- inserisco la lavorazione - local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i) - local nMchFId = EgtAddMachining( sNameF, sMilling) - if not nMchFId then - local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling - EgtOutLog( sErr) - return false, sErr - end - -- aggiungo geometria - EgtSetMachiningGeometry( {{ Proc.Id, i}}) - -- lato di lavoro e inversione - EgtSetMachiningParam( MCH_MP.INVERT, true) - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - -- uso della faccia - local nFaceUse = MCH_MILL_FU.PARAL_DOWN - if nSide == -2 then - nFaceUse = MCH_MILL_FU.PARAL_BACK - elseif nSide == 2 then - nFaceUse = MCH_MILL_FU.PARAL_FRONT - end - EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) - -- attacco e uscita - EgtSetMachiningParam( MCH_MP.LIPERP, 0) - EgtSetMachiningParam( MCH_MP.LITANG, dToolDiam / 2 + 30) - EgtSetMachiningParam( MCH_MP.LOPERP, 0) - EgtSetMachiningParam( MCH_MP.LOTANG, dToolDiam / 2 + 30) - -- eseguo - if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr + + -- eventuale lavorazione della faccia limitante la fine + if not bEndFixed then + local vtFin = EgtIf( bFront, -X_AX(), X_AX()) + for i = 1, Proc.Fct - 1 do + local _, vtN = EgtSurfTmFacetCenter( Proc.Id, i, GDB_ID.ROOT) + if vtFin * vtN > 0 then + MakeSideFace( Proc.Id, i, nSide, sMilling, dToolDiam) + end end end @@ -230,11 +282,13 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) -- recupero i dati dell'utensile local dToolDiam = 0 local dMaxDepth = 0 + local dThDiam = 0 if EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + dThDiam = EgtTdbGetCurrToolThDiam() or dThDiam end end -- larghezza faccia @@ -285,10 +339,12 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) -- imposto lato di lavoro e inversione EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) EgtSetMachiningParam( MCH_MP.INVERT, true) - if dWidth + dAgg > dMaxDepth - BD.COLL_SIC then - sWarn = 'Warning in LongCut : depth (' .. EgtNumToString( dWidth + dAgg, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth - BD.COLL_SIC, 1) .. ')' + -- verifico massimo affondamento (tengo conto dell'inclinazione utensile e della pinza con estremità conica) + local dCollSic = max( BD.COLL_SIC, ( dThDiam - dToolDiam) / 2 * abs( vtN:getY() / vtN:getZ()) - 3) + if dWidth + dAgg > dMaxDepth - dCollSic then + sWarn = 'Warning in LongCut : depth (' .. EgtNumToString( dWidth + dAgg, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth - dCollSic, 1) .. ')' end - local dDepth = min( dMaxDepth - BD.COLL_SIC, dWidth + dAgg) + local dDepth = min( dMaxDepth - dCollSic, dWidth + dAgg) EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) -- eseguo if not EgtApplyMachining( true, false) then @@ -299,7 +355,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) end end - return true + return true, sWarn end --------------------------------------------------------------------- diff --git a/LuaLibs/ProcessLongDoubleCut.lua b/LuaLibs/ProcessLongDoubleCut.lua index caa185e..86fc121 100644 --- a/LuaLibs/ProcessLongDoubleCut.lua +++ b/LuaLibs/ProcessLongDoubleCut.lua @@ -103,6 +103,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) _, _, vWidth[1] = BL.GetFaceHvRefDim( Proc.Id, nFc[1]) _, _, vWidth[2] = BL.GetFaceHvRefDim( Proc.Id, nFc[2]) + local sWarn -- Se non è sotto : lavorazione Long2Cut if nSide ~= - 1 then -- recupero la lavorazione @@ -201,7 +202,6 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) -- altrimenti è sotto : lavorazione Long2CutDown else - local sWarn -- recupero la lavorazione local sMilling = ML.FindMilling( 'Long2CutDown') if not sMilling then diff --git a/LuaLibs/ProcessRidgeLap.lua b/LuaLibs/ProcessRidgeLap.lua index 5095c1d..0eb6c36 100644 --- a/LuaLibs/ProcessRidgeLap.lua +++ b/LuaLibs/ProcessRidgeLap.lua @@ -1,4 +1,4 @@ --- ProcessRidgeLap.lua by Egaltech s.r.l. 2019/09/25 +-- ProcessRidgeLap.lua by Egaltech s.r.l. 2019/10/02 -- Gestione calcolo mezzolegno di testa per Travi -- Tabella per definizione modulo @@ -182,7 +182,7 @@ function ProcessRidgeLap.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if Proc.Head then local dHCI = 0 if abs( vtN[vFaceOrd[3]]:getZ()) > 0.1 then - local b3Fac1 = BL.GetFaceBox( Proc.Id, vFaceOrd[1] - 1) + local b3Fac1 = EgtSurfTmGetFacetBBoxGlob( Proc.Id, vFaceOrd[1] - 1, GDB_BB.STANDARD) if b3Fac1 then dHCI = b3Raw:getMax():getX() - dOvmHead - b3Fac1:getMin():getX() end else dHCI = b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX() @@ -191,7 +191,7 @@ function ProcessRidgeLap.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) elseif Proc.Tail then local dTCI = 0 if abs( vtN[vFaceOrd[3]]:getZ()) > 0.1 then - local b3Fac1 = BL.GetFaceBox( Proc.Id, vFaceOrd[1] - 1) + local b3Fac1 = EgtSurfTmGetFacetBBoxGlob( Proc.Id, vFaceOrd[1] - 1, GDB_BB.STANDARD) if b3Fac1 then dTCI = b3Fac1:getMax():getX() - b3Solid:getMin():getX() end else dTCI = Proc.Box:getMax():getX() - b3Solid:getMin():getX() diff --git a/LuaLibs/ProcessSimpleScarf.lua b/LuaLibs/ProcessSimpleScarf.lua index 175db49..b0ae7a3 100644 --- a/LuaLibs/ProcessSimpleScarf.lua +++ b/LuaLibs/ProcessSimpleScarf.lua @@ -1,4 +1,4 @@ --- ProcessSimpleScarf.lua by Egaltech s.r.l. 2018/11/04 +-- ProcessSimpleScarf.lua by Egaltech s.r.l. 2019/10/02 -- Gestione calcolo giunto Gerber per Travi -- Tabella per definizione modulo @@ -191,7 +191,7 @@ function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if Proc.Head then local dHCI = 0 if abs( vtRef:getZ()) > 0.1 then - local b3Fac1 = BL.GetFaceBox( Proc.Id, vFaceOrd[1] - 1) + local b3Fac1 = EgtSurfTmGetFacetBBoxGlob( Proc.Id, vFaceOrd[1] - 1, GDB_BB.STANDARD) if b3Fac1 then dHCI = b3Raw:getMax():getX() - dOvmHead - b3Fac1:getMin():getX() end else dHCI = b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX() @@ -200,7 +200,7 @@ function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) elseif Proc.Tail then local dTCI = 0 if abs( vtRef:getZ()) > 0.1 then - local b3Fac1 = BL.GetFaceBox( Proc.Id, vFaceOrd[1] - 1) + local b3Fac1 = EgtSurfTmGetFacetBBoxGlob( Proc.Id, vFaceOrd[1] - 1, GDB_BB.STANDARD) if b3Fac1 then dTCI = b3Fac1:getMax():getX() - b3Solid:getMin():getX() end else dTCI = Proc.Box:getMax():getX() - b3Solid:getMin():getX() diff --git a/LuaLibs/ProcessTenon.lua b/LuaLibs/ProcessTenon.lua index 0179cb5..f0adac2 100644 --- a/LuaLibs/ProcessTenon.lua +++ b/LuaLibs/ProcessTenon.lua @@ -18,11 +18,20 @@ local ML = require( 'MachiningLib') --------------------------------------------------------------------- local function VerifyOrientation( Proc, vtN, b3Raw) + -- se trave molto bassa + if b3Raw:getDimZ() <= 120 then + -- se tenone praticamente in asse, accetto fino a -45 deg + if abs( vtN:getY()) < 0.04 then + return ( vtN:getZ() >= -0.7072) + -- altrimenti accetto fino a -30deg + else + return ( vtN:getZ() >= -0.51) + end -- se trave bassa - if b3Raw:getDimZ() <= 200 then + elseif b3Raw:getDimZ() <= 200 then -- se tenone praticamente in asse, accetto fino a -30 deg if abs( vtN:getY()) < 0.04 then - return ( vtN:getZ() >= -0.5) + return ( vtN:getZ() >= -0.51) -- altrimenti accetto fino a -20deg else return ( vtN:getZ() >= -0.343) diff --git a/Process.lua b/Process.lua index 1cd3315..e0e827d 100644 --- a/Process.lua +++ b/Process.lua @@ -1,4 +1,4 @@ --- Process.lua by Egaltech s.r.l. 2019/07/02 +-- Process.lua by Egaltech s.r.l. 2019/10/03 -- Gestione calcolo disposizione e lavorazioni per Travi -- Si opera sulla macchina corrente @@ -174,7 +174,7 @@ local function MyProcessBeams() end EgtOutLog( 'Lraw : ' .. EgtNumToString( dRawL, 1) .. ' Lovm : '.. EgtNumToString( dOvmHead, 1), 1) - -- Verifico sezione barra + -- Verifico sezione barra non troppo grande if dRawW > BD.MAX_WIDTH + 10 * GEO.EPS_SMALL or dRawH > BD.MAX_HEIGHT + 10 * GEO.EPS_SMALL then local sOut = 'Sezione (' .. EgtNumToString( dRawW, 2) .. ' x ' .. EgtNumToString( dRawH, 2) .. ') ' .. 'oltre i limiti della macchina (' .. EgtNumToString( BD.MAX_WIDTH, 2) .. ' x ' .. EgtNumToString( BD.MAX_HEIGHT, 2) .. ')' @@ -184,6 +184,16 @@ local function MyProcessBeams() return false end + -- Verifico sezione barra non troppo piccola + if dRawW < BD.MIN_WIDTH - 10 * GEO.EPS_SMALL or dRawH < BD.MIN_HEIGHT - 10 * GEO.EPS_SMALL then + local sOut = 'Sezione (' .. EgtNumToString( dRawW, 2) .. ' x ' .. EgtNumToString( dRawH, 2) .. ') ' .. + 'sotto i limiti della macchina (' .. EgtNumToString( BD.MIN_WIDTH, 2) .. ' x ' .. EgtNumToString( BD.MIN_HEIGHT, 2) .. ')' + EgtOutLog( sOut) + EgtOutBox( sOut, 'Lavora Travi', 'WARNING') + EgtDraw() + return false + end + -- Sistemo le travi nel grezzo local bOk, sErr = BE.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam) if not bOk then