From b48fe0da34a3b88f8c9c3477df03665ec0b979c2 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 22 Nov 2022 09:33:22 +0100 Subject: [PATCH 1/3] Improvement/DownHeadInFreeContour: - fresatura ok, da sistemare funzionamento smussi --- LuaLibs/ProcessFreeContour.lua | 130 +++++++++++++++++++++++++-------- 1 file changed, 98 insertions(+), 32 deletions(-) diff --git a/LuaLibs/ProcessFreeContour.lua b/LuaLibs/ProcessFreeContour.lua index b681f39..607fb6a 100644 --- a/LuaLibs/ProcessFreeContour.lua +++ b/LuaLibs/ProcessFreeContour.lua @@ -121,7 +121,7 @@ function ProcessFreeContour.Classify( Proc, b3Raw) end --------------------------------------------------------------------- -local function VerifyChamfer( Proc, AuxId, nRawId, bMakeVertCham) +local function VerifyChamfer( Proc, AuxId, nRawId, bMakeVertCham, bDownHead) local nChamfer = 0 -- ingombro del grezzo local b3Raw = EgtGetRawPartBBox( nRawId) @@ -161,7 +161,11 @@ local function VerifyChamfer( Proc, AuxId, nRawId, bMakeVertCham) -- recupero la lavorazione local sMilling if nChamfer > 0 then - sMilling = ML.FindMilling( 'Mark') + if bDownHead then + sMilling = ML.FindMilling( 'Mark_H2') + else + sMilling = ML.FindMilling( 'Mark') + end if not sMilling then local sErr = 'Error : Mark not found in library' EgtOutLog( sErr) @@ -302,7 +306,7 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) end local dOriDepth = dDepth local nDouble = 1 - local bCanDouble = ( abs( vtExtr:getY()) > abs( vtExtr:getZ()) and bCross) + local bCanDouble = ( abs( vtExtr:getY()) > abs( vtExtr:getZ()) and bCross) or ( BD.DOWN_HEAD and bCross) local dDimStrip = BD.DIM_STRIP if dDimStrip < 0 then dDimStrip = EgtGetInfo( Proc.Id, Q_DIM_STRIP, 'd') or 0 @@ -323,6 +327,7 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) local bIsDepthReduced = false -- se parametro beamdata forza codolo in centro e lavorazione orizzontale e se larghezza trave è sufficientemente larga -- se chiamata da SimpleScarf il codolo è sempre attivo + local dDepthWork = dDepth if BD.DIM_TO_CENTER_STRIP and BD.DIM_TO_CENTER_STRIP > 10 * GEO.EPS_SMALL and ( nStep > 1 or Proc.Prc == 70) and bCanDouble and b3Raw:getDimY() > BD.DIM_TO_CENTER_STRIP - 0.1 then nDouble = 2 @@ -332,8 +337,9 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) if dDepth > dMaxDepth then if bCanDouble then nDouble = 2 - dDepth = min( 0.5 * dDepth, dMaxDepth) - if dDepth < 0.5 * dDepth - 10 * GEO.EPS_SMALL then + dDepthWork = 0.5 * dDepth + dDepth = min( dDepthWork, dMaxDepth) + if dDepth < dDepthWork - 10 * GEO.EPS_SMALL then bIsDepthReduced = true end else @@ -345,7 +351,7 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) local sWarn = '' -- se ho ridotto l'altezza emetto warning if bIsDepthReduced then - sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' (Free Contour) : elevation bigger than max tool depth' + sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' (Free Contour) : depth (' .. EgtNumToString( dDepthWork, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' EgtOutLog( sWarn) end -- se utensile orizzontale verso Y+, non in doppio e codolo da lasciare, devo invertire per lavorare sempre da Y- @@ -374,35 +380,66 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) -- se lavorazione da sopra o da sotto - if nSide ~= 0 then + if nSide == 0 then bDoubleCham = true - end - if Proc.Grp == 3 then - if not bToolInv then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - EgtSetMachiningParam( MCH_MP.INVERT, true) - else - if not bDownHead and vtExtr:getZ() < 0 then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - EgtSetMachiningParam( MCH_MP.INVERT, true) - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - else - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - EgtSetMachiningParam( MCH_MP.INVERT, true) - end - 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 - if not bDownHead and vtExtr:getZ() < 0 then + if Proc.Grp == 3 then + if not bToolInv then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) EgtSetMachiningParam( MCH_MP.INVERT, true) - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) else + if not bDownHead and vtExtr:getZ() < 0 then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + end + 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 + if not bDownHead and vtExtr:getZ() < 0 then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + end + end + end + else + bDoubleCham = true + if Proc.Grp == 3 then + if not bToolInv then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + else + if not bDownHead and vtExtr:getZ() < 0 then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + end + 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 + if not bDownHead and vtExtr:getZ() < 0 then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + end end end end @@ -446,11 +483,26 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) return false, sErr end + local sChamferDown + if nDouble > 1 and bCanDouble then + if nSide == 0 then + if BD.DOWN_HEAD then + -- recupero la lavorazione + _, _, sChamferDown = VerifyChamfer( Proc, AuxId, nRawId, true, bDownHead) + if not sChamferDown then + sWarn = 'Warning : chamfer from bottom not found in library' + EgtOutLog( sWarn) + bCanDouble = false + end + end + end + end + -- se lavorazione da due parti, aggiungo la seconda if bDoubleCham then -- inserisco la lavorazione local sName = 'ChamB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMchId = EgtAddMachining( sName, sChamfer) + local nMchId = EgtAddMachining( sName, EgtIf( BD.DOWN_HEAD and nSide == 0, sChamfer, sChamfer)) if not nMchId then local sErr = 'Error adding machining ' .. sName .. '-' .. sChamfer EgtOutLog( sErr) @@ -511,6 +563,20 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- verifico se devo fare sgrossatura più finitura local dOffsetPar = EgtGetInfo( Proc.Id, Q_OVERMAT_FOR_FINISH, 'i') or 0 + local sMillingDown + if nDouble > 1 and bCanDouble then + if nSide == 0 then + if BD.DOWN_HEAD then + -- recupero la lavorazione + sMillingDown = ML.FindMilling( 'Prof_H2', nil, nil, nil, nil, false, true) + if not sMillingDown then + sWarn = 'Warning : milling from bottom not found in library' + EgtOutLog( sWarn) + bCanDouble = false + end + end + end + end -- eseguo for i = 1, nStep do for j = 1, nDouble do @@ -535,7 +601,7 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) else -- inserisco la lavorazione sName = 'Free_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - nMchId = EgtAddMachining( sName, sMilling) + nMchId = EgtAddMachining( sName, EgtIf( j == 2 and BD.DOWN_HEAD and nSide == 0, sMillingDown, sMilling)) if not nMchId then local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling EgtOutLog( sErr) From 07dad8f8c20e6439ef93cab312088b7f0bb8ca1e Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 22 Nov 2022 14:51:39 +0100 Subject: [PATCH 2/3] Improvement/DownHeadInFreeContour: - correzione fresatura per casi in cui si parte dalla testa sotto --- LuaLibs/ProcessFreeContour.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/LuaLibs/ProcessFreeContour.lua b/LuaLibs/ProcessFreeContour.lua index 607fb6a..ea36115 100644 --- a/LuaLibs/ProcessFreeContour.lua +++ b/LuaLibs/ProcessFreeContour.lua @@ -381,7 +381,7 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) EgtSetMachiningGeometry( {{ AuxId, -1}}) -- se lavorazione da sopra o da sotto if nSide == 0 then - bDoubleCham = true + bDoubleCham = false if Proc.Grp == 3 then if not bToolInv then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) @@ -563,18 +563,26 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- verifico se devo fare sgrossatura più finitura local dOffsetPar = EgtGetInfo( Proc.Id, Q_OVERMAT_FOR_FINISH, 'i') or 0 - local sMillingDown + local sMillingDown, sMillingUp if nDouble > 1 and bCanDouble then if nSide == 0 then if BD.DOWN_HEAD then -- recupero la lavorazione - sMillingDown = ML.FindMilling( 'Prof_H2', nil, nil, nil, nil, false, true) + sMillingDown = ML.FindMilling( 'FreeContour_H2', nil, nil, nil, nil, false, true) if not sMillingDown then sWarn = 'Warning : milling from bottom not found in library' EgtOutLog( sWarn) bCanDouble = false end end + if EgtEndsWith( sMilling, '_H2') then + sMillingUp = ML.FindMilling( 'FreeContour', nil, nil, nil, nil, true, false) + if not sMillingDown then + sWarn = 'Warning : milling not found in library' + EgtOutLog( sWarn) + bCanDouble = false + end + end end end -- eseguo @@ -601,7 +609,11 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) else -- inserisco la lavorazione sName = 'Free_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - nMchId = EgtAddMachining( sName, EgtIf( j == 2 and BD.DOWN_HEAD and nSide == 0, sMillingDown, sMilling)) + if EgtEndsWith( sMilling, '_H2') then + nMchId = EgtAddMachining( sName, EgtIf( j == 2 and nSide == 0, sMillingUp, sMilling)) + else + nMchId = EgtAddMachining( sName, EgtIf( j == 2 and nSide == 0, sMillingDown, sMilling)) + end if not nMchId then local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling EgtOutLog( sErr) From 2c5de2516daf9e364de61c722f959d0eca5aa0cb Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 22 Nov 2022 17:53:17 +0100 Subject: [PATCH 3/3] Improvement/DownHeadInFreeContour: - implementazione corretta degli smussi --- LuaLibs/ProcessFreeContour.lua | 134 ++++++++++++++------------------- 1 file changed, 57 insertions(+), 77 deletions(-) diff --git a/LuaLibs/ProcessFreeContour.lua b/LuaLibs/ProcessFreeContour.lua index ea36115..696a610 100644 --- a/LuaLibs/ProcessFreeContour.lua +++ b/LuaLibs/ProcessFreeContour.lua @@ -162,7 +162,7 @@ local function VerifyChamfer( Proc, AuxId, nRawId, bMakeVertCham, bDownHead) local sMilling if nChamfer > 0 then if bDownHead then - sMilling = ML.FindMilling( 'Mark_H2') + sMilling = ML.FindMilling( 'Mark_H2', nil, nil, nil, nil, false, true) else sMilling = ML.FindMilling( 'Mark') end @@ -367,11 +367,30 @@ 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 + _, _, sChamferDown = VerifyChamfer( Proc, AuxId, nRawId, true, true) + if not sChamferDown then + sWarn = 'Warning : chamfer from bottom not found in library' + EgtOutLog( sWarn) + end + end + _, _, sChamferUp = VerifyChamfer( Proc, AuxId, nRawId, true, false) + if not sChamferUp then + sWarn = 'Warning : milling not found in library' + EgtOutLog( sWarn) + end + end + end -- eseguo for i = 1, nStep do -- inserisco la lavorazione local sNameCh = 'Cham_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMchId = EgtAddMachining( sNameCh, sChamfer) + local sChamferSide1 = EgtIf( bDownHead, sChamferDown, sChamfer) + local nMchId = EgtAddMachining( sNameCh, sChamferSide1) if not nMchId then local sErr = 'Error adding machining ' .. sNameCh .. '-' .. sChamfer EgtOutLog( sErr) @@ -380,68 +399,39 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) -- se lavorazione da sopra o da sotto - if nSide == 0 then - bDoubleCham = false - if Proc.Grp == 3 then - if not bToolInv then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - EgtSetMachiningParam( MCH_MP.INVERT, true) - else - if not bDownHead and vtExtr:getZ() < 0 then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - EgtSetMachiningParam( MCH_MP.INVERT, true) - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - else - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - EgtSetMachiningParam( MCH_MP.INVERT, true) - end - end - end - if Proc.Grp == 4 then - if not bToolInv then + if Proc.Grp == 3 then + if not bToolInv then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + else + if not bDownHead and vtExtr:getZ() < 0 then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) else - if not bDownHead and vtExtr:getZ() < 0 then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - EgtSetMachiningParam( MCH_MP.INVERT, true) - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - else - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - end + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.INVERT, true) end 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 + if not bDownHead and vtExtr:getZ() < 0 then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + end + end + end + if nSide == 0 then + bDoubleCham = BD.DOWN_HEAD else bDoubleCham = true - if Proc.Grp == 3 then - if not bToolInv then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - EgtSetMachiningParam( MCH_MP.INVERT, true) - else - if not bDownHead and vtExtr:getZ() < 0 then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - EgtSetMachiningParam( MCH_MP.INVERT, true) - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - else - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - EgtSetMachiningParam( MCH_MP.INVERT, true) - end - 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 - if not bDownHead and vtExtr:getZ() < 0 then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - EgtSetMachiningParam( MCH_MP.INVERT, true) - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - else - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - end - end - end end -- assegno affondamento e offset radiale EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra) @@ -482,27 +472,19 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) EgtSetOperationMode( nMchId, false) return false, sErr end - - local sChamferDown - if nDouble > 1 and bCanDouble then - if nSide == 0 then - if BD.DOWN_HEAD then - -- recupero la lavorazione - _, _, sChamferDown = VerifyChamfer( Proc, AuxId, nRawId, true, bDownHead) - if not sChamferDown then - sWarn = 'Warning : chamfer from bottom not found in library' - EgtOutLog( sWarn) - bCanDouble = false - end - end - end - end - -- se lavorazione da due parti, aggiungo la seconda if bDoubleCham then -- inserisco la lavorazione local sName = 'ChamB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMchId = EgtAddMachining( sName, EgtIf( BD.DOWN_HEAD and nSide == 0, sChamfer, sChamfer)) + local sChamferSide2 + if EgtEndsWith( sChamferSide1, 'H2') then + sChamferSide2 = sChamferUp + elseif nSide == 0 then + sChamferSide2 = sChamferDown + else + sChamferSide2 = sChamfer + end + nMchId = EgtAddMachining( sName, sChamferSide2) if not nMchId then local sErr = 'Error adding machining ' .. sName .. '-' .. sChamfer EgtOutLog( sErr) @@ -572,15 +554,13 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) if not sMillingDown then sWarn = 'Warning : milling from bottom not found in library' EgtOutLog( sWarn) - bCanDouble = false end end if EgtEndsWith( sMilling, '_H2') then sMillingUp = ML.FindMilling( 'FreeContour', nil, nil, nil, nil, true, false) - if not sMillingDown then + if not sMillingUp then sWarn = 'Warning : milling not found in library' EgtOutLog( sWarn) - bCanDouble = false end end end