diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index f61294f..f1fd9d9 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -56,6 +56,7 @@ local MIN_LEN_CUT = 30 -- variabili assegnazione parametri Q local Q_SIDE_MILL = '' -- d local Q_CORNER_CUT = '' -- i +local Q_USE_BLADE = '' -- i -- variabile settaggio doppia lavorazione su angolo > 90 local bMakeTwinCut = true @@ -80,10 +81,12 @@ local function AssignQIdent( Proc) -- reset assegnazione parametri Q Q_SIDE_MILL = '' Q_CORNER_CUT = '' + Q_USE_BLADE = '' if Proc.Prc == 11 then Q_SIDE_MILL = 'Q02' -- i Q_CORNER_CUT = 'Q05' -- i + Q_USE_BLADE = 'Q06' -- i elseif Proc.Prc == 12 then Q_SIDE_MILL = 'Q02' -- i Q_CORNER_CUT = '' -- i @@ -111,8 +114,13 @@ local function EvaluateQParam( Proc) -- 2 : ripresa corner senza pausa (fresa 30 deg) -- 3 : scarico corner (tipo foro). local nTypeCornerCut = EgtGetInfo( Proc.Id, Q_CORNER_CUT, 'i') or 0 + + -- Verifica forzatura utilizzo lama + -- 0 : automatico + -- 1 : usa lama + local nUseBlade = EgtGetInfo( Proc.Id, Q_USE_BLADE, 'i') or 0 - return nTypeCornerCut, nUseSideMillAsBlade + return nTypeCornerCut, nUseSideMillAsBlade, nUseBlade end --------------------------------------------------------------------- @@ -2507,6 +2515,40 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) return true, sWarn, sTuuid end +--------------------------------------------------------------------- +local function MakeOneFaceByBlade( Proc, sCutting, idFace) + -- inserisco la lavorazione + local sName = 'Cut_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) .. '_' .. tostring( Proc.Id) .. '_' .. tostring( i) + local nMchId = WM.AddMachining( Proc, sName, sCutting) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sCutting + EgtOutLog( sErr) + return false, sErr + end + EgtSetInfo( nMchId, 'Part', Proc.PartId) + -- aggiungo geometria + EgtSetMachiningGeometry( { { Proc.Id, idFace}}) + -- percorso da non invertire + EgtSetMachiningParam( MCH_MP.INVERT, false) + -- assegno affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, 0) + -- assegno il lato di lavoro + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + -- assegno l'attacco e l'uscita + EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT) + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT) + -- nessun criterio per il braccio è necessario + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + + return true +end + --------------------------------------------------------------------- local function MakeOneFace( Proc, nRawId, b3Raw) -- dati della faccia @@ -2587,7 +2629,7 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw) -- recupero la lavorazione di taglio con lama e i suoi parametri local sCutting, dSawDiam, dSawThick, dSawMaxDepth = WM.FindCutting( 'Standard') -- se parametro Q abilita lavorazione ribasso con fresa di fianco - local _, nUseMillOnSide = EvaluateQParam( Proc) + local _, nUseMillOnSide, nUseBlade = EvaluateQParam( Proc) local dMaxZVers, dMinZVers if nUseMillOnSide >= 1 then dMaxZVers = 0.866 @@ -2628,183 +2670,184 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw) dMaxZVers = 0.95 dMinZVers = 0.1 end - -- se di fianco in basso - if vtN[1]:getZ() < -dMaxZVers or vtN[2]:getZ() < -dMaxZVers then - -- cerco la faccia verticale o quasi - local nFacet = EgtIf( abs( vtN[1]:getZ()) < dMinZVers, 0, 1) - -- cerco nei parametri utensili la nota di affondamento di fianco SIDEDEPTH - local dMaxDepthOnSide = 0 - local dMillDiam = 0 - local dMillDiamTh = 0 - if bEnableMillOnSide and EgtMdbSetCurrMachining( sMillOnSide) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam - dMillDiamTh = EgtTdbGetCurrToolThDiam() or dMillDiamTh - dMaxDepthOnSide = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or dMaxDepthOnSide - dMaxDepthOnSide = min( dMaxDepthOnSide, 0.5 * ( dMillDiam - dMillDiamTh)) - end - end - local dMaxDist = 300 - if bEnableMillOnSide and dMaxDepthOnSide > 0 then - dMaxDist = dMaxDepthOnSide - end - -- se vicino al bordo del grezzo e non troppo larga, provo con fresatura di fianco - local ptMid = ( ptP1 + ptP2) / 2 - local bMakeFirstGroove - local bMachFromDn = true - local bInsertMach - local dSideDist - -- per evitare errori in casi di pezzi molto stretti, verifico le distanze in base alla direzione della faccia - -- se normale verso X - if vtN[nFacet+1]:getX() > 0.99 then - dSideDist = abs( ptMid:getX() - b3Raw:getMax():getX()) - -- altrimenti se normale verso X- - elseif vtN[nFacet+1]:getX() < -0.99 then - dSideDist = abs( ptMid:getX() - b3Raw:getMin():getX()) - -- altrimenti se normale verso Y+ - elseif vtN[nFacet+1]:getY() > 0.99 then - dSideDist = abs( ptMid:getY() - b3Raw:getMax():getY()) - -- altrimenti se normale verso Y- - elseif vtN[nFacet+1]:getY() < -0.99 then - dSideDist = abs( ptMid:getY() - b3Raw:getMin():getY()) - end - if dSideDist and dSideDist < dMaxDist then - bInsertMach = true - bMakeFirstGroove = false - -- altrimenti la distanza è maggiore e se è sempre abilitata la lavorazione MillOnSide - elseif bEnableMillOnSide and dMaxDepthOnSide then - bInsertMach = true - bMakeFirstGroove = true - end - -- se posso eseguire la lavorazione per distanza inferiore utensile o lavorazione preceduta da sgossatura gola - if bInsertMach then - return MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, nil, nil, nil, bDoubleMillOnSide) - else - local sErr = 'Error feature not machinable (dimensions)' - EgtOutLog( sErr) - return false, sErr - end - -- se altrimenti di fianco in alto - elseif vtN[1]:getZ() > dMaxZVers or vtN[2]:getZ() > dMaxZVers then - -- cerco la faccia con il maggior numero di adiacenze (e minor elevazione) - local nFacInd, _, nFacInd2 = WL.GetFaceWithMostAdj( Proc.Id, Proc.PartId) - if nFacInd == -2 then - local sErr = 'Error feature with 2 faces with undercut' - EgtOutLog( sErr) - return false, sErr - end - local vtNTemp = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT) - local dSideDist - local ptMid = ( ptP1 + ptP2) / 2 - -- faccia orizzontale - local nFacet = EgtIf( vtNTemp:getZ() >= WD.NZ_MINA, nFacInd, nFacInd2) - local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacet, GDB_ID.ROOT) - -- faccia verticale - local nFacetVert = EgtIf( nFacet == nFacInd, nFacInd2, nFacInd) - local vtNV = EgtSurfTmFacetNormVersor( Proc.Id, nFacetVert, GDB_ID.ROOT) - -- per evitare errori in casi di pezzi molto stretti, verifico le distanze in base alla direzione della faccia --- local dSideDist = min( abs( ptMid:getX() - b3Raw:getMin():getX()), abs( ptMid:getX() - b3Raw:getMax():getX()), --- abs( ptMid:getY() - b3Raw:getMin():getY()), abs( ptMid:getY() - b3Raw:getMax():getY())) - -- se normale verso X - if vtNV:getX() > 0.99 then - dSideDist = abs( ptMid:getX() - b3Raw:getMax():getX()) - -- altrimenti se normale verso X- - elseif vtNV:getX() < -0.99 then - dSideDist = abs( ptMid:getX() - b3Raw:getMin():getX()) - -- altrimenti se normale verso Y+ - elseif vtNV:getY() > 0.99 then - dSideDist = abs( ptMid:getY() - b3Raw:getMax():getY()) - -- altrimenti se normale verso Y- - elseif vtNV:getY() < -0.99 then - dSideDist = abs( ptMid:getY() - b3Raw:getMin():getY()) - end - -- cerco nei parametri utensili la nota di affondamento di fianco SIDEDEPTH - local dMaxDepthOnSide = 0 - local dMillDiam = 0 - if bEnableMillOnSide and EgtMdbSetCurrMachining( sMillOnSide) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam - dMaxDepthOnSide = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or dMaxDepthOnSide - end - end - -- 2021.10.08 E.S. in base a richieste del cliente: - -- Se parametro Q riduce utilizzo lavorazione di lato come lama ed elevazione laterale supera il 60% diametro utensile - -- disabilito - if nUseMillOnSide == 2 and dSideDist > 0.6 * dMillDiam then - bEnableMillOnSide = false - end - -- per il fianco in alto non ci sono problemi di inserimento massimo laterale, setto la variabile pari al raggio utensile - 1mm - dMaxDepthOnSide = ( 0.5 * dMillDiam) - 1 - local dMaxDist = 300 - if bEnableMillOnSide and dMaxDepthOnSide > 0 then - dMaxDist = dMaxDepthOnSide - end - -- se vicino al bordo del grezzo e non troppo larga, provo con fresatura di fianco - local bMakeFirstGroove = false - local bLikeAsMakeFirstGroove - local bMachFromDn = false - local bInsertMach - if dSideDist and dSideDist < dMaxDist then - -- se abilitata SideMill oppure se la specchiata guarda in basso e quindi l'attacco deve essere a filo - if ( bEnableMillOnSide and dMaxDepthOnSide > 0) or ( Proc.Double == 2 and Proc.MirrorDeltaZ and abs( Proc.MirrorDeltaZ) > GEO.EPS_SMALL) then - bLikeAsMakeFirstGroove = false - return MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, bLikeAsMakeFirstGroove, nil, nil, bDoubleMillOnSide) - else - local bOk, sErr, bSideMachiningNotFound = MakeByMill( Proc, nFacet, 1 - nFacet, nRawId, b3Raw, dSideDist) - if not bOk and bSideMachiningNotFound then - bOk, sErr = MakeByPocketing( Proc, nFacet, nRawId, b3Raw) + if nUseBlade == 0 then + if vtN[1]:getZ() < -dMaxZVers or vtN[2]:getZ() < -dMaxZVers then + -- cerco la faccia verticale o quasi + local nFacet = EgtIf( abs( vtN[1]:getZ()) < dMinZVers, 0, 1) + -- cerco nei parametri utensili la nota di affondamento di fianco SIDEDEPTH + local dMaxDepthOnSide = 0 + local dMillDiam = 0 + local dMillDiamTh = 0 + if bEnableMillOnSide and EgtMdbSetCurrMachining( sMillOnSide) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam + dMillDiamTh = EgtTdbGetCurrToolThDiam() or dMillDiamTh + dMaxDepthOnSide = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or dMaxDepthOnSide + dMaxDepthOnSide = min( dMaxDepthOnSide, 0.5 * ( dMillDiam - dMillDiamTh)) end + end + local dMaxDist = 300 + if bEnableMillOnSide and dMaxDepthOnSide > 0 then + dMaxDist = dMaxDepthOnSide + end + -- se vicino al bordo del grezzo e non troppo larga, provo con fresatura di fianco + local ptMid = ( ptP1 + ptP2) / 2 + local bMakeFirstGroove + local bMachFromDn = true + local bInsertMach + local dSideDist + -- per evitare errori in casi di pezzi molto stretti, verifico le distanze in base alla direzione della faccia + -- se normale verso X + if vtN[nFacet+1]:getX() > 0.99 then + dSideDist = abs( ptMid:getX() - b3Raw:getMax():getX()) + -- altrimenti se normale verso X- + elseif vtN[nFacet+1]:getX() < -0.99 then + dSideDist = abs( ptMid:getX() - b3Raw:getMin():getX()) + -- altrimenti se normale verso Y+ + elseif vtN[nFacet+1]:getY() > 0.99 then + dSideDist = abs( ptMid:getY() - b3Raw:getMax():getY()) + -- altrimenti se normale verso Y- + elseif vtN[nFacet+1]:getY() < -0.99 then + dSideDist = abs( ptMid:getY() - b3Raw:getMin():getY()) + end + if dSideDist and dSideDist < dMaxDist then + bInsertMach = true + bMakeFirstGroove = false + -- altrimenti la distanza è maggiore e se è sempre abilitata la lavorazione MillOnSide + elseif bEnableMillOnSide and dMaxDepthOnSide then + bInsertMach = true + bMakeFirstGroove = true + end + -- se posso eseguire la lavorazione per distanza inferiore utensile o lavorazione preceduta da sgossatura gola + if bInsertMach then + return MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, nil, nil, nil, bDoubleMillOnSide) + else + local sErr = 'Error feature not machinable (dimensions)' + EgtOutLog( sErr) + return false, sErr + end + -- se altrimenti di fianco in alto + elseif vtN[1]:getZ() > dMaxZVers or vtN[2]:getZ() > dMaxZVers then + -- cerco la faccia con il maggior numero di adiacenze (e minor elevazione) + local nFacInd, _, nFacInd2 = WL.GetFaceWithMostAdj( Proc.Id, Proc.PartId) + if nFacInd == -2 then + local sErr = 'Error feature with 2 faces with undercut' + EgtOutLog( sErr) + return false, sErr + end + local vtNTemp = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT) + local dSideDist + local ptMid = ( ptP1 + ptP2) / 2 + -- faccia orizzontale + local nFacet = EgtIf( vtNTemp:getZ() >= WD.NZ_MINA, nFacInd, nFacInd2) + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacet, GDB_ID.ROOT) + -- faccia verticale + local nFacetVert = EgtIf( nFacet == nFacInd, nFacInd2, nFacInd) + local vtNV = EgtSurfTmFacetNormVersor( Proc.Id, nFacetVert, GDB_ID.ROOT) + -- per evitare errori in casi di pezzi molto stretti, verifico le distanze in base alla direzione della faccia + -- local dSideDist = min( abs( ptMid:getX() - b3Raw:getMin():getX()), abs( ptMid:getX() - b3Raw:getMax():getX()), + -- abs( ptMid:getY() - b3Raw:getMin():getY()), abs( ptMid:getY() - b3Raw:getMax():getY())) + -- se normale verso X + if vtNV:getX() > 0.99 then + dSideDist = abs( ptMid:getX() - b3Raw:getMax():getX()) + -- altrimenti se normale verso X- + elseif vtNV:getX() < -0.99 then + dSideDist = abs( ptMid:getX() - b3Raw:getMin():getX()) + -- altrimenti se normale verso Y+ + elseif vtNV:getY() > 0.99 then + dSideDist = abs( ptMid:getY() - b3Raw:getMax():getY()) + -- altrimenti se normale verso Y- + elseif vtNV:getY() < -0.99 then + dSideDist = abs( ptMid:getY() - b3Raw:getMin():getY()) + end + -- cerco nei parametri utensili la nota di affondamento di fianco SIDEDEPTH + local dMaxDepthOnSide = 0 + local dMillDiam = 0 + if bEnableMillOnSide and EgtMdbSetCurrMachining( sMillOnSide) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam + dMaxDepthOnSide = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or dMaxDepthOnSide + end + end + -- 2021.10.08 E.S. in base a richieste del cliente: + -- Se parametro Q riduce utilizzo lavorazione di lato come lama ed elevazione laterale supera il 60% diametro utensile + -- disabilito + if nUseMillOnSide == 2 and dSideDist > 0.6 * dMillDiam then + bEnableMillOnSide = false + end + -- per il fianco in alto non ci sono problemi di inserimento massimo laterale, setto la variabile pari al raggio utensile - 1mm + dMaxDepthOnSide = ( 0.5 * dMillDiam) - 1 + local dMaxDist = 300 + if bEnableMillOnSide and dMaxDepthOnSide > 0 then + dMaxDist = dMaxDepthOnSide + end + -- se vicino al bordo del grezzo e non troppo larga, provo con fresatura di fianco + local bMakeFirstGroove = false + local bLikeAsMakeFirstGroove + local bMachFromDn = false + local bInsertMach + if dSideDist and dSideDist < dMaxDist then + -- se abilitata SideMill oppure se la specchiata guarda in basso e quindi l'attacco deve essere a filo + if ( bEnableMillOnSide and dMaxDepthOnSide > 0) or ( Proc.Double == 2 and Proc.MirrorDeltaZ and abs( Proc.MirrorDeltaZ) > GEO.EPS_SMALL) then + bLikeAsMakeFirstGroove = false + return MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, bLikeAsMakeFirstGroove, nil, nil, bDoubleMillOnSide) + else + local bOk, sErr, bSideMachiningNotFound = MakeByMill( Proc, nFacet, 1 - nFacet, nRawId, b3Raw, dSideDist) + if not bOk and bSideMachiningNotFound then + bOk, sErr = MakeByPocketing( Proc, nFacet, nRawId, b3Raw) + end + -- se angolo ottuso riprendo il lato quasi verticale + if bOk and dAng and dAng > -90 + 10 * GEO.EPS_SMALL then + local bOk2, sErr2 = MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, false, nil, true) + end + return bOk, sErr + end + elseif bEnableMillOnSide and dMaxDepthOnSide > 0 then + bLikeAsMakeFirstGroove = true + local bOk, sErr = MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, bLikeAsMakeFirstGroove, nil, nil, bDoubleMillOnSide) + if bOk then return true end + end + -- se non inclinate o capacità di taglio non sufficiente o non molto grandi (80mm), provo con contornatura o svuotatura + if vtN:getZ() > 0.866 or vtNV:getZ() > 0.866 or not sCutting or dSawMaxDepth < dDimY[1] + WD.CUT_SIC or dSawMaxDepth < dDimY[2] + WD.CUT_SIC or dDimY[1] < 80 or dDimY[2] < 80 then + -- eseguo la svuotatura + local bOk, sErr, sTuuid = MakeByPocketing( Proc, nFacet, nRawId, b3Raw) -- se angolo ottuso riprendo il lato quasi verticale if bOk and dAng and dAng > -90 + 10 * GEO.EPS_SMALL then - local bOk2, sErr2 = MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, false, nil, true) + local _, dHVert, dVVert = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacetVert, GDB_ID.ROOT) + local dDepth = min( dHVert, dVVert) + local _, dHHor, dVHor = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT) + local dDiam = 2 * min( dHHor, dVHor) + local sMillObtuseAngle = WM.FindMilling( 'FreeContour', dDepth, sTuuid, nil, dDiam, nil, nil, nil) + if not sMillObtuseAngle then + sMillObtuseAngle = WM.FindMilling( 'FreeContour', dDepth, nil, nil, dDiam, nil, nil, nil) + end + if not sMillObtuseAngle then + local sErrMillNotFound = 'Error : Processing to finish obtuse angle not found in library' + EgtOutLog( sErrMillNotFound) + return true, sErrMillNotFound + end + local bOk2, sErr2 = MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, sMillObtuseAngle, dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, false, nil, true) end return bOk, sErr end - elseif bEnableMillOnSide and dMaxDepthOnSide > 0 then - bLikeAsMakeFirstGroove = true - local bOk, sErr = MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, bLikeAsMakeFirstGroove, nil, nil, bDoubleMillOnSide) - if bOk then return true end - end - -- se non inclinate o capacità di taglio non sufficiente o non molto grandi (80mm), provo con contornatura o svuotatura - if vtN:getZ() > 0.866 or vtNV:getZ() > 0.866 or not sCutting or dSawMaxDepth < dDimY[1] + WD.CUT_SIC or dSawMaxDepth < dDimY[2] + WD.CUT_SIC or dDimY[1] < 80 or dDimY[2] < 80 then - -- eseguo la svuotatura - local bOk, sErr, sTuuid = MakeByPocketing( Proc, nFacet, nRawId, b3Raw) - -- se angolo ottuso riprendo il lato quasi verticale - if bOk and dAng and dAng > -90 + 10 * GEO.EPS_SMALL then - local _, dHVert, dVVert = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacetVert, GDB_ID.ROOT) - local dDepth = min( dHVert, dVVert) - local _, dHHor, dVHor = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT) - local dDiam = 2 * min( dHHor, dVHor) - local sMillObtuseAngle = WM.FindMilling( 'FreeContour', dDepth, sTuuid, nil, dDiam, nil, nil, nil) - if not sMillObtuseAngle then - sMillObtuseAngle = WM.FindMilling( 'FreeContour', dDepth, nil, nil, dDiam, nil, nil, nil) - end - if not sMillObtuseAngle then - local sErrMillNotFound = 'Error : Processing to finish obtuse angle not found in library' - EgtOutLog( sErrMillNotFound) - return true, sErrMillNotFound - end - local bOk2, sErr2 = MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, sMillObtuseAngle, dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, false, nil, true) + -- se una delle due facce rivolta verso il basso + elseif vtN[1]:getZ() < -0.001 or vtN[2]:getZ() < -0.001 then + -- cerco la faccia rivolta verso l'alto + local nFacet + if vtN[1]:getZ() > 0 then + nFacet = 0 + elseif vtN[2]:getZ() > 0 then + nFacet = 1 + else + local sErr = 'Error feature with 2 faces facing down' + EgtOutLog( sErr) + return false, sErr end - return bOk, sErr + -- eseguo la svuotatura + return MakeByPocketing( Proc, nFacet, nRawId, b3Raw) end - -- se una delle due facce rivolta verso il basso - elseif vtN[1]:getZ() < -0.001 or vtN[2]:getZ() < -0.001 then - -- cerco la faccia rivolta verso l'alto - local nFacet - if vtN[1]:getZ() > 0 then - nFacet = 0 - elseif vtN[2]:getZ() > 0 then - nFacet = 1 - else - local sErr = 'Error feature with 2 faces facing down' - EgtOutLog( sErr) - return false, sErr - end - -- eseguo la svuotatura - return MakeByPocketing( Proc, nFacet, nRawId, b3Raw) end -- ordino i tagli per fare prima quello meno inclinato local nOrd = { 0, 1} @@ -2812,37 +2855,15 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw) nOrd = { 1, 0} end -- eseguo i tagli di lama + local bOk, sErr for i = 1, 2 do - -- inserisco la lavorazione - local sName = 'Cut_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) .. '_' .. tostring( Proc.Id) .. '_' .. tostring( i) - local nMchId = WM.AddMachining( Proc, sName, sCutting) - if not nMchId then - local sErr = 'Error adding machining ' .. sName .. '-' .. sCutting - EgtOutLog( sErr) - return false, sErr - end - EgtSetInfo( nMchId, 'Part', Proc.PartId) - -- aggiungo geometria - EgtSetMachiningGeometry( { { Proc.Id, nOrd[i]}}) - -- percorso da non invertire - EgtSetMachiningParam( MCH_MP.INVERT, false) - -- assegno affondamento - EgtSetMachiningParam( MCH_MP.DEPTH, 0) - -- assegno il lato di lavoro - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - -- assegno l'attacco e l'uscita - EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT) - EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT) - -- nessun criterio per il braccio è necessario - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE) - -- eseguo - if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) - return false, sErr + bOk, sErr = MakeOneFaceByBlade( Proc, sCutting, nOrd[i]) + if not bOk then + return bOk, sErr end end - return true + + return bOk, sErr end ---------------------------------------------------------------------