diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 7d16652..18ddfe3 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1,4 +1,4 @@ --- BeamLib.lua by Egaltech s.r.l. 2022/05/03 +-- BeamLib.lua by Egaltech s.r.l. 2022/05/18 -- Libreria globale per Travi -- 2020/07/28 Corretto calcolo attacchi e uscite di lame per non uscire dalla faccia sotto. -- 2020/08/18 Aggiunto a GetNearestParalOpposite e GetNearestOrthoOpposite parametro opzionale vtNorm. @@ -11,6 +11,7 @@ -- 2022/01/11 In GetNearest*Opposite ridotto vantaggio XY rispetto a Z da 1 -> 0.9 a 1 -> 0.99. -- 2022/04/05 Modifiche a GetNzLimDownUp per FAST. -- 2022/05/03 Ulteriore limitazione a GetNzLimDownUp per FAST. +-- 2022/05/18 Correzioni e migliorie a PutStartNearestToEdge. -- Tabella per definizione modulo local BeamLib = {} @@ -194,30 +195,36 @@ function BeamLib.PutStartNearestToEdge( nCrvId, b3Raw, bDown) -- recupero il versore normale al piano di lavoro o estrusione local vtN = EgtCurveExtrusion( nCrvId, GDB_ID.ROOT) -- coefficienti per riportare la distanza nel piano di lavoro - local dCoeffX = 1 / ( sqrt( 1 - vtN:getX() * vtN:getX())) - local dCoeffY = 1 / ( sqrt( 1 - vtN:getY() * vtN:getY())) - local dCoeffZ = 1 / ( sqrt( 1 - vtN:getZ() * vtN:getZ())) + local dCoeffY = 0 + if abs( vtN:getY()) < 0.999 then dCoeffY= 1 / ( sqrt( 1 - vtN:getY() * vtN:getY())) end + local dCoeffZ = 0 + if abs( vtN:getZ()) < 0.999 then dCoeffZ = 1 / ( sqrt( 1 - vtN:getZ() * vtN:getZ())) end -- cerco l'estremo più vicino al box e lo imposto come inizio (se da sotto escludo Zmax e viceversa) local dUopt = 0 local dDopt = GEO.INFINITO + local dZopt = GEO.INFINITO local dUi, dUf = EgtCurveDomain( nCrvId) for dU = dUi, dUf, 0.5 do local ptP = EgtUP( nCrvId, dU, GDB_ID.ROOT) - if ptP then + local vtDp = EgtUV( nCrvId, dU, -1, GDB_ID.ROOT) + local vtDs = EgtUV( nCrvId, dU, 1, GDB_ID.ROOT) + local bTg = ( vtDp and vtDs and vtDp * vtDs > 0.96) + if ptP and bTg then local vtMin = ptP - b3Raw:getMin() local vtMax = ptP - b3Raw:getMax() - local dD = abs( vtMin:getX()) * dCoeffX - dD = min( abs( vtMax:getX()) * dCoeffX, dD) - dD = min( abs( vtMin:getY()) * dCoeffY, dD) + local dD = abs( vtMin:getY()) * dCoeffY dD = min( abs( vtMax:getY()) * dCoeffY, dD) - if bDown then - dD = min( abs( vtMin:getZ()) * dCoeffZ, dD) - else - dD = min( abs( vtMax:getZ()) * dCoeffZ, dD) - end - if dD < dDopt + GEO.EPS_SMALL then + dD = min( abs( vtMin:getZ()) * dCoeffZ, dD) + dD = min( abs( vtMax:getZ()) * dCoeffZ, dD) + local dZ = abs( EgtIf( bDown, vtMin:getZ(), vtMax:getZ())) * dCoeffZ + if dD < dDopt + 10 and dZ < dZopt + GEO.EPS_SMALL then + dUopt = dU + dDopt = min( dD, dDopt) + dZopt = dZ + elseif dD < dDopt - 10 or ( dD < dDopt + GEO.EPS_SMALL and dZ < dZopt + GEO.EPS_SMALL) then dDopt = dD dUopt = dU + dZopt = dZ end end end diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 926e5b2..555e551 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -356,7 +356,7 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead) end end local bH2, sOrigType = EndsWith( sType, '_H2') - if ( not BEAM or not BEAM.BW) and MachineHeadUse == TWO_UP_DOWN_HEADS and bH2 and bTopHead then + 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 end diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 6e58fa1..2ecc723 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -382,7 +382,7 @@ local function VerifyBHSideMill( Proc, bIsU, bIsL, bSinglePart, bPrevBhSideMill) -- le facce devono contenere X e quelle di chiusura devono essere perpendicolari a X local bStopY, bStopZ for i = 1, Proc.Fct do - local _, vtN = EgtSurfTmFacetCenter( Proc.Id, i-1, GDB_ID.ROOT) + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i-1, GDB_ID.ROOT) if abs( vtN:getX()) > 0.001 and abs( vtN:getX()) < 0.999962 then return false end @@ -412,20 +412,35 @@ local function VerifyBHSideMill( Proc, bIsU, bIsL, bSinglePart, bPrevBhSideMill) -- recupero i dati dell'utensile local dToolLength = 0 local dToolDiam = 0 - local dMaxDepth = 0 - local dThickTool = 0 + local dToolMaxDepth = 0 + local dToolThick = 0 + local dToolFreeLen = 0 if EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dToolLength = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dToolLength dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth - dThickTool = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dThickTool + local dToolThDiam = EgtTdbGetCurrToolThDiam() or 150 + if ( EgtTdbGetCurrToolParam( MCH_TP.TYPE) & MCH_TF.SAWBLADE) ~= 0 then + dToolMaxDepth = EgtTdbGetCurrToolMaxDepth() or dToolMaxDepth + dToolThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dToolThick + dToolFreeLen = dToolLength + else + dToolMaxDepth = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 0.5 * ( dToolDiam - dToolThDiam) + dToolThick = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) + dToolFreeLen = EgtTdbGetCurrToolMaxDepth() or dToolFreeLen + end end end -- verifico se abbastanza larga (oppure L) rispetto all'utensile - if Proc.Box:getDimX() < dThickTool - 15 * GEO.EPS_SMALL and not bIsL then + if Proc.Box:getDimX() < dToolThick - 15 * GEO.EPS_SMALL and not bIsL then + return false + end + + -- limiti trasversali + local dDepth = min( Proc.Box:getDimY(), Proc.Box:getDimZ()) + if dDepth > dToolMaxDepth then return false end @@ -440,14 +455,14 @@ local function VerifyBHSideMill( Proc, bIsU, bIsL, bSinglePart, bPrevBhSideMill) local bHead = bHeadDir -- verifico se raggiungibile con la testa senza collisioni - local bUseBHSideMill = EgtIf( bHead, ( dMaxT - dMinXF), ( dMaxXF - dMinT)) < dMaxDepth + local bUseBHSideMill = EgtIf( bHead, ( dMaxT - dMinXF), ( dMaxXF - dMinT)) < dToolFreeLen -- se diametro utensile maggiore della testa - if BD.HEAD_DIM_FOR_BH and dToolDiam > BD.HEAD_DIM_FOR_BH then + if BD.HEAD_DIM_FOR_BH and dToolDiam - 2 * dDepth > BD.HEAD_DIM_FOR_BH then bHead = true bUseBHSideMill = true end - return bUseBHSideMill, bHead, bHeadDir, sMilling, dThickTool, dToolDiam + return bUseBHSideMill, bHead, bHeadDir, sMilling, dToolThick, dToolDiam end --------------------------------------------------------------------- @@ -557,6 +572,29 @@ local function CalcCollisionSafety( vtDir) return dCollSic end +--------------------------------------------------------------------- +local function UpdateEncumbrance( Proc, nRawId, b3Raw, b3Solid) + -- verifico siano una o due facce + if Proc.Fct > 2 then return end + -- eventuale segnalazione ingombro di testa o coda + local dMinHIng = min( 0.5 * BD.VICE_MINH, 0.5 * b3Raw:getDimZ()) + if Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < b3Raw:getMin():getZ() + dMinHIng then + if Proc.Head then + local dOffs = b3Solid:getMax():getX() - Proc.Box:getMin():getX() + BL.UpdateHCING( nRawId, dOffs) + elseif Proc.Tail then + local dOffs = Proc.Box:getMax():getX() - b3Solid:getMin():getX() + BL.UpdateTCING( nRawId, dOffs) + elseif Proc.Fct > 1 and Proc.Box:getCenter():getX() > b3Solid:getCenter():getX() then + local dOffs = b3Solid:getMax():getX() - Proc.Box:getMin():getX() + local dDist = b3Solid:getMax():getX() - Proc.Box:getMax():getX() + -- sempre concavo aumento la distanza (rimane una punta...) + dDist = dDist + 10 + BL.UpdateHCING( nRawId, dOffs, dDist) + end + end +end + --------------------------------------------------------------------- -- Verifica se feature di testa function ProcessLapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH) @@ -863,16 +901,7 @@ local function MakeOneFaceByMill( Proc, nPhase, nRawId, nPartId) return false, sErr end -- eventuale segnalazione ingombro di testa o coda - local dMinHIng = min( 0.5 * BD.VICE_MINH, 0.5 * b3Raw:getDimZ()) - if Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < b3Raw:getMin():getZ() + dMinHIng then - if Proc.Head then - local dOffs = b3Solid:getMax():getX() - Proc.Box:getMin():getX() - BL.UpdateHCING( nRawId, dOffs) - elseif Proc.Tail then - local dOffs = Proc.Box:getMax():getX() - b3Solid:getMin():getX() - BL.UpdateTCING( nRawId, dOffs) - end - end + UpdateEncumbrance( Proc, nRawId, b3Raw, b3Solid) return true end @@ -1040,22 +1069,7 @@ local function MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId, bDownHead) return false, sErr end -- eventuale segnalazione ingombro di testa o coda - local dMinHIng = min( 0.5 * BD.VICE_MINH, 0.5 * b3Raw:getDimZ()) - if Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < b3Raw:getMin():getZ() + dMinHIng then - if Proc.Head then - local dOffs = b3Solid:getMax():getX() - Proc.Box:getMin():getX() - BL.UpdateHCING( nRawId, dOffs) - elseif Proc.Tail then - local dOffs = Proc.Box:getMax():getX() - b3Solid:getMin():getX() - BL.UpdateTCING( nRawId, dOffs) - elseif Proc.Box:getCenter():getX() > b3Solid:getCenter():getX() then - local dOffs = b3Solid:getMax():getX() - Proc.Box:getMin():getX() - local dDist = b3Solid:getMax():getX() - Proc.Box:getMax():getX() - -- sempre concavo aumento la distanza (rimane una punta...) - dDist = dDist + 10 - BL.UpdateHCING( nRawId, dOffs, dDist) - end - end + UpdateEncumbrance( Proc, nRawId, b3Raw, b3Solid) return true end @@ -2664,7 +2678,6 @@ local function MakeByMillAsSaw( Proc, nPhase, nRawId, nPartId, nFacInd, return false, sErr end end - if bOrthoFaces then -- ottengo le dimensioni del tunnel local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc, nPartId) @@ -4531,6 +4544,14 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa if bMakeBySideMill then -- se smusso non è esclusivo if nChamfer < 2 then + -- verifico che la faccia non sia diretta come X, altrimenti cerco di cambiarla + if abs( vtN:getX()) > 0.866 and nFacInd2 then + local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd2, GDB_ID.ROOT) + if vtN2 and abs( vtN2:getX()) < 0.866 then + nFacInd, nFacInd2 = nFacInd2, nFacInd + vtN, vtN2 = vtN2, vtN + end + end -- se lavorazione da sotto e lunga, va divisa in due metà local bDouble = ( vtN:getZ() < -0.5 and dH > ( BD.MAX_LEN_BH_FROM_BOTTOM or 200)) -- inserisco la lavorazione di fresatura @@ -4573,7 +4594,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0) EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.PERP_TG) EgtSetMachiningParam( MCH_MP.LOTANG, -( dToolDiam / 2 + b3Raw:getDimY() + BD.CUT_SIC)) - EgtSetMachiningParam( MCH_MP.LOPERP, dFacElev + BD.COLL_SIC) + EgtSetMachiningParam( MCH_MP.LOPERP, EgtIf( vtN:getZ() > -0.5, dFacElev + BD.COLL_SIC, BD.COLL_SIC)) if bDouble then EgtSetMachiningParam( MCH_MP.ENDADDLEN, - dH / 2) EgtSetMachiningParam( MCH_MP.LOTANG, -( dToolDiam / 2 + dH / 2 + BD.CUT_SIC)) @@ -5298,6 +5319,8 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa end end end + -- eventuale segnalazione ingombro di testa o coda + UpdateEncumbrance( Proc, nRawId, b3Raw, b3Solid) end return true, sWarn, bPrevBhSideMill diff --git a/LuaLibs/ProcessTenon.lua b/LuaLibs/ProcessTenon.lua index 38a360a..f752202 100644 --- a/LuaLibs/ProcessTenon.lua +++ b/LuaLibs/ProcessTenon.lua @@ -1,7 +1,8 @@ --- ProcessTenon.lua by Egaltech s.r.l. 2022/02/15 +-- ProcessTenon.lua by Egaltech s.r.l. 2022/05/18 -- Gestione calcolo tenone per Travi -- 2021/10/04 Corretto calcolo HCING per pezzi piccoli. -- 2022/02/15 Aggiornata VerifyOrientation per macchine con testa da sotto. +-- 2022/05/18 Migliorata gestione attacco. -- Tabella per definizione modulo local ProcessTenon = {} @@ -160,8 +161,6 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- abilitazione lavorazione da sotto local bMillUp = ( BD.DOWN_HEAD and vtExtr:getZ() > -0.259) local bMillDown = ( BD.DOWN_HEAD and vtExtr:getZ() < 0.1) - -- porto inizio curva il più possibile sul bordo - BL.PutStartNearestToEdge( AuxId, b3Solid, bMillDown and not bShortPart) -- se vero tenone inclinato o non esattamente alle estremità, necessario taglio di lama sulla testa if Proc.Prc ~= 52 and ( not AreSameOrOppositeVectorApprox( vtN, X_AX()) or @@ -234,7 +233,10 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- recupero la lavorazione local sMillType = 'Tenon' - local sMilling = ML.FindMilling( sMillType, dTenH, nil, nil, nil, bMillUp, bMillDown) or ML.FindMilling( sMillType, nil, nil, nil, bMillUp, bMillDown) + local sMilling, _, _, bH2 = ML.FindMilling( sMillType, dTenH, nil, nil, nil, bMillUp, bMillDown) + if not sMilling then + sMilling, _, _, bH2 = ML.FindMilling( sMillType, nil, nil, nil, nil, bMillUp, bMillDown) + end if not sMilling then local sErr = 'Error : milling not found in library' EgtOutLog( sErr) @@ -253,6 +255,9 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) bCW = ( dSpeed >= 0) end end + -- porto inizio curva il più possibile sul bordo + local bMyShortPart = ( bShortPart and abs( vtN:getX()) < 0.999) + BL.PutStartNearestToEdge( AuxId, b3Solid, bH2 ~= bMyShortPart) -- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente local sWarn local dDepth = 0