From b48fe0da34a3b88f8c9c3477df03665ec0b979c2 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 22 Nov 2022 09:33:22 +0100 Subject: [PATCH] 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)