diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 85a0666..674a259 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,4 +1,4 @@ --- BeamExec.lua by Egaltech s.r.l. 2022/06/25 +-- BeamExec.lua by Egaltech s.r.l. 2022/07/27 -- Libreria esecuzione lavorazioni per Travi -- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- 2019/09/04 Corretto controllo feature di testa e coda con sovramateriale di testa elevato. @@ -86,7 +86,7 @@ _G.package.loaded.ProcessTyroleanDovetail = nil _G.package.loaded.ProcessDovetail = nil _G.package.loaded.ProcessFreeContour = nil _G.package.loaded.ProcessDecor = nil -local BM = require( 'MachiningLib') +local ML = require( 'MachiningLib') local BL = require( 'BeamLib') local DC = require( 'DiceCut') local Fbs = require( 'FacesBySaw') @@ -387,6 +387,23 @@ end ------------------------------------------------------------------------------------------------------------- -- *** Inserimento delle travi nel grezzo *** +------------------------------------------------------------------------------------------------------------- +local function VerifyBigSectionCut( dRawW, dRawH) + local sCutting = ML.FindCutting( 'TailSide') + local dMaxDepth = 50 + if EgtMdbSetCurrMachining( sCutting or '') then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid or '') or '') then + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end + local dMaxVertDepth = dMaxDepth - ( BD.DECR_VERT_CUT or 0) + local dDimYRef = EgtIf( dRawH < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL, dMaxDepth, abs( BD.MAX_DIM_HTCUT_HBEAM)) + local bBigSectionCut = ( dRawW > 2 * dDimYRef - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) and + ( dRawH > EgtIf( BD.DOWN_HEAD or BD.TURN, 2, 1) * dMaxVertDepth - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) + return bBigSectionCut +end + ------------------------------------------------------------------------------------------------------------- function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam, bMachGroupOk) @@ -426,11 +443,8 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam, bMachGroup local DeltaS = dOvmHead local DeltaSMin = 0 local DeltaE = BD.OVM_MID - -- controllo sezione larga e alta per considerare taglio con sega - local bBigSectionCut = false - if BD.MAX_DIM_HTCUT and BD.CUT_EXTRA_MIN and ( dRawW > 2 * BD.MAX_DIM_HTCUT - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) and ( dRawH > 2 * BD.MAX_DIM_HTCUT - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) then - bBigSectionCut = true - end + -- controllo sezione larga e alta per considerare taglio con sega a catena + local bBigSectionCut = VerifyBigSectionCut( dRawW, dRawH) for i = 1, #vBeam do -- assegno identificativo pezzo local Pz = vBeam[i].Id diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 6105dc8..4163a5e 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -14,6 +14,8 @@ -- 2022/05/18 Correzioni e migliorie a PutStartNearestToEdge. -- 2022/06/25 Rese globali le funzioni GetChainSawBlockedAxis e GetChainSawInitAngs prima in ProcessLapJpoint. -- 2022/07/12 A GetFaceHvRefDim aggiunta possibilità di confronto e limitazione dimensioni con grezzo/pezzo (conta solo la sezione). +-- 2022/07/26 Aggiunta la funzione FindFaceBestOrientedAsAxis, precedentemente in ProcessLapJoint +-- 2022/07/26 Alla funzione FindFaceBestOrientedAsAxis aggiunta la possibilità di escludere una faccia dalla ricerca -- Tabella per definizione modulo local BeamLib = {} @@ -369,17 +371,17 @@ end --------------------------------------------------------------------- function BeamLib.GetVersRef( nOrthoOpposite) - if nOrthoOpposite == MCH_MILL_FU.ORTHO_LEFT then + if nOrthoOpposite == MCH_MILL_FU.ORTHO_LEFT or nOrthoOpposite == MCH_MILL_FU.ORTUP_LEFT or nOrthoOpposite == MCH_MILL_FU.PARAL_LEFT then return X_AX() - elseif nOrthoOpposite == MCH_MILL_FU.ORTHO_RIGHT then + elseif nOrthoOpposite == MCH_MILL_FU.ORTHO_RIGHT or nOrthoOpposite == MCH_MILL_FU.ORTUP_RIGHT or nOrthoOpposite == MCH_MILL_FU.PARAL_RIGHT then return -X_AX() - elseif nOrthoOpposite == MCH_MILL_FU.ORTHO_FRONT then + elseif nOrthoOpposite == MCH_MILL_FU.ORTHO_FRONT or nOrthoOpposite == MCH_MILL_FU.ORTUP_FRONT or nOrthoOpposite == MCH_MILL_FU.PARAL_FRONT then return Y_AX() - elseif nOrthoOpposite == MCH_MILL_FU.ORTHO_BACK then + elseif nOrthoOpposite == MCH_MILL_FU.ORTHO_BACK or nOrthoOpposite == MCH_MILL_FU.ORTUP_BACK or nOrthoOpposite == MCH_MILL_FU.PARAL_BACK then return -Y_AX() - elseif nOrthoOpposite == MCH_MILL_FU.ORTHO_DOWN then + elseif nOrthoOpposite == MCH_MILL_FU.ORTHO_DOWN or nOrthoOpposite == MCH_MILL_FU.ORTUP_DOWN or nOrthoOpposite == MCH_MILL_FU.PARAL_DOWN then return Z_AX() - elseif nOrthoOpposite == MCH_MILL_FU.ORTHO_TOP then + elseif nOrthoOpposite == MCH_MILL_FU.ORTHO_TOP or nOrthoOpposite == MCH_MILL_FU.ORTUP_TOP or nOrthoOpposite == MCH_MILL_FU.PARAL_TOP then return -Z_AX() end return nil @@ -794,5 +796,23 @@ function BeamLib.GetChainSawInitAngs( vtN, vtO, nInd) end end +--------------------------------------------------------------------- +-- Trova l'Ind (0 based) della faccia meglio orientata come l'asse vtAx. Restituisce anche vtN e ptC della faccia stessa. La faccia di indice (0 based) fctExclude non viene considerata nella ricerca. +function BeamLib.FindFaceBestOrientedAsAxis( Proc, vtAx, fctExclude) + local nFaceIndMax = 0 + local dMaxComp = 0 + fctExclude = fctExclude or -1 + for i = 1, Proc.Fct do + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT) + local dComp = abs( vtN * vtAx) + if dComp > dMaxComp and i ~= fctExclude + 1 then + nFaceIndMax = i -1 + dMaxComp = dComp + end + end + local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFaceIndMax, GDB_ID.ROOT) + return nFaceIndMax, ptC, vtN +end + ------------------------------------------------------------------------------------------------------------- return BeamLib diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 555e551..75294e5 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -1,6 +1,7 @@ -- MachiningLib.lua by Egaltech s.r.l. 2022/05/07 -- Libreria ricerca lavorazioni per Travi -- 2022/05/07 ES Profonde modifiche per scelta ottimale lavorazioni in macchine con più teste. +-- 2022/07/27 Aggiunta la gestione del tipo di foratura "AngleDrill" per fori molto inclinati -- Tabella per definizione modulo local MachiningLib = {} @@ -188,7 +189,7 @@ end --------------------------------------------------------------------- function VerifyTool( MachiningType, sType, Params, bH2) if MachiningType == MCH_MY.DRILLING then - if StartsWith( sType, 'Drill') then + if StartsWith( sType, 'Drill') or StartsWith( sType, 'AngleDrill') then return VerifyDrill( Params.Diam, Params.Depth, bH2) elseif StartsWith( sType, 'Pocket') then return VerifyDrillPocket( Params.Diam, Params.Depth, bH2) @@ -225,7 +226,7 @@ end function ReturnParams( MachiningType, MachiningName, sType, ToolParams) if MachiningType == MCH_MY.DRILLING then local _, sOrigType = EndsWith( sType, '_H2') - return MachiningName, sType, EgtIf( sOrigType == 'Drill', ToolParams.TMaxMat, ToolParams.TMaxDepth), ToolParams.MaxToolLength, ToolParams.ToolDiam, ToolParams.DiamTh, ToolParams.FreeLen + return MachiningName, sType, EgtIf( sOrigType == 'Drill' or sOrigType == 'AngleDrill' , ToolParams.TMaxMat, ToolParams.TMaxDepth), ToolParams.MaxToolLength, ToolParams.ToolDiam, ToolParams.DiamTh, ToolParams.FreeLen elseif MachiningType == MCH_MY.SAWING then return MachiningName, ToolParams.H2 elseif MachiningType == MCH_MY.MILLING then @@ -377,6 +378,14 @@ function MachiningLib.FindDrilling( dDiam, dDepth, bTopHead, bDownHead) end end +--------------------------------------------------------------------- +function MachiningLib.FindAngleDrilling( dDiam, dDepth, bTopHead, bDownHead) + local MachiningName, MachiningType, Param1, Param2, Param3, Param4, Param5 = FindMachining( MCH_MY.DRILLING, 'AngleDrill', { Diam = dDiam, Depth = dDepth}, bTopHead, bDownHead) + if MachiningName and MachiningName ~= '' then + return MachiningName, MachiningType, Param1, Param2, Param3, Param4, Param5 + end +end + --------------------------------------------------------------------- function MachiningLib.FindMilling( sType, dDepth, sTuuidMstr, dMaxDiam, dMaxTotLen, bTopHead, bDownHead) return FindMachining( MCH_MY.MILLING, sType, { Depth = dDepth, TuuidMstr = sTuuidMstr, MaxDiam = dMaxDiam, MaxTotLen = dMaxTotLen}, bTopHead, bDownHead) diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index e73cd59..03206cf 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -11,6 +11,7 @@ -- 2022/07/01 Aggiunta gestione allungamento percorsi fori in caso di materiale già rimosso da lavorazioni precedenti -- 2022/07/07 Aggiunta la gestione delle forature migliorate in presenza di feature testa/coda che tagliano tutta la sezione; gli Id delle feature sono nelle proprietà MachineAfterHeadCutId e MachineAfterTailCutId. -- 2022/07/12 Aggiunto un valore minimo (10) per la distanza di sicurezza. +-- 2022/07/27 Aggiunta la gestione del tipo di foratura "AngleDrill" per fori molto inclinati -- Tabella per definizione modulo local ProcessDrill = {} @@ -171,6 +172,8 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) + -- default per costanti + BD.DRILL_VX_MAX_ANGLEDRILL = ( BD.DRILL_VX_MAX_ANGLEDRILL or 0.921) -- ingombro del pezzo local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) if not b3Solid then @@ -323,6 +326,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) -- se foro non su testa o coda e inclinato local bInMid = false local bInvertFcse = ( bToInvert and Proc.Flg ~= -2) + local bTryAngleDrill = false if ( not bInvertFcse and Proc.Fcs ~= 5 and Proc.Fcs ~= 6) or ( bInvertFcse and Proc.Fce ~= 5 and Proc.Fce ~= 6) then bInMid = true local CosB = abs( vtExtr:getX()) @@ -330,7 +334,12 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) local TgA = CosB / sqrt( 1 - CosB * CosB) dSubL1 = ( dDiamTh / 2 + dDeltaRad + 2) * TgA else + -- settando dMaxDepth a 0 la lavorazione verrà disattivata dMaxDepth = 0 + -- se il foro è molto inclinato ma entro un certo limite, si cercheranno le forature speciali AngleDrill + if CosB < BD.DRILL_VX_MAX_ANGLEDRILL then + bTryAngleDrill = true + end end end -- se foro davanti o dietro e inclinato @@ -343,7 +352,12 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) local TgA = CosB / sqrt( 1 - CosB * CosB) dSubL2 = ( dDiamTh / 2 + dDeltaRad + 2) * TgA else + -- settando dMaxDepth a 0 la lavorazione verrà disattivata dMaxDepth = 0 + -- se il foro è molto inclinato ma entro un certo limite, si cercheranno le forature speciali AngleDrill + if CosB < BD.DRILL_VX_MAX_ANGLEDRILL then + bTryAngleDrill = true + end end end -- se foro sopra o sotto e inclinato @@ -356,13 +370,27 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) local TgA = CosB / sqrt( 1 - CosB * CosB) dSubL3 = ( dDiamTh / 2 + dDeltaRad + 2) * TgA else + -- settando dMaxDepth a 0 la lavorazione verrà disattivata dMaxDepth = 0 + -- se il foro è molto inclinato ma entro un certo limite, si cercheranno le forature speciali AngleDrill + if CosB < BD.DRILL_VX_MAX_ANGLEDRILL then + bTryAngleDrill = true + end end end local dSubL = max( dSubL1, dSubL2, dSubL3) if dMaxDepth > 0 then dMaxDepth = min( dMaxDepth, dToolFreeLen - dSubL) end + if bTryAngleDrill then + -- cerco le forature speciali AngleDrill + local sDrilling3, sType3, dMaxDepth3 = ML.FindAngleDrilling( dDiam, dCheckDepth, bDrillUp, bDrillDown) + if sDrilling3 then + sDrilling = sDrilling3 + sType = sType3 + dMaxDepth = dMaxDepth3 + end + end -- inserisco la lavorazione local sName = 'Drill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchId = EgtAddMachining( sName, sDrilling) @@ -374,7 +402,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) -- eventuale inversione - if sType == 'Drill' or sType == 'Drill_H2' then + if sType == 'Drill' or sType == 'Drill_H2' or sType == 'AngleDrill' then EgtSetMachiningParam( MCH_MP.INVERT, bToInvert) else EgtSetMachiningParam( MCH_MP.TOOLINVERT, bToInvert) @@ -458,7 +486,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) -- aggiungo alle note massima elevazione (coincide con affondamento) sUserNotes = sUserNotes .. 'MaxElev=' .. EgtNumToString( dMaxElev, 1) .. ';' -- se foro passante, aggiungo questa qualifica alle note - if ( sType == 'Drill' or sType == 'Drill_H2') and bOpen then + if ( sType == 'Drill' or sType == 'Drill_H2' or sType == 'AngleDrill') and bOpen then sUserNotes = sUserNotes .. 'Open=1;' end -- se lavorazione in doppio @@ -471,7 +499,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) -- eseguo local bOk = ML.ApplyMachining( true, false) if not bOk and BD.DOWN_HEAD then - if sType == 'Drill' or sType == 'Drill_H2' then + if sType == 'Drill' or sType == 'Drill_H2' or sType == 'AngleDrill' then EgtSetMachiningParam( MCH_MP.INVERT, true) else EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) diff --git a/LuaLibs/ProcessHeadCut.lua b/LuaLibs/ProcessHeadCut.lua index 4fd7316..966c6ed 100644 --- a/LuaLibs/ProcessHeadCut.lua +++ b/LuaLibs/ProcessHeadCut.lua @@ -1,4 +1,4 @@ --- ProcessSplit.lua by Egaltech s.r.l. 2022/06/07 +-- ProcessSplit.lua by Egaltech s.r.l. 2022/07/25 -- Gestione calcolo tagli di testa per Travi -- 2022/05/31 Aggiunta gestione sezioni alte e larghe con taglio di tipo diceCut. -- 2022/06/10 Per sezioni alte e larghe aggiunta gestione finitura in base a sovramateriale e a parametro Q05 dell' eventuale lavorazione sostituita. @@ -174,8 +174,9 @@ function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bNeedHCut end local dMaxVertDepth = dMaxDepth - ( BD.DECR_VERT_CUT or 0) -- caratteristiche taglio - local dDimYRef = EgtIf( b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL, dMaxDepth, BD.MAX_DIM_HTCUT_HBEAM) - local bBigSectionCut = ( b3Raw:getDimY() > 2 * dDimYRef - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) and ( b3Raw:getDimZ() > 2 * dDimYRef - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) + local dDimYRef = EgtIf( b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL, dMaxDepth, abs( BD.MAX_DIM_HTCUT_HBEAM)) + local bBigSectionCut = ( b3Raw:getDimY() > 2 * dDimYRef - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) and + ( b3Raw:getDimZ() > EgtIf( BD.DOWN_HEAD or BD.TURN, 2, 1) * dMaxVertDepth - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) local bHorizCut = ( not bBigSectionCut and ( b3Raw:getDimY() > b3Raw:getDimZ() + 10 * GEO.EPS_SMALL or BD.TURN) and b3Raw:getDimZ() < dMaxVertDepth - BD.CUT_EXTRA) local bDoubleHorizCut = ( ( BD.DOWN_HEAD or BD.TURN) and not bBigSectionCut and not bHorizCut and b3Raw:getDimY() > 2 * dDimYRef - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) local bDoubleCut = ( not bBigSectionCut and not bHorizCut and not bDoubleHorizCut and b3Raw:getDimY() > dDimYRef - BD.CUT_EXTRA + 10 * GEO.EPS_SMALL) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 6294f4c..aec4484 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -4354,23 +4354,6 @@ local function ManageAntiSplintByMill( Proc, nPhase, nRawId, nPartId, b3Raw, return true, sMyWarn end ---------------------------------------------------------------------- --- Trova l'Ind (0 based) della faccia meglio orientata come l'asse vtAx. Restituisce anche vtN e ptC della faccia stessa. -local function FindFaceBestOrientedAsAxis( Proc, vtAx) - local nFaceIndMax = 0 - local dMaxComp = 0 ; - for i = 1, Proc.Fct do - local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT) - local dComp = abs( vtN * vtAx) - if dComp > dMaxComp then - nFaceIndMax = i -1 - dMaxComp = dComp - end - end - local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFaceIndMax, GDB_ID.ROOT) - return nFaceIndMax, ptC, vtN -end - --------------------------------------------------------------------- local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePart, bPrevBhSideMill, bAllWithEndCap) if not BD.MAXDIAM_POCK_CORNER then @@ -5154,7 +5137,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa local bOrthoFacesMaster = nil local bSetOpenBorders = nil -- trovo la faccia con normale più inclinata verso Y - local nFacApproxY, ptCFacApproxY, vtNFacApproxY = FindFaceBestOrientedAsAxis( Proc, Y_AX()) + local nFacApproxY, ptCFacApproxY, vtNFacApproxY = BL.FindFaceBestOrientedAsAxis( Proc, Y_AX()) -- se Q03 = 2 e -- 3 facce a L, oppure -- 3 facce non a L ma con una faccia favorevole a Y, oppure diff --git a/LuaLibs/ProcessMortise.lua b/LuaLibs/ProcessMortise.lua index e9e30b2..f539e6c 100644 --- a/LuaLibs/ProcessMortise.lua +++ b/LuaLibs/ProcessMortise.lua @@ -2,6 +2,7 @@ -- Gestione calcolo mortase per Travi -- 2021/07/20 Aggiunta gestione rinvio angolare su FAST. -- 2021/12/01 Se frontale aggiungo taglio con Grp e Proc di vero taglio (per aggiornare ingombro di testa /coda). +-- 2022/07/26 Aggiunta gestione del parametro P04=1 per la pulizia degli angoli con mortasatrice (sega a catena) specifica -- Tabella per definizione modulo local ProcessMortise = {} @@ -79,6 +80,106 @@ function ProcessMortise.GetCutPlane( Proc) end --------------------------------------------------------------------- +-- Aggiunge la lavorazione di pulizia angoli + local function AddCleanCornersMachining( nProcId, sMortising, nWorkFaceInd, vtN) + local sName = 'Mort_' .. ( EgtGetName( nProcId) or tostring( nProcId)) .. '_CleanCorners1' + local nMchFId = EgtAddMachining( sName, sMortising) + if not nMchFId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMortising + EgtOutLog( sErr) + return false, sErr + end + sName = EgtGetOperationName( nMchFId) + -- aggiungo geometria + EgtSetMachiningGeometry( {{ nProcId, nWorkFaceInd}}) + local nFaceUse = BL.GetNearestParalOpposite( vtN) + local vtOrtho = BL.GetVersRef( nFaceUse) + -- imposto angolo 3° asse rot + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetChainSawBlockedAxis( 1)) + EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( vtN, vtOrtho, 1)) + -- imposto uso del lato faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) + -- applico il parametro plunge, che setta la lavorazione per affondare solamente, senza lavorare tutto il contorno; 1: solo lato iniziale, 2: solo lato finale, 3: entrambi + sNotes = 'Plunge=3;' + EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) + if not ML.ApplyMachining( true, false) then + if EgtGetOutstrokeInfo() then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + -- impostazione alternativa angolo 3° asse rot + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetChainSawBlockedAxis( 2)) + EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( vtN, vtOrtho, 2)) + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + end + if EgtIsMachiningEmpty() then + _, sWarn = EgtGetMachMgrWarning( 0) + EgtSetOperationMode( nMchFId, false) + return false, sWarn + end + return true, sWarn + end + +--------------------------------------------------------------------- +-- Pulizia angoli nel caso sia settato il parametro P04=1 +local function CleanCorners( Proc, dMorH, vtN, bOpenBtm) + -- verifico se è attiva la pulizia + local bCleanCorners = ( EgtGetInfo( Proc.Id, 'P04', 'i') == 1 and Proc.Prc ~= 51) + -- cerco la lavorazione adatta + local sMortisingCleanCorners = ML.FindSawing( 'Mortising') + if bCleanCorners and sMortisingCleanCorners then + local dSawWidth = 50 + local dSawThick = 12 + local dMaxDepth = 200 + -- se non trova la lavorazione non faccio nulla + if not sMortisingCleanCorners then + local sWarn = 'Warning: mortising tool not found, square tenon finishing skipped' + EgtOutLog( sWarn) + return true, sWarn + else + -- recupero i dati dell'utensile + if EgtMdbSetCurrMachining( sMortisingCleanCorners) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dSawWidth = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawWidth + dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThick + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end + -- al momento se l'utensile non arriva salto la lavorazione + local dFullMorH = EgtIf( bOpenBtm, dMorH * 2, dMorH) + if dFullMorH > dMaxDepth + 10 * GEO.EPS_SMALL then + local sErr = 'Error in Mortise : elevation (' .. EgtNumToString( dFullMorH, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' + EgtOutLog( sErr) + return false, sErr + end + -- cerco le due facce migliori da lavorare + local nWorkFaceInd, _, _ = BL.FindFaceBestOrientedAsAxis( Proc, vtN ^ X_AX()) + local nWorkFaceInd2, _, _ = BL.FindFaceBestOrientedAsAxis( Proc, vtN ^ X_AX(), nWorkFaceInd) + -- lavoro la prima faccia + local bOk1, sErr = AddCleanCornersMachining( Proc.Id, sMortisingCleanCorners, nWorkFaceInd, vtN) + -- lavoro la seconda faccia + local bOk2, sErr2 = AddCleanCornersMachining( Proc.Id, sMortisingCleanCorners, nWorkFaceInd2, vtN) + if sErr2 then + if not sErr then sErr = '' end + if sErr ~= sErr2 then + sErr = EgtIf( #sErr > 0, sErr .. '\n' .. sErr2, sErr2) + end + end + if not bOk1 or not bOk2 then + return false, sErr + end + return true, sErr + end + end +end + + --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- ingombro del pezzo @@ -326,6 +427,12 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetOperationMode( nMchFId, false) return false, sErr end + -- verifico se necessaria la pulizia degli angoli ( tenone ad angoli non raggiati) e applico nel caso + local _, sWarn2 = CleanCorners( Proc, dMorH, vtN, bOpenBtm) + if sWarn2 then + if not sWarn then sWarn = '' end + sWarn = EgtIf( #sWarn > 0, sWarn .. '\n' .. sWarn2, sWarn2) + end -- Se non c'è il fondo e la lavorazione non ha lavorato tutta la superficie per limite altezza utensile -- inserisco una ulteriore lavorazione contraria if bOpenBtm and not bForceOneSide and nDepthMin and abs(nDepthMin) > 0 then diff --git a/LuaLibs/ProcessSplit.lua b/LuaLibs/ProcessSplit.lua index 75cf220..5683299 100644 --- a/LuaLibs/ProcessSplit.lua +++ b/LuaLibs/ProcessSplit.lua @@ -1,4 +1,4 @@ --- ProcessSplit.lua by Egaltech s.r.l. 2022/06/07 +-- ProcessSplit.lua by Egaltech s.r.l. 2022/07/26 -- Gestione calcolo tagli di separazione per Travi -- 2022/05/31 Aggiunta gestione sezioni alte e larghe con taglio con sega a catena seguito da rifinitura con lama (aggiunta funzione MakeSplitByChainSaw); gestione eventuale creazione nuova fase dall'interno della Make. -- 2022/06/10 Per sezioni alte e larghe aggiunta gestione finitura in base a sovramateriale e a parametro Q05 dell' eventuale lavorazione sostituita. @@ -148,7 +148,7 @@ end -- lavorazione con sega a catena per sezioni alte e larghe local function MakeSplitByChainSaw( nSurfId, nFaceUse, dDepth, sNotes, dOffs) -- Recupero i dati dell'utensile - local sSawing = ML.FindSawing('Sawing') + local sSawing = ML.FindSawing( 'Sawing') local dMaxMat = 0 local dSawCornerRad = 0 local dSawThick = 0 @@ -182,10 +182,10 @@ local function MakeSplitByChainSaw( nSurfId, nFaceUse, dDepth, sNotes, dOffs) -- imposto uso del lato faccia EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) -- imposto angolo 3° asse rot - EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetChainSawBlockedAxis( 2)) + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetChainSawBlockedAxis( 1)) local _, vtN = EgtSurfTmFacetCenter( nSurfId, 0, GDB_ID.ROOT) - vtOrthO = BL.GetVersRef( nFaceUse) - EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( vtN, vtOrtho, 2)) + local vtOrtho = BL.GetVersRef( nFaceUse) + EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( vtN, vtOrtho, 1)) -- imposto offset radiale per mantenere il materiale in coda per la finitura EgtSetMachiningParam( MCH_MP.OFFSR, dOffs) -- imposto allungamento percorso iniziale e finale a zero @@ -212,8 +212,8 @@ local function MakeSplitByChainSaw( nSurfId, nFaceUse, dDepth, sNotes, dOffs) return false, sErr end -- impostazione alternativa angolo 3° asse rot - EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetChainSawBlockedAxis( 1)) - EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( vtN, vtOrtho, 1)) + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetChainSawBlockedAxis( 2)) + EgtSetMachiningParam( MCH_MP.INITANGS, BL.GetChainSawInitAngs( vtN, vtOrtho, 2)) if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nMchFId, false) @@ -232,9 +232,9 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrStd, bPreMove, vtMove, dOvmTail) - if not BD.OVM_CHAIN_HBEAM then - BD.OVM_CHAIN_HBEAM = 8 - end + -- impostazione default a variabili aggiunte + if not BD.OVM_CHAIN_HBEAM then BD.OVM_CHAIN_HBEAM = 8 end + if not BD.C_SIMM_ENC then BD.C_SIMM_ENC = 180 end -- ingombro del grezzo local b3Raw = EgtGetRawPartBBox( nRawId) -- inserimento smussi @@ -262,8 +262,9 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt end local dMaxVertDepth = dMaxDepth - ( BD.DECR_VERT_CUT or 0) -- caratteristiche taglio - local dDimYRef = EgtIf( b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL, dMaxDepth, BD.MAX_DIM_HTCUT_HBEAM) - local bBigSectionCut = ( b3Raw:getDimY() > 2 * dDimYRef - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) and ( b3Raw:getDimZ() > 2 * dDimYRef - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) + local dDimYRef = EgtIf( b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL, dMaxDepth, abs( BD.MAX_DIM_HTCUT_HBEAM)) + local bBigSectionCut = ( b3Raw:getDimY() > 2 * dDimYRef - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) and + ( b3Raw:getDimZ() > EgtIf( BD.DOWN_HEAD or BD.TURN, 2, 1) * dMaxVertDepth - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) local bHorizCut = ( not bBigSectionCut and ( b3Raw:getDimY() > b3Raw:getDimZ() + 10 * GEO.EPS_SMALL or BD.TURN) and ( b3Raw:getDimZ() < dMaxVertDepth - BD.CUT_EXTRA)) local bDoubleHorizCut = ( ( BD.DOWN_HEAD or BD.TURN) and not bBigSectionCut and not bHorizCut and b3Raw:getDimY() > 2 * dDimYRef - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL) local bDoubleCut = ( not bBigSectionCut and not bHorizCut and not bDoubleHorizCut and b3Raw:getDimY() > dDimYRef - BD.CUT_EXTRA + 10 * GEO.EPS_SMALL) @@ -293,43 +294,70 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt if bBigSectionCut then local bFinishingNeeded = false if bSplit then - --taglio sega a catena - local cutDepth = 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN - local sNotesSplit = 'Presplit;' + -- recupero lunghezza massima di lavoro della sega a catena + local sSawing = ML.FindSawing( 'Sawing') + local dMaxMat = 0 + local dTlen = 0 + if EgtMdbSetCurrMachining( sSawing or '') then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat + dTLen = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dTLen + end + end + -- assegno offset in lunghezza local dOffs = 0 if dOvmTail > BD.OVM_CHAIN_HBEAM then dOffs = dOvmTail - BD.OVM_CHAIN_HBEAM bFinishingNeeded = true end - local bOk, sErr = MakeSplitByChainSaw( Proc.Id, MCH_MILL_FU.PARAL_BACK, cutDepth, sNotesSplit, dOffs) - if not bOk then return bOk, sErr, nNewPhase end - sNotesSplit = 'Split;' - bOk, sErr = MakeSplitByChainSaw( Proc.Id, MCH_MILL_FU.PARAL_FRONT, cutDepth, sNotesSplit, dOffs) - if not bOk then return bOk, sErr, nNewPhase end - -- creo nuova fase per successiva finitura - BL.AddPhaseWithRawParts( nRawId, BD.OriXR, BD.PosXR, BD.RAW_OFFSET) - nNewPhase = EgtGetCurrPhase() - nDispId = EgtGetPhaseDisposition( nNewPhase) - if sDownOrSideOrStd == 'down' then - EgtRotateRawPart( nRawId, X_AX(), 180) - EgtSetInfo( nDispId, 'TYPE', 'MID2') - EgtSetInfo( nDispId, 'ROT', -2) - elseif sDownOrSideOrStd == 'side' then - if bPreMove then EgtMoveRawPart( nRawId, vtMove) end - EgtRotateRawPart( nRawId, X_AX(), EgtIf( BD.RIGHT_LOAD, -90, 90)) - if not bPreMove then EgtMoveRawPart( nRawId, vtMove) end - EgtSetInfo( nDispId, 'TYPE', 'MID2') - EgtSetInfo( nDispId, 'ROT', -1) + -- se pezzo non troppo alto, taglio singolo da sopra + if b3Raw:getDimZ() < dMaxMat - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL then + local cutDepth = b3Raw:getDimZ() + BD.CUT_EXTRA_MIN + sNotesSplit = 'Split;' + bOk, sErr = MakeSplitByChainSaw( Proc.Id, MCH_MILL_FU.PARAL_TOP, cutDepth, sNotesSplit, dOffs) + if not bOk then return bOk, sErr, nNewPhase end + -- se pezzo non troppo largo, taglio singolo da davanti + elseif b3Raw:getDimY() + BD.CUT_EXTRA_MIN < min( dMaxMat, dTLen - BD.C_SIMM_ENC) + 10 * GEO.EPS_SMALL then + local cutDepth = b3Raw:getDimY() + BD.CUT_EXTRA_MIN + sNotesSplit = 'Split;' + bOk, sErr = MakeSplitByChainSaw( Proc.Id, MCH_MILL_FU.PARAL_FRONT, cutDepth, sNotesSplit, dOffs) + if not bOk then return bOk, sErr, nNewPhase end + -- altrimenti tagli dai due fianchi (dietro e davanti) else - EgtSetInfo( nDispId, 'TYPE', 'END') + local cutDepth = 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN + local sNotesSplit = 'Presplit;' + local bOk, sErr = MakeSplitByChainSaw( Proc.Id, MCH_MILL_FU.PARAL_BACK, cutDepth, sNotesSplit, dOffs) + if not bOk then return bOk, sErr, nNewPhase end + sNotesSplit = 'Split;' + bOk, sErr = MakeSplitByChainSaw( Proc.Id, MCH_MILL_FU.PARAL_FRONT, cutDepth, sNotesSplit, dOffs) + if not bOk then return bOk, sErr, nNewPhase end + end + -- se necessaria finitura, creo nuova fase + if bFinishingNeeded then + BL.AddPhaseWithRawParts( nRawId, BD.OriXR, BD.PosXR, BD.RAW_OFFSET) + nNewPhase = EgtGetCurrPhase() + nDispId = EgtGetPhaseDisposition( nNewPhase) + if sDownOrSideOrStd == 'down' then + EgtRotateRawPart( nRawId, X_AX(), 180) + EgtSetInfo( nDispId, 'TYPE', 'MID2') + EgtSetInfo( nDispId, 'ROT', -2) + elseif sDownOrSideOrStd == 'side' then + if bPreMove then EgtMoveRawPart( nRawId, vtMove) end + EgtRotateRawPart( nRawId, X_AX(), EgtIf( BD.RIGHT_LOAD, -90, 90)) + if not bPreMove then EgtMoveRawPart( nRawId, vtMove) end + EgtSetInfo( nDispId, 'TYPE', 'MID2') + EgtSetInfo( nDispId, 'ROT', -1) + else + EgtSetInfo( nDispId, 'TYPE', 'END') + end + EgtSetInfo( nDispId, 'ORD', nOrd) + -- se grezzo successivo senza pezzi e finale, va tolto + local nNextRawId = EgtGetNextRawPart( nRawId) + if nNextRawId and EgtGetPartInRawPartCount( nNextRawId) == 0 and EgtGetRawPartBBox( nNextRawId):getDimX() < BD.MinRaw then + EgtRemoveRawPartFromCurrPhase( nNextRawId) + end end - EgtSetInfo( nDispId, 'ORD', nOrd) - -- se grezzo successivo senza pezzi e finale, va tolto - local nNextRawId = EgtGetNextRawPart( nRawId) - if nNextRawId and EgtGetPartInRawPartCount( nNextRawId) == 0 and EgtGetRawPartBBox( nNextRawId):getDimX() < BD.MinRaw then - EgtRemoveRawPartFromCurrPhase( nNextRawId) - end - -- fine creazione nuova fase end -- se è necessaria la finitura if bFinishingNeeded or not bSplit then