diff --git a/BatchProcess.lua b/BatchProcess.lua index 1058fe1..dd79c81 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -1,4 +1,4 @@ --- BatchProcess.lua by Egaltech s.r.l. 2020/01/14 +-- BatchProcess.lua by Egaltech s.r.l. 2020/01/24 -- Gestione calcolo batch disposizione e lavorazioni per Travi -- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- 2019/07/16 Aggiunta gestione modalità oltre 10 per impostazione macchina e uscita. @@ -312,9 +312,9 @@ if bToProcess then end -- Lunghezza della barra - local dRawL = EgtGetInfo( EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or GDB_ID.NULL, 'BARLEN', 'd') or 12000 + local dRawL = ( EgtGetInfo( EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or GDB_ID.NULL, 'BARLEN', 'd') or 12000) + 0.1 -- Sovramateriale di testa - local dOvmHead = vBeam[1].PosX or 10 + local dOvmHead = vBeam[1].PosX or 0 -- Sistemo le travi nel grezzo local bPbOk, sPbErr = BE.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index c5334d4..c001919 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1,4 +1,4 @@ --- BeamLib.lua by Egaltech s.r.l. 2019/10/03 +-- BeamLib.lua by Egaltech s.r.l. 2020/01/23 -- Libreria globale per Travi -- Tabella per definizione modulo @@ -459,11 +459,9 @@ function BeamLib.CalcLeadInOutGeom( ptP1, ptP2, vtV1, vtV2, vtN, dRad, vtRef, dC -- Versori di attacco e uscita nel riferimento intrinseco al taglio local vtLiL = Vector3d( vtLi) ; vtLiL:toLoc( frFace) local vtLoL = Vector3d( vtLo) ; vtLoL:toLoc( frFace) - -- Spostamento punti per effetto dell'extra di taglio - if dCutExtra > GEO.EPS_SMALL then - ptP1 = ptP1 + vtX * ( EgtIf( bRight, - dCutExtra, dCutExtra)) - ptP2 = ptP2 + vtX * ( EgtIf( bRight, - dCutExtra, dCutExtra)) - end + -- Spostamento punti per effetto dell'extra o della deficienza di taglio + ptP1 = ptP1 + vtX * ( EgtIf( bRight, - dCutExtra, dCutExtra)) + ptP2 = ptP2 + vtX * ( EgtIf( bRight, - dCutExtra, dCutExtra)) -- Attacco local dLiTang = 10000 local dLiPerp = 10000 @@ -545,11 +543,9 @@ function BeamLib.CalcLeadInOutTangGeom( ptP1, ptP2, vtN, dRad, vtRef, dCutExtra, vtX = - vtX end EgtOutLog( 'Vref=' .. tostring( vtRef) .. ' V1=' .. tostring( vtV1) .. ' V2=' .. tostring( vtV2), 3) - -- Spostamento punti per effetto dell'extra di taglio - if dCutExtra > GEO.EPS_SMALL then - ptP1 = ptP1 - vtX * dCutExtra - ptP2 = ptP2 - vtX * dCutExtra - end + -- Spostamento punti per effetto dell'extra o della deficienza di taglio + ptP1 = ptP1 - vtX * dCutExtra + ptP2 = ptP2 - vtX * dCutExtra -- Attacco local dLiTang = 10000 local dLiPerp = 0 diff --git a/LuaLibs/ProcessHeadCut.lua b/LuaLibs/ProcessHeadCut.lua index 11f0beb..dc8245e 100644 --- a/LuaLibs/ProcessHeadCut.lua +++ b/LuaLibs/ProcessHeadCut.lua @@ -1,4 +1,4 @@ --- ProcessSplit.lua by Egaltech s.r.l. 2019/06/29 +-- ProcessSplit.lua by Egaltech s.r.l. 2020/01/24 -- Gestione calcolo tagli di testa per Travi -- Tabella per definizione modulo @@ -25,8 +25,26 @@ end function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- ingombro del grezzo local b3Raw = EgtGetRawPartBBox( nRawId) - local bHorizCut = ( b3Raw:getDimY() > b3Raw:getDimZ() + 10 * GEO.EPS_SMALL and b3Raw:getDimZ() < BD.MAX_DIM_HTCUT) - local dDimYRef = EgtIf( b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL, BD.MAX_DIM_HTCUT, BD.MAX_DIM_HTCUT_HBEAM) + -- 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' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + local dSawDiam = 400 + local dMaxDepth = 50 + if EgtMdbSetCurrMachining( sCutting) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end + -- caratteristiche taglio + local bHorizCut = ( b3Raw:getDimY() > b3Raw:getDimZ() + 10 * GEO.EPS_SMALL and b3Raw:getDimZ() < dMaxDepth - 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) -- dati geometrici del taglio local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) @@ -39,31 +57,16 @@ function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- determino se più tagli con offset local nCuts = ceil( dOvmHead / BD.MAX_LEN_SCRAP) local dOffsL = dOvmHead / nCuts - -- 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' - EgtOutLog( sErr) - return false, sErr - end - -- recupero i dati dell'utensile - local dSawDiam = 400 - if EgtMdbSetCurrMachining( sCutting) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam - 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(), 0) + BD.CUT_EXTRA_MIN + dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN, BD.CUT_EXTRA) dAccStart = 0 else - dCutExtra = - ( b3Raw:getDimY() - BD.MAX_DIM_HTCUT - BD.CUT_EXTRA) + dCutExtra = - ( b3Raw:getDimY() - dMaxDepth - BD.CUT_EXTRA) local dSawRad = dSawDiam / 2 - local dKL = dSawRad - ( BD.MAX_DIM_HTCUT + BD.CUT_EXTRA) + b3Raw:getDimY() / 2 + BD.CUT_EXTRA_MIN + 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 diff --git a/LuaLibs/ProcessScarfJoint.lua b/LuaLibs/ProcessScarfJoint.lua index 71bd04e..e4504b1 100644 --- a/LuaLibs/ProcessScarfJoint.lua +++ b/LuaLibs/ProcessScarfJoint.lua @@ -1,4 +1,4 @@ --- ProcessScarfJoint.lua by Egaltech s.r.l. 2020/01/21 +-- ProcessScarfJoint.lua by Egaltech s.r.l. 2020/01/24 -- Gestione calcolo giunto Gerber per Travi -- Tabella per definizione modulo @@ -48,45 +48,80 @@ function ProcessScarfJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) EgtOutLog( sErr) return false, sErr end - -- verifico che ci siano almeno due facce (altrimenti non è da lavorare) + + -- verifico che ci siano almeno quattro facce (altrimenti non è da lavorare) local nFacetCnt = EgtSurfTmFacetCount( Proc.Id) - if nFacetCnt < 2 then - return true + if nFacetCnt < 3 then + local sErr = 'Not executed ' .. tostring( Proc.Id) .. ', number of faces not enough' + EgtOutLog( sErr) + return false, sErr end + -- dati delle facce local ptC = {} local vtN = {} for i = 1, nFacetCnt do ptC[i], vtN[i] = EgtSurfTmFacetCenter( Proc.Id, i-1, GDB_ID.ROOT) end - -- ordino le facce (1=esterna, 2=interna, 3=intermedia) - local vFaceOrd = { 0, 0, 0} - for i = 1, nFacetCnt do - if abs( vtN[i]:getY()) > 0.1 or abs( vtN[i]:getZ()) > 0.1 then - vFaceOrd[3] = i - break + + -- ordino le facce in base al loro numero e al parallelismo delle due facce principali + -- faccia 1: superficie tappo + -- faccia 2: superficie principale di fondo + -- faccia 3: superficie opposta alla faccia 1 + -- faccia 4: superficie principale superiore + -- faccia 5: superficie di testa + local vtRef + local vFaceOrd = { 0, 0, 0, 0, 0} + if nFacetCnt == 5 then -- se ho 5 facce controllo il parallelismo della faccia 2 e 4 + if not AreSameVectorApprox( vtN[2], vtN[4]) then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ', main faces are not parallel(fail btl import)' + EgtOutLog( sErr) + return false, sErr end - end - if vFaceOrd[3] == 0 then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing intermediate face' - EgtOutLog( sErr) - return false, sErr - end - for i = 1, nFacetCnt do - if i ~= vFaceOrd[3] then - local bTouch, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, i - 1, vFaceOrd[3] - 1, GDB_ID.ROOT) - if bTouch and dAng > 0 then - vFaceOrd[1] = i - elseif bTouch and dAng < 0 then - vFaceOrd[2] = i + -- carico gli id delle facce + for i = 1, nFacetCnt do + vFaceOrd[i] = i + end + -- vettore di riferimento per le facce ortogonali all'asse trave + vtRef = Vector3d( 0, vtN[vFaceOrd[4]]:getY(), vtN[vFaceOrd[4]]:getZ()) + elseif nFacetCnt == 4 then -- se ho 4 facce + if AreSameVectorApprox( vtN[1], vtN[3]) then -- sono nel caso in cui manca la faccia 1 + for i = 1, nFacetCnt do + vFaceOrd[i+1] = i end + elseif AreSameVectorApprox( vtN[2], vtN[4]) then -- sono nel caso in cui manca la faccia 5 + for i = 1, nFacetCnt do + vFaceOrd[i] = i + end + else -- altrimenti ho una condizione di facce non previsto e do errore + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ', crazy faces(4)' + EgtOutLog( sErr) + return false, sErr + end + -- vettore di riferimento per le facce ortogonali all'asse trave + vtRef = Vector3d( 0, vtN[vFaceOrd[4]]:getY(), vtN[vFaceOrd[4]]:getZ()) + elseif nFacetCnt == 3 then -- se ho 3 facce + if AreSameVectorApprox( vtN[1], vtN[3]) then -- sono nel caso in cui manca la faccia 1 + for i = 1, nFacetCnt do + vFaceOrd[i+1] = i + end + -- vettore di riferimento per le facce ortogonali all'asse trave + vtRef = Vector3d( 0, vtN[vFaceOrd[4]]:getY(), vtN[vFaceOrd[4]]:getZ()) + else + for i = 1, nFacetCnt do + vFaceOrd[i] = i + end + -- vettore di riferimento per le facce ortogonali all'asse trave + vtRef = Vector3d( 0, vtN[vFaceOrd[2]]:getY(), vtN[vFaceOrd[2]]:getZ()) end end + -- determino se di testa o di coda - local bHead = ( vtN[vFaceOrd[2]]:getX() > 0) - -- vettore di riferimento per le facce ortogonali all'asse trave - local vtRef = Vector3d( 0, vtN[vFaceOrd[3]]:getY(), vtN[vFaceOrd[3]]:getZ()) + local bHead = ( vtN[1]:getX() > 0) + + -- normalizzo vettore di riferimento per le facce ortogonali all'asse trave vtRef:normalize() + -- recupero la lavorazione local sCutting = ML.FindCutting( 'HeadSide') if not sCutting then @@ -102,91 +137,225 @@ function ProcessScarfJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam end end - -- taglio sulla faccia esterna - if vFaceOrd[1] ~= 0 then - -- in generale va fatto - local bCut = true - -- se di testa e coincide con inizio grezzo, non va fatto - if bHead and AreSameVectorApprox( vtN[vFaceOrd[1]], X_AX()) and abs( ptC[vFaceOrd[1]]:getX() - b3Raw:getMax():getX() + dOvmHead) < 10 * GEO.EPS_SMALL then - bCut = false - end - -- se di coda e coincide con taglio di separazione, non va fatto - if not bHead and AreSameVectorApprox( vtN[vFaceOrd[1]], - X_AX()) and abs( ptC[vFaceOrd[1]]:getX() - b3Raw:getMin():getX()) < BD.OVM_MID + 10 * GEO.EPS_SMALL then - bCut = false - end - -- se va fatto, inserisco la lavorazione - if bCut then - local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtRef) - local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, nil, b3Raw) - if not bOk then return bOk, sNameOrErr end - end + + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' + EgtOutLog( sErr) + return false, sErr end - -- se esistono faccia interna ed intermedia, verifico se richiedono taglio a cubetti - local vCuts = {} - if vFaceOrd[2] ~= 0 and vFaceOrd[3] ~= 0 then - vCuts = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC[vFaceOrd[3]], vtN[vFaceOrd[3]], false, ptC[vFaceOrd[2]], vtN[vFaceOrd[2]]) + + -- creo superfici partendo da punto e versore delle facce 4 (inclinata) e 1 (tappo) + local nFace1 + local nFace4 + local nGoodFace1 + local nGoodFace4 + if vtN[vFaceOrd[4]] then + nFace4 = EgtSurfTmPlaneInBBox( nAddGrpId, ptC[vFaceOrd[4]], vtN[vFaceOrd[4]], b3Solid, GDB_ID.ROOT) end - if #vCuts > 0 then - -- recupero gruppo per geometria addizionale - local nAddGrpId = BL.GetAddGroup( nPartId) - if not nAddGrpId then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' + if vtN[vFaceOrd[1]] then + nFace1 = EgtSurfTmPlaneInBBox( nAddGrpId, ptC[vFaceOrd[1]], vtN[vFaceOrd[1]], b3Solid, GDB_ID.ROOT) + end + if nFace4 and nFace1 then + -- taglio la superficie di tappo e quella inclinata per capire se per il taglio a cubetti si devono considerare una o due superfici + local bOk = EgtCutSurfTmPlane( nFace1, ptC[vFaceOrd[4]], -vtN[vFaceOrd[4]], false, GDB_ID.ROOT) + bOk = bOk and EgtCutSurfTmPlane( nFace4, ptC[vFaceOrd[1]], -vtN[vFaceOrd[1]], false, GDB_ID.ROOT) + + if not bOk then + local sErr = 'Error on cut surfaces of ' .. tostring( Proc.Id) .. ' cut not good' EgtOutLog( sErr) return false, sErr end + + -- se esistono faccia interna ed intermedia, verifico se richiedono taglio a cubetti + nGoodFace1 = EgtSurfTmFacetCount( nFace1) + nGoodFace4 = EgtSurfTmFacetCount( nFace4) + elseif nFace4 then + nGoodFace4 = EgtSurfTmFacetCount( nFace4) + elseif nFace1 then + nGoodFace1 = EgtSurfTmFacetCount( nFace1) + end + + local vCuts = {} + if nGoodFace1 and nGoodFace4 and nGoodFace1 > 0 and nGoodFace4 > 0 then + -- lavoro solo la faccia inclinata perché la faccia tappo completa la lavoro successivamente + -- questo evita di lavorare due volte la faccia tappo + vCuts = DC.GetDice( nAddGrpId, b3Solid, ptC[vFaceOrd[4]], vtN[vFaceOrd[4]], false, ptC[vFaceOrd[1]], vtN[vFaceOrd[1]]) + elseif nGoodFace4 and nGoodFace4 > 0 then + vCuts = DC.GetDice( nAddGrpId, b3Solid, ptC[vFaceOrd[4]], vtN[vFaceOrd[4]], true) + end + + if #vCuts > 0 then -- sistemo posizione nel DB e nome for i = 1, #vCuts do for j = 1, #vCuts[i] do - EgtRelocateGlob( vCuts[i][j], nAddGrpId) EgtSetName( vCuts[i][j], 'AddCut_' .. tostring( Proc.Id)) EgtSetInfo( vCuts[i][j], 'TASKID', Proc.TaskId) end end - -- calcolo secondo riferimento per facce inclinate - local vtRef2 = Vector3d( vtN[vFaceOrd[2]]) + -- calcolo secondo riferimento per testa o coda + local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) -- eseguo for i = 1, #vCuts do - local nOrthoOpposite +-- local nOrthoOpposite + local vtOrthoO if i % 2 == 1 then - nOrthoOpposite = BL.GetNearestOrthoOpposite( vtRef) + vtOrthoO = Vector3d( vtRef) else - nOrthoOpposite = BL.GetNearestOrthoOpposite( vtRef2) + if #vCuts[i-1] > 0 then + vtOrthoO = Vector3d( EgtIf( vtRef2, vtRef2, vtRef)) + else + local vtO + for j = 1, #vCuts[i-1] do + _, vtO = EgtSurfTmFacetCenter( vCuts[i-1][j], 0, GDB_ID.ROOT) + break + end + if vtO then + vtOrthoO = Vector3d( vtO) + else + vtOrthoO = Y_AX() + end + end end -- lavoro la faccia for j = 1, #vCuts[i] do - local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sErr end end end + -- lavoro la faccia interna in ogni caso + if vFaceOrd[1] ~= 0 then + -- inserisco la lavorazione + local vtOrthoO = Vector3d( vtRef) + local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then return bOk, sNameOrErr end + end + -- lavoro la faccia opposta (definita dal parametro P11) + if vFaceOrd[3] ~= 0 then + -- inserisco la lavorazione + local vtOrthoO = Vector3d( vtRef) + local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then return bOk, sNameOrErr end + end else -- taglio sulla faccia interna local bIntCut = false - if vFaceOrd[2] ~= 0 then + if vFaceOrd[1] ~= 0 then -- inserisco la lavorazione - local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtRef) - local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[2] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + local vtOrthoO = Vector3d( vtRef) + local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sNameOrErr end if #sNameOrErr > 0 then bIntCut = true end end - -- taglio sulla faccia intermedia - if vFaceOrd[3] ~= 0 then - -- inserisco la lavorazione - local vtRef2 = vtN[vFaceOrd[2]] + -- taglio sulla faccia intermedia (inclinata) + if vFaceOrd[4] ~= 0 then + -- calcolo secondo testa o coda + local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) + -- se non ho il taglio sulla faccia interna if not bIntCut then - local frHV, DimH, DimV = BL.GetFaceHvRefDim( Proc.Id, vFaceOrd[2] - 1) - if DimV <= DimH then - vtRef2 = Vector3d( frHV:getVersY()) - else + local frHV, DimH, DimV = BL.GetFaceHvRefDim( Proc.Id, vFaceOrd[4] - 1) + if DimV > DimH then vtRef2 = Vector3d( frHV:getVersX()) end end - local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtRef2) - local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + -- inserisco la lavorazione + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[4] - 1, sCutting, dSawDiam, vtRef2, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sErr end end + -- lavoro la faccia opposta (definita dal parametro P11) + if vFaceOrd[3] ~= 0 then + -- inserisco la lavorazione + local vtOrthoO = Vector3d( vtRef) + local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then return bOk, sNameOrErr end + end end + + -- taglio sulla faccia esterna + if vFaceOrd[5] ~= 0 then + -- in generale va fatto + local bCut = true + -- se di testa e coincide con inizio grezzo, non va fatto + if bHead and AreSameVectorApprox( vtN[vFaceOrd[5]], X_AX()) and abs( ptC[vFaceOrd[5]]:getX() - b3Raw:getMax():getX() + dOvmHead) < 10 * GEO.EPS_SMALL then + bCut = false + end + -- se di coda e coincide con taglio di separazione, non va fatto + if not bHead and AreSameVectorApprox( vtN[vFaceOrd[5]], - X_AX()) and abs( ptC[vFaceOrd[5]]:getX() - b3Raw:getMin():getX()) < BD.OVM_MID + 10 * GEO.EPS_SMALL then + bCut = false + end + -- se va fatto, inserisco la lavorazione + if bCut then + local vtOrthoO + local frHV, DimH, DimV = BL.GetFaceHvRefDim( Proc.Id, vFaceOrd[5] - 1) + if DimV > DimH then + vtOrthoO = Vector3d( frHV:getVersX()) + else + vtOrthoO = Vector3d( vtRef) + end + local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[5] - 1, sCutting, dSawDiam, vtOrthoO, nil, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then return bOk, sNameOrErr end + end + end + + -- lavoro superficie principale di fondo con una svuotatura + if vFaceOrd[2] ~= 0 then + + local frMor, dL, dW = EgtSurfTmFacetMinAreaRectangle( Proc.Id, vFaceOrd[2]-1, GDB_ID.ROOT) + -- calcolo la dimensione da passare + local dDiamMax = EgtIf( abs( frMor:getVersX():getY()) < abs( frMor:getVersY():getY()), dL, dW) + -- determino la distanza tra le due facce inclinate + local dDistFaces + if vFaceOrd[4] ~= 0 then + dDistFaces = abs((ptC[vFaceOrd[2]]-ptC[vFaceOrd[4]])*vtN[vFaceOrd[2]]) + end + -- recupero la lavorazione. considerando l dimensione del lato e l'affondamento + local sPocketing + if dDistFaces then + sPocketing = ML.FindPocketing( 'OpenPocket', dDiamMax, dDistFaces) + else + sPocketing = ML.FindPocketing( 'OpenPocket', dDiamMax) + end + + if not sPocketing then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + local dMillDiam = 20 + local dMaxDepth = 0 + if EgtMdbSetCurrMachining( sPocketing) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam + dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth) + end + end + -- inserisco la lavorazione di svuotatura + local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchFId = EgtAddMachining( sName, sPocketing) + if not nMchFId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sPocketing + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ Proc.Id, vFaceOrd[2]-1}}) + -- imposto elevazione + if dDistFaces then + EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dDistFaces, 1) .. ';') + end + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + end + -- aggiornamento ingombro di testa o coda if Proc.Head then local dHCI = 0 diff --git a/LuaLibs/ProcessSimpleScarf.lua b/LuaLibs/ProcessSimpleScarf.lua index b0ae7a3..4a45266 100644 --- a/LuaLibs/ProcessSimpleScarf.lua +++ b/LuaLibs/ProcessSimpleScarf.lua @@ -51,7 +51,9 @@ function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- verifico che ci siano almeno due facce (altrimenti non è da lavorare) local nFacetCnt = EgtSurfTmFacetCount( Proc.Id) if nFacetCnt < 2 then - return true + local sErr = 'Not executed ' .. tostring( Proc.Id) .. ' number of faces not enough' + EgtOutLog( sErr) + return false, sErr end -- dati delle facce local ptC = {} @@ -83,7 +85,12 @@ function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end end -- determino se di testa o di coda - local bHead = ( vtN[vFaceOrd[2]]:getX() > 0) + local bHead + if vtN[vFaceOrd[2]] then + bHead = ( vtN[vFaceOrd[2]]:getX() > 0) + else + bHead = ( vtN[vFaceOrd[1]]:getX() > 0) + end -- vettore di riferimento per le facce ortogonali all'asse trave local vtRef = Vector3d( 0, vtN[vFaceOrd[3]]:getY(), vtN[vFaceOrd[3]]:getZ()) vtRef:normalize() @@ -116,8 +123,8 @@ function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- se va fatto, inserisco la lavorazione if bCut then - local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtRef) - local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, nil, b3Raw) + local vtOrthoO = Vector3d( vtRef) + local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, vtOrthoO, nil, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sNameOrErr end end end @@ -125,6 +132,8 @@ function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local vCuts = {} if vFaceOrd[2] ~= 0 and vFaceOrd[3] ~= 0 then vCuts = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC[vFaceOrd[3]], vtN[vFaceOrd[3]], false, ptC[vFaceOrd[2]], vtN[vFaceOrd[2]]) + elseif vFaceOrd[3] ~= 0 then + vCuts = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC[vFaceOrd[3]], vtN[vFaceOrd[3]], true) end if #vCuts > 0 then -- recupero gruppo per geometria addizionale @@ -142,19 +151,32 @@ function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) EgtSetInfo( vCuts[i][j], 'TASKID', Proc.TaskId) end end - -- calcolo secondo riferimento per facce inclinate - local vtRef2 = Vector3d( vtN[vFaceOrd[2]]) + -- calcolo secondo riferimento per testa o coda + local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) -- eseguo for i = 1, #vCuts do - local nOrthoOpposite + local vtOrthoO if i % 2 == 1 then - nOrthoOpposite = BL.GetNearestOrthoOpposite( vtRef) + vtOrthoO = Vector3d( vtRef) else - nOrthoOpposite = BL.GetNearestOrthoOpposite( vtRef2) + if #vCuts[i-1] > 0 then + vtOrthoO = Vector3d( EgtIf( vtRef2, vtRef2, vtRef)) + else + local vtO + for j = 1, #vCuts[i-1] do + _, vtO = EgtSurfTmFacetCenter( vCuts[i-1][j], 0, GDB_ID.ROOT) + break + end + if vtO then + vtOrthoO = Vector3d( vtO) + else + vtOrthoO = Y_AX() + end + end end -- lavoro la faccia for j = 1, #vCuts[i] do - local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sErr end @@ -172,18 +194,17 @@ function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- taglio sulla faccia intermedia if vFaceOrd[3] ~= 0 then - -- inserisco la lavorazione - local vtRef2 = vtN[vFaceOrd[2]] + -- calcolo secondo testa o coda + local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) + -- se non ho il taglio sulla faccia interna if not bIntCut then - local frHV, DimH, DimV = BL.GetFaceHvRefDim( Proc.Id, vFaceOrd[2] - 1) - if DimV <= DimH then - vtRef2 = Vector3d( frHV:getVersY()) - else + local frHV, DimH, DimV = BL.GetFaceHvRefDim( Proc.Id, vFaceOrd[3] - 1) + if DimV > DimH then vtRef2 = Vector3d( frHV:getVersX()) end end - local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtRef2) - local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + -- inserisco la lavorazione + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, vtRef2, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sErr end end end diff --git a/LuaLibs/ProcessSplit.lua b/LuaLibs/ProcessSplit.lua index 1ac82e9..7fd689a 100644 --- a/LuaLibs/ProcessSplit.lua +++ b/LuaLibs/ProcessSplit.lua @@ -1,4 +1,4 @@ --- ProcessSplit.lua by Egaltech s.r.l. 2019/06/29 +-- ProcessSplit.lua by Egaltech s.r.l. 2020/01/24 -- Gestione calcolo tagli di separazione per Travi -- Tabella per definizione modulo @@ -25,8 +25,26 @@ end function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId) -- ingombro del grezzo local b3Raw = EgtGetRawPartBBox( nRawId) - local bHorizCut = ( b3Raw:getDimY() > b3Raw:getDimZ() + 10 * GEO.EPS_SMALL and b3Raw:getDimZ() < BD.MAX_DIM_HTCUT) - local dDimYRef = EgtIf( b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL, BD.MAX_DIM_HTCUT, BD.MAX_DIM_HTCUT_HBEAM) + -- recupero la lavorazione + local sCutting = ML.FindCutting( EgtIf( bSplit, 'SplitSide', 'TailSide')) + if not sCutting then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library' + EgtOutLog( sErr) + return false, true, sErr + end + -- recupero i dati dell'utensile + local dSawDiam = 400 + local dMaxDepth = 50 + if EgtMdbSetCurrMachining( sCutting) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end + -- caratteristiche taglio + local bHorizCut = ( b3Raw:getDimY() > b3Raw:getDimZ() + 10 * GEO.EPS_SMALL and b3Raw:getDimZ() < dMaxDepth - 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) -- dati geometrici del taglio local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) @@ -48,31 +66,16 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId) dOffsL = dLenEndRaw / nCuts end end - -- recupero la lavorazione - local sCutting = ML.FindCutting( EgtIf( bSplit, 'SplitSide', 'TailSide')) - if not sCutting then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library' - EgtOutLog( sErr) - return false, true, sErr - end - -- recupero i dati dell'utensile - local dSawDiam = 400 - if EgtMdbSetCurrMachining( sCutting) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam - 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(), 0) + BD.CUT_EXTRA_MIN + dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN, BD.CUT_EXTRA) dAccStart = 0 else - dCutExtra = - ( b3Raw:getDimY() - BD.MAX_DIM_HTCUT - BD.CUT_EXTRA) + dCutExtra = - ( b3Raw:getDimY() - dMaxDepth - BD.CUT_EXTRA) local dSawRad = dSawDiam / 2 - local dKL = dSawRad - ( BD.MAX_DIM_HTCUT + BD.CUT_EXTRA) + b3Raw:getDimY() / 2 + BD.CUT_EXTRA_MIN + 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