From 28af7069102ce01171562d3e1f7e331a22ca5994 Mon Sep 17 00:00:00 2001 From: DarioS Date: Mon, 1 Aug 2022 17:39:49 +0200 Subject: [PATCH] =?UTF-8?q?DataBeam=20:=20-=20tolleranza=20su=20sezione=20?= =?UTF-8?q?portata=20a=200.1=20mm=20(100=20*=20GEO.EPS=5FSMALL)=20-=20funz?= =?UTF-8?q?ioni=20StartsWith=20e=20EndsWith=20sostituite=20da=20analoghe?= =?UTF-8?q?=20funzioni=20di=20libreria=20(con=20prefisso=20Egt)=20-=20corr?= =?UTF-8?q?etta=20gestione=20tagli=20con=20testa=20che=20taglia=20da=20sot?= =?UTF-8?q?to=20in=20su=20-=20riordino=20forature=20per=20gestione=20incli?= =?UTF-8?q?nazione=20limite=20da=20superficie=20trave=20-=20in=20Mortasatu?= =?UTF-8?q?re=20se=20non=20si=20pu=C3=B2=20pulire=20angoli=20con=20mortasa?= =?UTF-8?q?trice=20warning=20invece=20di=20errore.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BatchProcessNew.lua | 7 +- LuaLibs/BeamExec.lua | 9 +- LuaLibs/BeamLib.lua | 2 +- LuaLibs/MachiningLib.lua | 32 +---- LuaLibs/ProcessCut.lua | 14 +- LuaLibs/ProcessDrill.lua | 237 ++++++++++++++----------------- LuaLibs/ProcessLongDoubleCut.lua | 2 +- LuaLibs/ProcessMortise.lua | 12 +- NestProcess.lua | 22 +-- 9 files changed, 150 insertions(+), 187 deletions(-) diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 5ec8bca..3ba711b 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -1,4 +1,4 @@ --- BatchProcessNew.lua by Egaltech s.r.l. 2022/07/24 +-- BatchProcessNew.lua by Egaltech s.r.l. 2022/08/01 -- Gestione calcolo batch disposizione e lavorazioni per Travi -- 2021/01/07 Per nuova interfaccia Egt. -- 2021/01/15 CREATE_BAR ora FLAG = 6 (prima 5). @@ -11,6 +11,7 @@ -- 2022/02/09 Aggiornato come Wall per gestione errori e verifica attrezzaggio utensili. -- 2022/04/28 In info generazione aggiunta indicazione se 64bit. -- 2022/07/24 Modifica per cancellare lavorazioni con ricalcolo e barra già definita. +-- 2022/08/01 Tolleranza su sezione portata a 0.1 mm (100 * GEO.EPS_SMALL). -- Intestazioni require( 'EgtBase') @@ -334,8 +335,8 @@ if bToProcess then for i = 2, #vBeam do local dDimW = vBeam[i].Box:getDimY() local dDimH = vBeam[i].Box:getDimZ() - if ( abs( dDimW - dRawW) > 10 * GEO.EPS_SMALL or abs( dDimH - dRawH) > 10 * GEO.EPS_SMALL) and - ( abs( dDimH - dRawW) > 10 * GEO.EPS_SMALL or abs( dDimW - dRawH) > 10 * GEO.EPS_SMALL) then + if ( abs( dDimW - dRawW) > 100 * GEO.EPS_SMALL or abs( dDimH - dRawH) > 100 * GEO.EPS_SMALL) and + ( abs( dDimH - dRawW) > 100 * GEO.EPS_SMALL or abs( dDimW - dRawH) > 100 * GEO.EPS_SMALL) then table.insert( vBeamErr, i) end end diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 674a259..d200a19 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,4 +1,4 @@ --- BeamExec.lua by Egaltech s.r.l. 2022/07/27 +-- BeamExec.lua by Egaltech s.r.l. 2022/08/01 -- 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. @@ -32,6 +32,7 @@ -- Create le funzioni AnalyzeHeadFeatures e AnalyzeTailFeatures. Spostate più in alto le funzioni CollectFeatures, isHeadFeature e isTailFeature. -- 2022/07/01 Aggiunta la gestione delle forature migliorate in presenza di feature testa/coda ad 1 faccia che tagliano tutta la sezione, -- controllata tramite il parametro IMPROVE_HEAD_TAIL_DRILLINGS da BeamData. Attivata di default. +-- 2022/08/01 Tolleranza su sezione portata a 0.1 mm (100 * GEO.EPS_SMALL). -- Tabella per definizione modulo local BeamExec = {} @@ -489,8 +490,8 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam, bMachGroup local PartWidth = b3Solid:getDimY() local PartHeight = b3Solid:getDimZ() local NextLen = Len - DeltaS - PartLen - DeltaE - if (( abs( PartWidth - dRawW) < 10 * GEO.EPS_SMALL and abs( PartHeight - dRawH) < 10 * GEO.EPS_SMALL) or - ( abs( PartHeight - dRawW) < 10 * GEO.EPS_SMALL and abs( PartWidth - dRawH) < 10 * GEO.EPS_SMALL)) and + if (( abs( PartWidth - dRawW) < 100 * GEO.EPS_SMALL and abs( PartHeight - dRawH) < 100 * GEO.EPS_SMALL) or + ( abs( PartHeight - dRawW) < 100 * GEO.EPS_SMALL and abs( PartWidth - dRawH) < 100 * GEO.EPS_SMALL)) and NextLen + DeltaE >= 0 then -- eventuale sovramateriale di testa if i > 1 and vBeam[i].PosX then @@ -529,7 +530,7 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam, bMachGroup EgtDeselectPartObjs( Pz) local ptPos = b3Part:getMin() - b3Solid:getMin() + Vector3d( Delta, ( dRawW - PartWidth) / 2, ( dRawH - PartHeight) / 2) EgtAddPartToRawPart( Pz, ptPos, nRaw) - if abs( PartWidth - dRawW) > 10 * GEO.EPS_SMALL then + if abs( PartWidth - dRawW) > 100 * GEO.EPS_SMALL then -- rotazione attorno a centro geometria complessiva del pezzo EgtRotatePartInRawPart( Pz, X_AX(), 90) -- correggo per eccentricità solido rispetto a geometria complessiva del pezzo diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 4163a5e..be26018 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -705,7 +705,7 @@ function BeamLib.GetNzLimDownUp( b3Raw, vtN, vtOrtho) if BD.C_SIMM or BD.TURN then return -0.484 else - if vtOrtho and vtOrtho:getZ() > 0.5 then + if vtOrtho and vtOrtho:getZ() > 0.35 then -- N_HorAng < 15° or N_HorAng > 55° if vtN and ( abs( vtN:getY()) < 0.259 or abs( vtN:getY()) > 0.819) then return -0.708 diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 75294e5..3daa60b 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -111,24 +111,6 @@ local function SetCurrMachiningAndTool( sMachName) return bActive, sTool, bH2, bFixed end ---------------------------------------------------------------------- -local function StartsWith( sStr, sStart) - if ( sStart == "" or sStr:sub( 1, #sStart) == sStart) then - return true, sStr:sub( 1, #sStr - #sStart) - else - return false, sStr - end -end - ---------------------------------------------------------------------- -local function EndsWith( sStr, sEnd) - if ( sEnd == "" or sStr:sub(-#sEnd) == sEnd) then - return true, sStr:sub(1, #sStr - #sEnd) - else - return false, sStr - end -end - --------------------------------------------------------------------- function VerifyDrill( dDiam, dDepth, bH2) local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) @@ -189,9 +171,9 @@ end --------------------------------------------------------------------- function VerifyTool( MachiningType, sType, Params, bH2) if MachiningType == MCH_MY.DRILLING then - if StartsWith( sType, 'Drill') or StartsWith( sType, 'AngleDrill') then + if EgtStartsWith( sType, 'Drill') or EgtStartsWith( sType, 'AngleDrill') then return VerifyDrill( Params.Diam, Params.Depth, bH2) - elseif StartsWith( sType, 'Pocket') then + elseif EgtStartsWith( sType, 'Pocket') then return VerifyDrillPocket( Params.Diam, Params.Depth, bH2) end elseif MachiningType == MCH_MY.SAWING then @@ -225,7 +207,7 @@ end --------------------------------------------------------------------- function ReturnParams( MachiningType, MachiningName, sType, ToolParams) if MachiningType == MCH_MY.DRILLING then - local _, sOrigType = EndsWith( sType, '_H2') + local _, sOrigType = EgtEndsWith( sType, '_H2') 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 @@ -267,9 +249,9 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead) ForStep = -1 end if ( BEAM and BEAM.BW) or MachineHeadType == ONE_HEAD or MachineHeadType == TWO_EQUAL_HEADS or ( MachineHeadType == TWO_UP_DOWN_HEADS and not bDownHead) then - _, sType = EndsWith( sType, '_H2') + _, sType = EgtEndsWith( sType, '_H2') elseif ( not BEAM or not BEAM.BW) and MachineHeadType == TWO_UP_DOWN_HEADS and bDownHead then - if not EndsWith( sType, '_H2') then + if not EgtEndsWith( sType, '_H2') then sType = sType .. '_H2' end end @@ -285,7 +267,7 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead) local Machining = Machinings[i] local sMachiningType = Machining.Type if BEAM and BEAM.BW then - _, sMachiningType = EndsWith( Machining.Type, '_H2') + _, sMachiningType = EgtEndsWith( Machining.Type, '_H2') end -- recupero dati utensile local bToolActive, sToolName, bH2, bFixed = SetCurrMachiningAndTool( Machining.Name) @@ -356,7 +338,7 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead) end end end - local bH2, sOrigType = EndsWith( sType, '_H2') + local bH2, sOrigType = EgtEndsWith( sType, '_H2') if ( not BEAM or not BEAM.BW) and MachineHeadType == TWO_UP_DOWN_HEADS and bH2 and bTopHead then return FindMachining( MachiningType, sOrigType, Params, true, false) end diff --git a/LuaLibs/ProcessCut.lua b/LuaLibs/ProcessCut.lua index bf30107..7df4d99 100644 --- a/LuaLibs/ProcessCut.lua +++ b/LuaLibs/ProcessCut.lua @@ -1,4 +1,4 @@ --- ProcessCut.lua by Egaltech s.r.l. 2022/06/28 +-- ProcessCut.lua by Egaltech s.r.l. 2022/07/28 -- Gestione calcolo singoli tagli di lama per Travi -- 2021/05/18 I due tagli con testa da sotto di un cubetto sono fatti di seguito. -- 2021/06/06 Correzioni per tagli con testa da sotto. @@ -403,14 +403,12 @@ local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, b else if bHorizCut then vtOrthoO = Z_AX() - elseif vtN:getY() > -0.02 then - if not Proc.Head then - vtOrthoO = -Y_AX() - else - vtOrthoO = Y_AX() - end else - vtOrthoO = -Y_AX() + if vtN:getZ() < dNzLimDwnUp then + vtOrthoO = EgtIf( vtN:getY() > -0.02, -Y_AX(), Y_AX()) + else + vtOrthoO = EgtIf( vtN:getY() > 0.02, Y_AX(), -Y_AX()) + end end end end diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index 03206cf..29a33ce 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -169,11 +169,43 @@ function ProcessDrill.Classify( Proc, b3Raw) end end +--------------------------------------------------------------------- +-- Funzione per riconoscimento faccia inizio foro e dati correlati +-- Indice faccia :1=Front, 2=Bottom, 3=Back, 4=Top, 5=Left, 6=Right +local function GetHoleStartData( ptCen, vtExtr, b3Solid) + -- Facce della trave + local vFaces = { { Dist = -b3Solid:getMin():getY(), Norm = -Y_AX()}, + { Dist = -b3Solid:getMin():getZ(), Norm = -Z_AX()}, + { Dist = b3Solid:getMax():getY(), Norm = Y_AX()}, + { Dist = b3Solid:getMax():getZ(), Norm = Z_AX()}, + { Dist = -b3Solid:getMin():getX(), Norm = -X_AX()}, + { Dist = b3Solid:getMax():getX(), Norm = X_AX()}} + -- Ricerca della faccia di inizio + local nFac = 0 + local dCosMin = 0.0871 + for i = 1, 6 do + if ( ptCen - ORIG()) * vFaces[i].Norm - vFaces[i].Dist > -2 then + local dCos = vtExtr * vFaces[i].Norm + if dCos > dCosMin then + nFac = i + dCosMin = dCos + if dCos > 0.7072 then break end + end + end + end + -- Coseno angolo dalla faccia + local CosB = 0 + if nFac ~= 0 then + CosB = sqrt( 1 - sqr( vtExtr * vFaces[nFac].Norm)) + end + return nFac, CosB, vFaces +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) + BD.DRILL_VX_MAX_ANGLEDRILL = ( BD.DRILL_VX_MAX_ANGLEDRILL or 0.928) -- ingombro del pezzo local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) if not b3Solid then @@ -192,21 +224,32 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) -- recupero i dati del foro local dDiam = 2 * EgtArcRadius( AuxId) local dLen = abs( EgtCurveThickness( AuxId)) + local ptCen = EgtCP( AuxId, GDB_RT.GLOB) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) - if Proc.Flg == -2 then vtExtr = - vtExtr end + if Proc.Flg == -2 then + ptCen = ptCen - vtExtr * dLen + vtExtr = - vtExtr + end local bOpen = ( Proc.Fcs ~= 0 and Proc.Fce ~= 0) -- verifico che il foro non sia fattibile solo da sotto - local bToInvert = ( vtExtr:getZ() < BD.DRILL_VZ_MIN) and not BD.DOWN_HEAD + local bToInvert = ( vtExtr:getZ() < BD.DRILL_VZ_MIN and not BD.DOWN_HEAD) if bToInvert and ( not bOpen or Proc.Flg ~= 1) then local sErr = 'Error : drilling from bottom impossible' EgtOutLog( sErr) return false, sErr end - -- se il foro è cieco o troppo inclinato all'inizio, lo inverto - if Proc.Fcs == 0 or ( abs( vtExtr:getX()) > BD.DRILL_VX_MAX and Proc.Fcs ~= 5 and Proc.Fcs ~= 6) then - bToInvert = true + -- se non già richiesta inversione e invertibile + if not bToInvert and Proc.Flg == 1 and ( -vtExtr:getZ() >= BD.DRILL_VZ_MIN or BD.DOWN_HEAD) then + -- se il foro è cieco o troppo inclinato all'inizio, lo inverto + local _, CosB, _ = GetHoleStartData( ptCen, vtExtr, b3Solid) + if Proc.Fcs == 0 or ( CosB > BD.DRILL_VX_MAX and bOpen) then + bToInvert = true + end + end + if bToInvert then + ptCen = ptCen - vtExtr * dLen + vtExtr = - vtExtr end - if bToInvert then vtExtr = - vtExtr end -- se foro è splittato ed è la parte opposta, inverto if Proc.Flg == -2 then bToInvert = true end -- profondità geometrica del foro @@ -220,7 +263,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) local nErrorCode = 0 -- abilitazione foratura da sotto local bDrillDown = ( BD.DOWN_HEAD and ( Proc.Down or vtExtr:getZ() < -0.1 or vtExtr:getZ() < 0.259)) - local bDrillUp = ( BD.DOWN_HEAD and vtExtr:getZ() > -0.259) + local bDrillUp = ( BD.DOWN_HEAD and vtExtr:getZ() > -0.5) -- primo gruppo di controlli con lunghezza utensile pari a metà foro se passante -- recupero la lavorazione local sDrilling, sType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, dCheckDepth, bDrillUp, bDrillDown) @@ -282,6 +325,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) local bCommonCompare = BD.MAX_TOOL_LEN_BACK_HOR_MACH and bOpen and abs(vtExtr:getX()) < 0.5 and abs(vtExtr:getZ()) < 0.5 if nErrorCode == 0 and not bToInvert and bCommonCompare and vtExtr:getY() > 0.866 and Proc.Flg == 1 and dMaxToolLength > BD.MAX_TOOL_LEN_BACK_HOR_MACH then bToInvert = true + ptCen = ptCen - vtExtr * dLen vtExtr = - vtExtr --------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -300,8 +344,9 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) dToolFreeLen = dToolFreeLen2 dDepth = dDepth2 if vtExtr:getY() > 0 then - bToInvert = true - vtExtr = - vtExtr + bToInvert = true + ptCen = ptCen - vtExtr * dLen + vtExtr = - vtExtr end -- se sono al secondo mezzo foro con utensile che supera la lunghezza di riferimento non lo eseguo elseif nErrorCode == 0 and bCommonCompare and abs(vtExtr:getY()) > 0.866 and Proc.Flg == -2 and dMaxToolLength2 > BD.MAX_TOOL_LEN_BACK_HOR_MACH then @@ -316,81 +361,65 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) EgtOutLog( sErr) return false, sErr end - -- conservo il valore originale di MaxDepth per poter eventualmente bypassare i check successivi + -- Determino la faccia di inizio del foro e dati correlati + local nFac, CosB, vFaces = GetHoleStartData( ptCen, vtExtr, b3Solid) + -- Calcolo acciorciamento affondamento utile per evitare collisione portautensile con faccia + local TgA = CosB / sqrt( 1 - CosB * CosB) + local dSubL = ( dDiamTh / 2 + ( Proc.Diam - dToolDiam) / 2 + 2) * TgA local dMaxDepthOri = dMaxDepth - -- verifico il massimo affondamento - local dSubL1 = 0 - local dSubL2 = 0 - local dSubL3 = 0 - local dDeltaRad = ( Proc.Diam - dToolDiam) / 2 - -- 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()) - if CosB < BD.DRILL_VX_MAX then - 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 - if dMaxDepth > 0 and abs( vtExtr:getY()) > abs( vtExtr:getZ()) then - local CosB = abs( vtExtr:getY()) - if bInMid then - CosB = sqrt( vtExtr:getZ() * vtExtr:getZ() + vtExtr:getX() * vtExtr:getX()) - end - if CosB < BD.DRILL_VX_MAX then - 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 - if dMaxDepth > 0 and abs( vtExtr:getZ()) > abs( vtExtr:getY()) then - local CosB = abs( vtExtr:getZ()) - if bInMid then - CosB = sqrt( vtExtr:getY() * vtExtr:getY() + vtExtr:getX() * vtExtr:getX()) - end - if CosB < BD.DRILL_VX_MAX then - 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 + dMaxDepth = min( dMaxDepth, dToolFreeLen - dSubL) + -- Verifico inclinazione foro nei limiti + local bTryDrill = ( CosB < BD.DRILL_VX_MAX) + if ( CosB > 0.8 * BD.DRILL_VX_MAX and CosB < BD.DRILL_VX_MAX_ANGLEDRILL) 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 + bTryDrill = true end end + -- aggiusto affondamento e MaxElev + local dMaxElev + local sMyWarn + -- se c'è un taglio precedente di testa o coda in cui il foro "entra" devo ricalcolare i dati della foratura + if (( Proc.MachineAfterHeadCutId and vtExtr:getX() > 0) or ( Proc.MachineAfterTailCutId and vtExtr:getX() < 0)) then + local bIntersectionOk, _, vDistance = EgtLineSurfTmInters( ptCen, -vtExtr, Proc.MachineAfterHeadCutId or Proc.MachineAfterTailCutId, GDB_RT.GLOB) + if bIntersectionOk then + local dHoleToCutDistance = vDistance[1] + -- se il taglio accorcia realmente il foro + if dHoleToCutDistance > 10 * GEO.EPS_SMALL and dHoleToCutDistance < dLen then + dMaxDepth = dMaxDepthOri + dMaxElev = dLen - dHoleToCutDistance + bTryDrill = true + local dToolAddLength = dLen - dMaxElev + -- se l'utensile è comunque troppo corto lavoro il massimo possibile + if dDepth - dToolAddLength > dMaxDepth + 10 * GEO.EPS_SMALL then + sMyWarn = 'Warning in drill : depth (' .. EgtNumToString( dDepth - dToolAddLength, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' + dDepth = dLen + else + -- se è un foro splittato cerco comunque di arrivare alla massima profondità possibile, evitando di sfondare dall'altro lato. + if Proc.Flg == 2 or Proc.Flg == -2 then + dDepth = dLen - 10 + end + -- se non lavoro la massima lunghezza disponibile devo correggere MaxElev + dMaxElev = dMaxElev - dLen + dDepth + end + end + end + end + -- se foro da saltare per eccessiva inclinazione + if not bTryDrill then + sMyWarn = 'Warning in drill : too slant hole' + dDepth = 0 + return true, sMyWarn + -- se non ridotto e affondamento richiesto supera il consentito + elseif not dMaxElev and dDepth > dMaxDepth + 10 * GEO.EPS_SMALL then + sMyWarn = 'Warning in drill : depth (' .. EgtNumToString( dDepth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' + dDepth = dMaxDepth + dMaxElev = dMaxDepth + end -- inserisco la lavorazione local sName = 'Drill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchId = EgtAddMachining( sName, sDrilling) @@ -424,57 +453,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) nSCC = MCH_SCC.NONE end EgtSetMachiningParam( MCH_MP.SCC, nSCC) - -- aggiusto affondamento e MaxElev - local dMaxElev = dDepth - local sMyWarn - if dDepth > dMaxDepth + 10 * GEO.EPS_SMALL then - -- se c'è un taglio precedente di testa o coda posso impostare MaxElev per allungare il percorso - -- considero solo i fori "entranti" in testa o coda - if (( Proc.MachineAfterHeadCutId and vtExtr:getX() > 0) or ( Proc.MachineAfterTailCutId and vtExtr:getX() < 0)) then - local ptCen = EgtCP( AuxId, GDB_RT.GLOB) - local bIntersectionOk, _, vDistance = EgtLineSurfTmInters( ptCen, -vtExtr, Proc.MachineAfterHeadCutId or Proc.MachineAfterTailCutId, GDB_RT.GLOB) - dHoleToCutDistance = vDistance[1] - -- setto MaxElev - -- il segno della distanza data dalla funzione di intersezione mi indica dove sia la geometria del foro - if bIntersectionOk then - -- se MaxDepth era stato settato a 0 per disattivare la lavorazione gli riassegno il valore originale - if dMaxDepth == 0 then - dMaxDepth = dMaxDepthOri - end - if dHoleToCutDistance > 10 * GEO.EPS_SMALL then - dMaxElev = dLen - dHoleToCutDistance - elseif dHoleToCutDistance < -10 * GEO.EPS_SMALL then - dMaxElev = -dHoleToCutDistance - end - local dToolAddLength = dLen - dMaxElev - -- se l'utensile è comunque troppo corto lavoro il massimo possibile - if dDepth - dToolAddLength > dMaxDepth + 10 * GEO.EPS_SMALL then - sMyWarn = 'Warning in drill : depth (' .. EgtNumToString( dDepth - dToolAddLength, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' - dDepth = dLen - else - -- se è un foro splittato cerco comunque di arrivare alla massima profondità possibile, evitando di sfondare dall'altro lato. - if Proc.Flg == 2 or Proc.Flg == -2 then - dDepth = dLen - 10 - end - -- se non lavoro la massima lunghezza disponibile devo correggere MaxElev - dMaxElev = dMaxElev - dLen + dDepth - end - -- se per qualche motivo fallisce l'intersezione torno al caso standard - else - sMyWarn = 'Warning in drill : depth (' .. EgtNumToString( dDepth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' - dDepth = dMaxDepth - dMaxElev = dMaxDepth - end - -- caso standard - else - sMyWarn = 'Warning in drill : depth (' .. EgtNumToString( dDepth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' - dDepth = dMaxDepth - dMaxElev = dMaxDepth - end - if sMyWarn then - EgtOutLog( sMyWarn) - end - end + -- imposto affondamento EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) -- imposto il valore della distanza di sicurezza per l'attacco. Se il valore del db utensili è troppo basso lo alzo a 10. local dToolDbStartPos = EgtGetMachiningParam( MCH_MP.STARTPOS) @@ -484,7 +463,9 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) -- Note utente con dichiarazione nessuna generazione sfridi per Vmill local sUserNotes = 'VMRS=0;' -- aggiungo alle note massima elevazione (coincide con affondamento) - sUserNotes = sUserNotes .. 'MaxElev=' .. EgtNumToString( dMaxElev, 1) .. ';' + if dMaxElev then + sUserNotes = sUserNotes .. 'MaxElev=' .. EgtNumToString( dMaxElev, 1) .. ';' + end -- se foro passante, aggiungo questa qualifica alle note if ( sType == 'Drill' or sType == 'Drill_H2' or sType == 'AngleDrill') and bOpen then sUserNotes = sUserNotes .. 'Open=1;' diff --git a/LuaLibs/ProcessLongDoubleCut.lua b/LuaLibs/ProcessLongDoubleCut.lua index 2a0fa37..e3d0cc8 100644 --- a/LuaLibs/ProcessLongDoubleCut.lua +++ b/LuaLibs/ProcessLongDoubleCut.lua @@ -877,7 +877,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster -- recupero la lavorazione local sMilling local bDownHead = ( nSide == -1 and BD.DOWN_HEAD) - sMilling = ML.FindMilling( 'Long2Cut_H2', dElev, nil, nil, nil, not bDownHead, bDownHead) + sMilling = ML.FindMilling( 'Long2Cut', dElev, nil, nil, nil, not bDownHead, bDownHead) if not sMilling then local sErr = 'Error : Long2Cut not found in library' diff --git a/LuaLibs/ProcessMortise.lua b/LuaLibs/ProcessMortise.lua index ca8c369..42c9201 100644 --- a/LuaLibs/ProcessMortise.lua +++ b/LuaLibs/ProcessMortise.lua @@ -158,9 +158,9 @@ local function CleanCorners( Proc, dMorH, vtN, bOpenBtm, AuxId) -- 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 - corner cleaning : elevation (' .. EgtNumToString( dFullMorH, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' - EgtOutLog( sErr) - return false, sErr + local sWarn = 'Warning in corner cleaning with mortise: elevation (' .. EgtNumToString( dFullMorH, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' + EgtOutLog( sWarn) + return true, sWarn end -- verifico se la tasca ha dimensioni sufficienti per l'utensile local nSurf = EgtSurfTmByFlatContour( EgtGetParent( AuxId), AuxId, 0.05) @@ -170,9 +170,9 @@ local function CleanCorners( Proc, dMorH, vtN, bOpenBtm, AuxId) end EgtErase( nFlat) if dSawWidth >= dMortiseWidth + 10 * GEO.EPS_SMALL or dSawThick >= dMortiseThick + 10 * GEO.EPS_SMALL then - local sErr = 'Error in Mortise - corner cleaning: pocket too small' - EgtOutLog( sErr) - return false, sErr + local sWarn = 'warning in corner cleaning with mortise: pocket too small' + EgtOutLog( sWarn) + return true, sWarn end -- cerco le due facce migliori da lavorare local nWorkFaceInd, nWorkFaceInd2 diff --git a/NestProcess.lua b/NestProcess.lua index ef1c03d..e82dc8a 100644 --- a/NestProcess.lua +++ b/NestProcess.lua @@ -1,5 +1,5 @@ -- BeamNestProcess.lua by Egaltech s.r.l. 2021/06/14 --- Gestione nesting automatico pareti +-- Gestione nesting automatico travi -- Intestazioni require( 'EgtBase') @@ -257,7 +257,7 @@ while TotRawCount( Raws) > 0 and PartsToFill( Parts) > 0 do local Results = {} for RawIndex = 1, #Raws do if Raws[RawIndex].Count > 0 then - Results[RawIndex] = ExecMaximumFilling( Raws[RawIndex], PartsToNest) + Results[RawIndex] = ExecMaximumFilling( Raws[RawIndex], PartsToNest) else Results[RawIndex] = { FillRatio = 0.001, LenToFill = 1000} end @@ -267,10 +267,10 @@ while TotRawCount( Raws) > 0 and PartsToFill( Parts) > 0 do local dMinWaste = 100000 for ResultIndex = 1, #Results do if Results[ResultIndex] then - local dWaste = (1 - Results[ResultIndex].FillRatio) * Raws[ResultIndex].LenToFill - if dWaste < dMinWaste then - dMinWaste = dWaste - nMinWasteRawIndex = ResultIndex + local dWaste = (1 - Results[ResultIndex].FillRatio) * Raws[ResultIndex].LenToFill + if dWaste < dMinWaste then + dMinWaste = dWaste + nMinWasteRawIndex = ResultIndex end end end @@ -301,11 +301,11 @@ while TotRawCount( Raws) > 0 and PartsToFill( Parts) > 0 do end end nRawTot = nRawTot + 1 - -- Aggiorno per prossima iterazione - Raws[nMinWasteRawIndex].Count = Raws[nMinWasteRawIndex].Count - 1 - for i = 1, Results[nMinWasteRawIndex].DiffParts do - local PartId = Results[nMinWasteRawIndex].Data[i].Id - PartsToNest[PartId].Cnt = PartsToNest[PartId].Cnt - Results[nMinWasteRawIndex].Data[i].Count + -- Aggiorno per prossima iterazione + Raws[nMinWasteRawIndex].Count = Raws[nMinWasteRawIndex].Count - 1 + for i = 1, Results[nMinWasteRawIndex].DiffParts do + local PartId = Results[nMinWasteRawIndex].Data[i].Id + PartsToNest[PartId].Cnt = PartsToNest[PartId].Cnt - Results[nMinWasteRawIndex].Data[i].Count end end nCycle = nCycle + 1