diff --git a/BatchProcess.lua b/BatchProcess.lua index 96b0aa2..937728e 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -1,8 +1,9 @@ --- BatchProcess.lua by Egaltech s.r.l. 2019/07/19 +-- BatchProcess.lua by Egaltech s.r.l. 2019/07/24 -- Gestione calcolo batch disposizione e lavorazioni per Travi -- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- 2019/07/16 Aggiunta gestione modalità oltre 10 per impostazione macchina e uscita. -- 2019/07/19 Aggiunta gestione collisioni. +-- 2019/07/24 Aggiunta gestione extra-corse. -- Intestazioni require( 'EgtBase') @@ -303,7 +304,13 @@ if BEAM.FLAG == 3 and bVerifyCollision then local bSimOk, nErr, sErr = EgtSimulate() if not bSimOk then BEAM.ERR = 22 - BEAM.MSG = 'Head-Part Collision' + if nErr == MCH_SHE.OUTSTROKE then + BEAM.MSG = 'Axis outstroke ' .. sErr + elseif nErr == MCH_SHE.COLLISION then + BEAM.MSG = 'Head-part collision' + else + BEAM.MSG = 'General failure (contact supplier)' + end BEAM.ROT = 0 BEAM.CUTID = 0 BEAM.TASKID = 0 diff --git a/Beam.ini b/Beam.ini index 6628e9a..a7ddf23 100644 --- a/Beam.ini +++ b/Beam.ini @@ -8,6 +8,7 @@ Button3=Swap.lua,Images\Swap.png,Scambia estremi trave Button4=Rotate.lua,Images\Rotate.png,Ruota trave Button5=DisableFeatures.lua,Images\DisableFeatures.png,Disabilita lavorazioni Button6=EnableFeatures.lua,Images\EnableFeatures.png,Abilita lavorazioni -Button7=HideAll.lua,Images\HideAll.png,Nascondi tutte le travi non selezionate -Button8=ShowAll.lua,Images\ShowAll.png,Visualizza tutte le travi -Button9=ShowBuilding.lua,Images\ShowBuilding.png,Visualizza struttura/Visualizza pezzi +Button7=BeamMachinings,Images\BeamMachinings.png,Lista lavorazioni +Button8=HideAll.lua,Images\HideAll.png,Nascondi tutte le travi non selezionate +Button9=ShowAll.lua,Images\ShowAll.png,Visualizza tutte le travi +Button10=ShowBuilding.lua,Images\ShowBuilding.png,Visualizza struttura/Visualizza pezzi diff --git a/Images/BeamMachinings.png b/Images/BeamMachinings.png new file mode 100644 index 0000000..5ab6b0c Binary files /dev/null and b/Images/BeamMachinings.png differ diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index f43688e..dfc57c9 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -84,15 +84,9 @@ EgtOutLog( ' BeamExec started', 1) -- *** Inserimento delle travi nel grezzo *** ------------------------------------------------------------------------------------------------------------- function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam) - + -- Determinazione minimo grezzo scaricabile - if dRawW * dRawH > 40000 then - BD.MinRaw = BD.MINRAW_L - elseif dRawW * dRawH > 14500 then - BD.MinRaw = BD.MINRAW_M - else - BD.MinRaw = BD.MINRAW_S - end + BeamExec.CalcMinUnloadableRaw( dRawW, dRawH) -- Creazione nuovo gruppo di lavoro local sMgName = EgtGetMachGroupNewName( 'Mach_1') @@ -130,17 +124,17 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam) local PartLen = b3Solid:getDimX() local PartWidth = b3Solid:getDimY() local PartHeight = b3Solid:getDimZ() - local NextLen = Len - DeltaS - DeltaE - PartLen + local NextLen = Len - DeltaS - PartLen - DeltaE if (( abs( PartWidth - dRawW) < 10 * GEO.EPS_SMALL and abs( PartHeight - dRawH) < 10 * GEO.EPS_SMALL) or ( abs( PartHeight - dRawW) < 10 * GEO.EPS_SMALL and abs( PartWidth - dRawH) < 10 * GEO.EPS_SMALL)) and - NextLen >= 0 then + NextLen + DeltaE >= 0 then -- eventuale sovramateriale di testa if vBeam[i].PosX then DeltaS = max( vBeam[i].PosX - ( dRawL - Len), 0) end -- dimensioni del grezzo - local CrawLen = PartLen + DeltaS + DeltaE - local Delta = DeltaE + local CrawLen = min( PartLen + DeltaS + DeltaE, Len) + local Delta = CrawLen - PartLen - DeltaS -- creo e posiziono il grezzo local nRaw = EgtAddRawPart( Point3d(0,0,0), CrawLen, dRawW, dRawH, BD.RAWCOL) EgtMoveToCornerRawPart( nRaw, BD.OriTR, MCH_CR.TR) @@ -177,7 +171,7 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam) Len = Len - CrawLen end -- se rimasto troppo poco grezzo, esco - if Len < BD.MinRaw then break end + --if Len < BD.MinRaw then break end DeltaS = 0 end @@ -194,6 +188,19 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam) return true end +------------------------------------------------------------------------------------------------------------- +function BeamExec.CalcMinUnloadableRaw( dRawW, dRawH) + + -- Determinazione minimo grezzo scaricabile + if dRawW * dRawH > 40000 then + BD.MinRaw = BD.MINRAW_L + elseif dRawW * dRawH > 14500 then + BD.MinRaw = BD.MINRAW_M + else + BD.MinRaw = BD.MINRAW_S + end +end + ------------------------------------------------------------------------------------------------------------- -- *** Inserimento delle lavorazioni nelle travi *** ------------------------------------------------------------------------------------------------------------- @@ -377,10 +384,14 @@ local function OrderFeatures( vProc, b3Raw) B1.Box:getMin():getX() < B2.Box:getMax():getX() + 100 * GEO.EPS_SMALL and B2.Box:getMin():getX() < B1.Box:getMax():getX() + 100 * GEO.EPS_SMALL then return ( B1.Prc == 50 and B2.Prc == 52) end - -- confronto standard - if abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) > 100.0 then + -- se uno di testa e non l'altro, privilegio questo + if B1.Head ~= B2.Head then + return B1.Head + end + -- confronto standard per feature che non si sovrappongono in X + if abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) > 0.5 * ( B1.Box:getDimX() + B2.Box:getDimX()) then return B1.Box:getCenter():getX() > B2.Box:getCenter():getX() - elseif abs( B1.Box:getCenter():getY() - B2.Box:getCenter():getY()) > 100.0 then + elseif abs( B1.Box:getCenter():getY() - B2.Box:getCenter():getY()) > 0.5 * ( B1.Box:getDimY() + B2.Box:getDimY()) then return B1.Box:getCenter():getY() > B2.Box:getCenter():getY() else return B1.Box:getCenter():getZ() > B2.Box:getCenter():getZ() diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index e02b9b3..49032f4 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1,4 +1,4 @@ --- BeamLib.lua by Egaltech s.r.l. 2019/05/27 +-- BeamLib.lua by Egaltech s.r.l. 2019/07/24 -- Libreria globale per Travi -- Tabella per definizione modulo @@ -423,7 +423,8 @@ function BeamLib.CalcLeadInOutGeom( ptP1, ptP2, vtV1, vtV2, vtN, dRad, vtRef, dC vtV1 = vtV1 - vtV1 * vtN * vtN ; vtV1:normalize() vtV2 = vtV2 - vtV2 * vtN * vtN ; vtV2:normalize() -- Versore tangente al taglio - local vtTg = ptP2 - ptP1 ; vtTg:normalize() + local vtTg = ptP2 - ptP1 ; + vtTg = vtTg - vtTg * vtN * vtN ; vtTg:normalize() -- Sistema di riferimento intrinseco al taglio local vtX = vtTg ^ vtN local frFace = Frame3d( ptP1, vtX, vtTg, vtN) @@ -520,7 +521,8 @@ end --------------------------------------------------------------------- function BeamLib.CalcLeadInOutTangGeom( ptP1, ptP2, vtN, dRad, vtRef, dCutExtra, b3Box) -- Versore tangente al taglio - local vtTg = ptP2 - ptP1 ; vtTg:normalize() + local vtTg = ptP2 - ptP1 ; + vtTg = vtTg - vtTg * vtN * vtN ; vtTg:normalize() -- Sistema di riferimento intrinseco al taglio local vtX = vtTg ^ vtN local frFace = Frame3d( ptP1, vtX, vtTg, vtN) diff --git a/LuaLibs/ProcessDoubleCut.lua b/LuaLibs/ProcessDoubleCut.lua index 11a1d49..d01f6ef 100644 --- a/LuaLibs/ProcessDoubleCut.lua +++ b/LuaLibs/ProcessDoubleCut.lua @@ -113,7 +113,7 @@ function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if not bOk then return bOk, sErr end end -- creo piano di taglio coincidente con la seconda faccia e lo lavoro - local AddId = EgtSurfTmPlaneInBBox( EgtGetParent( Proc.Id), ptC[2], vtN[2], b3Solid, GDB_RT.GLOB) + AddId = EgtSurfTmPlaneInBBox( EgtGetParent( Proc.Id), ptC[2], vtN[2], b3Solid, GDB_RT.GLOB) if AddId then EgtRelocate( AddId, nAddGrpId) EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index 4acfe1b..505458b 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -1,4 +1,4 @@ --- ProcessDrill.lua by Egaltech s.r.l. 2019/07/19 +-- ProcessDrill.lua by Egaltech s.r.l. 2019/07/24 -- Gestione calcolo forature per Travi -- Tabella per definizione modulo @@ -147,9 +147,6 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth end end - if nType == 'Pocket' then - dMaxDepth = dMaxDepth - 4 - end -- se foro intermedio e inclinato, limito il massimo affondamento if not ( Proc.Fcs == 5 or Proc.Fcs == 6) then local CosB = abs( vtExtr:getX()) diff --git a/LuaLibs/ProcessLongCut.lua b/LuaLibs/ProcessLongCut.lua index cb7c4dc..e242e8d 100644 --- a/LuaLibs/ProcessLongCut.lua +++ b/LuaLibs/ProcessLongCut.lua @@ -1,4 +1,4 @@ --- ProcessLongCut.lua by Egaltech s.r.l. 2019/02/15 +-- ProcessLongCut.lua by Egaltech s.r.l. 2019/07/22 -- Gestione calcolo taglio longitudinale per Travi -- Tabella per definizione modulo @@ -83,62 +83,32 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) if ( bLimXmin and vtN:getY() > 0) or ( bLimXmax and vtN:getY()< 0) then dEndDist = dToolDiam / 2 end - -- se va fatta in 3 o più parti + -- determino numero di parti local nC = ceil( ( dLen - 2 * BD.LONGCUT_ENDLEN) / BD.LONGCUT_MAXLEN) + local dC = ( dLen - 2 * BD.LONGCUT_ENDLEN) / nC + local dAccDist = BD.LONGCUT_ENDLEN if nC > 0 then - local dC = ( dLen - 2 * BD.LONGCUT_ENDLEN) / nC nC = nC + 2 - -- si percorre il lato basso della faccia - local nM = 0 - for i = 1, nC do - -- ciclo sulle passate - local nO = 1 - local dStep = 0 - if dWidth + 2 * BD.CUT_EXTRA > dToolDiam then - nO = ceil(( dWidth + 2 * BD.CUT_EXTRA) / dToolDiam) - if nO > 1 then - dStep = ( dWidth + 2 * BD.CUT_EXTRA - dToolDiam) / ( nO - 1) - end - end - for k = nO, 1, -1 do - -- inserisco le parti di lavorazione - nM = nM + 1 - local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM) - local nMchFId = EgtAddMachining( sNameF, sMilling) - if not nMchFId then - local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling - EgtOutLog( sErr) - return false, sErr - end - -- aggiungo geometria - EgtSetMachiningGeometry( {{ Proc.Id, 0}}) - -- limito opportunamente la lavorazione - local dSal = EgtIf( i == 1, -dStartDist, - BD.LONGCUT_ENDLEN - ( i - 2) * dC) - EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) - local dEal = EgtIf( i == nC, -dEndDist, - BD.LONGCUT_ENDLEN - ( nC - i - 1) * dC) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) - -- imposto offset radiale (nullo se concavo) - if k >1 then - EgtSetMachiningParam( MCH_MP.OFFSR, ( k - 1) * dStep) - else - EgtSetMachiningParam( MCH_MP.OFFSR, - BD.CUT_EXTRA) - end - -- eseguo - if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr - end - end - end - -- altrimenti una o due parti else nC = EgtIf( dLen > BD.LONGCUT_ENDLEN, 2, 1) - local dAccDist = EgtIf( nC == 2, dLen / 2, 0) - -- si percorre il lato basso della faccia - for i = 1, nC do + dAccDist = EgtIf( nC == 2, dLen / 2, 0) + end + -- si percorre il lato basso della faccia + local nM = 0 + for i = 1, nC do + -- ciclo sulle passate + local nO = 1 + local dStep = 0 + if dWidth + 2 * BD.CUT_EXTRA > dToolDiam then + nO = ceil(( dWidth + 2 * BD.CUT_EXTRA) / dToolDiam) + if nO > 1 then + dStep = ( dWidth + 2 * BD.CUT_EXTRA - dToolDiam) / ( nO - 1) + end + end + for k = nO, 1, -1 do -- inserisco le parti di lavorazione - local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + nM = nM + 1 + local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM) local nMchFId = EgtAddMachining( sNameF, sMilling) if not nMchFId then local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling @@ -148,39 +118,16 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, 0}}) -- limito opportunamente la lavorazione - local dSal = EgtIf( i == 1, -dStartDist, - dAccDist) + local dSal = EgtIf( i == 1, -dStartDist, - dAccDist - ( i - 2) * dC) EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) - local dEal = EgtIf( i == nC, -dEndDist, - dAccDist) + local dEal = EgtIf( i == nC, -dEndDist, - dAccDist - ( nC - i - 1) * dC) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) - -- eseguo - if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr + -- imposto offset radiale (nullo se concavo) + if k >1 then + EgtSetMachiningParam( MCH_MP.OFFSR, ( k - 1) * dStep) + else + EgtSetMachiningParam( MCH_MP.OFFSR, - BD.CUT_EXTRA) end - end - -- se ci sono le facce limitanti - for i = 1, Proc.Fct - 1 do - -- inserisco la lavorazione - local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i) - local nMchFId = EgtAddMachining( sNameF, sMilling) - if not nMchFId then - local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling - EgtOutLog( sErr) - return false, sErr - end - -- aggiungo geometria - EgtSetMachiningGeometry( {{ Proc.Id, i}}) - -- lato di lavoro e inversione - EgtSetMachiningParam( MCH_MP.INVERT, true) - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - -- uso della faccia - EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN) - -- attacco e uscita - EgtSetMachiningParam( MCH_MP.LIPERP, 0) - EgtSetMachiningParam( MCH_MP.LITANG, dToolDiam / 2 + 30) - EgtSetMachiningParam( MCH_MP.LOPERP, 0) - EgtSetMachiningParam( MCH_MP.LOTANG, dToolDiam / 2 + 30) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -189,6 +136,35 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId) end end end + -- se ci sono le facce limitanti + for i = 1, Proc.Fct - 1 do + -- inserisco la lavorazione + local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i) + local nMchFId = EgtAddMachining( sNameF, sMilling) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ Proc.Id, i}}) + -- lato di lavoro e inversione + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + -- uso della faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN) + -- attacco e uscita + EgtSetMachiningParam( MCH_MP.LIPERP, 0) + EgtSetMachiningParam( MCH_MP.LITANG, dToolDiam / 2 + 30) + EgtSetMachiningParam( MCH_MP.LOPERP, 0) + EgtSetMachiningParam( MCH_MP.LOTANG, dToolDiam / 2 + 30) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + end return true end diff --git a/Process.lua b/Process.lua index 5d64a0a..7d48425 100644 --- a/Process.lua +++ b/Process.lua @@ -127,12 +127,17 @@ end -- *** Inserimento delle travi nel grezzo *** ------------------------------------------------------------------------------------------------------------- local function MyProcessBeams() + + -- Determinazione minimo grezzo scaricabile + BE.CalcMinUnloadableRaw( dRawW, dRawH) + -- Lunghezza totale delle travi local dTotLen = 0 - for i = 1, #vBeam do + for i = 1, #vBeam - 1 do dTotLen = dTotLen + vBeam[i].Box:getDimX() end - local dAddLen = BD.OVM_HEAD + #vBeam * BD.OVM_MID + dTotLen = dTotLen + max( vBeam[#vBeam].Box:getDimX(), BD.MinRaw) + local dAddLen = BD.OVM_HEAD + ( #vBeam - 1) * BD.OVM_MID EgtOutLog( 'Ltot : ' .. EgtNumToString( dTotLen, 1) .. ' Lagg : '.. EgtNumToString( dAddLen, 1), 1) -- Richiedo lunghezza del grezzo e sovramateriale di testa @@ -201,9 +206,7 @@ local function MyProcessFeatures() local nWarnCnt = 0 local sOutput = '' for i = 1, #Stats do - if Stats[i].Err == 0 then - sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d Ok\n', Stats[i].CutId, Stats[i].TaskId) - elseif Stats[i].Err > 0 then + if Stats[i].Err > 0 then nErrCnt = nErrCnt + 1 sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg) elseif Stats[i].Err < 0 then