From 35fa519eb364d39b33d073684731ddac43335fea Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 18 Oct 2023 11:19:37 +0200 Subject: [PATCH] DataWall 2.5j3 : - nella ricerca lavorazione da usare controllo di utensile attivo sostituito con controllo utensile presente nel setup corrente - aggiunta gestione aree vietate per chiodature (LockOut for Nail). --- LuaLibs/WMachiningLib.lua | 7 +- LuaLibs/WProcessFreeContour.lua | 127 ++++++++++++++++++++------------ LuaLibs/WallExec.lua | 33 ++++++--- LuaLibs/WallLib.lua | 21 +++++- Version.lua | 2 +- 5 files changed, 127 insertions(+), 63 deletions(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index ee4f15e..9ffd7f6 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -1,9 +1,10 @@ --- MachiningLib.lua by Egaltech s.r.l. 2022/01/12 +-- MachiningLib.lua by Egaltech s.r.l. 2023/10/18 -- Libreria ricerca lavorazioni per Pareti -- 2023/03/09 Piccola correzione alla SideDepth in FindMilling -- In FindMilling aggiunta gestione spessore e massimo materiale nel caso di lam -- 2023/05/25 Aggiunta funzione AddMachining che incapsula EgtAddMachining trascrivendo le priorità btl dalle feature alle lavorazioni. -- 2023/06/07 Alla funzione AddMachining aggiunta la scrittura dell'info ISOUTLINE alle lavorazioni. +-- 2023/10/18 In SetCurrMachiningAndTool sostituito controllo di utensile attivo con controllo utensile nel setup corrente. -- Tabella per definizione modulo local WMachiningLib = {} @@ -32,7 +33,7 @@ local function SetCurrMachiningAndTool( sMachName) local sTool = EgtTdbGetToolFromUUID( sTuuid) if not sTool then return false end if not EgtTdbSetCurrTool( sTool) then return false end - return EgtTdbGetCurrToolParam( MCH_TP.ACTIVE) + return EgtFindToolInCurrSetup( sTool) end --------------------------------------------------------------------- @@ -186,7 +187,7 @@ end --------------------------------------------------------------------- function WMachiningLib.AddMachining( Proc, sName, sMachining) local nMchId, sFinalName = EgtAddMachining( sName, sMachining) - if type(Proc) == 'table' then + if type( Proc) == 'table' then local nPriority = EgtGetInfo( Proc.Id or GDB_ID.NULL, 'PRIORITY', 'i') EgtSetInfo( nMchId or GDB_ID.NULL, 'PRIORITY', nPriority) EgtSetInfo( nMchId or GDB_ID.NULL, 'ISOUTLINE', Proc.IsOutline) diff --git a/LuaLibs/WProcessFreeContour.lua b/LuaLibs/WProcessFreeContour.lua index 96d0b77..e1c4d15 100644 --- a/LuaLibs/WProcessFreeContour.lua +++ b/LuaLibs/WProcessFreeContour.lua @@ -64,6 +64,8 @@ end --------------------------------------------------------------------- -- Classificazione della feature function WPF.Classify( Proc, b3Raw) + -- se area vietata (LockOut) non faccio nulla + if Proc.LockOut then return true end -- verifico se di tipo pocket local bPocket = ( EgtGetInfo( Proc.Id, 'PCKT', 'i') == 1) -- recupero la curva associata @@ -2306,7 +2308,7 @@ local function MakeByMark( Proc, nRawId, b3Raw) end --------------------------------------------------------------------- -local function MakeByNail( Proc, nRawId, b3Raw) +local function MakeByNail( Proc, nRawId, b3Raw, vNLO) -- ingombro del pezzo local Ls = EgtGetFirstNameInGroup( Proc.PartId, 'Box') local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD) @@ -2333,6 +2335,36 @@ local function MakeByNail( Proc, nRawId, b3Raw) nCntData = nCntData + 10 end local dCntPar = EgtGetInfo( Proc.Id, 'CNT_PAR', 'd') or 100 + -- se presenti aree vietate alle chiodature, gestisco le geometrie + local vCrvs = {} + if #vNLO > 0 then + -- in presenza di aree vietate non sono ammesse lavorazioni in doppio (non dovrebbe mai accadere per precedenti controlli) + if Proc.Double then + local sErr = 'Error : nailing in double with LockOut Area not allowed' + EgtOutLog( sErr) + return false, sErr + end + -- gruppo ausiliario + local nAddGrpId = WL.GetAddGroup( Proc.PartId) + -- copio la curva da lavorare + vCrvs[1] = EgtCopyGlob( AuxId, nAddGrpId) + -- la trimmo con tutte le aree vietate + for i = 1, #vNLO do + local vRes = {} + for j = 1, #vCrvs do + local nNewId, nCount = EgtTrimCurveWithRegion( vCrvs[j], vNLO[i], false, false) + if nNewId then + vRes = EgtTableAdd( vRes, nNewId, nCount) + end + end + vCrvs = vRes + end + else + vCrvs[1] = AuxId + end + -- per debug + local sOut = table.concat( vCrvs, ',') + EgtOutLog( 'Nailing curve : '.. ( sOut or '')) -- recupero la lavorazione local sNailing = WM.FindNailing( nCntData) if not sNailing then @@ -2340,49 +2372,51 @@ local function MakeByNail( Proc, nRawId, b3Raw) EgtOutLog( sErr) return false, sErr end - -- inserisco la lavorazione - local sName = 'Nail_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMchId = WM.AddMachining( Proc, sName, sNailing) - if not nMchId then - local sErr = 'Error adding machining ' .. sName .. '-' .. sNailing - EgtOutLog( sErr) - return false, sErr - end - EgtSetInfo( nMchId, 'Part', Proc.PartId) - -- aggiungo geometria - EgtSetMachiningGeometry( {{ AuxId, -1}}) - -- percorso da non invertire - EgtSetMachiningParam( MCH_MP.INVERT, false) - -- se estrusione da sotto, inverto direzione fresa - if bToolInv then - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - end - -- assegno affondamento - EgtSetMachiningParam( MCH_MP.DEPTH, 10) - -- assegno lato di lavoro - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.CENTER) - -- se in doppio lungo Y, devo dimezzare opportunamente la lavorazione - local dExtraDelta = 0 - if Proc.Double == 2 then - dExtraDelta = 0.45 * dCntPar - if Proc.Delta > 0 then - EgtSetMachiningParam( MCH_MP.ENDADDLEN, -Proc.DblAcc - dExtraDelta) - else - EgtSetMachiningParam( MCH_MP.STARTADDLEN, -Proc.DblAcc - dExtraDelta) + for i = 1, #vCrvs do + -- inserisco la lavorazione + local sName = 'Nail_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_'..tostring( i) + local nMchId = WM.AddMachining( Proc, sName, sNailing) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sNailing + EgtOutLog( sErr) + return false, sErr + end + EgtSetInfo( nMchId, 'Part', Proc.PartId) + -- aggiungo geometria + EgtSetMachiningGeometry( {{ vCrvs[i], -1}}) + -- percorso da non invertire + EgtSetMachiningParam( MCH_MP.INVERT, false) + -- se estrusione da sotto, inverto direzione fresa + if bToolInv then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + end + -- assegno affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, 10) + -- assegno lato di lavoro + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.CENTER) + -- se in doppio lungo Y, devo dimezzare opportunamente la lavorazione + local dExtraDelta = 0 + if Proc.Double == 2 then + dExtraDelta = 0.45 * dCntPar + if Proc.Delta > 0 then + EgtSetMachiningParam( MCH_MP.ENDADDLEN, -Proc.DblAcc - dExtraDelta) + else + EgtSetMachiningParam( MCH_MP.STARTADDLEN, -Proc.DblAcc - dExtraDelta) + end + end + -- assegno parametri a note utente + local sUserNotes = 'Par=' .. EgtNumToString( dCntPar, 0) .. ';' + if Proc.Double and Proc.Double > 0 then + sUserNotes = sUserNotes .. 'Dbl=' .. EgtNumToString( Proc.Double, 0) .. ';' .. + 'Dlt=' .. EgtNumToString( abs( Proc.Delta) + dExtraDelta, 0) .. ';' + end + EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr end - end - -- assegno parametri a note utente - local sUserNotes = 'Par=' .. EgtNumToString( dCntPar, 0) .. ';' - if Proc.Double and Proc.Double > 0 then - sUserNotes = sUserNotes .. 'Dbl=' .. EgtNumToString( Proc.Double, 0) .. ';' .. - 'Dlt=' .. EgtNumToString( abs( Proc.Delta) + dExtraDelta, 0) .. ';' - end - EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) - -- eseguo - if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) - return false, sErr end return true end @@ -2569,7 +2603,7 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione -function WPF.Make( Proc, nRawId, b3Raw) +function WPF.Make( Proc, nRawId, b3Raw, vNLO) -- recupero la tipologia (contorno o tasca) local bPocket = ( EgtGetInfo( Proc.Id, 'PCKT', 'i') == 1) -- se svuotatura @@ -2589,10 +2623,7 @@ function WPF.Make( Proc, nRawId, b3Raw) return MakeByMark( Proc, nRawId, b3Raw) -- se chiodatura elseif nCntType == 20 then - return MakeByNail( Proc, nRawId, b3Raw) - -- area vietata - elseif nCntType == 200 then - return true, 'Lock-out area Ignored' + return MakeByNail( Proc, nRawId, b3Raw, vNLO) -- altrimenti, taglio con lama e pulizia angoli con fresa else return MakeByCut( Proc, nRawId, b3Raw) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 84aff1e..2b6d933 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -1,9 +1,10 @@ --- WallExec.lua by Egaltech s.r.l. 2023/07/04 +-- WallExec.lua by Egaltech s.r.l. 2023/10/16 -- Libreria esecuzione lavorazioni per Pareti -- 2023/05/25 Aggiunto ordinamento in base a priorità da btl. -- 2023/06/07 Nel caso di outline con priorità aggiunta la rimozione degli sfridi nella lavorazione successiva. -- 2023/06/27 Aggiunte origini TN e BN. -- 2023/07/04 Se c'è funzione di macchina WD.GetOrigCorner si lascia scegliere posizione default a questa impostando 0 se non c'è 'REFPOS'. +-- 2023/10/16 Aggiunta gestione Aree vietate (LockOut) per chiodature. -- Tabella per definizione modulo local WallExec = {} @@ -216,6 +217,16 @@ function WallExec.CollectFeatures( PartId, b3Raw) Proc2.TaskId = Proc.TaskId table.insert( vProc, Proc2) end + -- se free contour + elseif FreeContour.Identify( Proc) then + -- recupero il tipo e il dato della lavorazione + local nCntType = EgtGetInfo( Proc.Id, 'CNT_TYPE', 'i') or 0 + local nCntData = EgtGetInfo( Proc.Id, 'CNT_DATA', 'i') or 0 + -- imposto se area vietata + if nCntType == 200 then + Proc.LockOut = EgtIf( ( nCntData == 0 or ( nCntData & 1) ~= 0), 1, -1) + end + if Proc.LockOut then Proc.Flg = 0 end end else EgtOutLog( ' Feature ' .. tostring( Proc.Id) .. ' is empty (no geometry)') @@ -285,15 +296,15 @@ local function PrintFeatures( vProc) EgtOutLog( ' *** Feature List ***') for i = 1, #vProc do local Proc = vProc[i] - local sOut = string.format( 'Part=%3d Proc=%3d Grp=%1d Prc=%3d TC=%2d/%d Flg=%2d Fcse=%1d,%1d Diam=%.2f Fct=%2d Dbl=%2d Dlt=%.1f Box=%s', + local sOut = string.format( 'Part=%3d Proc=%3d Grp=%1d Prc=%3d TC=%2d/%d Flg=%2d Lo=%d Fcse=%1d,%1d Diam=%.2f Fct=%2d Dbl=%2d Dlt=%.1f Box=%s', Proc.PartId, Proc.Id, Proc.Grp, Proc.Prc, Proc.TaskId, Proc.CutId, - Proc.Flg, Proc.Fcs, Proc.Fce, Proc.Diam, Proc.Fct, Proc.Double or 0, Proc.Delta or 0, tostring( Proc.Box)) + Proc.Flg, EgtIf( Proc.LockOut, 1, 0), Proc.Fcs, Proc.Fce, Proc.Diam, Proc.Fct, Proc.Double or 0, Proc.Delta or 0, tostring( Proc.Box)) EgtOutLog( sOut) end end ------------------------------------------------------------------------------------------------------------- -local function AddFeatureMachining( Proc, nRawId, b3Raw) +local function AddFeatureMachining( Proc, nRawId, b3Raw, vNLO) local bOk = true local sErr = '' EgtOutLog( ' * Process ' .. tostring( Proc.Id) .. ' *', 1) @@ -335,8 +346,8 @@ local function AddFeatureMachining( Proc, nRawId, b3Raw) bOk, sErr = Text.Make( Proc, nRawId, b3Raw) -- se contorno libero, outline o apertura ( 0/3/4-250/251/252-X) elseif FreeContour.Identify( Proc) then - -- esecuzione contorno - bOk, sErr = FreeContour.Make( Proc, nRawId, b3Raw) + -- esecuzione contorno libero + bOk, sErr = FreeContour.Make( Proc, nRawId, b3Raw, vNLO) -- se feature custom (Variant) elseif Variant.Identify( Proc) then -- esecuzione @@ -641,9 +652,11 @@ function WallExec.ProcessFeatures() end -- classifico le feature ClassifyFeatures( vProc, b3Raw) - -- Eventuale determinazione delle feature lavorabili in parallelo (implementata nella configurazione macchina) + -- recupero l'elenco delle aree vietate alle chiodature + local vNLO = WL.GetNailLockOutAreas( vProc) + -- Se non ci sono aree vietate alle chiodature, eventuale determinazione delle feature lavorabili in parallelo (implementata nella configurazione macchina) -- si impostano i flag Double (nil/0=no, 1=su X, 2=su Y) e Delta (offset tra T14 e T12 positivo o negativo) - if WD.FindFeaturesInDouble then + if #vNLO == 0 and WD.FindFeaturesInDouble then WD.FindFeaturesInDouble( vProc, b3Raw) end -- debug @@ -656,7 +669,7 @@ function WallExec.ProcessFeatures() -- creo la lavorazione local Proc = vProc[i] if Proc.Flg ~= 0 then - local bOk, sMsg = AddFeatureMachining( Proc, nRawId, b3Raw) + local bOk, sMsg = AddFeatureMachining( Proc, nRawId, b3Raw, vNLO) if not bOk then nTotErr = nTotErr + 1 table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) @@ -665,7 +678,7 @@ function WallExec.ProcessFeatures() else table.insert( Stats, {Err=0, Msg='', Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) end - elseif not Proc.Double then + elseif not Proc.Double and not Proc.LockOut then local sMsg = 'Feature not machinable by orientation' table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) end diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index e19d316..5d054ea 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -1,4 +1,4 @@ --- WallLib.lua by Egaltech s.r.l. 2022/04/04 +-- WallLib.lua by Egaltech s.r.l. 2023/10/16 -- Libreria globale per Pareti -- Tabella per definizione modulo @@ -316,5 +316,24 @@ function WallLib.GetNearestOrthoOpposite( vtRef, vtNorm) return nil end +------------------------------------------------------------------------------------------------------------- +function WallLib.GetNailLockOutAreas( vProc) + local vNLO = {} + for i = 1, #vProc do + if vProc[i].LockOut == 1 then + local AuxId = EgtGetInfo( vProc[i].Id, 'AUXID', 'i') + if AuxId then AuxId = AuxId + vProc[i].Id end + if AuxId then + local nAddGrpId = WallLib.GetAddGroup( vProc[i].PartId) + local nSfrId = EgtSurfFlatRegion( nAddGrpId, {AuxId}) + if nSfrId then + table.insert( vNLO, nSfrId) + end + end + end + end + return vNLO +end + ------------------------------------------------------------------------------------------------------------- return WallLib diff --git a/Version.lua b/Version.lua index 703ae26..952613c 100644 --- a/Version.lua +++ b/Version.lua @@ -2,5 +2,5 @@ -- Gestione della versione di Wall NAME = 'Wall' -VERSION = '2.5j2' +VERSION = '2.5j3' MIN_EXE = '2.5b3'