diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index d6d1a00..7ebf422 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1,4 +1,4 @@ --- BeamLib.lua by Egaltech s.r.l. 2019/03/29 +-- BeamLib.lua by Egaltech s.r.l. 2019/04/13 -- Libreria globale per Travi -- Tabella per definizione modulo @@ -615,18 +615,16 @@ function BeamLib.MakeOneFaceBySaw( nSurfId, nFacet, sCutting, dSawDiam, nOrthoOp local bDownUp = ( vtN:getZ() < -0.5) local nFaceUse = nOrthoOpposite if bDownUp then nFaceUse = BeamLib.GetOrtupOpposite( nOrthoOpposite) end - local nWorkSide = EgtIf( ( bInvert ~= bDownUp), MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + local bWsRight = ( bInvert ~= bDownUp) + local nWorkSide = EgtIf( bWsRight, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) -- Versore di riferimento local vtRef = BeamLib.GetVersRef( nOrthoOpposite) vtRef = vtRef - vtRef * vtN * vtN ; vtRef:normalize() -- Versore esterno - local vtOut = vtN - if abs( vtOut:getZ()) > 0.866 then - vtOut = vtRef - vtRef * vtTg * vtTg ; vtOut:normalize() - end + local vtOut = vtRef - vtRef * vtTg * vtTg ; vtOut:normalize() -- Versore ausiliario (direzione braccio) local vtAux = Vector3d( vtN:getX(), vtN:getY(), 0) ; vtAux:normalize() - vtAux:rotate( Z_AX(), 90) + vtAux:rotate( Z_AX(), EgtIf( bWsRight, 90, - 90)) if vtAux:isSmall() then vtAux = Vector3d( vtOut:getX(), vtOut:getY(), 0) ; vtAux:normalize() else diff --git a/LuaLibs/DiceCut.lua b/LuaLibs/DiceCut.lua index bc46d3f..648f7e2 100644 --- a/LuaLibs/DiceCut.lua +++ b/LuaLibs/DiceCut.lua @@ -1,4 +1,4 @@ --- DiceCut.lua by Egaltech s.r.l. 2018/11/26 +-- DiceCut.lua by Egaltech s.r.l. 2019/04/13 -- Gestione dei piano paralleli nei tagli lunghi -- Tabella per definizione modulo @@ -131,7 +131,8 @@ local function GetOrtoCutCenter( FacetId, ptC, vtN, vtO, dOffsetEff) local dLen = Box:getDimX() local dWidth = Box:getDimY() - if dLen < dOffsetEff + 1.0 or dWidth < dOffsetEff + 1.0 then + -- se faccia con un lato piccolo e non diretta troppo verso il basso, non servono dice + if ( dLen < dOffsetEff + 1.0 or dWidth < dOffsetEff + 1.0) and vtN:getZ() > -0.5 then return nil, nil, nil end @@ -231,43 +232,46 @@ local function SortOrtoCutsByNormalMethod( TabParallelPlanes, TabOrtoPlanes) end ---------------------------------------------------------------------------------------------------------------------------------------------------- --- GetSurfSum: +-- VerifyFirstOrthoCut : -- CutTable: tabella dei tagli -- OffsetP: offset della distanza dal punto centrale -- BBoxRawPart: il grezzo della barra --- Verifica se l'asse X del box costruito sopra le 2 facce è più piccolo di un certo offset e quindi la faccia 12 è superflua -local function GetSurfSum( CutTable, OffsetP, BBoxRawPart) +-- Verifica se l'asse X del box costruito sopra le 2 facce è più piccolo di un certo offset e quindi la faccia O è superflua +local function VerifyFirstOrthoCut( CutTable, OffsetP, BBoxRawPart) if not CutTable[1] or not CutTable[2] then return end + local CutOId = CutTable[1][1] local Cut1Id = CutTable[2][1] local Cut2Id = CutTable[2][2] - local Cut12Id = CutTable[1][1] - if Cut1Id and Cut2Id and Cut12Id then + if CutOId and Cut1Id and Cut2Id then + -- centri e normali delle due semifacce local ptC1, vtN1 = EgtSurfTmFacetCenter( Cut1Id, 0, GDB_ID.ROOT) - local _, vtO = EgtSurfTmFacetCenter( Cut12Id, 0, GDB_ID.ROOT) + local ptC2, vtN2 = EgtSurfTmFacetCenter( Cut2Id, 0, GDB_ID.ROOT) + -- normale alla faccia ortogonale + local _, vtO = EgtSurfTmFacetCenter( CutOId, 0, GDB_ID.ROOT) vtO = vtO - vtO * vtN1 * vtN1 ; vtO:normalize() + -- calcolo lunghezza prima semi-faccia local asseX1 = vtO local asseY1 = vtN1 ^ asseX1 local Frame1 = Frame3d( ptC1, ptC1+asseX1, ptC1+asseY1) local Box1 = EgtGetBBoxRef( Cut1Id, GDB_BB.STANDARD, Frame1) local x1 = Box1:getDimX() - - local ptC2, vtN2 = EgtSurfTmFacetCenter( Cut2Id, 0, GDB_ID.ROOT) + -- calcolo lunghezza seconda semi-faccia local asseX2 = vtO local asseY2 = vtN2 ^ asseX2 local Frame2 = Frame3d( ptC2, ptC2+asseX2, ptC2+asseY2) local Box2 = EgtGetBBoxRef( Cut2Id, GDB_BB.STANDARD, Frame2) local x2 = Box2:getDimX() - + -- lunghezza totale faccia local dLongSize = x1 + x2 - - if dLongSize <= OffsetP + 1.0 then + -- se faccia piccola e non orientata verso il basso, elimino ortogonale e unisco le due parti + if dLongSize <= OffsetP + 1.0 and vtN1:getZ() > -0.5 then local nParent = EgtGetParent( Cut1Id) local SurfId = EgtSurfTmBySewing( nParent, { Cut1Id, Cut2Id}) EgtSetColor( SurfId, Color3d( FUCHSIA(), 60)) - EgtErase( Cut12Id) + EgtErase( CutOId) table.remove( CutTable[1], 1) table.remove( CutTable[2], 1) table.remove( CutTable[2], 1) @@ -296,7 +300,7 @@ function DiceCut.GetDice( nParent, BBoxRawPart, ptCPlanes, vtNPlanes, bGetOrtoPl -- se normali senza componenti in Y, uso per offset i limiti dei tagli di testa e coda if abs( vtNPlanes:getY()) < 0.1 and ( not vtNBond or abs( vtNBond:getY()) < 0.1) then - OffsetP = BD.MAX_DIM_HTCUT + --OffsetP = BD.MAX_DIM_HTCUT OffsetO = BD.MAX_DIM_HTCUT end @@ -409,7 +413,7 @@ function DiceCut.GetDice( nParent, BBoxRawPart, ptCPlanes, vtNPlanes, bGetOrtoPl -- Se esiste la superficie limitante (nFacet == 2) verifica se il taglio più esterno è superfluo e quindi viene eliminato if not bGetOrtoPlanes then - GetSurfSum( UltimateTable, originalOffsetP, BBoxRawPart) + VerifyFirstOrthoCut( UltimateTable, originalOffsetP, BBoxRawPart) end return UltimateTable diff --git a/LuaLibs/ProcessCut.lua b/LuaLibs/ProcessCut.lua index 1fb4b03..7a19e5e 100644 --- a/LuaLibs/ProcessCut.lua +++ b/LuaLibs/ProcessCut.lua @@ -1,4 +1,4 @@ --- ProcessCut.lua by Egaltech s.r.l. 2019/03/23 +-- ProcessCut.lua by Egaltech s.r.l. 2019/04/13 -- Gestione calcolo singoli tagli di lama per Travi -- Tabella per definizione modulo @@ -116,7 +116,11 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if i % 2 == 1 then nOrthoOpposite = BL.GetNearestOrthoOpposite( vtN) else - nOrthoOpposite = BL.GetNearestOrthoOpposite( vtO) + if #vCuts[i-1] > 0 then + nOrthoOpposite = BL.GetNearestOrthoOpposite( vtO) + else + nOrthoOpposite = MCH_MILL_FU.ORTHO_DOWN + end end else if bHorizCut then @@ -129,9 +133,27 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- lavoro la faccia for j = 1, #vCuts[i] do - local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, 0, BD.CUT_SIC, 0, nil, b3Raw) - if not bOk then - return bOk, sErr + -- se taglio dal basso + if bDownCut then + -- se strato pari composto da 1 o 2 elementi + if i % 2 == 0 and #vCuts[i] <= 2 then + -- il primo elemento prende la direzione prevista, il secondo quella opposta + local nNewOrthoOpposite = nOrthoOpposite + if j ~= 1 then + nNewOrthoOpposite = EgtIf( nOrthoOpposite == MCH_MILL_FU.ORTHO_FRONT, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT) + end + local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nNewOrthoOpposite, 0, BD.CUT_SIC, 0, nil, b3Raw) + if not bOk then + return bOk, sErr + end + end + -- tutti gli altri casi vengono saltati + -- caso generale + else + local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, 0, BD.CUT_SIC, 0, nil, b3Raw) + if not bOk then + return bOk, sErr + end end end end diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index 4c846ac..6576192 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -1,4 +1,4 @@ --- ProcessDrill.lua by Egaltech s.r.l. 2019/04/01 +-- ProcessDrill.lua by Egaltech s.r.l. 2019/04/11 -- Gestione calcolo forature per Travi -- Tabella per definizione modulo @@ -45,10 +45,18 @@ end --------------------------------------------------------------------- local function FindDrilling( dDiam) - for i = 1, #Drillings do + -- ricerca sulle forature con punte, dal diametro maggiore al minore + for i = #Drillings, 1, -1 do local Drilling = Drillings[i] - if abs( dDiam - Drilling.Diam) < 1.1 then - return i, Drilling.Name + if ( Drilling.Type == 'Drill' and Drilling.Diam < dDiam + 10 * GEO.EPS_SMALL and Drilling.Diam > dDiam - BD.DRILL_TOL - 10 * GEO.EPS_SMALL) then + return i, Drilling.Name, Drilling.Type + end + end + -- ricerca sull svuotature con frese, dal diametro maggiore al minore + for i = #Drillings, 1, -1 do + local Drilling = Drillings[i] + if ( Drilling.Type == 'Pocket' and dDiam > Drilling.Diam + 10 * GEO.EPS_SMALL) then + return i, Drilling.Name, Drilling.Type end end return 0 @@ -129,7 +137,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) if bToInvert then vtExtr = - vtExtr end if Proc.Flg == -2 then bToInvert = true end -- recupero la lavorazione - local nDri, sDrilling = FindDrilling( dDiam) + local nDri, sDrilling, nType = FindDrilling( dDiam) if not sDrilling then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' drilling not found in library' EgtOutLog( sErr) @@ -144,9 +152,13 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) return false, sErr end -- aggiungo geometria - EgtSetMachiningGeometry( {{ AuxId, 0}}) + EgtSetMachiningGeometry( {{ AuxId, -1}}) -- eventuale inversione - EgtSetMachiningParam( MCH_MP.INVERT, bToInvert) + if nType == 'Drill' then + EgtSetMachiningParam( MCH_MP.INVERT, bToInvert) + else + EgtSetMachiningParam( MCH_MP.TOOLINVERT, bToInvert) + end -- imposto posizione braccio porta testa local nSCC = MCH_SCC.ADIR_YM if vtExtr:getY() > 100 * GEO.EPS_ZERO then diff --git a/LuaLibs/ProcessFreeContour.lua b/LuaLibs/ProcessFreeContour.lua index 1e5b1d8..394ac2c 100644 --- a/LuaLibs/ProcessFreeContour.lua +++ b/LuaLibs/ProcessFreeContour.lua @@ -1,4 +1,4 @@ --- ProcessFreeContour.lua by Egaltech s.r.l. 2019/02/23 +-- ProcessFreeContour.lua by Egaltech s.r.l. 2019/04/13 -- Gestione calcolo profilo libero per Travi -- Tabella per definizione modulo @@ -13,6 +13,7 @@ EgtOutLog( ' ProcessFreeContour started', 1) -- Dati local BD = require( 'BeamData') local Millings = require( 'MillingData') +local Pocketings = require( 'PocketingData') --------------------------------------------------------------------- -- Riconoscimento della feature @@ -88,8 +89,7 @@ local function FindMilling( sType) end --------------------------------------------------------------------- --- Applicazione della lavorazione -function ProcessFreeContour.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) +local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) -- recupero l'ingombro del grezzo di appartenenza local b3Raw = EgtGetRawPartBBox( nRawId) -- recupero e verifico l'entità curva @@ -104,7 +104,7 @@ function ProcessFreeContour.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local dDepth = abs( EgtCurveThickness( AuxId)) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) local bToolInv = ( vtExtr:getZ() < -0.1) - -- recupero la lavorazione + -- recupero la lavorazione local nMill, sMilling = FindMilling( 'FreeContour') if not sMilling then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library' @@ -212,7 +212,97 @@ function ProcessFreeContour.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) BL.UpdateTCING( nRawId, Proc.Box:getMax():getX() - b3Raw:getMin():getX()) end return true -end +end + +--------------------------------------------------------------------- +local function FindPocketing( sType) + for i = 1, #Pocketings do + local Pocketing = Pocketings[i] + if Pocketing.Type == sType then + return i, Pocketing.Name + end + end + return 0 +end + +--------------------------------------------------------------------- +local function MakeByPocket( Proc, nPhase, nRawId, nPartId, dOvmHead) + -- recupero e verifico l'entità curva + local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 + if AuxId then AuxId = AuxId + Proc.Id end + if not AuxId or ( EgtGetType( AuxId) & 256) == 0 then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati della curva e del profilo + local dDepth = abs( EgtCurveThickness( AuxId)) + local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) + --local bToolInv = ( vtExtr:getZ() < -0.1) + -- recupero la lavorazione + local nMill, sPocketing = FindPocketing( 'Mortise') + if not sPocketing then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + local dMillDiam = 20 + local dMaxDepth = 0 + if EgtMdbSetCurrMachining( sPocketing) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end + -- inserisco la lavorazione di svuotatura + local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchFId = EgtAddMachining( sName, sPocketing) + if not nMchFId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sPocketing + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ AuxId, -1}}) + -- imposto posizione braccio porta testa + if vtExtr:getY() <= 0 then + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM) + else + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP) + end + -- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente + if dDepth > dMaxDepth + 10 * GEO.EPS_SMALL then + dDepth = dMaxDepth + local sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : elevation bigger than max tool depth' + EgtOutLog( sWarn) + end + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + -- imposto elevazione + EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dMaxDepth, 1) .. ';') + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + return true +end + +--------------------------------------------------------------------- +-- Applicazione della lavorazione +function ProcessFreeContour.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) + -- recupero la tipologia + local bPocket = ( EgtGetInfo( Proc.Id, 'PCKT', 'i') == 1) + -- se svuotatura + if bPocket then + return MakeByPocket( Proc, nPhase, nRawId, nPartId, dOvmHead) + -- altrimenti contornatura + else + return MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) + end +end --------------------------------------------------------------------- return ProcessFreeContour diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 55e6a7d..c05fd62 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -508,12 +508,10 @@ end -- Applicazione della lavorazione --------------------------------------------------------------------- function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId) - -- dimensioni della feature - local b3Fea = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) -- con fresa local MAX_MILL_X = 80 local MAX_MILL_VOL = ( 80 * 240 * 20) / 2 - if Proc.Fct > 2 or ( b3Fea:getDimX() < MAX_MILL_X and b3Fea:getDimX() * b3Fea:getDimY() * b3Fea:getDimZ() < MAX_MILL_VOL) then + if Proc.Fct > 2 or ( Proc.Box:getDimX() < MAX_MILL_X and Proc.Box:getDimX() * Proc.Box:getDimY() * Proc.Box:getDimZ() < MAX_MILL_VOL) then return MakeByMillOrChain( Proc, nPhase, nRawId, nPartId) -- con lama else