diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index 9efa025..28a95a0 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -1,4 +1,4 @@ --- MachiningLib.lua by Egaltech s.r.l. 2021/03/05 +-- MachiningLib.lua by Egaltech s.r.l. 2021/08/29 -- Libreria ricerca lavorazioni per Pareti -- Tabella per definizione modulo @@ -16,6 +16,10 @@ local Millings = require( 'MillingData') local Pocketings = require( 'PocketingData') local Sawings = require( 'SawingData') local Drillings = require( 'DrillData') +local Surfacings +if EgtExistsFile( EgtGetCurrMachineDir() .. '\\Wall\\SurfacingData.lua') then + Surfacings = require( 'SurfacingData') +end --------------------------------------------------------------------- local function SetCurrMachiningAndTool( sMachName) @@ -43,16 +47,18 @@ function WMachiningLib.FindCutting( sType, dDepth) end --------------------------------------------------------------------- -function WMachiningLib.FindMilling( sType, dDepth, sTuuidMstr) +function WMachiningLib.FindMilling( sType, dDepth, sTuuid, nTool_ID) for i = 1, #Millings do local Milling = Millings[i] if Milling.On and Milling.Type == sType and SetCurrMachiningAndTool( Milling.Name) then - local sTuuid = EgtGetMachiningParam( MCH_MP.TUUID) + local sMyTuuid = EgtGetMachiningParam( MCH_MP.TUUID) local dTMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, dTMaxMat, EgtTdbGetCurrToolMaxDepth()) local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - if ( not sTuuidMstr or sTuuidMstr == sTuuid) and - ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) then + local nMyTool_ID = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i') + if ( not sTuuid or sTuuid == sMyTuuid) and + ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and + ( not nTool_ID or nTool_ID == nMyTool_ID) then return Milling.Name, dTMaxDepth, dTMaxMat, dTDiam end end @@ -95,7 +101,6 @@ function WMachiningLib.FindSawing( sType) return Sawing.Name end end - end --------------------------------------------------------------------- @@ -124,5 +129,16 @@ function WMachiningLib.FindDrilling( dDiam) end end +--------------------------------------------------------------------- +function WMachiningLib.FindSurfacing( sType) + if not Surfacings then return end + for i = 1, #Surfacings do + local Surfacing = Surfacings[i] + if Surfacing.On and Surfacing.Type == sType and SetCurrMachiningAndTool( Surfacing.Name) then + return Surfacing.Name + end + end +end + ------------------------------------------------------------------------------------------------------------- return WMachiningLib diff --git a/LuaLibs/WProcessDrill.lua b/LuaLibs/WProcessDrill.lua index 640f8a5..be9d054 100644 --- a/LuaLibs/WProcessDrill.lua +++ b/LuaLibs/WProcessDrill.lua @@ -1,5 +1,6 @@ --- WProcessDrill.lua by Egaltech s.r.l. 2021/02/19 +-- WProcessDrill.lua by Egaltech s.r.l. 2021/08/29 -- Gestione calcolo forature per Pareti +-- 2021/08/29 DS Se foratura di fianco setto flag per farla dopo i tagli. -- Tabella per definizione modulo local WPD = {} @@ -139,6 +140,10 @@ function WPD.Make( Proc, nRawId, b3Raw) return false, sErr end EgtSetInfo( nMchId, 'Part', Proc.PartId) + -- se foratura di fianco setto la nota per spostarla dopo i tagli di lama + if vtExtr:getZ() < WD.NZ_MINA then + EgtSetInfo( nMchId, 'MOVE_AFTER', 1) + end -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) -- eventuale inversione diff --git a/LuaLibs/WProcessFreeContour.lua b/LuaLibs/WProcessFreeContour.lua index b988225..12b2cd7 100644 --- a/LuaLibs/WProcessFreeContour.lua +++ b/LuaLibs/WProcessFreeContour.lua @@ -1761,8 +1761,9 @@ local function MakeByMill( Proc, nRawId, b3Raw) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) local b3Aux = EgtGetBBoxGlob( AuxId, GDB_BB.STANDARD) local bToolInv = ( vtExtr:getZ() < -0.1) + local nTool_ID = EgtGetInfo( Proc.Id, 'CNT_DATA', 'i') -- recupero la lavorazione - local sMilling = WM.FindMilling( 'FreeContour') + local sMilling = WM.FindMilling( 'FreeContour', nil, nil, nTool_ID) if not sMilling then local sErr = 'Error : milling not found in library' EgtOutLog( sErr) @@ -2074,8 +2075,11 @@ function WPF.Make( Proc, nRawId, b3Raw) else -- recupero il tipo di lavorazione local nCntType = EgtGetInfo( Proc.Id, 'CNT_TYPE', 'i') or 0 + -- se fresatura + if nCntType == 2 then + return MakeByMill( Proc, nRawId, b3Raw) -- se chiodatura - if nCntType == 20 then + elseif nCntType == 20 then return MakeByNail( Proc, nRawId, b3Raw) -- altrimenti, taglio con lama e pulizia angoli con fresa else diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 41fc897..2870734 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -1,5 +1,7 @@ --- WProcessLapJoint.lua by Egaltech s.r.l. 2021/04/28 +-- WProcessLapJoint.lua by Egaltech s.r.l. 2021/08/29 -- Gestione calcolo mezzo-legno per Pareti +-- 2021/08/27 DS Se tre o più facce con flag PCKT=1 forzo svuotatura con fresa (per Variant). +-- 2021/08/29 DS Se svuotatura di fianco setto flag per farla dopo i tagli. -- Tabella per definizione modulo local WPL = {} @@ -1295,6 +1297,10 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) return false, sErr end EgtSetInfo( nMchFId, 'Part', Proc.PartId) + -- se lavorazione di fianco setto la nota per spostarla dopo i tagli di lama + if vtN:getZ() < WD.NZ_MINA then + EgtSetInfo( nMchFId, 'MOVE_AFTER', 1) + end -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, nFacet}}) -- imposto posizione braccio porta testa @@ -1512,6 +1518,8 @@ end local function MakeMoreFaces( Proc, nRawId, b3Raw) -- con una faccia di fondo valida if Proc.Stype == 1 or Proc.Stype == 2 then + -- recupero eventuale flag forzatura svuotatura + local bPckt = ( EgtGetInfo( Proc.Id, 'PCKT', 'i') == 1) -- cerco la faccia con il maggior numero di adiacenze local nFacInd, dElev, nFacInd2, dElev2 = WL.GetFaceWithMostAdj( Proc.Id, Proc.PartId) -- se necessario scambio le facce @@ -1521,7 +1529,7 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw) local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT) local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) -- se di fianco - if Proc.Fct >= 3 and vtN:getZ() < WD.NZ_MINA then + if not bPckt and Proc.Fct >= 3 and vtN:getZ() < WD.NZ_MINA then -- fresatura (se definita) local sMilling, _, dMaxMat, dDiam = WM.FindMilling( 'SideGroove') if sMilling and dElev < dDiam / 2 - 30 and dMaxMat <= min( dH, dV) + 20 * GEO.EPS_SMALL then @@ -1531,7 +1539,7 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw) return MakeByChainSaw( Proc, nFacInd, nRawId, b3Raw, dElev, dH, dV) end end - local nFacet = EgtIf( vtN:getZ() >= WD.NZ_MINA, nFacInd, nFacInd2) + local nFacet = EgtIf( bPckt or vtN:getZ() >= WD.NZ_MINA, nFacInd, nFacInd2) -- eseguo la svuotatura return MakeByPocketing( Proc, nFacet, nRawId, b3Raw, true) -- fessura verticale diff --git a/LuaLibs/WProcessVariant.lua b/LuaLibs/WProcessVariant.lua new file mode 100644 index 0000000..303be65 --- /dev/null +++ b/LuaLibs/WProcessVariant.lua @@ -0,0 +1,115 @@ +-- WProcessVariant.lua by Egaltech s.r.l. 2021/08/27 +-- Gestione calcolo Feature Custom (Variant) per Pareti + +-- Tabella per definizione modulo +local WPV = {} + +-- Include +require( 'EgtBase') +local WL = require( 'WallLib') + +EgtOutLog( ' WProcessVariant started', 1) + +-- Dati +local WD = require( 'WallData') +local WM = require( 'WMachiningLib') + +--------------------------------------------------------------------- +-- Riconoscimento della feature +function WPV.Identify( Proc) + return (( Proc.Grp == 0 or Proc.Grp == 1 or Proc.Grp == 2 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 900) +end + +--------------------------------------------------------------------- +-- Classificazione della feature: decide se la feature è in una posizione lavorabile +local function ClassifyCode_1( Proc, b3Raw) + local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') + if AuxId then + AuxId = AuxId + Proc.Id + end + if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then + local sErr = 'Error : missing containement geometry' + EgtOutLog( sErr) + return false + end + local vtExtr = EgtCurveExtrusion( AuxId or GDB_ID.NULL, GDB_ID.ROOT) + return ( vtExtr:getZ() > -0.01) +end + +--------------------------------------------------------------------- +function WPV.Classify( Proc, b3Raw) + -- recupero il codice identificativo + local sCode = EgtGetInfo( Proc.Id, 'DES') + -- gestione in base al codice + if sCode == '1' then + return ClassifyCode_1( Proc, b3Raw) + else + return false + end +end + +--------------------------------------------------------------------- +-- Applicazione della lavorazione +local function MakeCode_1( Proc, nRawId, b3Raw) + -- recupero e verifico l'entità curva associata + local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') + if AuxId then + AuxId = AuxId + Proc.Id + end + if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then + local sErr = 'Error : missing containement geometry' + EgtOutLog( sErr) + return false, sErr + end + local vtExtr = EgtCurveExtrusion( AuxId or GDB_ID.NULL, GDB_ID.ROOT) + -- recupero la lavorazione + local sSurfFin = WM.FindSurfacing( 'Finishing') + if not sSurfFin then + local sErr = 'Error : surface finishing not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- inserisco la lavorazione di finitura superficie + local sName = 'SurfFin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchFId = EgtAddMachining( sName, sSurfFin) + if not nMchFId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sSurfFin + EgtOutLog( sErr) + return false, sErr + end + EgtSetInfo( nMchFId, 'Part', Proc.PartId) + -- se lavorazione di fianco setto la nota per spostarla dopo i tagli di lama + if vtExtr:getZ() < WD.NZ_MINA then + EgtSetInfo( nMchFId, 'MOVE_AFTER', 1) + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ Proc.Id, -1},{AuxId, -1}}) + -- imposto posizione braccio porta testa + local nSCC = MCH_SCC.ADIR_ZP + if AreSameVectorApprox( vtExtr, Z_AX()) then + nSCC = EgtIf( Proc.Box:getDimX() >= Proc.Box:getDimY(), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_XP) + end + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + return true +end + +--------------------------------------------------------------------- +function WPV.Make( Proc, nRawId, b3Raw) + -- recupero il codice identificativo + local sCode = EgtGetInfo( Proc.Id, 'DES') + -- gestione in base al codice + if sCode == '1' then + return MakeCode_1( Proc, nRawId, b3Raw) + else + return false, 'Feature Id Code non recognized for machining' + end +end + +--------------------------------------------------------------------- +return WPV diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 150a01a..ff506dd 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -1,4 +1,4 @@ --- WallExec.lua by Egaltech s.r.l. 2021/07/08 +-- WallExec.lua by Egaltech s.r.l. 2021/08/27 -- Libreria esecuzione lavorazioni per Pareti -- Tabella per definizione modulo @@ -29,6 +29,7 @@ _G.package.loaded.WProcessDtMortise = nil _G.package.loaded.WProcessMark = nil _G.package.loaded.WProcessText = nil _G.package.loaded.WProcessFreeContour = nil +_G.package.loaded.WProcessVariant = nil local WM = require( 'WMachiningLib') local WL = require( 'WallLib') local Cut = require( 'WProcessCut') @@ -41,6 +42,8 @@ local DtMortise = require( 'WProcessDtMortise') local Mark = require( 'WProcessMark') local Text = require( 'WProcessText') local FreeContour = require( 'WProcessFreeContour') +local Variant = require( 'WProcessVariant') + ------------------------------------------------------------------------------------------------------------- -- *** Inserimento delle pareti nel pannello *** @@ -213,6 +216,10 @@ local function ClassifyFeatures( vProc, b3Raw) elseif FreeContour.Identify( Proc) then local bOk = FreeContour.Classify( Proc, b3Raw) if not bOk then Proc.Flg = 0 end + -- se feature custom (Variant) + elseif Variant.Identify( Proc) then + local bOk = Variant.Classify( Proc, b3Raw) + if not bOk then Proc.Flg = 0 end end end end @@ -274,6 +281,10 @@ local function AddFeatureMachining( Proc, nRawId, b3Raw) elseif FreeContour.Identify( Proc) then -- esecuzione contorno bOk, sErr = FreeContour.Make( Proc, nRawId, b3Raw) + -- se feature custom (Variant) + elseif Variant.Identify( Proc) then + -- esecuzione + bOk, sErr = Variant.Make( Proc, nRawId, b3Raw) -- altrimenti feature non riconosciuta else bOk = false @@ -364,9 +375,11 @@ local function SortMachinings( nPhase, PrevMch, nPartId) -- Tagli con sega a catena che sono rifiniture di spigoli PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MORTISING, 'Csaw_', false) -- Forature - PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.DRILLING) + PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.DRILLING, nil, nil, 'MOVE_AFTER', false) -- Svuotature - PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.POCKETING) + PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.POCKETING, nil, nil, 'MOVE_AFTER', false) + -- Lavorazioni di superficie + PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_MY.SURFFINISHING, nil, nil, 'MOVE_AFTER', false) -- Fresature che sono rifiniture di spigoli PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, 'Clean_', false, 'MOVE_AFTER', false) -- Fresature che sono puliture di spigoli @@ -378,6 +391,12 @@ local function SortMachinings( nPhase, PrevMch, nPartId) PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MORTISING, 'Csaw_', true) -- Fresature (puliture di spigoli) che vanno fatte dopo i tagli con lama PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, nil, nil, 'MOVE_AFTER', true) + -- Forature che vanno fatte dopo i tagli con lama + PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.DRILLING, nil, nil, 'MOVE_AFTER', true) + -- Svuotature che vanno fatte dopo i tagli con lama + PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.POCKETING, nil, nil, 'MOVE_AFTER', true) + -- Lavorazioni di superficie che vanno fatte dopo i tagli con lama + PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_MY.SURFFINISHING, nil, nil, 'MOVE_AFTER', true) return PrevMch end