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