From 786b1224a2ef075d543bc39ee1033c09a15ca5b7 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 25 Jan 2021 08:18:54 +0000 Subject: [PATCH] DataBeam : - correzioni varie. --- LuaLibs/BeamExec.lua | 14 +++++++--- LuaLibs/DiceCut.lua | 15 +++++++---- LuaLibs/ProcessCut.lua | 7 ++--- LuaLibs/ProcessDrill.lua | 2 +- LuaLibs/ProcessLapJoint.lua | 52 ++++++++++++++++++++++-------------- LuaLibs/ProcessStepJoint.lua | 28 +++++++++---------- LuaLibs/ProcessTenon.lua | 16 ++++++----- 7 files changed, 80 insertions(+), 54 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 0477f19..e94b7ed 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,4 +1,4 @@ --- BeamExec.lua by Egaltech s.r.l. 2020/12/29 +-- BeamExec.lua by Egaltech s.r.l. 2021/01/21 -- 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. @@ -415,6 +415,7 @@ end ------------------------------------------------------------------------------------------------------------- local function OrderFeatures( vProc, b3Raw) + local dDrillPenalty = EgtIf( BD.PRESS_ROLLER, 200, 100) local dSmallDrillRange = EgtIf( b3Raw:getDimX() < BD.LEN_SHORT_PART, 200, 600) -- funzione di confronto @@ -479,11 +480,11 @@ local function OrderFeatures( vProc, b3Raw) end -- se primo è foro e l'altro no, lo penalizzo if B1.Prc == 40 and B2.Prc ~= 40 then - return B1.Box:getCenter():getX() - 100 > B2.Box:getMax():getX() + return B1.Box:getCenter():getX() - dDrillPenalty > B2.Box:getMax():getX() end -- se primo è altro e secondo è foro, lo premio if B1.Prc ~= 40 and B2.Prc == 40 then - return B1.Box:getMax():getX() + 100 > B2.Box:getCenter():getX() + return B1.Box:getMax():getX() + dDrillPenalty > B2.Box:getCenter():getX() end -- se entrambi fori con posizione praticamente uguale ordino secondo diametro e faccia di inizio (Fcs) if B1.Prc == 40 and B2.Prc == 40 and abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) < dSmallDrillRange then @@ -518,7 +519,12 @@ local function OrderFeatures( vProc, b3Raw) table.sort( vProc, CompareFeatures) -- riunisco fori con lo stesso diametro e non troppo lontani - local dDrillRange = EgtIf( BD.GO_FAST == 2, 6000, dSmallDrillRange) + local dDrillRange = dSmallDrillRange + if BD.GO_FAST == 2 then + dDrillRange = 6000 + elseif BD.PRESS_ROLLER then + dDrillRange = 2000 + end for i = 1, #vProc do local ProcI = vProc[i] if ProcI.Prc == 40 then diff --git a/LuaLibs/DiceCut.lua b/LuaLibs/DiceCut.lua index 1a44461..1b82beb 100644 --- a/LuaLibs/DiceCut.lua +++ b/LuaLibs/DiceCut.lua @@ -1,4 +1,4 @@ --- DiceCut.lua by Egaltech s.r.l. 2021/01/06 +-- DiceCut.lua by Egaltech s.r.l. 2021/01/21 -- Gestione dei piano paralleli nei tagli lunghi: equidistanziamento dei piani paralleli -- Tabella per definizione modulo @@ -37,7 +37,7 @@ local function GetParallelPlanes( nParent, BBoxRawPart, ptC, vtN, nCopyPlane, dO if dTolerance then ptMyCCut = Point3d( ptCCut + dTolerance * vtNCut) end - ptMyCCut = Point3d( ptCCut + dTolerance * vtNCut) + ptMyCCut = Point3d( ptCCut) end local ptMyCCut1 if ptCCut1 and vtNCut1 then @@ -48,13 +48,19 @@ local function GetParallelPlanes( nParent, BBoxRawPart, ptC, vtN, nCopyPlane, dO while i < nStep do local SurfId = EgtSurfTmPlaneInBBox( nParent, ptC + ( i * dOffset) * vtN, vtN, BBoxRawPart, GDB_RT.GLOB) local nFacet = EgtSurfTmFacetCount( SurfId or GDB_ID.NULL) + if nFacet == 0 then + -- se sono al primo taglio do una possibilità in più di girare + if i > nCopyPlane then + break + end + end if nFacet > 0 and vtNCut and ptMyCCut and EgtSurfArea(SurfId) > AreaMin then if i == nCopyPlane and bNoTolOnFirstCut then EgtCutSurfTmPlane( SurfId, ptCCut, -vtNCut, false, GDB_RT.GLOB) else EgtCutSurfTmPlane( SurfId, ptMyCCut, -vtNCut, false, GDB_RT.GLOB) end - nFacet = EgtSurfTmFacetCount( SurfId) + nFacet = EgtSurfTmFacetCount( SurfId) end if nFacet > 0 and vtNCut1 and ptMyCCut1 and EgtSurfArea(SurfId) > AreaMin then if i == nCopyPlane and bNoTolOnFirstCut then @@ -62,14 +68,13 @@ local function GetParallelPlanes( nParent, BBoxRawPart, ptC, vtN, nCopyPlane, dO else EgtCutSurfTmPlane( SurfId, ptMyCCut1, -vtNCut1, false, GDB_RT.GLOB) end - nFacet = EgtSurfTmFacetCount( SurfId) + nFacet = EgtSurfTmFacetCount( SurfId) end if nFacet > 0 and EgtSurfArea(SurfId) > AreaMin then table.insert( TabellaTmSurfParallel, SurfId) EgtSetColor( SurfId, Color) else EgtErase( SurfId) - break end if dOffset == 0 then break diff --git a/LuaLibs/ProcessCut.lua b/LuaLibs/ProcessCut.lua index 23fb214..8f574b3 100644 --- a/LuaLibs/ProcessCut.lua +++ b/LuaLibs/ProcessCut.lua @@ -1,4 +1,4 @@ --- ProcessCut.lua by Egaltech s.r.l. 2021/01/15 +-- ProcessCut.lua by Egaltech s.r.l. 2021/01/20 -- Gestione calcolo singoli tagli di lama per Travi -- Tabella per definizione modulo @@ -192,6 +192,7 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, -- dati geometrici del taglio local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) local bDownCut = ( vtN:getZ() <= dNzLimDwnUp) + if bFromBottom == nil then bFromBottom = ( b3Solid:getDimX() < BD.LEN_SHORT_PART and vtN:getZ() > 0.25) end local bFillAreaPiece local bFillTail -- se taglio di testa @@ -470,9 +471,9 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, return bOk, sErr end end - -- eventuale segnalazione ingombro di testa o coda + -- eventuale segnalazione ingombro di testa o coda (se non chiamata da altre feature) 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 ProcessCut.Identify( Proc) and Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < b3Raw:getMin():getZ() + dMinHIng then if Proc.Head then local dOffs = b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX() if vtN:getZ() > 0.5 then diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index 33eab90..debc013 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -205,7 +205,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) dCheckDepth2 = nil end -- abilitazione foratura da sotto - local bDrillDown = ( BD.DOWN_HEAD and ( Proc.Down or vtExtr:getZ() < 0.1 or EgtExistsInfo( Proc.Id, 'MAIN')) and not EgtExistsInfo( Proc.Id, 'DOU')) + local bDrillDown = ( BD.DOWN_HEAD and ( Proc.Down or vtExtr:getZ() < -0.1 or vtExtr:getY() > 0 or EgtExistsInfo( Proc.Id, 'MAIN')) and not EgtExistsInfo( Proc.Id, 'DOU')) -- primo gruppo di controlli con lunghezza utensile calcolata -- recupero la lavorazione local sDrilling, nType, dMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dToolFreeLen = ML.FindDrilling( dDiam, dCheckDepth, bDrillDown) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index fc6af69..ff09f91 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,6 +1,7 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2021/01/13 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2021/01/24 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. +-- 2021/01/24 Con sega a catena ora sempre impostato asse A. -- Tabella per definizione modulo local ProcessLapJoint = {} @@ -2067,12 +2068,8 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, if bGoFromHead then -- Calcolo uso faccia local nFaceUse = BL.GetNearestParalOpposite( rfFac:getVersZ()) - -- Calcolo angolo 3° asse rot (da direz. utensile) + -- Calcolo normale faccia adiacente local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacAdj, GDB_ID.ROOT) - local ptP1, ptP2 = EgtSurfTmFacetOppositeSide( Proc.Id, nFacAdj, rfFac:getVersZ(), GDB_ID.ROOT) - local vtT = vtN ^ (ptP2 - ptP1) - vtT:normalize() - local d3RotAng = EgtIf( abs( vtT:getZ()) < 0.1, 0, 90) -- Verifico se necessarie più passate local nStep = ceil( ( dV - 10 * GEO.EPS_SMALL) / dSawThick) local dStep = 0 @@ -2116,7 +2113,7 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, EgtSetMachiningParam( MCH_MP.ENDADDLEN, EgtIf( bOpenEnd, 0, - dSawWidth / 2)) end -- imposto angolo 3° asse rot - EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, 'A=' .. EgtNumToString( d3RotAng)) + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, 'A=90') -- imposto offset radiale local dOffs = ( i - 1) * dStep EgtSetMachiningParam( MCH_MP.OFFSR, dOffs) @@ -2132,10 +2129,14 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) -- eseguo if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr - elseif EgtIsMachiningEmpty() then + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, 'A=0') + if not EgtApplyMachining( 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 @@ -2179,6 +2180,7 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, --else -- EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_RIGHT) end + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, 'A=90') -- imposto offset radiale local dOffs = ( i - 1) * dStep EgtSetMachiningParam( MCH_MP.OFFSR, dOffs) @@ -2196,10 +2198,14 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, end -- eseguo if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr - elseif EgtIsMachiningEmpty() then + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, 'A=0') + if not EgtApplyMachining( 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 @@ -3070,6 +3076,8 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa else EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_BACK) end + -- imposto angolo 3° asse rot + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, 'A=90') -- imposto offset radiale local dOffs = ( i - 1) * dStep EgtSetMachiningParam( MCH_MP.OFFSR, dOffs) @@ -3084,10 +3092,14 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa end -- eseguo if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr - elseif EgtIsMachiningEmpty() then + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, 'A=0') + if not EgtApplyMachining( 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 @@ -3383,7 +3395,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa end --EgtOutLog( 'Mortise Find Diam =' .. EgtNumToString( dDiam)) local sPocketing - if BD.DOWN_HEAD and vtN:getZ() < -BD.NZ_MINA then sMchFind = sMchFind .. '_H2' end + if BD.DOWN_HEAD and sMchFind and vtN:getZ() < -BD.NZ_MINA then sMchFind = sMchFind .. '_H2' end if nUseRoughTool == 1 then sMyPocketing, dMyTDiam, dMyTMaxDepth = ML.FindPocketing( sMchFind, dDiam) if sMyPocketing and dMyTMaxDepth > 0.8 * dFacElev + dCollSic then diff --git a/LuaLibs/ProcessStepJoint.lua b/LuaLibs/ProcessStepJoint.lua index e32a803..1116579 100644 --- a/LuaLibs/ProcessStepJoint.lua +++ b/LuaLibs/ProcessStepJoint.lua @@ -1,4 +1,4 @@ --- ProcessStepJoint.lua by Egaltech s.r.l. 2020/12/02 +-- ProcessStepJoint.lua by Egaltech s.r.l. 2021/01/23 -- Gestione calcolo giunto a gradino per Travi -- Tabella per definizione modulo @@ -157,7 +157,7 @@ local function MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) -- normale media per capire se taglio di testa o di coda local vtNm = ( vtN[1] + vtN[2]) ; vtNm:normalize() local bHead = ( vtNm:getX() > 0) - -- angolo diedro per stabilire se taglio convesso + -- angolo diedro per stabilire se taglio convesso (due facce separate sono sicuramente convesse) local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) local bConvex = true local bOnY = true @@ -168,18 +168,6 @@ local function MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) ptPs = ( ptP1 + ptP2) / 2 bConvex = ( dAng > 0) end - -- calcolo direzione di lavoro - local vtRef = {} - local vtTg = ptP2 - ptP1 ; - vtRef[1] = vtN[1] ^ vtTg - if vtRef[1] * vtN[2] < 0 then vtRef[1] = - vtRef[1] end - vtRef[2] = vtN[2] ^ vtTg - if vtRef[2] * vtN[1] < 0 then vtRef[2] = - vtRef[2] end - -- determino quale faccia è più grande - local _, dB1, dH1 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 0) - local _, dB2, dH2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 1) - local nBigInd = EgtIf( dB1 * dH1 >= dB2 * dH2, 1, 2) - local nSmaInd = 3 - nBigInd -- recupero la lavorazione local sCutting = ML.FindCutting( EgtIf( bHead, 'HeadSide', 'TailSide')) if not sCutting then @@ -235,6 +223,18 @@ local function MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- altrimenti concavo else + -- calcolo direzione di lavoro + local vtRef = {} + local vtTg = ptP2 - ptP1 ; + vtRef[1] = vtN[1] ^ vtTg + if vtRef[1] * vtN[2] < 0 then vtRef[1] = - vtRef[1] end + vtRef[2] = vtN[2] ^ vtTg + if vtRef[2] * vtN[1] < 0 then vtRef[2] = - vtRef[2] end + -- determino quale faccia è più grande + local _, dB1, dH1 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 0) + local _, dB2, dH2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 1) + local nBigInd = EgtIf( dB1 * dH1 >= dB2 * dH2, 1, 2) + local nSmaInd = 3 - nBigInd -- calcolo extra taglio local dCutExtra = dExtraUp if dAng < -90.5 and dAng > -179.5 then diff --git a/LuaLibs/ProcessTenon.lua b/LuaLibs/ProcessTenon.lua index f65c0ec..c8612eb 100644 --- a/LuaLibs/ProcessTenon.lua +++ b/LuaLibs/ProcessTenon.lua @@ -1,4 +1,4 @@ --- ProcessTenon.lua by Egaltech s.r.l. 2020/12/30 +-- ProcessTenon.lua by Egaltech s.r.l. 2021/01/20 -- Gestione calcolo tenone per Travi -- Tabella per definizione modulo @@ -119,6 +119,7 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) EgtOutLog( sErr) return false, sErr end + local bShortPart = ( b3Solid:getDimX() < BD.LEN_SHORT_PART) -- recupero e verifico l'entità curva local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') if AuxId then AuxId = AuxId + Proc.Id end @@ -153,7 +154,7 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- abilitazione lavorazione da sotto local bMillDown = ( BD.DOWN_HEAD and vtExtr:getZ() < 0.1) -- porto inizio curva il più possibile sul bordo - BL.PutStartNearestToEdge( AuxId, b3Solid, bMillDown) + 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 @@ -171,8 +172,8 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if AddId then EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) EgtSetInfo( AddId, 'TASKID', Proc.TaskId) - -- se pezzo piccolo, in coda e piano inclinato attorno a Z applico svuotatura - if b3Solid:getDimX() < BD.LEN_SHORT_PART and vtExtr:getX() < 0 and abs( vtExtr:getX()) < 0.985 then + -- se pezzo piccolo, in coda, con piano inclinato verso il basso e macchina con testa da sotto applico svuotatura + if bShortPart and vtExtr:getX() < 0 and vtExtr:getZ() < -0.09 and BD.DOWN_HEAD then local sPockType = EgtIf( bMillDown, 'OpenPocket_H2', 'OpenPocket') local sPocketing = ML.FindPocketing( sPockType) local dMaxDepth = 100 @@ -218,7 +219,7 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local b3Cut = EgtGetBBoxGlob( AddId or GDB_ID.NULL, GDB_BB.STANDARD) local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = b3Cut, Fct = 1, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} - local bFromBottom = ( b3Solid:getDimX() < BD.LEN_SHORT_PART and vtExtr:getZ() > 0.25) + local bFromBottom = ( bShortPart and vtExtr:getZ() > 0.25) local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom) if not bOk then return bOk, sErr end end @@ -307,8 +308,9 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if abs( vtN:getY()) < 0.1 and vtN:getZ() > 0.5 then dOffs = 0.5 * dOffs end - if b3Solid:getDimX() < BD.LEN_SHORT_PART and b3Raw:getDimZ() < BD.VICE_MINH and abs( vtN:getZ()) > 0.575 then - dOffs = 0.2 * dOffs + if bShortPart and b3Raw:getDimZ() < BD.VICE_MINH and abs( vtN:getZ()) > 0.575 then + local b3Base = EgtSurfTmGetFacetBBoxGlob( Proc.Id, 0, GDB_BB.STANDARD) + dOffs = dOffs - 0.825 * b3Base:getDimX() end BL.UpdateHCING( nRawId, dOffs) elseif Proc.Tail then