From 3aa7979be4264330dc2177dc0fc81f7ddc0a8fdf Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Tue, 5 Mar 2024 09:56:18 +0100 Subject: [PATCH] In FreeContour aggiunto smusso se lav. di svuotatura e corretto caso non passante --- LuaLibs/ProcessFreeContour.lua | 114 ++++++++++++++++++++++++++------- 1 file changed, 91 insertions(+), 23 deletions(-) diff --git a/LuaLibs/ProcessFreeContour.lua b/LuaLibs/ProcessFreeContour.lua index d03e8a0..4fbcdfe 100644 --- a/LuaLibs/ProcessFreeContour.lua +++ b/LuaLibs/ProcessFreeContour.lua @@ -9,6 +9,8 @@ -- 2023/03/03 Corretta MakeByMark ( non definiti b3Raw e b3Aux ). -- 2023/06/21 In CalcSpecialAdd modificato l'angolo minimo da 5 a 15 deg. -- 2023/07/28 In MakeByPocket aggiunta Q06 per specificare un eventuale offset radiale del contorno. +-- 2024/03/05 In MakebyPocket aggiunta lavorazione di smusso +-- In MakeByMill eliminata doppia lavorazione smusso se contorno non passante -- Tabella per definizione modulo local ProcessFreeContour = {} @@ -294,16 +296,18 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) local bCross = false if abs( vtExtr:getX()) < 0.707 then if abs( vtExtr:getY()) > abs( vtExtr:getZ()) then + -- se è passante if b3Aux:getDimY() > b3Raw:getDimY() - 1.0 then bCross = true dDepth = min( dDepth, b3Raw:getDimY() / abs( vtExtr:getY())) end if bDown then - nSide = -1 + nSide = -1 else - nSide = 1 + nSide = 1 end else + -- se è passante if b3Aux:getDimZ() > b3Raw:getDimZ() - 1.0 then bCross = true dDepth = min( dDepth, b3Raw:getDimZ() / abs( vtExtr:getZ())) @@ -373,28 +377,28 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) if nChamfer > 0 and Proc.Grp ~= 0 and dOriDepth > dDepthCham and Proc.Prc ~= 70 then local bDoubleCham = false local dExtra = 2 - local sChamferDown, sChamferUp - if nDouble > 1 and bCanDouble then - if nSide == 0 then - if BD.DOWN_HEAD then - -- recupero la lavorazione - local nChamferDown - nChamferDown, _, sChamferDown = VerifyChamfer( Proc, AuxId, nRawId, true, true) - if nChamferDown < 0 then + local sChamferDown, sChamferUp + if nDouble > 1 and bCanDouble then + if nSide == 0 then + if BD.DOWN_HEAD then + -- recupero la lavorazione + local nChamferDown + nChamferDown, _, sChamferDown = VerifyChamfer( Proc, AuxId, nRawId, true, true) + if nChamferDown < 0 then + sWarn = 'Warning : chamfer from bottom not found in library' + sChamferDown = nil + EgtOutLog( sWarn) + end + end + local nChamferUp + nChamferUp, _, sChamferUp = VerifyChamfer( Proc, AuxId, nRawId, true, false) + if nChamferUp < 0 then sWarn = 'Warning : chamfer from bottom not found in library' - sChamferDown = nil + sChamferUp = nil EgtOutLog( sWarn) end end - local nChamferUp - nChamferUp, _, sChamferUp = VerifyChamfer( Proc, AuxId, nRawId, true, false) - if nChamferUp < 0 then - sWarn = 'Warning : chamfer from bottom not found in library' - sChamferUp = nil - EgtOutLog( sWarn) - end end - end -- eseguo for i = 1, nStep do -- inserisco la lavorazione @@ -439,9 +443,9 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) end end if nSide == 0 then - bDoubleCham = EgtIf( sChamferDown and BD.DOWN_HEAD, true, false) + bDoubleCham = EgtIf( sChamferDown and BD.DOWN_HEAD, true, false) and bCanDouble else - bDoubleCham = true + bDoubleCham = bCanDouble end -- assegno affondamento e offset radiale EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra) @@ -734,8 +738,72 @@ local function MakeByPocket( Proc, nPhase, nRawId, nPartId, dOvmHead) -- recupero i dati della curva e del profilo local dDepth = abs( EgtCurveThickness( AuxId)) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) - --local bToolInv = ( vtExtr:getZ() < -0.1) - -- recupero la lavorazione + local bDownHead = ( BD.DOWN_HEAD and vtExtr:getZ() < 0.1) + local bToolInv = ( not bDownHead and vtExtr:getZ() < -0.1 and b3Aux:getDimZ() > b3Raw:getDimZ() - 5) + local dExtra = 2 + + -- verifico se servono gli smussi. Se lavorazione principale di svuotatura significa che è solo da un lato + -- generalmente sono lavorazioni non molto lunghe, quindi non si gestistono gli step + -- verifico i parametri Q per profondità smusso e per eseguirlo in esclusiva + local nChamfer, dDepthCham, sChamfer = VerifyChamfer( Proc, AuxId, nRawId, true) + -- se devo inserire il chamfer + if nChamfer > 0 and Proc.Grp ~= 0 and dDepth > dDepthCham and Proc.Prc ~= 70 then + -- inserisco la lavorazione + local sNameCh = 'Cham_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchId = EgtAddMachining( sNameCh, sChamfer) + if not nMchId then + local sErr = 'Error adding machining ' .. sNameCh .. '-' .. sChamfer + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ AuxId, -1}}) + -- se lavorazione da sopra o da sotto + if Proc.Grp == 3 then + if not bToolInv then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + end + end + if Proc.Grp == 4 then + if not bToolInv then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + end + end + -- assegno affondamento e offset radiale + EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra) + EgtSetMachiningParam( MCH_MP.OFFSR, dExtra) + -- posizione braccio porta testa + local nSCC = MCH_SCC.NONE + if not BD.C_SIMM then + if Proc.Head then + nSCC = MCH_SCC.ADIR_XP + elseif Proc.Tail then + nSCC = MCH_SCC.ADIR_XM + elseif AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then + nSCC = MCH_SCC.ADIR_YP + elseif vtExtr:getY() > -0.01 then + nSCC = MCH_SCC.ADIR_YP + else + nSCC = MCH_SCC.ADIR_YM + end + end + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + end + + -- recupero la lavorazione di svuotatura local sPocketing = ML.FindPocketing( 'Pocket', nil, dDepth) if not sPocketing then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library'