diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index b0fc5de..8bc2617 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,4 +1,4 @@ --- BeamExec.lua by Egaltech s.r.l. 2021/02/25 +-- BeamExec.lua by Egaltech s.r.l. 2021/03/14 -- 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. @@ -397,6 +397,15 @@ local function CollectFeatures( PartId, b3Raw, dCurrOvmH) Proc2.TaskId = Proc.TaskId table.insert( vProc, Proc2) end + -- se BlockHaus HalfLap + elseif Proc.Prc == 37 then + local nFacInd = BL.GetFaceWithMostAdj( Proc.Id, PartId) + if nFacInd then + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT) + if vtN then + Proc.vtN = Vector3d( vtN) + end + end end else Proc.Head = false @@ -579,6 +588,41 @@ local function OrderFeatures( vProc, b3Raw) end end end + -- ordino BlockHaus HalfLap vicini (davanti, sotto, dietro, sopra) + local dBHHLRange = 100 + for i = 1, #vProc do + local ProcI = vProc[i] + if ProcI.Prc == 37 then + for j = i + 1, #vProc do + local ProcJ = vProc[j] + if ProcJ.Prc == 37 and abs( ProcI.Box:getCenter():getX() - ProcJ.Box:getCenter():getX()) < dBHHLRange then + if ProcI.HeadDir then + if ProcJ.vtN:getY() < -0.5 then + table.insert( vProc, i, table.remove( vProc, j)) + break + elseif ProcJ.vtN:getZ() < -0.5 and ProcI.vtN:getY() > -0.5 then + table.insert( vProc, i, table.remove( vProc, j)) + ProcI = vProc[i] + elseif ProcJ.vtN:getY() > 0.5 and ProcI.vtN:getY() > -0.5 and ProcI.vtN:getZ() > -0.5 then + table.insert( vProc, i, table.remove( vProc, j)) + ProcI = vProc[i] + end + else + if ProcJ.vtN:getY() > 0.5 then + table.insert( vProc, i, table.remove( vProc, j)) + break + elseif ProcJ.vtN:getZ() < -0.5 and ProcI.vtN:getY() < 0.5 then + table.insert( vProc, i, table.remove( vProc, j)) + ProcI = vProc[i] + elseif ProcJ.vtN:getY() < -0.5 and ProcI.vtN:getY() < 0.5 and ProcI.vtN:getZ() > -0.5 then + table.insert( vProc, i, table.remove( vProc, j)) + ProcI = vProc[i] + end + end + end + end + end + end end ------------------------------------------------------------------------------------------------------------- @@ -758,6 +802,11 @@ local function PrintFeatures( vProc, b3Raw) Proc.Id, Proc.Grp, Proc.Prc, Proc.TaskId, Proc.CutId, Proc.Flg, EgtIf( Proc.Down, 'T', 'F'), EgtIf( Proc.Side, 'T', 'F'), EgtIf( Proc.Head, 'T', 'F'), EgtIf( Proc.Tail, 'T', 'F'), Proc.Fcs, Proc.Fce, Proc.Diam, Proc.Fct, tostring( Proc.Box)) + -- info speciali per Block Haus Half Lap + if Proc.Prc == 37 then + local sSpec = string.format( ' N=%s Hd=%s', tostring( Proc.vtN or V_NULL()), EgtIf( Proc.HeadDir, 'T', 'F')) + sOut = sOut .. sSpec + end EgtOutLog( sOut) end end @@ -775,7 +824,7 @@ local function AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, bN -- se separazione ( 2-350-X ) elseif Split.Identify( Proc) then -- esecuzione separazione o eliminazione grezzo residuo - bOk, _, sErr = Split.Make( Proc, nPhase, nRawId, nPartId) + bOk, sErr = Split.Make( Proc, nPhase, nRawId, nPartId) -- richiedo il passaggio alla seconda fase di lavorazione di questa trave bNewPhase = true -- se taglio ( 1/2-010-X) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 6147c2e..33d0122 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2021/03/04 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2021/03/16 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. -- 2021/01/24 Con sega a catena ora sempre impostato asse A. @@ -261,9 +261,11 @@ end local function VerifyIfByBHSideMill( Proc) local bUseBHSideMill = false local bHead = true + local bHeadDir = true local sMilling local dMaxMat = 10 - -- se non feature BlockHausHalfLap e non abilitato parametro Q per lavorarlo di fianco esco + local dToolDiam = 0 + -- se non feature BlockHausHalfLap o non abilitato parametro Q per lavorarlo di fianco esco local nUseSideTool = EgtGetInfo( Proc.Id, Q_SIDE_ROUGH_TOOL, 'i') or 0 if Proc.Prc ~= 37 and nUseSideTool == 0 then return false @@ -282,6 +284,7 @@ local function VerifyIfByBHSideMill( Proc) 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 dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat end @@ -295,14 +298,20 @@ local function VerifyIfByBHSideMill( Proc) local dMaxXF = Proc.Box:getMax():getX() local dMinT = b3Solid:getMin():getX() local dMaxT = b3Solid:getMax():getX() - -- determino se è più vicino alla testa o al bordo - bHead = ( dMaxT - dMinXF) < ( dMaxXF - dMinT) + -- determino se è più vicino alla testa o al bordo (con offset per evitare problemi a metà) + bHeadDir = ( dMaxT - dMinXF) < ( dMaxXF - dMinT) + 50 + bHead = bHeadDir -- determino se è compatibile con il massimo affondamento dell'utensile - bUseBHSideMill = EgtIf( bHead, (dMaxT - dMinXF), (dMaxXF - dMinT)) < dMaxDepth + bUseBHSideMill = EgtIf( bHead, ( dMaxT - dMinXF), ( dMaxXF - dMinT)) < dMaxDepth + -- se diametro maggiore della testa + if BD.HEAD_DIM_FOR_BH and dToolDiam > BD.HEAD_DIM_FOR_BH then + bHead = true + bUseBHSideMill = true + end end end end - return bUseBHSideMill, bHead, sMilling, dMaxMat + return bUseBHSideMill, bHead, bHeadDir, sMilling, dMaxMat, dToolDiam end --------------------------------------------------------------------- @@ -468,8 +477,9 @@ function ProcessLapJoint.IsTailFeature( Proc, b3Raw) -- in base al tipo di feature attribuisco il significato dei parametri Q AssignQIdent( Proc) -- se può essere fatto con utensile tipo lama - local bUseBHSideMill, bHead = VerifyIfByBHSideMill( Proc) + local bUseBHSideMill, bHead, bHeadDir = VerifyIfByBHSideMill( Proc) if bUseBHSideMill then + Proc.HeadDir = bHeadDir return not bHead end -- verifico se è in coda @@ -601,7 +611,7 @@ function ProcessLapJoint.Classify( Proc, b3Raw) else local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) -- se può essere fatto con utensile tipo lama - local bUseBHSideMill, _, _, dMaxMat = VerifyIfByBHSideMill( Proc) + local bUseBHSideMill, _, _, _, dMaxMat = VerifyIfByBHSideMill( Proc) if bUseBHSideMill and ( dMaxMat <= dV + 15 * GEO.EPS_SMALL) then return true, false -- altrimenti controllo se deve essere ruotato con le altre lavorazioni @@ -3143,10 +3153,21 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa -- verifico se due facce o L con una o due facce di terminazione local bIsL = ( Proc.Fct == 2 or TestElleShape3( Proc) or TestElleShape4( Proc) == 2) -- se fattibile con fresa BH di fianco e spessore utensile inferiore alla larghezza faccia - local bMakeBySideMill, bHead, sMilling, dMaxMat = VerifyIfByBHSideMill( Proc) + local bMakeBySideMill, bHead, bHeadDir, sMilling, dMaxMat, dToolDiam = VerifyIfByBHSideMill( Proc) if bMakeBySideMill and ( dMaxMat <= dV + 15 * GEO.EPS_SMALL) then -- se smusso non è esclusivo if nChamfer < 2 then + -- recupero la larghezza della faccia perpendicolarmente alle altre 2 + local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, EgtIf( nFacInd == 0, 1, 0), GDB_ID.ROOT) + local vtX = vtN2 ^ vtN + local frRef = Frame3d( ptC, ptC + 100 * vtX, ptC + 100 * vtN2) + local b3Ref = EgtSurfTmGetFacetBBoxRef( Proc.Id, nFacInd, GDB_BB.STANDARD, frRef) + if b3Ref then + dV = b3Ref:getDimY() + dH = b3Ref:getDimX() + 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 local sName = 'BHMill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchFId = EgtAddMachining( sName, sMilling) @@ -3155,26 +3176,71 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa EgtOutLog( sErr) return false, sErr end + sName = EgtGetName( nMchFId) -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, nFacInd}}) -- imposto uso del lato faccia - EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( bHead, MCH_MILL_FU.PARAL_LEFT, MCH_MILL_FU.PARAL_RIGHT)) + EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( bHeadDir, MCH_MILL_FU.PARAL_LEFT, MCH_MILL_FU.PARAL_RIGHT)) -- calcolo step effettivo ed elevazione local dVcalc = dV - dMaxMat local dStep = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) or dMaxMat local nStep = ceil( dVcalc / dStep) - dStep = dVcalc / nStep + if vtN:getZ() < - 0.5 and ( nStep % 2) == 0 then + nStep = nStep + 1 + end + dStep = dVcalc / nStep + 0.1 EgtSetMachiningParam( MCH_MP.STEP, dStep) -- imposto elevazione e dichiaro non si generano sfridi per VMill local sNotes = 'MaxElev=' .. EgtNumToString( dVcalc + dStep, 2) .. ';' sNotes = sNotes .. 'VMRS=0;' EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) + -- attacchi e uscite + if vtN:getZ() > -0.5 then + EgtSetMachiningParam( MCH_MP.LITANG, 0) + EgtSetMachiningParam( MCH_MP.LIPERP, dFacElev + BD.CUT_SIC) + else + EgtSetMachiningParam( MCH_MP.LITANG, dToolDiam / 2 + BD.CUT_SIC) + EgtSetMachiningParam( MCH_MP.LIPERP, 0) + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.LINEAR) + EgtSetMachiningParam( MCH_MP.LOTANG, 0) + EgtSetMachiningParam( MCH_MP.LOPERP, dFacElev + BD.COLL_SIC) + if bDouble then + EgtSetMachiningParam( MCH_MP.ENDADDLEN, - dH / 2) + end + end + -- tipo passate multiple + local nStepType = EgtIf( ( Proc.HeadDir and vtN:getY() < -0.5) or ( not Proc.HeadDir and vtN:getY() > 0.5), MCH_MILL_ST.ONEWAY, MCH_MILL_ST.ZIGZAG) + EgtSetMachiningParam( MCH_MP.STEPTYPE, nStepType) + -- imposto posizione braccio porta testa + local nSCC = EgtIf( ( vtN:getY() > 0.5 or ( bHeadDir and vtN:getZ() > 0.5 ) or ( not bHeadDir and vtN:getZ() < -0.5)), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) + EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nMchFId, false) return false, sErr end + -- se divisa in due metà + if bDouble then + local nMchFNId = EgtCopyMachining( sName .. '_2', sName) + if not nMchFNId then + local sErr = 'Error copying machining ' .. sName + EgtOutLog( sErr) + return false, sErr + end + -- inverto direzione e lato di lavoro e direzione ausiliaria + local bInvert = EgtGetMachiningParam( MCH_MP.INVERT) + EgtSetMachiningParam( MCH_MP.INVERT, not bInvert) + local nWorkSide = EgtGetMachiningParam( MCH_MP.WORKSIDE) + EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( nWorkSide == MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT)) + EgtSetMachiningParam( MCH_MP.SCC, EgtIf( nSCC == MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM, MCH_SCC.ADIR_YP)) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFNId, false) + return false, sErr + end + end end -- altrimenti lavoro con svuotatura else diff --git a/LuaLibs/ProcessSplit.lua b/LuaLibs/ProcessSplit.lua index 9190319..0d9988f 100644 --- a/LuaLibs/ProcessSplit.lua +++ b/LuaLibs/ProcessSplit.lua @@ -1,4 +1,4 @@ --- ProcessSplit.lua by Egaltech s.r.l. 2021/03/02 +-- ProcessSplit.lua by Egaltech s.r.l. 2021/03/14 -- Gestione calcolo tagli di separazione per Travi -- Tabella per definizione modulo @@ -155,7 +155,7 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId) if not sCutting then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library' EgtOutLog( sErr) - return false, true, sErr + return false, sErr end -- recupero i dati dell'utensile local dSawDiam = 400 @@ -214,7 +214,7 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId) local dCutOffset = ( i - 1) * dOffsL local sNotes = EgtIf( bSplit, 'Presplit;', 'Precut;') local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_FRONT, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, sNotes, b3Raw) - if not bOk then return false, true, sErr end + if not bOk then return false, sErr end end end -- eseguo i tagli necessari @@ -227,13 +227,13 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId) sNotes = EgtIf( i == 1, 'Cut;', 'Precut;') end local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, sNotes, b3Raw) - if not bOk then return false, true, sErr end + if not bOk then return false, sErr end end -- altrimenti necessari tagli da sopra e sotto con testa opportuna else -- verifico di avere la testa da sotto if not BD.DOWN_HEAD then - local sErr = 'Error : section too big for head cut' + local sErr = 'Error : section too big for split cut' EgtOutLog( sErr) return false, sErr end @@ -271,7 +271,7 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId) local dCutOffset = ( i - 1) * dOffsL local sNotes = EgtIf( bSplit, 'Presplit;', 'Precut;') local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting2, dSawDiam2, MCH_MILL_FU.ORTHO_TOP, nil, dCutExtra2, BD.CUT_SIC, dCutOffset, dAccStart, sNotes, b3Raw) - if not bOk then return false, true, sErr end + if not bOk then return false, sErr end end -- eseguo i tagli necessari for i = nCuts, 1, -1 do @@ -283,11 +283,10 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId) sNotes = EgtIf( i == 1, 'Cut;', 'Precut;') end local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_DOWN, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, sNotes, b3Raw) - if not bOk then return false, true, sErr end + if not bOk then return false, sErr end end end - -- ritorno anche flag di passaggio a fase successiva - return true, true + return true end ---------------------------------------------------------------------