diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 25f266d..0c6af3f 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,7 +1,8 @@ --- BeamExec.lua by Egaltech s.r.l. 2019/09/04 +-- BeamExec.lua by Egaltech s.r.l. 2019/09/25 -- 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. +-- 2019/09/25 Aggiunta gestione StepJoint e StepJointNotch -- Tabella per definizione modulo local BeamExec = {} @@ -61,6 +62,10 @@ _G.package.loaded.ProcessText = nil local Text = require( 'ProcessText') _G.package.loaded.ProcessSimpleScarf = nil local Scarf = require( 'ProcessSimpleScarf') +_G.package.loaded.ProcessStepJoint = nil +local StepJoint = require( 'ProcessStepJoint') +_G.package.loaded.ProcessStepJointNotch = nil +local StJoNotch = require( 'ProcessStepJointNotch') _G.package.loaded.ProcessProfFront = nil local ProfFront = require( 'ProcessProfFront') _G.package.loaded.ProcessProfConcave = nil @@ -500,6 +505,12 @@ local function ClassifyFeatures( vProc, b3Raw, Stats) -- se giunto Gerber elseif Scarf.Identify( Proc) then bOk, bDown = Scarf.Classify( Proc) + -- se giunto a gradino + elseif StepJoint.Identify( Proc) then + bOk, bDown = StepJoint.Classify( Proc) + -- se tacca a gradino + elseif StJoNotch.Identify( Proc) then + bOk, bDown = StJoNotch.Classify( Proc) -- se arco elseif RoundArch.Identify( Proc) then bOk, bDown = RoundArch.Classify( Proc) @@ -643,6 +654,14 @@ local function AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3 elseif Scarf.Identify( Proc) then -- esecuzione giunto Gerber bOk, sErr = Scarf.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) + -- se giunto a gradino + elseif StepJoint.Identify( Proc) then + -- esecuzione giunto a gradino + bOk, sErr = StepJoint.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) + -- se tacca a gradino + elseif StJoNotch.Identify( Proc) then + -- esecuzione tacca a gradino + bOk, sErr = StJoNotch.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- se profilo Front ( 3/4-100-X) elseif ProfFront.Identify( Proc) then -- esecuzione profilo diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 66431ee..f611fa2 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -159,9 +159,9 @@ function BeamLib.PutStartNearestToEdge( nCrvId, b3Raw) end ------------------------------------------------------------------------------------------------------------- -function BeamLib.GetPointDirDepth( nRawId, ptP, vtDir) +function BeamLib.GetPointDirDepth( nPartId, ptP, vtDir) -- recupero il solido del grezzo - local nSolId = EgtGetFirstNameInGroup( nRawId, 'RawSolid') + local nSolId = EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, 'Box') if not nSolId then return end -- interseco con la retta local bOk, vType, vPar = EgtLineSurfTmInters( ptP, vtDir, nSolId, GDB_RT.GLOB) @@ -319,7 +319,7 @@ function BeamLib.GetBoxFaceNorm( b3Box, ptP, vtV) end --------------------------------------------------------------------- -function BeamLib.GetFaceWithMostAdj( nSurfId) +function BeamLib.GetFaceWithMostAdj( nSurfId, nPartId) -- recupero il numero di facce local nFacCnt = EgtSurfTmFacetCount( nSurfId) -- recupero le normali delle facce @@ -390,16 +390,23 @@ function BeamLib.GetFaceWithMostAdj( nSurfId) local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, nFacInd[i], GDB_ID.ROOT) local frOCS = Frame3d( ptC, vtN) ; local b3Box = EgtGetBBoxRef( nSurfId, GDB_BB.STANDARD, frOCS) - if b3Box:getDimZ() < dMinElev then + local dElev = b3Box:getDimZ() + if nPartId then + local _, dCenElev = BeamLib.GetPointDirDepth( nPartId, ptC, vtN) + if dCenElev and dCenElev > dElev then + dElev = dCenElev + end + end + if dElev < dMinElev then if dMinElev < dMinElev2 then nFacOpt2 = nFacOpt dMinElev2 = dMinElev end nFacOpt = nFacInd[i] - dMinElev = b3Box:getDimZ() - elseif b3Box:getDimZ() < dMinElev2 then + dMinElev = dElev + elseif dElev < dMinElev2 then nFacOpt2 = nFacInd[i] - dMinElev2 = b3Box:getDimZ() + dMinElev2 = dElev end end return nFacOpt, dMinElev, nFacOpt2, dMinElev2 diff --git a/LuaLibs/ProcessDoubleCut.lua b/LuaLibs/ProcessDoubleCut.lua index 5d3a1a6..6e3c9c9 100644 --- a/LuaLibs/ProcessDoubleCut.lua +++ b/LuaLibs/ProcessDoubleCut.lua @@ -1,4 +1,4 @@ --- ProcessDrill.lua by Egaltech s.r.l. 2019/09/17 +-- ProcessDoubleCut.lua by Egaltech s.r.l. 2019/09/25 -- Gestione calcolo doppi tagli di lama per Travi -- Tabella per definizione modulo @@ -31,8 +31,8 @@ function ProcessDoubleCut.Classify( Proc) -- se due facce, verifico se convesso local bConvex = true if nFacetCnt == 2 then - local _, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) - bConvex = ( dAng > 0) + local bAdj, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) + bConvex = not bAdj or ( dAng > 0) end -- verifico le normali delle facce for i = 1, nFacetCnt do @@ -66,16 +66,20 @@ function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local vtNm = ( vtN[1] + vtN[2]) ; vtNm:normalize() local bHead = ( vtNm:getX() > 0) -- angolo diedro per stabilire se taglio convesso - local _, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) - local vtDir = ptP1 - ptP2 ; vtDir:normalize() - local bOnY = abs( vtDir:getZ()) > 0.5 and ( abs( vtDir:getZ()) + abs( vtDir:getX()) > abs( vtDir:getY())) - local bConvex = ( dAng > 0) - local dLen = dist( ptP1, ptP2) - local ptPs = ( ptP1 + ptP2) / 2 + local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) + local bConvex = true + local bOnY = true + local ptPs = ( ptC[1] + ptC[2]) / 2 + if bAdj then + local vtDir = ptP1 - ptP2 ; vtDir:normalize() + bOnY = abs( vtDir:getZ()) > 0.5 and ( abs( vtDir:getZ()) + abs( vtDir:getX()) > abs( vtDir:getY())) + ptPs = ( ptP1 + ptP2) / 2 + bConvex = ( dAng > 0) + end -- determino quale faccia è più grande - local dSqDim1 = ( ptC[1] - ptPs):sqlen() - local dSqDim2 = ( ptC[2] - ptPs):sqlen() - local nBigInd = EgtIf( dSqDim1 >= dSqDim2, 1, 2) + 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')) @@ -153,7 +157,7 @@ function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) for i = 1, #vCuts do -- determino il modo di tagliare local k, l = nBigInd, nSmaInd - if ( i % 2 == 1) == ( not bConvex) then + if ( i % 2) == 1 then k, l = l, k end local nOrthoOpposite @@ -161,18 +165,8 @@ function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local bFront = ( ptC[k]:getY() < ptPs:getY()) nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT) else - if bConvex then - if dLen < dMaxDepth then - local bFront = ( vtN[k]:getY() < 0.02) - nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT) - else - local bOver = ( ptC[k]:getZ() > ptC[l]:getZ()) - nOrthoOpposite = EgtIf( bOver, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_TOP) - end - else - local bOver = ( ptC[k]:getZ() > ptC[l]:getZ()) - nOrthoOpposite = EgtIf( bOver, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_TOP) - end + local bOver = ( ptC[k]:getZ() > ptC[l]:getZ()) + nOrthoOpposite = EgtIf( bOver, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_TOP) end -- lavoro la faccia for j = 1, #vCuts[i] do diff --git a/LuaLibs/ProcessDtMortise.lua b/LuaLibs/ProcessDtMortise.lua index 2991d56..8fb91ea 100644 --- a/LuaLibs/ProcessDtMortise.lua +++ b/LuaLibs/ProcessDtMortise.lua @@ -1,4 +1,4 @@ --- ProcessMortise.lua by Egaltech s.r.l. 2019/08/07 +-- ProcessMortise.lua by Egaltech s.r.l. 2019/09/25 -- Gestione calcolo mortase a coda di rondice per Travi -- Tabella per definizione modulo @@ -64,13 +64,14 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId) return false, sErr end -- recupero il diametro dell'utensile - local dToolDiam = 50 + local dToolDiam = 10 if EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam end end + dToolDiam = max( dToolDiam, 10) -- verifico se necessarie più passate (distanza all'imbocco ortogonale all'asse) local vtDiff = EgtEP( AuxId, GDB_RT.GLOB) - EgtSP( AuxId, GDB_RT.GLOB) local vtAx = EgtEV( AuxId, GDB_RT.GLOB) - EgtSV( AuxId, GDB_RT.GLOB) diff --git a/LuaLibs/ProcessDtTenon.lua b/LuaLibs/ProcessDtTenon.lua index d8d2252..6debdac 100644 --- a/LuaLibs/ProcessDtTenon.lua +++ b/LuaLibs/ProcessDtTenon.lua @@ -1,4 +1,4 @@ --- ProcessTenon.lua by Egaltech s.r.l. 2019/07/16 +-- ProcessTenon.lua by Egaltech s.r.l. 2019/09/25 -- Gestione calcolo tenone a coda di rondine per Travi -- Tabella per definizione modulo @@ -29,8 +29,8 @@ function ProcessDtTenon.Classify( Proc) if not AuxId then return false end AuxId = AuxId + Proc.Id local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) - -- verifico se il tenone è lavorabile solo da sotto - local bDown = ( vtExtr:getZ() < - 0.26) + -- verifico se il tenone è lavorabile solo da sotto (-20 deg) + local bDown = ( vtExtr:getZ() < -0.35) return true, bDown end @@ -59,8 +59,8 @@ function ProcessDtTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local dDepth = abs( EgtCurveThickness( AuxId)) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) local ptBC = EgtGP( AuxId, GDB_RT.GLOB) - -- verifico che il tenone non sia orientato verso il basso (-15 deg) - if vtExtr:getZ() < - 0.26 then + -- verifico che il tenone non sia orientato verso il basso (-20 deg) + if vtExtr:getZ() < - 0.35 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' DtTenon from bottom impossible' EgtOutLog( sErr) return false, sErr diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 25e1c23..4a68d30 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2019/09/09 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2019/09/25 -- Gestione calcolo mezzo-legno per Travi -- Tabella per definizione modulo @@ -46,7 +46,8 @@ function ProcessLapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH) return true end -- deve avere la normale principale diretta verso la testa - local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id) + local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL) + local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId) local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) if vtN:getZ() < BD.NZ_MINA and nFacInd2 then ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) @@ -81,7 +82,8 @@ function ProcessLapJoint.IsTailFeature( Proc, b3Raw) return true end -- deve avere la normale principale diretta verso la coda - local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id) + local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL) + local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId) local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) if vtN:getZ() < BD.NZ_MINA and nFacInd2 then ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) @@ -122,7 +124,8 @@ function ProcessLapJoint.Classify( Proc) -- se più di 2 facce else -- recupero la faccia con il maggior numero di adiacenze e minor elevazione - local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id) + local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL) + local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId) if nFacInd < 0 then return false end @@ -484,7 +487,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) -- recupero l'ingombro del grezzo di appartenenza local b3Raw = EgtGetRawPartBBox( nRawId) -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa - local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id) + local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, nPartId) assert( ( nFacInd and nFacInd >= 0), 'Error : MakeMoreFaces could not find reference face') -- dati della faccia local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) @@ -510,7 +513,9 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) end end -- recupero la lavorazione - local sPocketing = ML.FindPocketing( 'Mortise', min( dH, dV)) + local dDiam = min( dH, dV) * EgtIf( Proc.Fct > 3, 1, 1.4) + EgtOutLog( 'Mortise Find Diam =' .. EgtNumToString( dDiam)) + local sPocketing = ML.FindPocketing( 'Mortise', dDiam) -- se non trova una svuotatura adatta, provo con la sega a catena o lama if not sPocketing then return MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev) diff --git a/LuaLibs/ProcessLongCut.lua b/LuaLibs/ProcessLongCut.lua index 253f8ea..63fddff 100644 --- a/LuaLibs/ProcessLongCut.lua +++ b/LuaLibs/ProcessLongCut.lua @@ -1,4 +1,4 @@ --- ProcessLongCut.lua by Egaltech s.r.l. 2019/07/25 +-- ProcessLongCut.lua by Egaltech s.r.l. 2019/09/25 -- Gestione calcolo taglio longitudinale per Travi -- Tabella per definizione modulo @@ -235,7 +235,10 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) -- imposto lato di lavoro e inversione EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) EgtSetMachiningParam( MCH_MP.INVERT, true) - local dDepth = min( dMaxDepth, dWidth + dAgg) + if dWidth + dAgg > dMaxDepth - BD.COLL_SIC then + sWarn = 'Warning in LongCut : depth (' .. EgtNumToString( dWidth + dAgg, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth - BD.COLL_SIC, 1) .. ')' + end + local dDepth = min( dMaxDepth - BD.COLL_SIC, dWidth + dAgg) EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) -- eseguo if not EgtApplyMachining( true, false) then diff --git a/LuaLibs/ProcessLongDoubleCut.lua b/LuaLibs/ProcessLongDoubleCut.lua index 49ee116..caa185e 100644 --- a/LuaLibs/ProcessLongDoubleCut.lua +++ b/LuaLibs/ProcessLongDoubleCut.lua @@ -263,7 +263,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) EgtSetMachiningParam( MCH_MP.INVERT, true) if vWidth[vOrd[i]] + dAgg > dMaxDepth - BD.COLL_SIC then - sWarn = 'Warning in double cut : depth (' .. EgtNumToString( vWidth[vOrd[i]] + dAgg, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth - BD.COLL_SIC, 1) .. ')' + sWarn = 'Warning in LongDoubleCut : depth (' .. EgtNumToString( vWidth[vOrd[i]] + dAgg, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth - BD.COLL_SIC, 1) .. ')' end local dDepth = min( dMaxDepth - BD.COLL_SIC, vWidth[vOrd[i]] + dAgg) EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) diff --git a/LuaLibs/ProcessMortise.lua b/LuaLibs/ProcessMortise.lua index 0a1b088..bb8f18e 100644 --- a/LuaLibs/ProcessMortise.lua +++ b/LuaLibs/ProcessMortise.lua @@ -67,7 +67,7 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId) local b3Mor = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frMor) local dMorH = b3Mor:getDimZ() -- elevazione del punto centro - local _, dCenElev = BL.GetPointDirDepth( nRawId, ptC, vtN) + local _, dCenElev = BL.GetPointDirDepth( nPartId, ptC, vtN) dMorH = max( dMorH, dCenElev or 0) -- recupero la lavorazione local sPocketing = ML.FindPocketing( 'Mortise', 30) diff --git a/LuaLibs/ProcessRidgeLap.lua b/LuaLibs/ProcessRidgeLap.lua index 26af5a9..5095c1d 100644 --- a/LuaLibs/ProcessRidgeLap.lua +++ b/LuaLibs/ProcessRidgeLap.lua @@ -1,4 +1,4 @@ --- ProcessRidgeLap.lua by Egaltech s.r.l. 2019/04/01 +-- ProcessRidgeLap.lua by Egaltech s.r.l. 2019/09/25 -- Gestione calcolo mezzolegno di testa per Travi -- Tabella per definizione modulo @@ -145,7 +145,7 @@ function ProcessRidgeLap.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- calcolo riferimenti per facce inclinate local vtRef = Vector3d( vtN[vFaceOrd[3]]) - local vtRef2 = Vector3d( vtN[vFaceOrd[2]]) + local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) -- eseguo for i = 1, #vCuts do local nOrthoOpposite @@ -173,7 +173,7 @@ function ProcessRidgeLap.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- taglio sulla faccia intermedia if vFaceOrd[3] ~= 0 then -- inserisco la lavorazione - local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtN[vFaceOrd[2]]) + local nOrthoOpposite = BL.GetNearestOrthoOpposite( EgtIf( bHead, X_AX(), -X_AX())) local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sErr end end diff --git a/LuaLibs/ProcessStepJoint.lua b/LuaLibs/ProcessStepJoint.lua new file mode 100644 index 0000000..cd4cf4f --- /dev/null +++ b/LuaLibs/ProcessStepJoint.lua @@ -0,0 +1,213 @@ +-- ProcessStepJoint.lua by Egaltech s.r.l. 2019/09/25 +-- Gestione calcolo giunto a gradino per Travi + +-- Tabella per definizione modulo +local ProcessStepJoint = {} + +-- Include +require( 'EgtBase') +local BL = require( 'BeamLib') +local DC = require( 'DiceCut') +local Cut = require( 'ProcessCut') +local Fbs = require( 'FacesBySaw') + +EgtOutLog( ' ProcessStepJoint started', 1) + +-- Dati +local BD = require( 'BeamData') +local ML = require( 'MachiningLib') + +--------------------------------------------------------------------- +-- Riconoscimento della feature +function ProcessStepJoint.Identify( Proc) + return ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 80) +end + +--------------------------------------------------------------------- +-- Classificazione della feature +function ProcessStepJoint.Classify( Proc) + -- numero delle facce + local nFacetCnt = EgtSurfTmFacetCount( Proc.Id) + -- gestisco solo 2 facce + if nFacetCnt ~= 2 then + return false, false + end + -- se due facce, verifico se convesso + local bConvex = true + if nFacetCnt == 2 then + local bAdj, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) + bConvex = not bAdj or ( dAng > 0) + end + -- verifico le normali delle facce + for i = 1, nFacetCnt do + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i-1, GDB_ID.ROOT) + if not bConvex and vtN:getZ() < - 0.72 then + return true, true + end + end + return true, false +end + +--------------------------------------------------------------------- +-- Applicazione della lavorazione +function ProcessStepJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) + -- ingombro del grezzo + local b3Raw = EgtGetRawPartBBox( nRawId) + -- ingombro del pezzo + local Ls = EgtGetFirstNameInGroup( nPartId, 'Box') + local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD) + if not b3Solid then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' part box not found' + EgtOutLog( sErr) + return false, sErr + end + -- dati delle facce + local ptC = {} + local vtN = {} + ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) + ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT) + -- 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 + local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) + local bConvex = true + local bOnY = true + local ptPs = ( ptC[1] + ptC[2]) / 2 + if bAdj then + local vtDir = ptP1 - ptP2 ; vtDir:normalize() + bOnY = abs( vtDir:getZ()) > 0.5 and ( abs( vtDir:getZ()) + abs( vtDir:getX()) > abs( vtDir:getY())) + ptPs = ( ptP1 + ptP2) / 2 + bConvex = ( dAng > 0) + 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 + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + local dSawDiam = 400 + local dMaxDepth = 0 + if EgtMdbSetCurrMachining( sCutting) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end + -- se convesso, lo tratto come due tagli singoli + if bConvex then + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end + -- lavoro per prima la faccia più diretta in alto + local vOrd = { 1, 2} + if vtN[2]:getZ() > vtN[1]:getZ() then + vOrd = { 2, 1} + end + -- creo piano di taglio coincidente con la prima faccia e lo lavoro + local AddId = EgtSurfTmPlaneInBBox( EgtGetParent( Proc.Id), ptC[vOrd[1]], vtN[vOrd[1]], b3Solid, GDB_RT.GLOB) + if AddId then + EgtRelocate( AddId, nAddGrpId) + EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) + -- applico lavorazione + local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg} + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + if not bOk then return bOk, sErr end + end + -- creo piano di taglio coincidente con la seconda faccia e lo lavoro + AddId = EgtSurfTmPlaneInBBox( EgtGetParent( Proc.Id), ptC[vOrd[2]], vtN[vOrd[2]], b3Solid, GDB_RT.GLOB) + if AddId then + EgtRelocate( AddId, nAddGrpId) + EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) + -- applico lavorazione + local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg} + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + if not bOk then return bOk, sErr end + end + -- altrimenti + else + -- verifico se necessari tagli supplementari + local vCuts = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC[nBigInd], vtN[nBigInd], false, ptC[nSmaInd], vtN[nSmaInd]) + --DC.PrintOrderCut( vCuts) + if #vCuts > 0 then + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end + -- sistemo posizione nel DB e nome + for i = 1, #vCuts do + for j = 1, #vCuts[i] do + EgtRelocateGlob( vCuts[i][j], nAddGrpId) + EgtSetName( vCuts[i][j], 'AddCut_' .. tostring( Proc.Id)) + EgtSetInfo( vCuts[i][j], 'TASKID', Proc.TaskId) + end + end + -- eseguo + for i = 1, #vCuts do + -- determino il modo di tagliare + local k, l = nBigInd, nSmaInd + if ( i % 2) == 1 then + k, l = l, k + end + local nOrthoOpposite + if bOnY then + local bFront = ( ptC[k]:getY() < ptPs:getY()) + nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT) + else + local bOver = ( ptC[k]:getZ() > ptC[l]:getZ()) + nOrthoOpposite = EgtIf( bOver, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_TOP) + end + -- lavoro la faccia + for j = 1, #vCuts[i] do + local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then + return bOk, sErr + end + end + end + -- altrimenti, tagli diretti delle facce + else + local bOk, sErr = Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, EgtIf( bHead, 'HeadSide', 'TailSide')) + if not bOk then + return bOk, sErr + end + end + end + -- eventuale segnalazione ingombro di testa o coda + if Proc.Head then + local dOffs = b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX() + if vtNm:getZ() > 0.5 then + dOffs = 0.5 * dOffs + elseif abs( vtNm:getZ()) > 0.35 then + dOffs = 0.75 * dOffs + end + BL.UpdateHCING( nRawId, dOffs) + elseif Proc.Tail then + local dOffs = Proc.Box:getMax():getX() - b3Solid:getMin():getX() + if vtNm:getZ() > 0.5 then + dOffs = 0.5 * dOffs + elseif abs( vtNm:getZ()) > 0.35 then + dOffs = 0.75 * dOffs + end + BL.UpdateTCING( nRawId, dOffs) + end + return true +end + +--------------------------------------------------------------------- +return ProcessStepJoint diff --git a/LuaLibs/ProcessStepJointNotch.lua b/LuaLibs/ProcessStepJointNotch.lua new file mode 100644 index 0000000..967bfee --- /dev/null +++ b/LuaLibs/ProcessStepJointNotch.lua @@ -0,0 +1,152 @@ +-- ProcessStepJointNotch.lua by Egaltech s.r.l. 2019/09/25 +-- Gestione calcolo tacca a gradino per Travi + +-- Tabella per definizione modulo +local ProcessStepJointNotch = {} + +-- Include +require( 'EgtBase') +local BL = require( 'BeamLib') +local DC = require( 'DiceCut') +local Cut = require( 'ProcessCut') +local Fbs = require( 'FacesBySaw') + +EgtOutLog( ' ProcessStepJointNotch started', 1) + +-- Dati +local BD = require( 'BeamData') +local ML = require( 'MachiningLib') + +--------------------------------------------------------------------- +-- Riconoscimento della feature +function ProcessStepJointNotch.Identify( Proc) + return ( ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 80) +end + +--------------------------------------------------------------------- +-- Classificazione della feature +function ProcessStepJointNotch.Classify( Proc) + -- numero delle facce + local nFacetCnt = EgtSurfTmFacetCount( Proc.Id) + -- gestisco solo 2 facce + if nFacetCnt ~= 2 then + return false, false + end + -- verifico le normali delle facce + local bDown = false + for i = 1, nFacetCnt do + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i-1, GDB_ID.ROOT) + if vtN:getZ() < -0.1 then + bDown = true + end + end + return true, bDown +end + +--------------------------------------------------------------------- +-- Applicazione della lavorazione +function ProcessStepJointNotch.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) + -- ingombro del grezzo + local b3Raw = EgtGetRawPartBBox( nRawId) + -- ingombro del pezzo + local Ls = EgtGetFirstNameInGroup( nPartId, 'Box') + local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD) + if not b3Solid then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' part box not found' + EgtOutLog( sErr) + return false, sErr + end + -- dati delle facce + local ptC = {} + local vtN = {} + ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) + ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT) + -- 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 + local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) + local bOnY = true + local ptPs = ( ptC[1] + ptC[2]) / 2 + if bAdj then + local vtDir = ptP1 - ptP2 ; vtDir:normalize() + bOnY = abs( vtDir:getZ()) > 0.5 and ( abs( vtDir:getZ()) + abs( vtDir:getX()) > abs( vtDir:getY())) + ptPs = ( ptP1 + ptP2) / 2 + bConvex = ( dAng > 0) + 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( 'HeadSide') + if not sCutting then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + local dSawDiam = 400 + local dMaxDepth = 0 + if EgtMdbSetCurrMachining( sCutting) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end + -- verifico se necessari tagli supplementari + local vCuts = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC[nBigInd], vtN[nBigInd], false, ptC[nSmaInd], vtN[nSmaInd]) + --DC.PrintOrderCut( vCuts) + if #vCuts > 0 then + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end + -- sistemo posizione nel DB e nome + for i = 1, #vCuts do + for j = 1, #vCuts[i] do + EgtRelocateGlob( vCuts[i][j], nAddGrpId) + EgtSetName( vCuts[i][j], 'AddCut_' .. tostring( Proc.Id)) + EgtSetInfo( vCuts[i][j], 'TASKID', Proc.TaskId) + end + end + -- eseguo + for i = 1, #vCuts do + -- determino il modo di tagliare + local k, l = nBigInd, nSmaInd + if ( i % 2) == 1 then + k, l = l, k + end + local nOrthoOpposite + if bOnY then + local bFront = ( ptC[k]:getY() < ptPs:getY()) + nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT) + else + local bOver = ( ptC[k]:getZ() > ptC[l]:getZ()) + nOrthoOpposite = EgtIf( bOver, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_TOP) + end + -- lavoro la faccia + for j = 1, #vCuts[i] do + local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then + return bOk, sErr + end + end + end + -- altrimenti, tagli diretti delle facce + else + local bOk, sErr = Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, 'HeadSide') + if not bOk then + return bOk, sErr + end + end + return true +end + +--------------------------------------------------------------------- +return ProcessStepJointNotch diff --git a/LuaLibs/ProcessTenon.lua b/LuaLibs/ProcessTenon.lua index cae9204..9a318d2 100644 --- a/LuaLibs/ProcessTenon.lua +++ b/LuaLibs/ProcessTenon.lua @@ -1,4 +1,4 @@ --- ProcessTenon.lua by Egaltech s.r.l. 2019/07/16 +-- ProcessTenon.lua by Egaltech s.r.l. 2019/09/25 -- Gestione calcolo tenone per Travi -- Tabella per definizione modulo @@ -30,8 +30,8 @@ function ProcessTenon.Classify( Proc) if not AuxId then return false end AuxId = AuxId + Proc.Id local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) - -- verifico se il tenone è lavorabile solo da sotto - local bDown = ( vtExtr:getZ() < - 0.26) + -- verifico se il tenone è lavorabile solo da sotto (-20 deg) + local bDown = ( vtExtr:getZ() < - 0.35) return true, bDown end @@ -60,8 +60,8 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) local ptBC = EgtGP( AuxId, GDB_RT.GLOB) local bClosed = EgtCurveIsClosed( AuxId) - -- verifico che il tenone non sia orientato verso il basso (-15 deg) - if vtExtr:getZ() < - 0.26 then + -- verifico che il tenone non sia orientato verso il basso (-20 deg) + if vtExtr:getZ() < - 0.35 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Tenon from bottom impossible' EgtOutLog( sErr) return false, sErr