From 03b521aee3e21e56808d8cb9452874d8b9e10140 Mon Sep 17 00:00:00 2001 From: DarioS Date: Mon, 17 May 2021 20:32:52 +0200 Subject: [PATCH] DataWall : - aggiunta gestione feature DoubleCut - aggiunta gestione feature SawCut - modifica gestione FreeContour con una sola faccia - correzioni per nesting pareti. --- BatchProcessNew.lua | 61 +++-------- LuaLibs/WProcessDoubleCut.lua | 51 +++++++++ LuaLibs/WProcessFreeContour.lua | 2 +- LuaLibs/WProcessSawCut.lua | 42 ++++++++ LuaLibs/WallExec.lua | 4 +- NestProcess.lua | 179 ++++++++++++++++++++------------ 6 files changed, 221 insertions(+), 118 deletions(-) create mode 100644 LuaLibs/WProcessDoubleCut.lua create mode 100644 LuaLibs/WProcessSawCut.lua diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 13319bb..894d821 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -1,4 +1,4 @@ --- BatchProcess.lua by Egaltech s.r.l. 2021/01/15 +-- BatchProcess.lua by Egaltech s.r.l. 2021/05/16 -- Gestione calcolo batch disposizione e lavorazioni per Pareti -- 2021/01/15 Per nuova interfaccia Egt. @@ -122,7 +122,7 @@ EgtAddToPackagePath( sMachDir .. '\\Wall\\?.lua') -- Carico le librerie _G.package.loaded.WallExec = nil local WE = require( 'WallExec') ---local BL = require( 'BeamLib') +local WL = require( 'WallLib') -- Carico i dati globali local WD = require( 'WallData') @@ -295,53 +295,6 @@ if bToProcess then -- Se devo creare il pannello if bCreatePanel then - -- Eseguo eventuali rotazioni e inversioni testa-coda - --for i = 1, #vWall do - -- local b3Solid = vWall[i].Box - -- -- rotazione - -- local dRotAng = EgtGetInfo( vWall[i].Id, 'ROTATED', 'd') - -- if dRotAng then - -- if abs( dRotAng) > GEO.EPS_ANG_SMALL then - -- local ptRotCen = b3Solid:getCenter() - -- EgtRotate( vWall[i].Id, ptRotCen, X_AX(), dRotAng, GDB_RT.GLOB) - -- b3Solid:rotate( ptRotCen, X_AX(), dRotAng) - -- end - -- EgtSetInfo( vWall[i].Id, 'ROTATED_DONE', dRotAng) - -- end - -- -- inversione - -- local dInvAng = EgtGetInfo( vWall[i].Id, 'INVERTED', 'd') - -- if dInvAng then - -- if abs( dInvAng - 180) > GEO.EPS_ANG_SMALL and abs( dInvAng + 180) > GEO.EPS_ANG_SMALL then - -- local ptInvCen = b3Solid:getCenter() - -- EgtRotate( vWall[i].Id, ptInvCen, Z_AX(), dInvAng - 180, GDB_RT.GLOB) - -- b3Solid:rotate( ptInvCen, Z_AX(), dInvAng - 180) - -- end - -- EgtSetInfo( vWall[i].Id, 'INVERTED_DONE', dInvAng) - -- end - -- -- correzioni per rotazioni non centrate di produzioni TS3 (quasi sempre 0 o 180 deg) - -- if not bProj and dRotAng and dInvAng then - -- if abs( dInvAng - 0) < GEO.EPS_ANG_SMALL then - -- if abs( dRotAng - 180) < GEO.EPS_ANG_SMALL then - -- vWall[i].PosZ = vWall[i].PosZ - vWall[i].Box:getDimY() - -- end - -- elseif abs( dInvAng - 90) < GEO.EPS_ANG_SMALL or abs( dInvAng + 270) < GEO.EPS_ANG_SMALL then - -- vWall[i].PosZ = vWall[i].PosZ - vWall[i].Box:getDimY() - -- if abs( dRotAng - 180) < GEO.EPS_ANG_SMALL then - -- vWall[i].PosX = vWall[i].PosX - vWall[i].Box:getDimX() - -- end - -- elseif abs( dInvAng - 180) < GEO.EPS_ANG_SMALL or abs( dInvAng + 180) < GEO.EPS_ANG_SMALL then - -- vWall[i].PosX = vWall[i].PosX - vWall[i].Box:getDimX() - -- if abs( dRotAng - 0) < GEO.EPS_ANG_SMALL then - -- vWall[i].PosZ = vWall[i].PosZ - vWall[i].Box:getDimY() - -- end - -- elseif abs( dInvAng - 270) < GEO.EPS_ANG_SMALL or abs( dInvAng + 90) < GEO.EPS_ANG_SMALL then - -- if abs( dRotAng - 0) < GEO.EPS_ANG_SMALL then - -- vWall[i].PosX = vWall[i].PosX - vWall[i].Box:getDimX() - -- end - -- end - -- end - --end - -- Ne verifico le dimensioni local dRawH = vWall[1].Box:getDimZ() local vWallErr = {} @@ -402,6 +355,16 @@ if bToProcess then local nMGrpId = EgtGetCurrMachGroup() EgtSetInfo(nMGrpId, 'PANELHEIGHT', dRawH) end + -- altrimenti sistemo + else + -- recupero il grezzo + local nRawId = EgtGetFirstRawPart() + -- ciclo sui pezzi + local nPartId = EgtGetFirstPartInRawPart( nRawId) + while nPartId do + WL.CreateOrEmptyAddGroup( nPartId) + nPartId = EgtGetNextPartInRawPart( nPartId) + end end -- Se richiesta solo pannello, esco diff --git a/LuaLibs/WProcessDoubleCut.lua b/LuaLibs/WProcessDoubleCut.lua new file mode 100644 index 0000000..0a36eed --- /dev/null +++ b/LuaLibs/WProcessDoubleCut.lua @@ -0,0 +1,51 @@ +-- WProcessDoubleCut.lua by Egaltech s.r.l. 2021/04/28 +-- Gestione calcolo doppi tagli di lama per Pareti + +-- Tabella per definizione modulo +local WPDC = {} + +-- Include +require( 'EgtBase') +local WL = require( 'WallLib') +local Cut = require( 'WProcessCut') +local LapJoint = require( 'WProcessLapJoint') + +EgtOutLog( ' WProcessDoubleCut started', 1) + +-- Dati +local WD = require( 'WallData') +local ML = require( 'WMachiningLib') + +--------------------------------------------------------------------- +-- Riconoscimento della feature +function WPDC.Identify( Proc) + return ( (( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 11) or + ( Proc.Grp == 0 and Proc.Prc == 12)) +end + +--------------------------------------------------------------------- +-- Classificazione della feature +function WPDC.Classify( Proc, b3Raw) + -- se una faccia, uso la classificazione dei tagli singoli + if Proc.Fct == 1 then return Cut.Classify( Proc, b3Raw) end + -- se più di due facce non si fa + if Proc.Fct > 2 then return false end + -- dati delle facce + local vtN = {} + vtN[1] = EgtSurfTmFacetNormVersor( Proc.Id, 0, GDB_ID.ROOT) + vtN[2] = EgtSurfTmFacetNormVersor( Proc.Id, 1, GDB_ID.ROOT) + -- verifico se è lavorabile da sopra o di fianco + return ( vtN[1]:getZ() >= - 0.01 or vtN[2]:getZ() >= - 0.01) +end + +--------------------------------------------------------------------- +-- Applicazione della lavorazione +function WPDC.Make( Proc, nRawId, b3Raw) + -- se singola faccia, passo a quella lavorazione + if Proc.Fct == 1 then return Cut.Make( Proc, nRawId, b3Raw) end + -- altrimenti due facce e passo alla LapJoint + return LapJoint.Make( Proc, nRawId, b3Raw) +end + +--------------------------------------------------------------------- +return WPDC diff --git a/LuaLibs/WProcessFreeContour.lua b/LuaLibs/WProcessFreeContour.lua index ce294b5..8bba72e 100644 --- a/LuaLibs/WProcessFreeContour.lua +++ b/LuaLibs/WProcessFreeContour.lua @@ -1093,7 +1093,7 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd end end -- se entità singola in parte fatta con lama, non lavoro - if #vFace == 1 and vFace[1].Type ~= 4 then return true end + --if #vFace == 1 and vFace[1].Type ~= 4 then return true end -- verifico se ciclo chiuso local bClosed = ( abs( vFace[1].PrevAng) > 0.1) -- ciclo di inserimento delle fresate sulle facce del contorno in esame diff --git a/LuaLibs/WProcessSawCut.lua b/LuaLibs/WProcessSawCut.lua new file mode 100644 index 0000000..70391b0 --- /dev/null +++ b/LuaLibs/WProcessSawCut.lua @@ -0,0 +1,42 @@ +-- WProcessSawCut.lua by Egaltech s.r.l. 2021/04/28 +-- Gestione calcolo taglio di lama per Pareti + +-- Tabella per definizione modulo +local WPSC = {} + +-- Include +require( 'EgtBase') +local WL = require( 'WallLib') +local Cut = require( 'WProcessCut') + +EgtOutLog( ' WProcessSawCut started', 1) + +-- Dati +local WD = require( 'WallData') +local WM = require( 'WMachiningLib') + +--------------------------------------------------------------------- +-- Riconoscimento della feature +function WPSC.Identify( Proc) + return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 13) +end + +--------------------------------------------------------------------- +-- Classificazione della feature +function WPSC.Classify( Proc, b3Raw) + -- recupero i dati del versore direzione di accesso della lavorazione + local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') + if not AuxId then return false end + AuxId = AuxId + Proc.Id + local vtDir = EgtSV( AuxId, GDB_ID.ROOT) + return ( vtDir:getZ() > 0.5) +end + +--------------------------------------------------------------------- +-- Applicazione della lavorazione +function WPSC.Make( Proc, nRawId, b3Raw) + return Cut.Make( Proc, nRawId, b3Raw) +end + +--------------------------------------------------------------------- +return WPSC diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index bcde431..5779f57 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -117,7 +117,7 @@ end ------------------------------------------------------------------------------------------------------------- -- *** Inserimento delle lavorazioni nelle pareti *** ------------------------------------------------------------------------------------------------------------- -local function CollectFeatures( PartId, b3Raw) +function WallExec.CollectFeatures( PartId, b3Raw) -- recupero le feature local vProc = {} local LayerId = {} @@ -396,7 +396,7 @@ function WallExec.ProcessFeatures() local vProc = {} for i = 1, #vPart do -- recupero le feature di lavorazione della parete - local vPartProc = CollectFeatures( vPart[i].Id, b3Raw) + local vPartProc = WallExec.CollectFeatures( vPart[i].Id, b3Raw) vProc = EgtJoinTables( vProc, vPartProc) end -- classifico le feature diff --git a/NestProcess.lua b/NestProcess.lua index ee58b79..1534345 100644 --- a/NestProcess.lua +++ b/NestProcess.lua @@ -1,4 +1,4 @@ --- NestProcess.lua by Egaltech s.r.l. 2021/02/13 +-- NestProcess.lua by Egaltech s.r.l. 2021/05/16 -- Gestione nesting automatico pareti -- Intestazioni @@ -12,7 +12,7 @@ EgtEnableDebug( false) --NEST.MACHINE = 'Essetre-90480019_MW' --NEST.FLAG = 3 -local sLog = 'BatchProcess : ' .. NEST.FILE .. ', ' .. NEST.MACHINE .. ', ' .. NEST.PANELLEN .. ', ' .. NEST.PANELWIDTH +local sLog = 'BatchProcess : ' .. NEST.FILE .. ', ' .. NEST.MACHINE .. ', ' .. NEST.LEN .. ', ' .. NEST.WIDTH EgtOutLog( sLog) -- Cancello file di log specifico @@ -87,6 +87,28 @@ end local sBaseDir = EgtGetSourceDir() EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') +-- Verifico che la macchina corrente sia abilitata per la lavorazione delle Pareti +local sMachDir = EgtGetCurrMachineDir() +if not EgtExistsFile( sMachDir .. '\\Wall\\WallData.lua') then + WALL.ERR = 12 + WALL.MSG = 'Error not configured for walls machine : ' .. sMachine + WriteErrToLogFile( WALL.ERR, WALL.MSG) + PostErrView( WALL.ERR, WALL.MSG) + return +end + +-- Elimino direttori altre macchine e imposto direttorio macchina corrente per ricerca librerie +EgtRemoveBaseMachineDirFromPackagePath() +EgtAddToPackagePath( sMachDir .. '\\Wall\\?.lua') + +-- Carico le librerie +_G.package.loaded.WallExec = nil +local WE = require( 'WallExec') +_G.package.loaded.WallLib = nil +local WL = require( 'WallLib') +_G.package.loaded.WProcessLapJoint = nil +local LapJoint = require( 'WProcessLapJoint') + -- Inizializzo contatori errori e avvisi local nErrCnt = 0 local nWarnCnt = 0 @@ -100,18 +122,42 @@ local SheetPartId = EgtGroup(GDB_ID.ROOT) EgtSetName(SheetPartId, "Sheet") local SheetLayerId = EgtGroup(SheetPartId) EgtSetName(SheetLayerId, OUTLINE) -local SheetOutlineId = EgtRectangle2P(SheetLayerId, Point3d(0,0,0), Point3d(NEST.PANELLEN, NEST.PANELWIDTH, 0), GDB_RT.GLOB) +local SheetOutlineId = EgtRectangle2P(SheetLayerId, Point3d(0,0,0), Point3d(NEST.LEN, NEST.WIDTH, 0), GDB_RT.GLOB) -- EgtModifyCurveThickness(SheetOutlineId, -Material.T_mm) EgtSetName(SheetOutlineId, OUTLINE) -- creo foglio per nesting -EgtAutoNestAddSheet( SheetPartId, SheetOutlineId, 20, 0, 50) -- EgtAutoNestAddSheet( SheetId, OutlineId, dKerf, nPriority, nCount) +EgtAutoNestAddSheet( SheetPartId, SheetOutlineId, NEST.KERF, 0, 50) -- EgtAutoNestAddSheet( SheetId, OutlineId, dKerf, nPriority, nCount) -- ciclo su pezzi per aggiungerli al nesting for nPartId, nCount in pairs( PART) do + -- verifico se ruotare pareti + -- recupero le feature di lavorazione della parete + local bFtDown = false + local vPartProc = WE.CollectFeatures( nPartId, b3Raw) + for nInd = 1, #vPartProc do + if LapJoint.Identify( vPartProc[nInd]) then + local nFacOpt, dMinElev, nFacOpt2, dMinElev2 = WL.GetFaceWithMostAdj( vPartProc[nInd].Id, vPartProc[nInd].PartId) + if nFacOpt then + local vtN = EgtSurfTmFacetNormVersor( vPartProc[nInd].Id, nFacOpt, GDB_ID.ROOT) + if vtN:getZ() < -0.09 then + bFtDown = true + break + end + end + end + end + -- ruoto se necessario + if bFtDown then + local b3Solid = EgtGetBBoxGlob(nPartId, GDB_BB.IGNORE_TEXT) + local ptRotCen = b3Solid:getCenter() + EgtRotate( nPartId, ptRotCen, X_AX(), 180, GDB_RT.GLOB) + end + + -- recupero contorno local nOutlineLayer = EgtGetFirstNameInGroup(nPartId, "Outline") - local nOutline = GDB_ID.NULL - local nTrimesh = GDB_ID.NULL + local nOutline + local nTrimesh local bFirst = true local bSecond = false local bUseBox = false @@ -125,48 +171,53 @@ for nPartId, nCount in pairs( PART) do if not nTrimesh then nTrimesh = EgtGetFirstNameInGroup( nOutlineLayer, "4-Out") end - local nAuxId = EgtGetInfo(nTrimesh, "AUXID", 'i') - nOutline = nTrimesh + nAuxId - - --- local nIndex = EgtGetFirstInGroup(nOutlineLayer) --- while nIndex do --- local nType = EgtGetType(nIndex) --- if nType == GDB_TY.CRV_COMPO then --- nOutline = nIndex --- if bFirst then --- bFirst = false --- else --- bSecond = true --- end --- elseif nType == GDB_TY.SRF_MESH then --- nTrimesh = nIndex --- end --- nIndex = EgtGetNext(nIndex) --- end - -- se c'è solo una compo verifico se ha lati inclinati --- if not bSecond then - local nFacetCount = EgtSurfTmFacetCount(nTrimesh) - for nIndex = 0, nFacetCount - 1 do - local vtNorm = EgtSurfTmFacetNormVersor(nTrimesh, nIndex, GDB_ID.ROOT) - if abs( vtNorm:getZ()) > 10 * GEO.EPS_SMALL then - bUseBox = true - break + -- se trovato contorno + if nTrimesh then + -- recupero la curva associata + local nAuxId = EgtGetInfo(nTrimesh, "AUXID", 'i') + nOutline = nTrimesh + nAuxId + -- verifico che il contorno sia verticale + local nFacetCount = EgtSurfTmFacetCount(nTrimesh) + for nIndex = 0, nFacetCount - 1 do + local vtNorm = EgtSurfTmFacetNormVersor(nTrimesh, nIndex, GDB_ID.ROOT) + if abs( vtNorm:getZ()) > 10 * GEO.EPS_SMALL then + bUseBox = true + break + end end + -- se due compo o una e lati inclinati + if bUseBox then + -- calcolo box della trimesh + local b3Outline = EgtGetBBoxGlob(nTrimesh, GDB_BB.IGNORE_TEXT) + local ptP1 = Point3d( b3Outline:getMin():getX(), b3Outline:getMin():getY(), 0) + local ptP2 = Point3d( b3Outline:getMax():getX(), b3Outline:getMax():getY(), 0) + -- creo outline del box + nOutline = EgtRectangle2P(nOutlineLayer, ptP1, ptP2, GDB_RT.GLOB) + EgtSetStatus(nOutline, GDB_ST.OFF) + end + -- altrimenti cerco la regione sopra + else + local nReg + for i = 1, 4 do + local sRegName = string.format( '%d-Top', i) + nReg = EgtGetFirstNameInGroup( nOutlineLayer, sRegName) + if nReg then + local vtNorm = EgtSurfFrNormVersor( nReg, GDB_ID.ROOT) + if vtNorm:getZ() > 0.99 then break end + end + end + if not nReg then + EgtOutLog("Errore: regione superiore non trovata") + end + local OutId, nCnt = EgtExtractSurfFrChunkLoops( nReg, 0, nOutlineLayer) + if OutId and nCnt > 1 then + for i = 2, nCnt do + EgtErase( OutId + i - 1) + end + end + nOutline = OutId end --- else --- bUseBox = true --- end - -- se due compo o una e lati inclinati - if bUseBox then - -- calcolo box della trimesh - local b3Outline = EgtGetBBoxGlob(nTrimesh, GDB_BB.IGNORE_TEXT) - local ptP1 = Point3d( b3Outline:getMin():getX(), b3Outline:getMin():getY(), 0) - local ptP2 = Point3d( b3Outline:getMax():getX(), b3Outline:getMax():getY(), 0) - -- creo outline del box - nOutline = EgtRectangle2P(nOutlineLayer, ptP1, ptP2, GDB_RT.GLOB) - EgtSetStatus(nOutline, GDB_ST.OFF) - end + if nOutline then -- aggiungo pezzo al nesting EgtAutoNestAddPart( nPartId, nOutline, false, true, 90, 0, nCount) @@ -175,7 +226,7 @@ for nPartId, nCount in pairs( PART) do end -- aggiungo offset tra pezzi -EgtAutoNestSetInterpartGap(50) +EgtAutoNestSetInterpartGap(NEST.OFFSET) -- Impostazione corner di inizio del nesting (NST_CORNER.BL, TL, BR, TR) EgtAutoNestSetStartCorner( NST_CORNER.BR) @@ -221,33 +272,27 @@ if bOk then -- creo gruppo di lavorazione local MachGroupName = NewMachGroupName() nMachGroup = EgtAddMachGroup(MachGroupName, sCurrMachName) - EgtSetInfo(nMachGroup, "PANELLEN", NEST.PANELLEN) - EgtSetInfo(nMachGroup, "PANELWIDTH", NEST.PANELWIDTH) + EgtSetInfo(nMachGroup, "PANELLEN", NEST.LEN) + EgtSetInfo(nMachGroup, "PANELWIDTH", NEST.WIDTH) EgtSetInfo(nMachGroup, "AUTONEST", 1) nPartCount = 0 -- altrimenti pezzo else local PartId = nId nPartCount = nPartCount + 1 --- if nFlag ~= 0 then --- EgtMirror( PartId, ORIG(), Y_AX(), GDB_RT.GLOB) --- end --- EgtRotate( PartId, ORIG(), Z_AX(), dAngRot, GDB_RT.GLOB) --- EgtMove( PartId, Vector3d( dX, dY, 0) + vtAdd, GDB_RT.GLOB) -- se c'e' un grezzo valido if nMachGroup and nMachGroup ~= GDB_ID.NULL then -- creo pezzo copia - local nPartDuploId = EgtDuploNew(nId) + local nPartDuploId = EgtDuploNew( nId) EgtRotate( nPartDuploId, ORIG(), Z_AX(), dAngRot, GDB_RT.GLOB) EgtMove( nPartDuploId, Vector3d( dX, dY, 0), GDB_RT.GLOB) - local PartBBox = EgtGetBBoxGlob(nPartDuploId, GDB_BB.STANDARD) --- local ptPos = Point3d(PartBBox:getMin():getX(), PartBBox:getMin():getY(), 0) - EgtSetInfo(nMachGroup, "PART" .. nPartCount, nPartDuploId .. "," .. PartBBox:getMin():getX() .. "," .. PartBBox:getMin():getY().. "," .. 0 .. "," .. 0) --- EgtSetInfo(nMachGroup, "PART" .. nPartCount, nId .. "," .. 10 .. "," .. 10 .. "," .. 0 .. "," .. 0) - --- local PartBBox = EgtGetBBoxGlob(PartId, GDB_BB.STANDARD) --- local ptPos = Point3d(PartBBox:getMin():getX(), PartBBox:getMin():getY(), 0) --- local bOk = EgtAddPartToRawPart(PartId, ptPos, nRawId) + local PartBBox = EgtGetBBoxGlob( nPartDuploId, GDB_BB.STANDARD) + local ptPos = Point3d( PartBBox:getMin():getX(), PartBBox:getMin():getY(), 0) + EgtSetInfo( nMachGroup, "PART" .. nPartCount, nPartDuploId .. "," .. EgtNumToString( ptPos:getX(), 3) .. "," .. EgtNumToString( ptPos:getY(), 3) .. "," .. 0 .. "," .. 0) + EgtSetInfo( nPartDuploId, "POSX", ptPos:getX()) + EgtSetInfo( nPartDuploId, "POSY", ptPos:getY()) + EgtSetInfo( nPartDuploId, "ROT", 0) + EgtSetInfo( nPartDuploId, "FLIP", 0) end end end @@ -261,16 +306,18 @@ if bOk then while nMachGroup do EgtSetCurrMachGroup(nMachGroup) if EgtGetInfo(nMachGroup, "AUTONEST",'i') == 1 then - EgtSetInfo(nMachGroup, "AUTONEST", "") + EgtRemoveInfo(nMachGroup, "AUTONEST") + EgtSetInfo(nMachGroup, "UPDATEUI", 1) dofile(EgtGetSourceDir() .. "BatchProcessNew.lua") end nMachGroup = EgtGetNextMachGroup(nMachGroup) end - +else + EgtOutLog("Errore: nesting fallito") end EgtResetCurrMachGroup() --- nascondo rettangolo +-- nascondo rettangolo del materiale per nesting EgtErase(SheetPartId) -- EgtSaveFile("c:\\Temp\\Prova1.nge")