diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index debc013..cf36306 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -1,4 +1,4 @@ --- ProcessDrill.lua by Egaltech s.r.l. 2021/01/13 +-- ProcessDrill.lua by Egaltech s.r.l. 2021/02/18 -- Gestione calcolo forature per Travi -- Tabella per definizione modulo @@ -205,15 +205,24 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) dCheckDepth2 = nil end -- abilitazione foratura da sotto - local bDrillDown = ( BD.DOWN_HEAD and ( Proc.Down or vtExtr:getZ() < -0.1 or vtExtr:getY() > 0 or EgtExistsInfo( Proc.Id, 'MAIN')) and not EgtExistsInfo( Proc.Id, 'DOU')) + --local bDrillDown = ( BD.DOWN_HEAD and ( Proc.Down or vtExtr:getZ() < -0.1 or vtExtr:getY() > 0 or EgtExistsInfo( Proc.Id, 'MAIN')) and not EgtExistsInfo( Proc.Id, 'DOU')) + local bDrillUp = ( BD.DOWN_HEAD and vtExtr:getZ() > -0.259) + local bDrillDown = ( BD.DOWN_HEAD and ( Proc.Down or vtExtr:getZ() < -0.1 or ( vtExtr:getZ() < 0.259 and vtExtr:getY() > 0))) -- primo gruppo di controlli con lunghezza utensile calcolata -- recupero la lavorazione local sDrilling, nType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, dCheckDepth, bDrillDown) if not sDrilling then -- se ho passato altezza di taglio utensile allora rifaccio la ricerca senza passare altezza utensile if dCheckDepth then - dCheckDepth = nil sDrilling, nType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, 0, bDrillDown) + if sDrilling then dCheckDepth = nil end + end + if not sDrilling and bDrillUp then + sDrilling, nType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, dCheckDepth) + if dCheckDepth then + sDrilling, nType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, 0) + if sDrilling then dCheckDepth = nil end + end end if not sDrilling then nErrorCode = 1 diff --git a/LuaLibs/ProcessHeadCut.lua b/LuaLibs/ProcessHeadCut.lua index f9e6398..621a040 100644 --- a/LuaLibs/ProcessHeadCut.lua +++ b/LuaLibs/ProcessHeadCut.lua @@ -1,4 +1,4 @@ --- ProcessSplit.lua by Egaltech s.r.l. 2020/06/16 +-- ProcessSplit.lua by Egaltech s.r.l. 2021/02/17 -- Gestione calcolo tagli di testa per Travi -- Tabella per definizione modulo @@ -153,7 +153,7 @@ function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bNeedHCut -- recupero la lavorazione local sCutting = ML.FindCutting( 'HeadSide') if not sCutting then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library' + local sErr = 'Error : cutting not found in library' EgtOutLog( sErr) return false, sErr end @@ -167,46 +167,100 @@ function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bNeedHCut dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth end end + local dMaxVertDepth = dMaxDepth - ( BD.DECR_VERT_CUT or 0) -- caratteristiche taglio - local bHorizCut = ( b3Raw:getDimY() > b3Raw:getDimZ() + 10 * GEO.EPS_SMALL and b3Raw:getDimZ() < dMaxDepth - BD.CUT_EXTRA) + local bHorizCut = ( b3Raw:getDimY() > b3Raw:getDimZ() + 10 * GEO.EPS_SMALL and b3Raw:getDimZ() < dMaxVertDepth - BD.CUT_EXTRA) local dDimYRef = EgtIf( b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL, dMaxDepth - BD.CUT_EXTRA, BD.MAX_DIM_HTCUT_HBEAM) - local bDoubleCut = ( not bHorizCut and b3Raw:getDimY() > dDimYRef + 10 * GEO.EPS_SMALL) + local bDoubleHorizCut = ( b3Raw:getDimY() > 2 * dDimYRef - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) + local bDoubleCut = ( not bHorizCut and not bDoubleHorizCut and b3Raw:getDimY() > dDimYRef + 10 * GEO.EPS_SMALL) -- dati geometrici del taglio local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) -- se non obbligatorio e coincide con inizio grezzo, non va fatto if not bNeedHCut and AreSameVectorApprox( vtN, X_AX()) and abs( ptC:getX() - b3Raw:getMax():getX()) < 10 * GEO.EPS_SMALL then return true end - -- flag di lavorazione faccia - local nOrthoOpposite = EgtIf( bHorizCut, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_FRONT) -- determino se più tagli con offset local nCuts = max( ceil( dOvmHead / ( BD.MAX_LEN_SCRAP_START or BD.MAX_LEN_SCRAP)), 1) local dOffsL = dOvmHead / nCuts - -- calcolo extra taglio ed accorciamento - local dCutExtra = 0 - local dAccStart = 0 - if b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL or b3Raw:getDimY() < 2 * BD.MAX_DIM_HTCUT_HBEAM + 10 * GEO.EPS_SMALL then - dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN, BD.CUT_EXTRA) - dAccStart = 0 - else - dCutExtra = - ( b3Raw:getDimY() - dMaxDepth - BD.CUT_EXTRA) - local dSawRad = dSawDiam / 2 - local dKL = dSawRad - dMaxDepth + b3Raw:getDimY() / 2 + BD.CUT_EXTRA_MIN - dAccStart = sqrt( dSawRad * dSawRad - dKL * dKL) - end - -- se necessari tagli in doppio, eseguo gli opposti - if bDoubleCut then + -- se tagli standard + if not bDoubleHorizCut then + -- flag di lavorazione faccia + local nOrthoOpposite = EgtIf( bHorizCut, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_FRONT) + -- calcolo extra taglio ed accorciamento + local dCutExtra = 0 + local dAccStart = 0 + if b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL or b3Raw:getDimY() < 2 * BD.MAX_DIM_HTCUT_HBEAM + 10 * GEO.EPS_SMALL then + dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN, BD.CUT_EXTRA) + dAccStart = 0 + else + dCutExtra = - ( b3Raw:getDimY() - dMaxDepth - BD.CUT_EXTRA) + local dSawRad = dSawDiam / 2 + local dKL = dSawRad - dMaxDepth + b3Raw:getDimY() / 2 + BD.CUT_EXTRA_MIN + dAccStart = sqrt( dSawRad * dSawRad - dKL * dKL) + end + -- se necessari tagli in doppio, eseguo gli opposti + if bDoubleCut then + for i = nCuts, 1, -1 do + local dCutOffset = ( i - 1) * dOffsL + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_BACK, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, '', b3Raw) + if not bOk then return false, sErr end + end + end + -- eseguo i tagli necessari for i = nCuts, 1, -1 do local dCutOffset = ( i - 1) * dOffsL - local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_BACK, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, '', b3Raw) + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, '', b3Raw) + if not bOk then return false, sErr end + end + -- altrimenti necessari tagli da sopra e sotto con testa opportuna + else + -- verifico di avere la testa da sotto + if not BD.DOWN_HEAD then + local sErr = 'Error : section too big for head cut' + EgtOutLog( sErr) + return false, sErr + end + -- recupero la lavorazione con lama da sotto + local sCutting2 = ML.FindCutting( 'HeadSide_H2') + if not sCutting2 then + local sErr = 'Error : cutting not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati della seconda lama + local dSawDiam2 = 400 + local dMaxDepth2 = 50 + if EgtMdbSetCurrMachining( sCutting2) then + local sTuuid2 = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid2) or '') then + dSawDiam2 = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam2 + dMaxDepth2 = EgtTdbGetCurrToolMaxDepth() or dMaxDepth2 + end + end + -- verifico che le due lame riescano a lavorare la sezione + local dDimZ = b3Raw:getDimZ() + local dExtra = dMaxVertDepth + dMaxDepth2 - dDimZ - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL + if dExtra < 0 then + local sErr = 'Error : section too height for head cut' + EgtOutLog( sErr) + return false, sErr + end + -- calcolo extra taglio ed accorciamento + local dCutExtra = - dMaxDepth2 + dExtra / 2 + BD.CUT_EXTRA_MIN + local dCutExtra2 = - dMaxVertDepth + dExtra / 2 + BD.CUT_EXTRA_MIN + local dAccStart = 0 + -- eseguo i tagli da sotto necessari + for i = nCuts, 1, -1 do + local dCutOffset = ( i - 1) * dOffsL + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting2, dSawDiam2, MCH_MILL_FU.ORTHO_TOP, nil, dCutExtra2, BD.CUT_SIC, dCutOffset, dAccStart, '', b3Raw) + if not bOk then return false, sErr end + end + -- eseguo i tagli da sopra necessari + for i = nCuts, 1, -1 do + local dCutOffset = ( i - 1) * dOffsL + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_DOWN, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, '', b3Raw) if not bOk then return false, sErr end end - end - -- eseguo i tagli necessari - for i = nCuts, 1, -1 do - local dCutOffset = ( i - 1) * dOffsL - local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, '', b3Raw) - if not bOk then return false, sErr end end return true end diff --git a/LuaLibs/ProcessSplit.lua b/LuaLibs/ProcessSplit.lua index cf66f61..2c26ce2 100644 --- a/LuaLibs/ProcessSplit.lua +++ b/LuaLibs/ProcessSplit.lua @@ -1,4 +1,4 @@ --- ProcessSplit.lua by Egaltech s.r.l. 2021/01/02 +-- ProcessSplit.lua by Egaltech s.r.l. 2021/02/17 -- Gestione calcolo tagli di separazione per Travi -- Tabella per definizione modulo @@ -167,9 +167,11 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId) dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth end end + local dMaxVertDepth = dMaxDepth - ( BD.DECR_VERT_CUT or 0) -- caratteristiche taglio - local bHorizCut = ( b3Raw:getDimY() > b3Raw:getDimZ() + 10 * GEO.EPS_SMALL and b3Raw:getDimZ() < dMaxDepth - BD.CUT_EXTRA) + local bHorizCut = ( b3Raw:getDimY() > b3Raw:getDimZ() + 10 * GEO.EPS_SMALL and b3Raw:getDimZ() < dMaxVertDepth - BD.CUT_EXTRA) local dDimYRef = EgtIf( b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL, dMaxDepth - BD.CUT_EXTRA, BD.MAX_DIM_HTCUT_HBEAM) + local bDoubleHorizCut = ( b3Raw:getDimY() > 2 * dDimYRef - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) local bDoubleCut = ( not bHorizCut and b3Raw:getDimY() > dDimYRef + 10 * GEO.EPS_SMALL) -- dati geometrici del taglio local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) @@ -192,38 +194,97 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId) b3Raw:Add( b3NextRaw) end end - -- calcolo extra taglio ed accorciamento - local dCutExtra = 0 - local dAccStart = 0 - if b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL or b3Raw:getDimY() < 2 * BD.MAX_DIM_HTCUT_HBEAM + 10 * GEO.EPS_SMALL then - dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN, BD.CUT_EXTRA) - dAccStart = 0 + -- se tagli standard + if not bDoubleHorizCut then + -- calcolo extra taglio ed accorciamento + local dCutExtra = 0 + local dAccStart = 0 + if b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL or b3Raw:getDimY() < 2 * BD.MAX_DIM_HTCUT_HBEAM + 10 * GEO.EPS_SMALL then + dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN, BD.CUT_EXTRA) + dAccStart = 0 + else + dCutExtra = - ( b3Raw:getDimY() - dMaxDepth - BD.CUT_EXTRA) + local dSawRad = dSawDiam / 2 + local dKL = dSawRad - dMaxDepth + b3Raw:getDimY() / 2 + BD.CUT_EXTRA_MIN + dAccStart = sqrt( dSawRad * dSawRad - dKL * dKL) + end + -- se necessari tagli in doppio, eseguo gli opposti + if bDoubleCut then + for i = nCuts, 1, -1 do + local dCutOffset = ( i - 1) * dOffsL + local sNotes = EgtIf( bSplit, 'Presplit;', 'Precut;') + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_FRONT, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, sNotes, b3Raw) + if not bOk then return false, true, sErr end + end + end + -- eseguo i tagli necessari + for i = nCuts, 1, -1 do + local dCutOffset = ( i - 1) * dOffsL + local sNotes + if bSplit then + sNotes = EgtIf( i == 1, 'Split;', 'Presplit;') + else + sNotes = EgtIf( i == 1, 'Cut;', 'Precut;') + end + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, sNotes, b3Raw) + if not bOk then return false, true, sErr end + end + -- altrimenti necessari tagli da sopra e sotto con testa opportuna else - dCutExtra = - ( b3Raw:getDimY() - dMaxDepth - BD.CUT_EXTRA) - local dSawRad = dSawDiam / 2 - local dKL = dSawRad - dMaxDepth + b3Raw:getDimY() / 2 + BD.CUT_EXTRA_MIN - dAccStart = sqrt( dSawRad * dSawRad - dKL * dKL) - end - -- se necessari tagli in doppio, eseguo gli opposti - if bDoubleCut then + -- verifico di avere la testa da sotto + if not BD.DOWN_HEAD then + local sErr = 'Error : section too big for head cut' + EgtOutLog( sErr) + return false, sErr + end + -- recupero la lavorazione con lama da sotto + local sCutting2 = ML.FindCutting( 'TailSide_H2') + if not sCutting2 then + local sErr = 'Error : cutting not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati della seconda lama + local dSawDiam2 = 400 + local dMaxDepth2 = 50 + if EgtMdbSetCurrMachining( sCutting2) then + local sTuuid2 = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid2) or '') then + dSawDiam2 = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam2 + dMaxDepth2 = EgtTdbGetCurrToolMaxDepth() or dMaxDepth2 + end + end + -- verifico che le due lame riescano a lavorare la sezione + local dDimZ = b3Raw:getDimZ() + local dExtra = dMaxVertDepth + dMaxDepth2 - dDimZ - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL + if dExtra < 0 then + local sErr = 'Error : section too height for head cut' + EgtOutLog( sErr) + return false, sErr + end + -- calcolo extra taglio ed accorciamento + local dCutExtra = - dMaxDepth2 + dExtra / 2 + BD.CUT_EXTRA_MIN + local dCutExtra2 = - dMaxVertDepth + dExtra / 2 + BD.CUT_EXTRA_MIN + local dAccStart = 0 + -- eseguo i tagli da sotto necessari for i = nCuts, 1, -1 do local dCutOffset = ( i - 1) * dOffsL local sNotes = EgtIf( bSplit, 'Presplit;', 'Precut;') - local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_FRONT, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, sNotes, b3Raw) + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting2, dSawDiam2, MCH_MILL_FU.ORTHO_TOP, nil, dCutExtra2, BD.CUT_SIC, dCutOffset, dAccStart, sNotes, b3Raw) if not bOk then return false, true, sErr end end - end - -- eseguo i tagli necessari - for i = nCuts, 1, -1 do - local dCutOffset = ( i - 1) * dOffsL - local sNotes - if bSplit then - sNotes = EgtIf( i == 1, 'Split;', 'Presplit;') - else - sNotes = EgtIf( i == 1, 'Cut;', 'Precut;') + -- eseguo i tagli necessari + for i = nCuts, 1, -1 do + local dCutOffset = ( i - 1) * dOffsL + local sNotes + if bSplit then + sNotes = EgtIf( i == 1, 'Split;', 'Presplit;') + else + sNotes = EgtIf( i == 1, 'Cut;', 'Precut;') + end + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_DOWN, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, sNotes, b3Raw) + if not bOk then return false, true, sErr end end - local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, sNotes, b3Raw) - if not bOk then return false, true, sErr end end -- ritorno anche flag di passaggio a fase successiva return true, true