From 767e7287a5961b35a9a14b3af9d456552e255f3f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 11 Jul 2020 09:40:28 +0000 Subject: [PATCH] DataWall : - sistemazioni varie durante prime prove con macchina S3. --- BatchProcess.lua | 21 +++- LuaLibs/WMachiningLib.lua | 5 +- LuaLibs/WProcessDrill.lua | 6 +- LuaLibs/WProcessFreeContour.lua | 202 +++++++++++++++++++++++++------- LuaLibs/WProcessLapJoint.lua | 162 ++++++++++++++++++++++--- LuaLibs/WallExec.lua | 7 ++ Process.lua | 21 +++- 7 files changed, 347 insertions(+), 77 deletions(-) diff --git a/BatchProcess.lua b/BatchProcess.lua index 5054cf9..8cd5987 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -1,4 +1,4 @@ --- BatchProcess.lua by Egaltech s.r.l. 2020/06/29 +-- BatchProcess.lua by Egaltech s.r.l. 2020/07/07 -- Gestione calcolo batch disposizione e lavorazioni per Pareti @@ -148,7 +148,7 @@ if bBtl and string.find( sTitle, 'Bar_', 1, true) and EgtExistsFile( sNgeFile) t if nDiff == 0 then bToProcess = false -- se cambiata configurazione macchina da ultima elaborazione, devo riprocessare - if EgtCompareFilesLastWriteTime( sOriFile, sMachDir .. '\\Beam\\TS3Data.lua') == -1 or + if EgtCompareFilesLastWriteTime( sOriFile, sMachDir .. '\\Wall\\TS3Data.lua') == -1 or EgtCompareFilesLastWriteTime( sOriFile, sMachDir .. '\\Tools\\Tools.data') == -1 then bToRecalc = true end @@ -254,17 +254,26 @@ if bToProcess then b3Solid:rotate( ptRotCen, X_AX(), dRotAng) end EgtSetInfo( vWall[i].Id, 'ROTATED_DONE', dRotAng) - EgtRemoveInfo( vWall[i].Id, 'ROTATED') end -- inversione local dInvAng = EgtGetInfo( vWall[i].Id, 'INVERTED', 'd') if dInvAng then - if abs( 180 - dInvAng) > GEO.EPS_ANG_SMALL then + if abs( dInvAng - 180) > GEO.EPS_ANG_SMALL then local ptInvCen = b3Solid:getCenter() - EgtRotate( vWall[i].Id, ptInvCen, Z_AX(), 180 - dInvAng, GDB_RT.GLOB) + EgtRotate( vWall[i].Id, ptInvCen, Z_AX(), dInvAng - 180, GDB_RT.GLOB) end EgtSetInfo( vWall[i].Id, 'INVERTED_DONE', dInvAng) - EgtRemoveInfo( vWall[i].Id, 'INVERTED') + end + -- correzioni per rotazioni non centrate di TS3 (quasi sempre 0 o 180 deg) + if dRotAng and dInvAng then + if abs( dInvAng) > GEO.EPS_ANG_SMALL then + vWall[i].PosX = vWall[i].PosX - vWall[i].Box:getDimX() + if abs( dRotAng) < GEO.EPS_ANG_SMALL then + vWall[i].PosZ = vWall[i].PosZ - vWall[i].Box:getDimY() + end + elseif abs( dRotAng) > GEO.EPS_ANG_SMALL then + vWall[i].PosZ = vWall[i].PosZ - vWall[i].Box:getDimY() + end end end diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index 4f4ca85..4cd4a8b 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -32,7 +32,10 @@ function WMachiningLib.FindCutting( sType) for i = 1, #Cuttings do local Cutting = Cuttings[i] if Cutting.On and Cutting.Type == sType and SetCurrMachiningAndTool( Cutting.Name) then - return Cutting.Name + local dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or 0 + local dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or 0 + local dSawMaxDepth = EgtTdbGetCurrToolMaxDepth() or 0 + return Cutting.Name, dSawDiam, dSawThick, dSawMaxDepth end end end diff --git a/LuaLibs/WProcessDrill.lua b/LuaLibs/WProcessDrill.lua index 044db3a..4260c34 100644 --- a/LuaLibs/WProcessDrill.lua +++ b/LuaLibs/WProcessDrill.lua @@ -1,4 +1,4 @@ --- WProcessDrill.lua by Egaltech s.r.l. 2020/06/24 +-- WProcessDrill.lua by Egaltech s.r.l. 2020/07/10 -- Gestione calcolo forature per Pareti -- Tabella per definizione modulo @@ -159,8 +159,8 @@ function WPD.Make( Proc, nRawId, b3Raw) EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) end -- imposto posizione braccio porta testa - local nSCC = MCH_SCC.ADIR_YM - if vtExtr:getY() > 100 * GEO.EPS_ZERO then + local nSCC = MCH_SCC.ADIR_ZP + if AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then nSCC = MCH_SCC.ADIR_YP end EgtSetMachiningParam( MCH_MP.SCC, nSCC) diff --git a/LuaLibs/WProcessFreeContour.lua b/LuaLibs/WProcessFreeContour.lua index d12606e..fcd856a 100644 --- a/LuaLibs/WProcessFreeContour.lua +++ b/LuaLibs/WProcessFreeContour.lua @@ -1,4 +1,4 @@ --- ProcessFreeContour.lua by Egaltech s.r.l. 2020/07/01 +-- ProcessFreeContour.lua by Egaltech s.r.l. 2020/07/08 -- Gestione calcolo profilo libero per Pareti -- Tabella per definizione modulo @@ -13,6 +13,7 @@ EgtOutLog( ' WProcessFreeContour started', 1) -- Dati local WD = require( 'WallData') local WM = require( 'WMachiningLib') +local WHISK_OFFS = 0.1 local WHISK_SAFE = 5 local MIN_LEN_CUT = 5 @@ -119,7 +120,11 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw) -- assegno lato di lavoro EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) -- posizione braccio porta testa - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP) + local nSCC = MCH_SCC.ADIR_ZP + if abs( vFace[i].Norm:getZ()) < GEO.EPS_SMALL then + nSCC = MCH_SCC.ADIR_YP + end + EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -180,12 +185,105 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw) return true end +--------------------------------------------------------------------- +local function AddSawings( sSawing, vFace, Proc, nRawId, b3Raw) + -- recupero i dati dell'utensile + local dSawDiam = 0 + local dMaxDepth = 0 + if EgtMdbSetCurrMachining( sSawing) 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 + -- ciclo di inserimento dei tagli con sega a catena + for i = 1, #vFace do + -- se inizio faccia non tagliato completamente, inserisco un ripasso con sega a catena + if ( vFace[i].Type & 1) ~= 0 then + -- inserisco la lavorazione + local sName = 'Free_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) + local nMchId = EgtAddMachining( sName, sSawing) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sSawing + EgtOutLog( sErr) + return false, sErr + end + -- calcolo l'affondamento + local dDepth = min( vFace[i].Width + WD.CUT_EXTRA, dMaxDepth) + -- aggiungo geometria + EgtSetMachiningGeometry( {{ Proc.Id, i - 1}}) + local dSal = - dSawDiam / 2 + local dEal = vFace[i].Whisk - vFace[i].Len - dSawDiam / 2 + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) + -- percorso da non invertire + EgtSetMachiningParam( MCH_MP.INVERT, false) + -- assegno utilizzo faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN) + -- assegno affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + -- assegno lato di lavoro + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + -- posizione braccio porta testa + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + end + -- se fine faccia non tagliato completamente o faccia non tagliata completamente e abbastanza lunga, inserisco un ripasso con sega a catena + if ( vFace[i].Type & 1) ~= 0 or ( vFace[i].Type == 4 and vFace[i].Len > dSawDiam + 1) then + -- inserisco la lavorazione + local sName = 'Free_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) + local nMchId = EgtAddMachining( sName, sSawing) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sSawing + EgtOutLog( sErr) + return false, sErr + end + -- calcolo l'affondamento + local dDepth = min( vFace[i].Width + WD.CUT_EXTRA, dMaxDepth) + -- aggiungo geometria + EgtSetMachiningGeometry( {{ Proc.Id, i - 1}}) + local dSal = - dSawDiam / 2 + local dEal = - dSawDiam / 2 + if ( vFace[i].Type & 2) ~= 0 then + dSal = vFace[i].Whisk - vFace[i].Len - dSawDiam / 2 + end + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) + -- percorso da non invertire + EgtSetMachiningParam( MCH_MP.INVERT, false) + -- assegno utilizzo faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN) + -- assegno affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + -- assegno lato di lavoro + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + -- posizione braccio porta testa + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + end + end + return true +end + --------------------------------------------------------------------- local function AddCuts( sCutting, vFace, Proc, nRawId, b3Raw) -- ciclo di inserimento dei tagli sulle facce del contorno in esame for i = 1, #vFace do -- se non è faccia da saltare, inserisco il taglio di lama if vFace[i].Type ~= 4 then + -- indice del successivo + local j = EgtIf( i < #vFace, i + 1, 1) -- inserisco la lavorazione local sName = 'Cut_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) .. '_' .. tostring( i) local nMchId = EgtAddMachining( sName, sCutting) @@ -196,27 +294,36 @@ local function AddCuts( sCutting, vFace, Proc, nRawId, b3Raw) end -- aggiungo geometria EgtSetMachiningGeometry( { { Proc.Id, i - 1}}) - -- percorso da non invertire - EgtSetMachiningParam( MCH_MP.INVERT, false) -- assegno affondamento EgtSetMachiningParam( MCH_MP.DEPTH, vFace[i].Depth) - -- assegno il lato di lavoro - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + -- verifico se va invertita la direzione di lavorazione perchè faccia verso l'alto (angolo maggiore di 0.01 deg) + local bInvert = ( vFace[i].Norm:getZ() > 0.0001745) + -- imposto inversione + EgtSetMachiningParam( MCH_MP.INVERT, bInvert) + -- imposto lato di lavoro + EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( bInvert, MCH_SAW_WS.LEFT, MCH_SAW_WS.RIGHT)) + -- lato mandrino sempre a sinistra (rotazione lama oraria) + EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.LEFT) -- assegno i dati di attacco (sicurezza solo se angolo interno) - local nLeadIn = EgtIf( ( vFace[i].Type & 1) == 0, MCH_SAW_LI.CENT, MCH_SAW_LI.STRICT) + local nLeadIn = MCH_SAW_LI.CENT + if ( not bInvert and ( vFace[i].Type & 1) ~= 0) or ( bInvert and ( vFace[i].Type & 2) ~= 0) then + nLeadIn = MCH_SAW_LI.STRICT + end EgtSetMachiningParam( MCH_MP.LEADINTYPE, nLeadIn) - if vFace[i].AngPrev < -0.1 then + if ( not bInvert and vFace[i].AngPrev < -0.1) or ( bInvert and vFace[j].AngPrev < -0.1) then EgtSetMachiningParam( MCH_MP.STARTADDLEN, -WHISK_SAFE) end -- assegno i dati di uscita (sicurezza solo se angolo interno) - local nLeadOut = EgtIf( ( vFace[i].Type & 2) == 0, MCH_SAW_LO.CENT, MCH_SAW_LO.STRICT) + local nLeadOut = MCH_SAW_LO.CENT + if ( not bInvert and ( vFace[i].Type & 2) ~= 0) or ( bInvert and ( vFace[i].Type & 1) ~= 0) then + nLeadOut = MCH_SAW_LO.STRICT + end EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, nLeadOut) - local j = EgtIf( i < #vFace, i + 1, 1) - if vFace[j].AngPrev < -0.1 then + if ( not bInvert and vFace[j].AngPrev < -0.1) or ( bInvert and vFace[i].AngPrev < -0.1) then EgtSetMachiningParam( MCH_MP.ENDADDLEN, -WHISK_SAFE) end -- posizione braccio porta testa - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP) + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -239,31 +346,21 @@ local function MakeByCut( Proc, nRawId, b3Raw) return false, sErr end -- recupero la lavorazione di fresatura - local sMilling = WM.FindMilling( 'FreeContour') + local sMilling, dMillMaxDepth = WM.FindMilling( 'FreeContour') if not sMilling then local sErr = 'Error : milling not found in library' EgtOutLog( sErr) return false, sErr end - -- recupero la lavorazione di taglio con lama - local sCutting = WM.FindCutting( 'Standard') + -- recupero la lavorazione con sega a catena + local sSawing = WM.FindSawing( 'Sawing') + -- recupero la lavorazione di taglio con lama e i suoi parametri + local sCutting, dSawDiam, dSawThick, dSawMaxDepth = WM.FindCutting( 'Standard') if not sCutting then local sErr = 'Error : cutting not found in library' EgtOutLog( sErr) return false, sErr end - -- recupero i dati della lama - local dSawDiam = 400 - local dSawThick = 10 - local dSawMaxDepth = 0 - if EgtMdbSetCurrMachining( sCutting) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam - dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThick - dSawMaxDepth = EgtTdbGetCurrToolMaxDepth() or dSawMaxDepth - end - end -- recupero i dati di tutte le facce local vFace = {} for i = 1, Proc.Fct do @@ -277,7 +374,12 @@ local function MakeByCut( Proc, nRawId, b3Raw) vFace[i] = { Cen = ptCen, Norm = vtN, Len = dLen, Width = dWidth, AngPrev = EgtIf( bAdj, dAng, 0)} end -- analizzo le facce + local dMaxWidth = 0 for i = 1, #vFace do + -- aggiorno la massima larghezza + if vFace[i].Width > dMaxWidth then + dMaxWidth = vFace[i].Width + end -- verifico l'affondamento local dDepth = WD.CUT_EXTRA if vFace[i].Width + WD.CUT_EXTRA > dSawMaxDepth then @@ -313,10 +415,12 @@ local function MakeByCut( Proc, nRawId, b3Raw) -- verifico il baffo iniziale if vFace[i].Type ~= 4 and ( vFace[i].Type & 1) == 0 then -- creo il rettangolo del baffo - local vtDir = Vector3d( vFace[i].Norm) ; vtDir:rotate( Z_AX(), -90) - local ptIni = vFace[i].Cen + vFace[i].Len / 2 * vtDir - local ptDir = ptIni + vFace[i].Whisk * vtDir - local ptCross = ptDir + dSawThick * vFace[i].Norm + local vtOrt = Vector3d( vFace[i].Norm:getX(), vFace[i].Norm:getY(), 0) ; vtOrt:normalize() + local vtDir = Vector3d( vtOrt) ; vtDir:rotate( Z_AX(), -90) + local vtUp = Vector3d( vtDir) ; vtUp:rotate( vFace[i].Norm, -90) + local ptIni = vFace[i].Cen + vFace[i].Width / 2 * vtUp + ( vFace[i].Len / 2 + WHISK_OFFS) * vtDir + WHISK_OFFS * vtOrt + local ptDir = ptIni + ( vFace[i].Whisk - WHISK_OFFS) * vtDir + local ptCross = ptDir + ( dSawThick - WHISK_OFFS) * vtOrt local WhId = EgtSurfFrRectangle3P( nAddGrpId, ptIni, ptCross, ptDir, GDB_RT.GLOB) local b3Wh = EgtGetBBoxGlob( WhId or GDB_ID.NULL, GDB_BB.STANDARD) -- verifico se interferisce con gli altri pezzi @@ -339,10 +443,12 @@ local function MakeByCut( Proc, nRawId, b3Raw) -- verifico il baffo finale if vFace[i].Type ~= 4 and ( vFace[i].Type & 2) == 0 then -- creo il rettangolo del baffo - local vtDir = Vector3d( vFace[i].Norm) ; vtDir:rotate( Z_AX(), 90) - local ptIni = vFace[i].Cen + vFace[i].Len / 2 * vtDir - local ptDir = ptIni + vFace[i].Whisk * vtDir - local ptCross = ptDir + dSawThick * vFace[i].Norm + local vtOrt = Vector3d( vFace[i].Norm:getX(), vFace[i].Norm:getY(), 0) ; vtOrt:normalize() + local vtDir = Vector3d( vtOrt) ; vtDir:rotate( Z_AX(), 90) + local vtUp = Vector3d( vtDir) ; vtUp:rotate( vFace[i].Norm, 90) + local ptIni = vFace[i].Cen + vFace[i].Width / 2 * vtUp + ( vFace[i].Len / 2 + WHISK_OFFS) * vtDir + WHISK_OFFS * vtOrt + local ptDir = ptIni + ( vFace[i].Whisk - WHISK_OFFS) * vtDir + local ptCross = ptDir + ( dSawThick - WHISK_OFFS) * vtOrt local WhId = EgtSurfFrRectangle3P( nAddGrpId, ptIni, ptCross, ptDir, GDB_RT.GLOB) local b3Wh = EgtGetBBoxGlob( WhId or GDB_ID.NULL, GDB_BB.STANDARD) -- verifico se interferisce con gli altri pezzi @@ -366,9 +472,15 @@ local function MakeByCut( Proc, nRawId, b3Raw) -- inserimento dei tagli di lama local bCtOk, sCtErr = AddCuts( sCutting, vFace, Proc, nRawId, b3Raw) if not bCtOk then return bCtOk, sCtErr end - -- inserimento delle fresature - local bMlOk, sMlErr = AddMillings( sMilling, vFace, Proc, nRawId, b3Raw) - if not bMlOk then return bMlOk, sMlErr end + -- se possibile, inserimento delle fresature + if dMaxWidth + WD.CUT_EXTRA < dMillMaxDepth then + local bMlOk, sMlErr = AddMillings( sMilling, vFace, Proc, nRawId, b3Raw) + if not bMlOk then return bMlOk, sMlErr end + -- altrimenti provo con la sega a catena + else + local bCsOk, sCSErr = AddSawings( sSawing, vFace, Proc, nRawId, b3Raw) + if not bCsOk then return bCsOk, sCsErr end + end return true end @@ -446,7 +558,11 @@ local function MakeByMill( Proc, nRawId, b3Raw) EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) end -- posizione braccio porta testa - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP) + local nSCC = MCH_SCC.ADIR_ZP + if AreSameOrOppositeVectorApprox( 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() @@ -498,11 +614,11 @@ local function MakeByPocket( Proc, nRawId, b3Raw) -- 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) + 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) -- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente if dDepth > dMaxDepth + 10 * GEO.EPS_SMALL then dDepth = dMaxDepth diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 15f1ac7..534d4ad 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -1,4 +1,4 @@ --- WProcessLapJoint.lua by Egaltech s.r.l. 2020/06/30 +-- WProcessLapJoint.lua by Egaltech s.r.l. 2020/07/10 -- Gestione calcolo mezzo-legno per Pareti -- Tabella per definizione modulo @@ -17,7 +17,10 @@ local WM = require( 'WMachiningLib') --------------------------------------------------------------------- -- Riconoscimento della feature function WPL.Identify( Proc) - return ( ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 30) or + return ( ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 16) or + ( ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 17) or + ( ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 20) or + ( ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 30) or ( ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 32) or ( ( Proc.Grp == 4) and Proc.Prc == 39) end @@ -52,11 +55,12 @@ function WPL.Classify( Proc, b3Raw) end --------------------------------------------------------------------- -local function MakePocketing( Proc, nFacet, nRawId, b3Raw) - -- recupero i dati della curva e del profilo +local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw) + -- dati della faccia + local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacet, GDB_ID.ROOT) local dElev = WL.GetFaceElevation( Proc.Id, nFacet, nPartId) -- recupero la lavorazione - local sPocketing = WM.FindPocketing( 'Pocket', nil, dDepth) + local sPocketing = WM.FindPocketing( 'Pocket', nil, dElev) if not sPocketing then local sErr = 'Error : pocketing not found in library' EgtOutLog( sErr) @@ -83,7 +87,11 @@ local function MakePocketing( Proc, nFacet, nRawId, b3Raw) -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, nFacet}}) -- imposto posizione braccio porta testa - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP) + local nSCC = MCH_SCC.ADIR_ZP + if AreSameVectorApprox( vtN, 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) -- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente local dDepth = 0 if dElev > dMaxDepth + 10 * GEO.EPS_SMALL then @@ -104,22 +112,140 @@ local function MakePocketing( Proc, nFacet, nRawId, b3Raw) end --------------------------------------------------------------------- --- Applicazione della lavorazione -function WPL.Make( Proc, nRawId, b3Raw) - -- svuotatura della faccia principale - local nFacet - if Proc.Fct == 1 then - nFacet = 0 - elseif Proc.Fct >= 2 then +local function MakeOneFace( Proc, nRawId, b3Raw) + -- dati della faccia + local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) + -- dimensioni della faccia + local _, dDimH, dDimV = WL.GetFaceHvRefDim( Proc.Id, 0) + -- recupero la lavorazione di taglio con lama e i suoi parametri + local sCutting, dSawDiam, dSawThick, dSawMaxDepth = WM.FindCutting( 'Standard') + -- se non inclinata o capacità di taglio non sufficiente, provo con svuotatura + if not sCutting or vtN:getZ() > 0.95 or dSawMaxDepth < dDimV + WD.CUT_SIC then + -- faccio con svuotatura + local nFacet = 0 + return MakeByPocketing( Proc, nFacet, nRawId, b3Raw) + end + -- eseguo il taglio di lama + local sName = 'Cut_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) .. '_' .. tostring( Proc.Id) + 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, 0}}) + -- percorso da non invertire + EgtSetMachiningParam( MCH_MP.INVERT, false) + -- assegno affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, 0) + -- assegno il lato di lavoro + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + -- assegno l'attacco e l'uscita + EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT) + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT) + -- nessun criterio per il braccio è necessario + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + return true +end + +--------------------------------------------------------------------- +local function MakeTwoFaces( Proc, nRawId, b3Raw) + -- dati delle facce + local ptC = {} + local vtN = {} + ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) + ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT) + -- determino l'intersezione tra le due facce + local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) + if not bAdj then + return false, 'Feature with two faces not adjacentes' + end + -- versore della linea di intersezione + local vtX = ptP2 - ptP1 ; vtX:normalize() + -- larghezza delle facce ortogonalmente all'intersezione + local dDimY = {} + for i = 1, 2 do + local vtY = vtN[i] ^ vtX ; vtY:normalize() + local frRef = Frame3d( ptC[i], ptC[i] + 100 * vtX, ptC[i] + 100 * vtY) + local b3Ref = EgtSurfTmGetFacetBBoxRef( Proc.Id, i - 1, GDB_BB.STANDARD, frRef) + dDimY[i] = b3Ref:getDimY() + end + -- recupero la lavorazione di taglio con lama e i suoi parametri + local sCutting, dSawDiam, dSawThick, dSawMaxDepth = WM.FindCutting( 'Standard') + -- se non inclinate o capacità di taglio non sufficiente, provo con svuotatura + if not sCutting or vtN[1]:getZ() > 0.95 or vtN[2]:getZ() > 0.95 or dSawMaxDepth < dDimY[1] + WD.CUT_SIC or dSawMaxDepth < dDimY[2] + WD.CUT_SIC then + -- cerco la faccia con il maggior numero di adiacenze local nFacInd, _, nFacInd2 = WL.GetFaceWithMostAdj( Proc.Id, Proc.PartId) local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT) - if vtN:getZ() >= WD.NZ_MINA then - nFacet = nFacInd - else - nFacet = nFacInd2 + local nFacet = EgtIf( vtN:getZ() >= WD.NZ_MINA, nFacInd, nFacInd2) + -- eseguo la svuotatura + return MakeByPocketing( Proc, nFacet, nRawId, b3Raw) + end + -- ordino i tagli per fare prima quello meno inclinato + local nOrd = { 0, 1} + if vtN[2]:getZ() > vtN[1]:getZ() then + nOrd = { 1, 0} + end + -- eseguo i tagli di lama + for i = 1, 2 do + -- inserisco la lavorazione + local sName = 'Cut_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) .. '_' .. tostring( Proc.Id) .. '_' .. 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, nOrd[i]}}) + -- percorso da non invertire + EgtSetMachiningParam( MCH_MP.INVERT, false) + -- assegno affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, 0) + -- assegno il lato di lavoro + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + -- assegno l'attacco e l'uscita + EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT) + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT) + -- nessun criterio per il braccio è necessario + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr end end - return MakePocketing( Proc, nFacet, nRawId, b3Raw) + return true +end + +--------------------------------------------------------------------- +local function MakeMoreFaces( Proc, nRawId, b3Raw) + -- cerco la faccia con il maggior numero di adiacenze + local nFacInd, _, nFacInd2 = WL.GetFaceWithMostAdj( Proc.Id, Proc.PartId) + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT) + local nFacet = EgtIf( vtN:getZ() >= WD.NZ_MINA, nFacInd, nFacInd2) + -- eseguo la svuotatura + return MakeByPocketing( Proc, nFacet, nRawId, b3Raw) +end + +--------------------------------------------------------------------- +-- Applicazione della lavorazione +function WPL.Make( Proc, nRawId, b3Raw) + if Proc.Fct == 1 then + return MakeOneFace( Proc, nRawId, b3Raw) + elseif Proc.Fct == 2 then + return MakeTwoFaces( Proc, nRawId, b3Raw) + else + return MakeMoreFaces( Proc, nRawId, b3Raw) + end end --------------------------------------------------------------------- diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 2225962..5bfd4ec 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -168,6 +168,10 @@ local function AddFeatureMachining( Proc, nRawId, b3Raw) elseif FreeContour.Identify( Proc) then -- esecuzione contorno bOk, sErr = FreeContour.Make( Proc, nRawId, b3Raw) + -- altrimenti feature non riconosciuta + else + bOk = false + sErr = 'Feature type non recognized for machining' end return bOk, sErr end @@ -211,6 +215,9 @@ function WallExec.ProcessFeatures() else table.insert( Stats, {Err=0, Msg='', Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) end + else + local sMsg = 'Feature not machinable by orientation' + table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) end end -- restituzione risultati diff --git a/Process.lua b/Process.lua index 13d3d30..62d556e 100644 --- a/Process.lua +++ b/Process.lua @@ -1,4 +1,4 @@ --- Process.lua by Egaltech s.r.l. 2020/04/29 +-- Process.lua by Egaltech s.r.l. 2020/07/07 -- Gestione calcolo disposizione e lavorazioni per Pareti -- Si opera sulla macchina corrente @@ -105,23 +105,32 @@ local function MyProcessInputData() -- rotazione local dRotAng = EgtGetInfo( vWall[i].Id, 'ROTATED', 'd') if dRotAng then - if abs( dRotAng) > GEO.EPS_ANG_SMALL then + if abs( dRotAng) > GEO.EPS_ANG_SMALL and not EgtExistsInfo( vWall[i].Id, 'ROTATED_DONE') 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) - EgtRemoveInfo( vWall[i].Id, 'ROTATED') end -- inversione local dInvAng = EgtGetInfo( vWall[i].Id, 'INVERTED', 'd') if dInvAng then - if abs( 180 - dInvAng) > GEO.EPS_ANG_SMALL then + if abs( dInvAng - 180) > GEO.EPS_ANG_SMALL and not EgtExistsInfo( vWall[i].Id, 'INVERTED_DONE') then local ptInvCen = b3Solid:getCenter() - EgtRotate( vWall[i].Id, ptInvCen, Z_AX(), 180 - dInvAng, GDB_RT.GLOB) + EgtRotate( vWall[i].Id, ptInvCen, Z_AX(), dInvAng - 180, GDB_RT.GLOB) end EgtSetInfo( vWall[i].Id, 'INVERTED_DONE', dInvAng) - EgtRemoveInfo( vWall[i].Id, 'INVERTED') + end + -- correzioni per rotazioni non centrate di TS3 (quasi sempre 0 o 180 deg) + if dRotAng and dInvAng then + if abs( dInvAng) > GEO.EPS_ANG_SMALL then + vWall[i].PosX = vWall[i].PosX - vWall[i].Box:getDimX() + if abs( dRotAng) < GEO.EPS_ANG_SMALL then + vWall[i].PosZ = vWall[i].PosZ - vWall[i].Box:getDimY() + end + elseif abs( dRotAng) > GEO.EPS_ANG_SMALL then + vWall[i].PosZ = vWall[i].PosZ - vWall[i].Box:getDimY() + end end end