diff --git a/LuaLibs/ProcessFreeContour.lua b/LuaLibs/ProcessFreeContour.lua index 139576f..1e70c10 100644 --- a/LuaLibs/ProcessFreeContour.lua +++ b/LuaLibs/ProcessFreeContour.lua @@ -6,7 +6,7 @@ local ProcessFreeContour = {} -- Include require( 'EgtBase') ---local BL = require( 'BeamLib') +local WL = require( 'WallLib') EgtOutLog( ' ProcessFreeContour started', 1) @@ -47,6 +47,101 @@ function ProcessFreeContour.Classify( Proc, b3Raw) end end +--------------------------------------------------------------------- +local function MakeByCut( Proc, nRawId, b3Raw) + -- ingombro del pezzo + local Ls = EgtGetFirstNameInGroup( Proc.PartId, 'Box') + local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD) + if not b3Solid then + local sErr = 'Error : part box not found' + EgtOutLog( sErr) + return false, sErr + end + -- recupero la lavorazione + local sCutting = ML.FindCutting( 'Standard') + if not sCutting then + local sErr = 'Error : 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 + -- recupero i dati di tutte le facce + local vFace = {} + for i = 1, Proc.Fct do + -- recupero centro e normale della faccia + local ptCen, vtN = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT) + -- recupero le dimensioni della faccia + local _, dLen, dWidth = WL.GetFaceHvRefDim( Proc.Id, i - 1) + -- recupero l'angolo con la faccia successiva + local bAdj, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, EgtIf( i == 1, Proc.Fct - 1, i - 2), i -1, GDB_ID.ROOT) + -- salvo i dati + vFace[i] = { Cen = ptCen, Norm = vtN, Len = dLen, Width = dWidth, AngPrev = EgtIf( bAdj, dAng, 0)} + end + -- ciclo sulle facce del contorno in esame + for i = 1, Proc.Fct do + -- verifico l'affondamento + local dDepth = WD.CUT_EXTRA + if vFace[i].Width + WD.CUT_EXTRA > dMaxDepth then + dDepth = dMaxDepth - vFace[i].Width + end + -- lunghezza baffo + local dElev = vFace[i].Width + dDepth + local dWhisk = dElev * sqrt( dSawDiam / dElev - 1) + -- determino la lunghezza del taglio passante e il tipo di attacco e uscita + local dLen = vFace[i].Len + local nLeadIn = MCH_SAW_LI.CENT + local nLeadOut = MCH_SAW_LO.CENT + if vFace[i].AngPrev < -0.1 then + dLen = dLen - dWhisk + nLeadIn = MCH_SAW_LI.STRICT + end + if vFace[EgtIf( i < Proc.Fct, i + 1, 1)].AngPrev < -0.1 then + dLen = dLen - dWhisk + nLeadOut = MCH_SAW_LO.STRICT + end + -- se lunghezza significativa, inserisco la lavorazione + if dLen > 1 then + local sName = 'Cut_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) .. '_' .. tostring( i) + local nMchId = EgtAddMachining( sName, sCutting) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sCutting + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( { { Proc.Id, i - 1}}) + -- percorso da non invertire + EgtSetMachiningParam( MCH_MP.INVERT, false) + -- assegno affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + -- assegno il lato di lavoro + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + -- assegno il tipo di attacco + EgtSetMachiningParam( MCH_MP.LEADINTYPE, nLeadIn) + -- assegno il tipo di uscita + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, nLeadOut) + -- posizione braccio porta testa + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + end + end + return true +end + --------------------------------------------------------------------- local function MakeByMill( Proc, nRawId, b3Raw) -- ingombro del pezzo @@ -87,10 +182,8 @@ local function MakeByMill( Proc, nRawId, b3Raw) end -- eventuale spezzatura sul tratto più lungo se curva chiusa --BL.PutStartOnLonger( AuxId) - -- verifiche per affondamento ( possibili lavorazioni in doppio) - local bCross = false + -- verifiche per affondamento if b3Aux:getDimZ() > b3Raw:getDimZ() - 1.0 then - bCross = true dDepth = min( dDepth, b3Raw:getDimZ()) + WD.CUT_EXTRA end if dDepth > dMaxDepth then @@ -206,6 +299,9 @@ function ProcessFreeContour.Make( Proc, nRawId, b3Raw) -- se svuotatura if bPocket then return MakeByPocket( Proc, nRawId, b3Raw) + -- se lati diritti, taglio con lama e pulizia angoli con fresa + elseif true then + return MakeByCut( Proc, nRawId, b3Raw) -- altrimenti contornatura else return MakeByMill( Proc, nRawId, b3Raw) diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua new file mode 100644 index 0000000..6b6e49e --- /dev/null +++ b/LuaLibs/WallLib.lua @@ -0,0 +1,29 @@ +-- WallLib.lua by Egaltech s.r.l. 2020/06/24 +-- Libreria globale per Pareti + +-- Tabella per definizione modulo +local WallLib = {} + +-- Include +require( 'EgtBase') + +EgtOutLog( ' WallLib started', 1) + +--------------------------------------------------------------------- +function WallLib.GetFaceHvRefDim( nSurfId, nFacet) + -- recupero centro e normale della faccia + local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, nFacet, GDB_ID.ROOT) + if not ptC or not vtN then return end + -- riferimento tipo OCS della faccia (X orizz, Y max pendenza, Z normale) + local frHV = Frame3d( ptC, vtN) + if frHV:getVersY():getZ() < 0 then + frHV:rotate( ptC, vtN, 180) + end + -- determino l'ingombro in questo riferimento + local b3HV = EgtSurfTmGetFacetBBoxRef( nSurfId, nFacet, GDB_BB.STANDARD, frHV) + -- restituisco i valori calcolati + return frHV, b3HV:getDimX(), b3HV:getDimY() +end + +------------------------------------------------------------------------------------------------------------- +return WallLib