From 808536a3aab42dbfb0942800f24fe5fbc2345d7c Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 25 Jul 2023 12:56:22 +0200 Subject: [PATCH] - in LapJoint aggiunte passate laterali per SideGroove, se specificato SIDESTEP nelle note utensile - piccole correzioni minori --- LuaLibs/WProcessLapJoint.lua | 261 +++++++++++++++++++---------------- LuaLibs/WallExec.lua | 2 +- 2 files changed, 144 insertions(+), 119 deletions(-) diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 3a2bd66..4051cba 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -23,6 +23,7 @@ -- 2023/05/25 Funzioni EgtAddMachining sostituite da WM.AddMachining in modo da trascrivere le priorità da btl alle lavorazioni. -- 2023/06/30 Aggiunta lettura delle note esistenti dalle lavorazioni per evitare di sovrascriverle. -- 2023/07/10 In MakeSideGrooveByMill si impedisce ora di lavorare una groove se la testa deve scendere sotto al limite superiore del grezzo. +-- 2023/07/25 Aggiunte passate laterali per SideGroove, se specificato SIDESTEP nelle note utensile. -- Tabella per definizione modulo local WPL = {} @@ -1454,6 +1455,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d local dMillDiamTh = 999 local dMillDiamThStem = 0 local dMillLenTh = 0 + local dSideStep = 0 if EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then @@ -1464,6 +1466,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d dMillDiamTh = EgtTdbGetCurrToolThDiam() or dMillDiamTh dMillDiamThStem = EgtTdbGetCurrToolParam( MCH_TP.STEMDIAM) or dMillDiamThStem dMillLenTh = EgtTdbGetCurrToolThLength() or dMillLenTh + dSideStep = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDESTEP', 'd') or dSideStep if ( EgtTdbGetCurrToolParam( MCH_TP.TYPE) & MCH_TF.SAWBLADE) ~= 0 then dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dMaxMat if not dMaxDepthOnSide or dMaxDepthOnSide < 0.1 then @@ -1486,7 +1489,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d end end -- se profondità ribasso è maggiore della capacità di sottosquadro dell'utensile - if ( not bEnablePreMill and bMachFromDn) and ( dElev >= ( 0.5 * ( dMillDiam - dMillDiamTh))) then + if ( not bEnablePreMill and bMachFromDn) and ( dElev > 0.5 * ( dMillDiam - dMillDiamTh) - 10 * GEO.EPS_SMALL) then local sErr = 'Error : Side Elevation (' .. dElev .. ') bigger than max tool side depth (' .. ( 0.5 * ( dMillDiam - dMillDiamTh)) ..')' EgtOutLog( sErr) return false, sErr @@ -1502,8 +1505,9 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d EgtOutLog( sErr) return false, sErr end - -- se la testa scende sotto al limite superiore del grezzo - if dMillTotLen < ( abs( dRawMaxZ - dGrooveMinZ) + 1) then + -- se la testa scende sotto al limite superiore del grezzo e non c'è sufficiente capacità di sottosquadro + local dHeadMaxWidth = 250 + if dMillTotLen < ( abs( dRawMaxZ - dGrooveMinZ) + 1) and ( dElev > 0.5 * ( dMillDiam - dHeadMaxWidth) - 10 * GEO.EPS_SMALL) then local sErr = 'Error : Tool too short, head will collide with rawpart' EgtOutLog( sErr) return false, sErr @@ -1855,126 +1859,147 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d local dStepOri if not bExcludeSideMill then - -- inserisco la lavorazione di ribasso o gola - local sName = EgtIf( bEnablePreMill ~= nil, 'SideMill_', 'Mill_') .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMchFId = WM.AddMachining( Proc, sName, sMilling) - if not nMchFId then - local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling - EgtOutLog( sErr) - return false, sErr + local nSideStep = 1 + if dSideStep > 0 and not ( bEnablePreMill or bAsEnablePreMill) and nModifyLeadInOut < 1 then + nSideStep = ceil( dElev / dSideStep) + dSideStep = max( dElev / nSideStep, 0) end - EgtSetInfo( nMchFId, 'Part', Proc.PartId) - -- se ho abilitato la lavorazione di lama per garantire passaggio utensile, setto la nota per spostare la fresatura dopo i tagli di lama - if bEnablePreMill or bAsEnablePreMill then - EgtSetInfo( nMchFId, 'MOVE_AFTER', 1) - end - -- aggiungo geometria - EgtSetMachiningGeometry( {{ Proc.Id, nFacet}}) - -- imposto posizione braccio porta testa - local nSCC = MCH_SCC.ADIR_NEAR - EgtSetMachiningParam( MCH_MP.SCC, nSCC) - -- imposto modo di lavorare la faccia - local nFaceUse = WL.GetNearestParalOpposite( Z_AX()) - EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) - -- imposto elevazione e step - local dStep = EgtGetMachiningParam( MCH_MP.STEP) - dStepOri = dStep - if dStep < GEO.EPS_SMALL then dStep = 0.75 * dMaxMat end - local nStep = ceil( ( dThick - dMaxMat) / dStep) - dStep = max( ( dThick - dMaxMat) / max( nStep, 1), 0) - local dMaxElev = max( ( nStep + 1) * dStep - GEO.EPS_SMALL, 0) - if nSinglePass and nSinglePass > 0 then - dStep = 0 - if nSinglePass == 1 then - EgtSetMachiningParam( MCH_MP.DEPTH, dMaxMat) + for i = 1, nSideStep do + -- inserisco la lavorazione di ribasso o gola + local sName = EgtIf( bEnablePreMill ~= nil, 'SideMill_', 'Mill_') .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchFId = WM.AddMachining( Proc, sName, sMilling) + if not nMchFId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr end - end - if bUpwardMilling then - dStep = -dStep - end - EgtSetMachiningParam( MCH_MP.STEP, dStep) - -- leggo eventuali note esistenti della lavorazione - local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) - -- aggiungo alle note massima elevazione - sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', EgtNumToString( dMaxElev, 3)) - -- scrivo le note della lavorazione - EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) - -- setto il lato di lavoro standard - EgtSetMachiningParam( MCH_MP.INVERT, true) - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - -- modifico ingressi e uscita - -- se ho inserito il pretaglio modifico - if bEnablePreMill or bAsEnablePreMill then - if nModifyLeadInOut > 0 then - -- Confronto il raggio fresa con l'elevazione dalla normale per vedere se devo modificare l'uscita - if dElev > ( 0.5 * dMillDiam) then - if nModifyLeadInOut == 1 then - -- setto il tipo di passo a una via - EgtSetMachiningParam( MCH_MP.STEPTYPE, MCH_MILL_ST.ONEWAY) - -- modifico il tipo di uscita - EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.PERP_TG) + EgtSetInfo( nMchFId, 'Part', Proc.PartId) + -- se ho abilitato la lavorazione di lama per garantire passaggio utensile, setto la nota per spostare la fresatura dopo i tagli di lama + if bEnablePreMill or bAsEnablePreMill then + EgtSetInfo( nMchFId, 'MOVE_AFTER', 1) + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ Proc.Id, nFacet}}) + -- imposto posizione braccio porta testa + local nSCC = MCH_SCC.ADIR_NEAR + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- imposto modo di lavorare la faccia + local nFaceUse = WL.GetNearestParalOpposite( Z_AX()) + EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) + -- imposto elevazione e step + local dStep = EgtGetMachiningParam( MCH_MP.STEP) + dStepOri = dStep + if dStep < GEO.EPS_SMALL then dStep = 0.75 * dMaxMat end + local nStep = ceil( ( dThick - dMaxMat) / dStep) + dStep = max( ( dThick - dMaxMat) / max( nStep, 1), 0) + local dMaxElev = max( ( nStep + 1) * dStep - GEO.EPS_SMALL, 0) + if nSinglePass and nSinglePass > 0 then + dStep = 0 + if nSinglePass == 1 then + EgtSetMachiningParam( MCH_MP.DEPTH, dMaxMat) + end + end + if bUpwardMilling then + dStep = -dStep + end + EgtSetMachiningParam( MCH_MP.STEP, dStep) + -- leggo eventuali note esistenti della lavorazione + local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + -- aggiungo alle note massima elevazione + sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', EgtNumToString( dMaxElev, 3)) + -- scrivo le note della lavorazione + EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) + -- setto il lato di lavoro standard + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + -- setto offset radiale per gestire le eventuali passate in orizzontale + local dRadialOffset = dSideStep * ( nSideStep - i) + EgtSetMachiningParam( MCH_MP.OFFSR, dRadialOffset) + -- modifico ingressi e uscita + -- se ho inserito il pretaglio modifico + if bEnablePreMill or bAsEnablePreMill then + if nModifyLeadInOut > 0 then + -- Confronto il raggio fresa con l'elevazione dalla normale per vedere se devo modificare l'uscita + if dElev > ( 0.5 * dMillDiam) then + if nModifyLeadInOut == 1 then + -- setto il tipo di passo a una via + EgtSetMachiningParam( MCH_MP.STEPTYPE, MCH_MILL_ST.ONEWAY) + -- modifico il tipo di uscita + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.PERP_TG) + EgtSetMachiningParam( MCH_MP.LIPERP, 0) + -- modifico dati supplementari uscita + EgtSetMachiningParam( MCH_MP.LOPERP, 0.5) + EgtSetMachiningParam( MCH_MP.LOTANG, -( dLongGorge + dExtraLongIni + dExtraLongEnd)) + else + EgtSetMachiningParam( MCH_MP.LIPERP, dElev) + EgtSetMachiningParam( MCH_MP.LOPERP, dElev) + end + end + -- setto allungamenti iniziali e finali + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dExtraLongIni) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dExtraLongEnd) + if bInvertMach then + -- setto il lato di lavoro invertito + EgtSetMachiningParam( MCH_MP.INVERT, false) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + end + else + -- setto allungamenti iniziali e finali + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dExtraLongIni) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dExtraLongEnd) + -- Confronto il raggio fresa con l'elevazione dalla normale per vedere se devo modificare l'uscita + if dElev > ( 0.5 * dMillDiam) then + -- setto allungamenti perpendicolari EgtSetMachiningParam( MCH_MP.LIPERP, 0) - -- modifico dati supplementari uscita - EgtSetMachiningParam( MCH_MP.LOPERP, 0.5) - EgtSetMachiningParam( MCH_MP.LOTANG, -( dLongGorge + dExtraLongIni + dExtraLongEnd)) - else - EgtSetMachiningParam( MCH_MP.LIPERP, dElev) - EgtSetMachiningParam( MCH_MP.LOPERP, dElev) + EgtSetMachiningParam( MCH_MP.LOPERP, 0) + end + end + -- se richiesto, setto la nota per spostare la lavorazione alla fine + if not WD.SIDEMILL_BEFORE then + EgtSetInfo( nMchFId, 'MOVE_AFTER', 1) + end + else + if nModifyLeadInOut > 0 then + -- Confronto il raggio fresa con l'elevazione dalla normale per vedere se devo modificare l'uscita + if dElev > ( 0.5 * dMillDiam) then + -- setto il tipo di passo a una via + EgtSetMachiningParam( MCH_MP.STEPTYPE, 1) + end + if bInvertMach then + -- setto il lato di lavoro invertito + EgtSetMachiningParam( MCH_MP.INVERT, false) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) end end -- setto allungamenti iniziali e finali EgtSetMachiningParam( MCH_MP.STARTADDLEN, dExtraLongIni) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dExtraLongEnd) - if bInvertMach then - -- setto il lato di lavoro invertito - EgtSetMachiningParam( MCH_MP.INVERT, false) - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + -- se ho passate orizzontali riduco l'eventuale allungamento settato dall'utente + local dLiPerp = EgtGetMachiningParam( MCH_MP.LIPERP) + local dLoPerp = EgtGetMachiningParam( MCH_MP.LOPERP) + if dLiPerp > 0 then + dLiPerp = dLiPerp - dRadialOffset end - else - -- setto allungamenti iniziali e finali - EgtSetMachiningParam( MCH_MP.STARTADDLEN, dExtraLongIni) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, dExtraLongEnd) - -- Confronto il raggio fresa con l'elevazione dalla normale per vedere se devo modificare l'uscita - if dElev > ( 0.5 * dMillDiam) then - -- setto allungamenti perpendicolari - EgtSetMachiningParam( MCH_MP.LIPERP, 0) - EgtSetMachiningParam( MCH_MP.LOPERP, 0) + if dLoPerp > 0 then + dLoPerp = dLoPerp - dRadialOffset + end + EgtSetMachiningParam( MCH_MP.LIPERP, dLiPerp) + EgtSetMachiningParam( MCH_MP.LOPERP, dLoPerp) + -- se richiesto, setto la nota per spostare la lavorazione alla fine + if not WD.SIDEMILL_BEFORE then + EgtSetInfo( nMchFId, 'MOVE_AFTER', 1) end end - -- se richiesto, setto la nota per spostare la lavorazione alla fine - if not WD.SIDEMILL_BEFORE then - EgtSetInfo( nMchFId, 'MOVE_AFTER', 1) - end - else - if nModifyLeadInOut > 0 then - -- Confronto il raggio fresa con l'elevazione dalla normale per vedere se devo modificare l'uscita - if dElev > ( 0.5 * dMillDiam) then - -- setto il tipo di passo a una via - EgtSetMachiningParam( MCH_MP.STEPTYPE, 1) - end - if bInvertMach then - -- setto il lato di lavoro invertito - EgtSetMachiningParam( MCH_MP.INVERT, false) - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - end - end - -- setto allungamenti iniziali e finali - EgtSetMachiningParam( MCH_MP.STARTADDLEN, dExtraLongIni) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, dExtraLongEnd) - -- se richiesto, setto la nota per spostare la lavorazione alla fine - if not WD.SIDEMILL_BEFORE then - EgtSetInfo( nMchFId, 'MOVE_AFTER', 1) - end - end - -- eseguo - if not EgtApplyMachining( true, false) then - -- provo a invertire posizione braccio porta testa - nSCC = MCH_SCC.ADIR_FAR - EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- eseguo if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr + -- provo a invertire posizione braccio porta testa + nSCC = MCH_SCC.ADIR_FAR + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end end end else @@ -2634,7 +2659,7 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw) end else -- fresatura (se definita) - local sMilling = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV)) + local sMilling = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV), nil, dSideElev) -- recupero i dati dell'utensile local dMaxMat = 1000 local dMaxDepthOnSide = 0 @@ -2657,12 +2682,12 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw) end end end - if sMilling and dElev < dMaxDepthOnSide then - return MakeSideGrooveByMill( Proc, nFacInd, nRawId, b3Raw, sMilling) - -- altrimenti sega a catena - else - return MakeByChainSaw( Proc, nFacInd, nRawId, b3Raw, dElev, dH, dV) - end + if sMilling and dElev < dMaxDepthOnSide then + return MakeSideGrooveByMill( Proc, nFacInd, nRawId, b3Raw, sMilling) + -- altrimenti sega a catena + else + return MakeByChainSaw( Proc, nFacInd, nRawId, b3Raw, dElev, dH, dV) + end end end local nFacet = EgtIf( bPckt or vtN:getZ() >= WD.NZ_MINA, nFacInd, nFacInd2) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 9c69514..457dbd6 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -612,7 +612,7 @@ function InsertScrapRemoval( nPhase) end nCurrentOperationId = EgtGetNextOperation( nCurrentOperationId) end - EgtSetCurrMachining( nActiveMachiningId) + EgtSetCurrMachining( nActiveMachiningId or GDB_ID.NULL) end -------------------------------------------------------------------------------------------------------------