diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 09e5a6e..514f014 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -254,29 +254,24 @@ end --------------------------------------------------------------------- local function VerifyIfPocket( Proc, dDiam, vtOrtho, sMchFindMaster) - local bUsePocketing = false - local sMchFind = 'Pocket' - if sMchFindMaster and #sMchFindMaster > 0 then - sMchFind = sMchFindMaster - end --- local dCollSic = 2 * BD.COLL_SIC --- if abs( vtOrtho:getX()) > 0.996 or abs( vtOrtho:getY()) > 0.996 or abs( vtOrtho:getZ()) > 0.996 then dCollSic = BD.COLL_SIC end + -- tipo di svuotatura + local sMchFind = EgtIf( sMchFindMaster and #sMchFindMaster > 0, sMchFindMaster, 'Pocket') + -- ricerca della svuotatura local sPocketing = ML.FindPocketing( sMchFind, dDiam) - local dMaxMat = 0 - -- se non trova una svuotatura adatta if not sPocketing then - return bUsePocketing - else - -- recupero i dati dell'utensile - if EgtMdbSetCurrMachining( sPocketing) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat - end - bUsePocketing = true - end + return false end - return bUsePocketing, sPocketing, dMaxMat + -- recupero i dati dell'utensile + local bUsePocketing = false + local dMaxDepth = 0 + if EgtMdbSetCurrMachining( sPocketing) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + bUsePocketing = true + end + return bUsePocketing, sPocketing, dMaxDepth end --------------------------------------------------------------------- @@ -2415,8 +2410,6 @@ local function MakePocket( Proc, nPartId, ptPs, tvtN, nFaceRef, sMchFind, nUseRo elseif tvtN[2]:getY() > 0.1 then nSCC = MCH_SCC.ADIR_YP end - else - nSCC = MCH_SCC.NONE end EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- se tasca aperta e non lavorata col truciolatore, imposto opportuno attacco @@ -2787,11 +2780,10 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha bOrthoFaces = bOrthoFacesMaster end - -- se è un tunnel provo a vedere se è possibile lavorarlo con la svuotatura + -- se è un tunnel verifico se è possibile usare la svuotatura if bOrthoFaces then -- ottengo le dimensioni del tunnel dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc, nPartId) - -- verifico la direzione -- se devo inserire il chamfer if nChamfer > 0 then local nOk, sErr = MakeChamfer( Proc, b3FacesUsed, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) @@ -2800,12 +2792,12 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha -- se smusso non è esclusivo if nChamfer < 2 then -- verifico se può essere fatto con svuotatura - local bMakePocket, sPocketing, dMaxMat = VerifyIfPocket( Proc, dDimMin, vtOrtho, sMchFind) + local bMakePocket, sPocketing, dMaxDepth = VerifyIfPocket( Proc, dDimMin, vtOrtho, sMchFind) if bMakePocket then -- gestione svuotatura da un solo lato o anche dal lato opposto (se non verticale) -- estraggo il contorno dalla superfice per evitare i problemi con la svuotatura -- e assegno l'estrusione - local nPathInt, _ = EgtExtractSurfTmLoops( nSurfInt, nAddGrpId) + local nPathInt = EgtExtractSurfTmLoops( nSurfInt, nAddGrpId) EgtModifyCurveExtrusion( nPathInt, vtOrtho, GDB_RT.GLOB) -- se ho 3 facce, ciclo sulle entià del percorso per segnare quelle che sono aperte if b3FacesUsed then @@ -2816,30 +2808,35 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha local dElev = 0 local bDoubleSide -- se possibile svuotare completamente da una sola parte - if dMaxMat > ( dDepth + 2) then + if dMaxDepth > ( dDepth + 2) then dMachDepth = (dDepth / 2) + 2 dElev = dDepth else -- se direzione verso la verticale setto max affondamento possibile ed -- emetto messaggio di warning perché non lavorabile interamente - if abs(vtOrtho:getZ()) >= 0.707 then - dMachDepth = dMaxMat - (dDepth / 2) - dElev = dMaxMat + if abs( vtOrtho:getZ()) >= 0.707 then + dMachDepth = dMaxDepth - (dDepth / 2) + dElev = dMaxDepth sWarn = 'Warning : elevation bigger than max tool depth' EgtOutLog( sWarn) -- altrimenti setto il flag per fare la svuotatura da due parti else -- se l'altezza utensile riesce a lavorare completamente da due parti - if dMaxMat > (dDepth / 2) then + if dMaxDepth > ( dDepth / 2) then dMachDepth = 1 - dElev = (dDepth / 2) + 1 + dElev = ( dDepth / 2) + 1 -- altrimenti non si riesce in due passate, limito la profondità e setto l'elevazione else - dMachDepth = dMaxMat - (dDepth / 2) - dElev = dMaxMat - -- se sono in questo caso verifico la direzione, se le componenti x,y e z deviano molto - -- allora considero la lavorazione non idonea perchè potrebbe avere anche delle collisioni - if abs(vtOrtho:getX()) > 0.5 or abs(vtOrtho:getY()) > 0.5 or abs(vtOrtho:getZ()) > 0.5 then + dMachDepth = dMaxDepth - ( dDepth / 2) + dElev = dMaxDepth + -- se molto inclinato rispetto alla normale della faccia di riferimento, lavorazione non idonea per probabili collisioni + local vtRef = Y_AX() + if abs( vtOrtho:getX()) > abs( vtOrtho:getY()) and abs( vtOrtho:getX()) > abs( vtOrtho:getZ()) then + vtRef = X_AX() + elseif abs( vtOrtho:getZ()) > abs( vtOrtho:getX()) and abs( vtOrtho:getZ()) > abs( vtOrtho:getX()) then + vtRef = Z_AX() + end + if abs( vtOrtho * vtRef) < 0.5 then bBadMach = true end end @@ -2872,15 +2869,17 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha bInvertMach = true end -- imposto posizione braccio porta testa - local nSCC - if abs( vtOrtho:getX()) < 0.02 and abs( vtOrtho:getY()) > 0.02 then - local bNearTail = ( Proc.Box:getCenter():getX() < b3Solid:getCenter():getX() and Proc.Box:getCenter():getX() - b3Solid:getMin():getX() < 1000) - local bVeryShortPart = ( BD.LEN_VERY_SHORT_PART and b3Solid:getDimX() < BD.LEN_VERY_SHORT_PART) - nSCC = EgtIf( BL.IsPartFinalPhase( nPhase) or ( bNearTail and not bVeryShortPart), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) - elseif vtOrtho:getY() < GEO.EPS_SMALL then - nSCC = EgtIf( bInvertMach, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) - else - nSCC = EgtIf( bInvertMach, MCH_SCC.ADIR_YM, MCH_SCC.ADIR_YP) + local nSCC = MCH_SCC.NONE + if not BD.C_SIMM then + if AreSameOrOppositeVectorApprox( vtOrtho, Z_AX()) then + nSCC = MCH_SCC.ADIR_YM + elseif abs( vtOrtho:getX()) < 0.1 then + nSCC = EgtIf( BL.IsPartFinalPhase( nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + elseif vtOrtho:getY() < GEO.EPS_SMALL then + nSCC = EgtIf( bInvertMach, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) + else + nSCC = EgtIf( bInvertMach, MCH_SCC.ADIR_YM, MCH_SCC.ADIR_YP) + end end EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- se tasca aperta, imposto opportuno attacco @@ -2909,9 +2908,9 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha if bDoubleSide then -- se anche lavorando dal lato opposto non riesco a svuotare completamente la fessura -- setto i parametri affondamento ed emetto warning - if dMaxMat*2 < dDepth then - dMachDepth = dMaxMat - (dDepth / 2) - dElev = dMaxMat + if 2 * dMaxDepth < dDepth then + dMachDepth = dMaxDepth - (dDepth / 2) + dElev = dMaxDepth sWarn = 'Warning : elevation bigger than max tool depth' EgtOutLog( sWarn) end @@ -2928,15 +2927,17 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha -- imposto direzione utensile opposta EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) -- imposto posizione braccio porta testa - local nSCC - if abs( vtOrtho:getX()) < 0.02 and abs( vtOrtho:getY()) > 0.02 then - local bNearTail = ( Proc.Box:getCenter():getX() < b3Solid:getCenter():getX() and Proc.Box:getCenter():getX() - b3Solid:getMin():getX() < 1000) - local bVeryShortPart = ( BD.LEN_VERY_SHORT_PART and b3Solid:getDimX() < BD.LEN_VERY_SHORT_PART) - nSCC = EgtIf( BL.IsPartFinalPhase( nPhase) or ( bNearTail and not bVeryShortPart), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) - elseif vtOrtho:getY() < GEO.EPS_SMALL then - nSCC = MCH_SCC.ADIR_YP - else - nSCC = MCH_SCC.ADIR_YM + local nSCC = MCH_SCC.NONE + if not BD.C_SIMM then + if AreSameVectorApprox( vtOrtho, Z_AX()) then + nSCC = MCH_SCC.ADIR_YM + elseif abs( vtOrtho:getX()) < 0.1 then + nSCC = EgtIf( BL.IsPartFinalPhase( nPhase), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + elseif vtOrtho:getY() < GEO.EPS_SMALL then + nSCC = MCH_SCC.ADIR_YP + else + nSCC = MCH_SCC.ADIR_YM + end end EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- se tasca aperta, imposto opportuno attacco @@ -3944,7 +3945,7 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- se ortogonali e non forzata lama oppure con testa da sotto, con fresa if ( not bUseBlade or bDownHead) and bAdj and abs( dAng + 90) < 1 then -- se piccole - if ( Proc.Box:getDimX() < MAX_MILL_LIN and ( Proc.Box:getDimZ() < MAX_MILL_LIN or Proc.Box:getDimY() < MAX_MILL_LIN)) then + if Proc.Box:getDimX() < MAX_MILL_LIN and ( Proc.Box:getDimZ() < MAX_MILL_LIN or Proc.Box:getDimY() < MAX_MILL_LIN) then return MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId, bDownHead) else return MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, true) @@ -3964,7 +3965,7 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- verifico se sono presenti i parametri Q per la profondità smusso e -- per eseguire in esclusiva solo lo smusso local nChamfer, dDepthCham, sErrCham = EvaluateQParam( Proc) - if (Proc.Fct == 2 and bIsL) and nChamfer > 0 then + if Proc.Fct == 2 and bIsL and nChamfer > 0 then local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc, nPartId) local nOk, sErr = MakeChamfer( Proc, true, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) if nOk < 0 then return false, sErr end