diff --git a/BatchProcess.lua b/BatchProcess.lua index e6ca111..2974832 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -1,6 +1,6 @@ --- BatchProcess.lua by Egaltech s.r.l. 2019/07/01 +-- BatchProcess.lua by Egaltech s.r.l. 2019/07/12 -- Gestione calcolo batch disposizione e lavorazioni per Travi - +-- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- Intestazioni require( 'EgtBase') @@ -21,15 +21,21 @@ EgtOutLog( sLog) local sLogFile = EgtChangePathExtension( BEAM.FILE, '.txt') EgtEraseFile( sLogFile) --- Funzione per scrittura su file di log specifico -local function WriteLogFile( nErr, sMsg, nCutId, nTaskId) +-- Funzioni per scrittura su file di log specifico +local function WriteErrToLogFile( nErr, sMsg, nRot, nCutId, nTaskId) local hFile = io.open( sLogFile, 'a') hFile:write( 'ERR=' .. tostring( nErr) .. '\n') hFile:write( sMsg .. '\n') + hFile:write( 'ROT=' .. tostring( nRot or 0) .. '\n') hFile:write( 'CUTID=' .. tostring( nCutId or 0) .. '\n') hFile:write( 'TASKID=' .. tostring( nTaskId or 0) .. '\n') hFile:close() end +local function WriteTimeToLogFile( dTime) + local hFile = io.open( sLogFile, 'a') + hFile:write( 'TIME=' .. EgtNumToString( dTime) .. '\n') + hFile:close() +end -- Funzione per gestire visualizzazione dopo errore local function PostErrView( nErr, sMsg) @@ -59,7 +65,7 @@ local sMachine = 'Essetre-' .. BEAM.MACHINE if not EgtSetCurrMachine( sMachine) then BEAM.ERR = 11 BEAM.MSG = 'Error selecting machine : ' .. sMachine - WriteLogFile( BEAM.ERR, BEAM.MSG) + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) return end @@ -69,7 +75,7 @@ local sMachDir = EgtGetCurrMachineDir() if not EgtExistsFile( sMachDir .. '\\Beam\\BeamData.lua') then BEAM.ERR = 12 BEAM.MSG = 'Error not configured for beams machine : ' .. sMachine - WriteLogFile( BEAM.ERR, BEAM.MSG) + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) return end @@ -94,7 +100,7 @@ EgtNewFile() if not EgtImportBtl( BEAM.FILE, EIB_FL.TS3_POS) then BEAM.ERR = 13 BEAM.MSG = 'Error importing BTL file : ' .. BEAM.FILE - WriteLogFile( BEAM.ERR, BEAM.MSG) + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) return end @@ -109,7 +115,7 @@ end if #vBeam == 0 then BEAM.ERR = 14 BEAM.MSG = 'Error no beams in the file : ' .. BEAM.FILE - WriteLogFile( BEAM.ERR, BEAM.MSG) + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) return else @@ -128,7 +134,7 @@ for i = 1, #vBeam do if not b3Solid then BEAM.ERR = 15 BEAM.MSG = 'Box undefined for beam ' .. vBeam[i].Name - WriteLogFile( BEAM.ERR, BEAM.MSG) + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) return else @@ -136,6 +142,12 @@ for i = 1, #vBeam do end end +-- Ne recupero la posizione +for i = 1, #vBeam do + local PosX = EgtGetInfo( vBeam[i].Id, 'POSX', 'd') + vBeam[i].PosX = PosX +end + -- Eseguo eventuali rotazioni e inversioni testa-coda for i = 1, #vBeam do local b3Solid = vBeam[i].Box @@ -174,7 +186,7 @@ if #vBeamErr > 0 then end BEAM.ERR = 16 BEAM.MSG = sOut - WriteLogFile( BEAM.ERR, BEAM.MSG) + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) return end @@ -185,7 +197,7 @@ if dRawW > BD.MAX_WIDTH + 10 * GEO.EPS_SMALL or dRawH > BD.MAX_HEIGHT + 10 * GEO 'oltre i limiti della macchina (' .. EgtNumToString( BD.MAX_WIDTH, 2) .. ' x ' .. EgtNumToString( BD.MAX_HEIGHT, 2) .. ')' BEAM.ERR = 17 BEAM.MSG = sOut - WriteLogFile( BEAM.ERR, BEAM.MSG) + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) return end @@ -200,7 +212,7 @@ local bPbOk, sPbErr = BE.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam) if not bPbOk then BEAM.ERR = 18 BEAM.MSG = sPbErr - WriteLogFile( BEAM.ERR, BEAM.MSG) + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) return end @@ -221,26 +233,29 @@ 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) BEAM.ERR = 0 - BEAM.MSG = '' + BEAM.MSG = '---' + BEAM.ROT = Stats[i].Rot or 0 BEAM.CUTID = Stats[i].CutId BEAM.TASKID = Stats[i].TaskId - WriteLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.TASKID) + WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID) elseif 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) BEAM.ERR = 19 BEAM.MSG = Stats[i].Msg + BEAM.ROT = Stats[i].Rot or 0 BEAM.CUTID = Stats[i].CutId BEAM.TASKID = Stats[i].TaskId - WriteLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.TASKID) + WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID) elseif Stats[i].Err < 0 then nWarnCnt = nWarnCnt + 1 sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg) BEAM.ERR = -19 BEAM.MSG = Stats[i].Msg + BEAM.ROT = Stats[i].Rot or 0 BEAM.CUTID = Stats[i].CutId BEAM.TASKID = Stats[i].TaskId - WriteLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.TASKID) + WriteErrToLogFile( BEAM.ERR, BEAM.MSG, BEAM.ROT, BEAM.CUTID, BEAM.TASKID) end end if #sOutput > 0 then EgtOutLog( sOutput) end @@ -260,12 +275,24 @@ if BEAM.FLAG == 0 then if not EgtGenerate( '', 'EgtCAM5 - ' .. sNgeFile) then BEAM.ERR = 20 BEAM.MSG = 'Error generating NC part program : ' .. sName - WriteLogFile( BEAM.ERR, BEAM.MSG) + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) PostErrView( BEAM.ERR, BEAM.MSG) return end end +-- Eseguo stima tempi +if not EgtEstimate( '', 'EgtCAM5 - ' .. sNgeFile) then + BEAM.ERR = 21 + BEAM.MSG = 'Error estimating production time : ' .. sName + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) + PostErrView( BEAM.ERR, BEAM.MSG) + return +end +local Ttot = EgtGetInfo( EgtGetCurrMachGroup(), 'Ttot') +local sTime = 'Total Time = ' .. EgtNumToString( Ttot, 1) +EgtOutLog( sTime) + -- Imposto la vista ISO 3d, se richiesto if BEAM.FLAG == 1 or BEAM.FLAG == 2 then EgtSetView( SCE_VD.ISO_SW, false) @@ -274,6 +301,9 @@ end -- Completamento senza errori e avvisi if nWarnCnt == 0 then BEAM.ERR = 0 - BEAM.MSG = '' - WriteLogFile( BEAM.ERR, BEAM.MSG) + BEAM.MSG = '---' + WriteErrToLogFile( BEAM.ERR, BEAM.MSG) end + +-- Scrittura tempo totale stimato di lavorazione +WriteTimeToLogFile( Ttot) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 44a051f..f43688e 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,5 +1,6 @@ --- BeamExec.lua by Egaltech s.r.l. 2019/07/01 +-- BeamExec.lua by Egaltech s.r.l. 2019/07/12 -- Libreria esecuzione lavorazioni per Travi +-- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- Tabella per definizione modulo local BeamExec = {} @@ -133,6 +134,10 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam) 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 + -- 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 @@ -148,8 +153,8 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, vBeam) local sOut = 'Error creating Additional Group in Part ' .. tostring( Pz) return false, sOut end - -- se primo pezzo con sovramateriale, aggiungo faccia per taglio iniziale al pezzo - if i == 1 and dOvmHead > 1. then + -- se sovramateriale di testa, aggiungo faccia per taglio iniziale al pezzo + if DeltaS > 1. then BL.AddPartStartFace( Pz, b3Solid) EgtSetInfo( nRaw, 'HOVM', DeltaS) end @@ -323,12 +328,12 @@ local function OrderFeatures( vProc, b3Raw) -- funzione di confronto -- secondo centro box in X (taglio di intestazione prima di altri tagli di testa e taglio di separazione però prima di altri tagli di coda) local function CompareFeatures( B1, B2) - -- se primo è feature di testa e l'altro è intestazione - if B1.Head and Hcut.Identify( B2) then + -- se l'altro è intestazione va sempre prima + if Hcut.Identify( B2) then return false end - -- se secondo è feature di testa e l'altro è intestazione - if B2.Head and Hcut.Identify( B1) then + -- se primo è intestazione va sempre prima + if Hcut.Identify( B1) then return true end -- se primo è feature di coda e l'altro è separazione o non è feature di coda @@ -373,9 +378,9 @@ local function OrderFeatures( vProc, b3Raw) return ( B1.Prc == 50 and B2.Prc == 52) end -- confronto standard - if abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) > 1.0 then + if abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) > 100.0 then return B1.Box:getCenter():getX() > B2.Box:getCenter():getX() - elseif abs( B1.Box:getCenter():getY() - B2.Box:getCenter():getY()) > 1.0 then + elseif abs( B1.Box:getCenter():getY() - B2.Box:getCenter():getY()) > 100.0 then return B1.Box:getCenter():getY() > B2.Box:getCenter():getY() else return B1.Box:getCenter():getZ() > B2.Box:getCenter():getZ() @@ -694,11 +699,11 @@ function BeamExec.ProcessFeatures() local bOk, sMsg, bNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3Raw) if not bOk then nTotErr = nTotErr + 1 - table.insert( Stats, {Err=1, Msg=sMsg, CutId=Proc.CutId, TaskId=Proc.TaskId}) + table.insert( Stats, {Err=1, Msg=sMsg, Rot=-2, CutId=Proc.CutId, TaskId=Proc.TaskId}) elseif sMsg and #sMsg > 0 then - table.insert( Stats, {Err=-1, Msg=sMsg, CutId=Proc.CutId, TaskId=Proc.TaskId}) + table.insert( Stats, {Err=-1, Msg=sMsg, Rot=-2, CutId=Proc.CutId, TaskId=Proc.TaskId}) else - table.insert( Stats, {Err=0, Msg='', CutId=Proc.CutId, TaskId=Proc.TaskId}) + table.insert( Stats, {Err=0, Msg='', Rot=-2, CutId=Proc.CutId, TaskId=Proc.TaskId}) end -- se era taglio di separazione, aggiungo nuova fase if bNewPhase then @@ -742,11 +747,11 @@ function BeamExec.ProcessFeatures() local bOk, sMsg, bNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3Raw) if not bOk then nTotErr = nTotErr + 1 - table.insert( Stats, {Err=1, Msg=sMsg, CutId=Proc.CutId, TaskId=Proc.TaskId}) + table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) elseif sMsg and #sMsg > 0 then - table.insert( Stats, {Err=-1, Msg=sMsg, CutId=Proc.CutId, TaskId=Proc.TaskId}) + table.insert( Stats, {Err=-1, Msg=sMsg, Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) else - table.insert( Stats, {Err=0, Msg='', CutId=Proc.CutId, TaskId=Proc.TaskId}) + table.insert( Stats, {Err=0, Msg='', Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) end -- se era taglio di separazione, aggiungo nuova fase if bNewPhase then @@ -773,7 +778,7 @@ function BeamExec.ProcessFeatures() local bApplOk, sApplErrors = EgtApplyAllMachinings() if not bApplOk then nTotErr = nTotErr + 1 - table.insert( Stats, {Err = 1, Msg=sApplErrors, CutId=0, TaskId=0}) + table.insert( Stats, {Err = 1, Msg=sApplErrors, Rot=0, CutId=0, TaskId=0}) end return ( nTotErr == 0), Stats diff --git a/LuaLibs/ProcessDtTenon.lua b/LuaLibs/ProcessDtTenon.lua index 6df80c6..f6477c8 100644 --- a/LuaLibs/ProcessDtTenon.lua +++ b/LuaLibs/ProcessDtTenon.lua @@ -1,4 +1,4 @@ --- ProcessTenon.lua by Egaltech s.r.l. 2019/06/29 +-- ProcessTenon.lua by Egaltech s.r.l. 2019/07/12 -- Gestione calcolo tenone a coda di rondine per Travi -- Tabella per definizione modulo @@ -106,17 +106,22 @@ function ProcessDtTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- calcolo distanza massima della curva dal punto più lontano della base tenone Dt (facet 0) local dMaxDist = 0 local nLoopId, nLoopCnt = EgtExtractSurfTmFacetLoops( Proc.Id, 0, EgtGetParent( Proc.Id)) - local dUmin, dUmax = EgtCurveDomain( nLoopId) - for dU = dUmin, dUmax do - local ptP = EgtUP( nLoopId, dU, GDB_ID.ROOT) - local ptNear = EgtNP( AuxId, ptP, GDB_ID.ROOT) - local dDist = dist( ptP, ptNear) - if dDist > dMaxDist then - dMaxDist = dDist + if nLoopId then + local dUmin, dUmax = EgtCurveDomain( nLoopId) + for dU = dUmin, dUmax do + local ptP = EgtUP( nLoopId, dU, GDB_ID.ROOT) + local ptNear = EgtNP( AuxId, ptP, GDB_ID.ROOT) + local dDist = dist( ptP, ptNear) + if dDist > dMaxDist then + dMaxDist = dDist + end end - end - for i = 1, nLoopCnt do - EgtErase( nLoopId + i - 1) + for i = 1, nLoopCnt do + EgtErase( nLoopId + i - 1) + end + else + local b3DtAux = EgtGetBBoxRef( AuxId, GDB_BB.STANDARD, frDtTen) + dMaxDist = 2 * ( b3DtTen:getRadius() - b3DtAux:getRadius()) end EgtOutLog( 'MaxDist=' .. EgtNumToString( dMaxDist, 3), 3) -- Cicli di lavorazione (max 4) diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index f3a59b5..a4d20d2 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2019/07/08 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2019/07/12 -- Gestione calcolo mezzo-legno per Travi -- Tabella per definizione modulo @@ -110,10 +110,10 @@ function ProcessLapJoint.Classify( Proc) ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT) -- verifico se è lavorabile solo dal basso - local bSmall = ( Proc.Box:getDimX() < BD.MAX_LEN_RIDGELAP_FROM_BOTTOM) + local bSmall = (Proc.Head or Proc.Tail) and ( Proc.Box:getDimX() < BD.MAX_LEN_RIDGELAP_FROM_BOTTOM) local bDown = ( vtN[1]:getZ() < BD.NZ_MINB and vtN[2]:getZ() < BD.NZ_MINB) or - ( vtN[1]:getZ() < BD.NZ_MINA and ( abs( vtN[2]:getZ()) > 0.1 or not bSmall)) or - ( vtN[2]:getZ() < BD.NZ_MINA and ( abs( vtN[1]:getZ()) > 0.1 or not bSmall)) + ( vtN[1]:getZ() < BD.NZ_MINA and ( vtN[2]:getZ() < -0.1 or not bSmall)) or + ( vtN[2]:getZ() < BD.NZ_MINA and ( vtN[1]:getZ() < -0.1 or not bSmall)) return true, bDown -- se più di 2 facce else @@ -499,12 +499,6 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) if dH < dMillDiam or dV < dMillDiam then return MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev) end - -- se troppo lunga, per il momento la salto, andrà spezzata n parti - if dH > 3400 or dV > 3400 then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' feature too long' - EgtOutLog( sErr) - return false, sErr - end -- inserisco la lavorazione di svuotatura local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchFId = EgtAddMachining( sName, sPocketing) @@ -541,6 +535,14 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) return true end +--------------------------------------------------------------------- +local function MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId) + -- troppo lunga, per il momento la salto, andrà spezzata in parti + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' feature too long' + EgtOutLog( sErr) + return false, sErr +end + --------------------------------------------------------------------- -- Applicazione della lavorazione --------------------------------------------------------------------- @@ -550,12 +552,49 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId) local MAX_MILL_VOL = ( 80 * 240 * 20) / 2 -- recupero l'ingombro del grezzo di appartenenza local b3Raw = EgtGetRawPartBBox( nRawId) - -- una faccia - if Proc.Fct == 1 then - -- se lunghezza richiede spezzatura - if Proc.Box:getDimX() > min( BD.LONGCUT_MAXLEN, 0.5 * b3Raw:getDimX()) then + + -- se lunghezza richiede spezzatura + if Proc.Box:getDimX() > min( BD.LONGCUT_MAXLEN, 0.5 * b3Raw:getDimX()) then + -- una faccia + if Proc.Fct == 1 then return LongCut.Make( Proc, nPhase, nRawId, nPartId) + -- due facce + elseif Proc.Fct == 2 then + return Long2Cut.Make( Proc, nPhase, nRawId, nPartId) + -- tre facce + elseif Proc.Fct == 3 then + -- determino se L con una faccia terminale o U con tre facce + local bIsL = true + for i = 1, 3 do + local vFacAdj = EgtSurfTmFacetAdjacencies( Proc.Id, i - 1)[1] + -- le conto + local nCount = 0 + for j = 1, #vFacAdj do + if vFacAdj[j] >= 0 then + nCount = nCount + 1 + end + end + if nCount == 1 then + bIsL = false + break + end + end + -- se una faccia terminale e due lunghe + if bIsL then + return Long2Cut.Make( Proc, nPhase, nRawId, nPartId) + -- altrimenti U lunga + else + return MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId) + end + -- più facce else + return MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId) + end + + -- altrimenti lavorazione unica + else + -- una faccia + if Proc.Fct == 1 then -- se piccola, con fresa if ( Proc.Box:getDimX() < MAX_MILL_XZ and Proc.Box:getDimZ() < MAX_MILL_XZ) or Proc.Box:getDimX() * Proc.Box:getDimY() * Proc.Box:getDimZ() < MAX_MILL_VOL then return MakeOneFaceByMill( Proc, nPhase, nRawId, nPartId) @@ -563,13 +602,8 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId) else return Cut.Make( Proc, nPhase, nRawId, nPartId, 0) end - end - -- due facce - elseif Proc.Fct == 2 then - -- se lunghezza richiede spezzatura - if Proc.Box:getDimX() > min( BD.LONGCUT_MAXLEN, 0.5 * b3Raw:getDimX()) then - return Long2Cut.Make( Proc, nPhase, nRawId, nPartId) - else + -- due facce + elseif Proc.Fct == 2 then -- determino l'angolo tra le facce local _, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) -- se ortogonali e piccole, con fresa @@ -580,10 +614,10 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId) else return Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, 'HeadSide') end + -- tre o più facce + else + return MakeMoreFaces( Proc, nPhase, nRawId, nPartId) end - -- tre o più facce - else - return MakeMoreFaces( Proc, nPhase, nRawId, nPartId) end end diff --git a/LuaLibs/ProcessLongDoubleCut.lua b/LuaLibs/ProcessLongDoubleCut.lua index d126ee3..5ab4930 100644 --- a/LuaLibs/ProcessLongDoubleCut.lua +++ b/LuaLibs/ProcessLongDoubleCut.lua @@ -1,4 +1,4 @@ --- ProcessLongDoubleCut.lua by Egaltech s.r.l. 2019/07/08 +-- ProcessLongDoubleCut.lua by Egaltech s.r.l. 2019/07/12 -- Gestione calcolo doppio taglio longitudinale per Travi -- Tabella per definizione modulo @@ -38,10 +38,20 @@ end -- Applicazione della lavorazione function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) -- dati delle facce + local nFc = {0,1} 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) + if Proc.Fct == 3 then + if abs( vtN[1]:getX()) > 0.5 then + nFc = {2,1} + ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 2, GDB_ID.ROOT) + elseif abs( vtN[2]:getX()) > 0.5 then + nFc = {0,2} + ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 2, GDB_ID.ROOT) + end + end local dLen = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD):getDimX() -- verifico che il doppio taglio longitudinale non sia orientato verso il basso --if vtN[1]:getZ() < - 0.707 or vtN[2]:getZ() < - 0.707 then @@ -51,22 +61,20 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) --end -- verifico posizione (+1=sopra, -1=sotto, 0=sui lati) local nSide = 0 - if vtN[1]:getZ() > -GEO.EPS_SMALL and vtN[2]:getZ() > -GEO.EPS_SMALL then + if vtN[1]:getZ() > -10 * GEO.EPS_SMALL and vtN[2]:getZ() > -10 * GEO.EPS_SMALL then nSide = 1 - elseif vtN[1]:getZ() < GEO.EPS_SMALL and vtN[2]:getZ() < GEO.EPS_SMALL then + elseif vtN[1]:getZ() < 10 * GEO.EPS_SMALL and vtN[2]:getZ() < 10 * GEO.EPS_SMALL then nSide = -1 end -- angolo diedro per stabilire se taglio convesso - local bInt, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) - local ptM + local bInt, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFc[1], nFc[2], GDB_ID.ROOT) local bConvex if bInt then - ptM = ( ptP1 + ptP2) / 2 bConvex = ( dAng >= 0) else - ptM = ( ptC[1] + ptC[2]) / 2 bConvex = true end + local ptM = ( ptC[1] + ptC[2]) / 2 local bOrtho = ( abs( dAng + 90) < 1) -- analisi del taglio local vOrd = {} @@ -88,8 +96,8 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) end end local vWidth = {} - _, _, vWidth[1] = BL.GetFaceHvRefDim( Proc.Id, 1 - 1) - _, _, vWidth[2] = BL.GetFaceHvRefDim( Proc.Id, 2 - 1) + _, _, vWidth[1] = BL.GetFaceHvRefDim( Proc.Id, nFc[1]) + _, _, vWidth[2] = BL.GetFaceHvRefDim( Proc.Id, nFc[2]) -- Se non è sotto : lavorazione Long2Cut if nSide ~= - 1 then @@ -122,7 +130,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) -- ciclo sulle parti local nM = 0 for j = 1, nC do - -- se facce ortogonali (concave), lavoro solo quella con versore maggiomente verso l'alto + -- se facce ortogonali (concave), lavoro solo quella con versore maggiormente verso l'alto local nIni, nFin = 1, 2 if bOrtho then if vtN[vOrd[1]]:getZ() >= vtN[vOrd[2]]:getZ() then @@ -162,7 +170,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) return false, sErr end -- aggiungo geometria - EgtSetMachiningGeometry( {{ Proc.Id, vOrd[i] - 1}}) + EgtSetMachiningGeometry( {{ Proc.Id, nFc[vOrd[i]]}}) -- limito opportunamente la lavorazione EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) @@ -242,7 +250,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId) return false, sErr end -- aggiungo geometria - EgtSetMachiningGeometry( {{ Proc.Id, vOrd[i] - 1}}) + EgtSetMachiningGeometry( {{ Proc.Id, nFc[vOrd[i]]}}) -- limito opportunamente la lavorazione EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal)