6eaba8a577
- primo rilascio.
103 lines
4.0 KiB
Lua
103 lines
4.0 KiB
Lua
-- ProcessSplit.lua by Egaltech s.r.l. 2018/11/22
|
|
-- Gestione calcolo tagli di separazione per Travi
|
|
|
|
-- Tabella per definizione modulo
|
|
local ProcessSplit = {}
|
|
|
|
-- Include
|
|
require( 'EgtBase')
|
|
local BL = require( 'BeamLib')
|
|
|
|
EgtOutLog( ' ProcessSplit started', 1)
|
|
|
|
-- Dati
|
|
local BD = require( 'BeamData')
|
|
local Cuttings = require( 'CutData')
|
|
|
|
---------------------------------------------------------------------
|
|
local function FindCutting( sType)
|
|
for i = 1, #Cuttings do
|
|
local Cutting = Cuttings[i]
|
|
if Cutting.Type == sType then
|
|
return i, Cutting.Name
|
|
end
|
|
end
|
|
return 0
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
-- Riconoscimento della feature
|
|
function ProcessSplit.Identify( Proc)
|
|
return ( Proc.Grp == 2 and Proc.Prc == 350)
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
-- Applicazione della lavorazione
|
|
function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId)
|
|
-- ingombro del grezzo
|
|
local b3Raw = EgtGetRawPartBBox( nRawId)
|
|
local bHorizCut = ( b3Raw:getDimY() > b3Raw:getDimZ() + 10 * GEO.EPS_SMALL and b3Raw:getDimZ() < BD.MAX_DIM_HTCUT)
|
|
local bDoubleCut = ( not bHorizCut and b3Raw:getDimY() > BD.MAX_DIM_HTCUT+ 10 * GEO.EPS_SMALL)
|
|
-- dati geometrici del taglio
|
|
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
|
|
-- flag di lavorazione faccia
|
|
local nOrthoOpposite = EgtIf( bHorizCut, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_FRONT)
|
|
-- separazione solo se esiste grezzo successivo con pezzi o scaricabile
|
|
local nNextRawId = EgtGetNextRawPart( nRawId)
|
|
local bSplit = ( nNextRawId and ( EgtGetPartInRawPartCount( nNextRawId) > 0 or EgtGetRawPartBBox( nNextRawId):getDimX() > BD.MinRaw))
|
|
-- determino se più tagli con offset
|
|
local nCuts = 1
|
|
local dOffsL = 0
|
|
if not bSplit then
|
|
-- cerco grezzo successivo che sia nella fase
|
|
local nNextRawId = EgtGetNextRawPart( nRawId)
|
|
if nNextRawId and EgtVerifyRawPartPhase( nNextRawId, nPhase) then
|
|
local b3NextRaw = EgtGetRawPartBBox( nNextRawId)
|
|
local dLenEndRaw = ptC:getX() - b3NextRaw:getMin():getX()
|
|
nCuts = ceil( dLenEndRaw / BD.MAX_LEN_SCRAP)
|
|
dOffsL = dLenEndRaw / nCuts
|
|
end
|
|
end
|
|
-- recupero la lavorazione
|
|
local _, sCutting = FindCutting( EgtIf( bSplit, 'SplitSide', 'TailSide'))
|
|
if not sCutting then
|
|
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library'
|
|
EgtOutLog( sErr)
|
|
return false, true, sErr
|
|
end
|
|
-- recupero i dati dell'utensile
|
|
local dSawDiam = 400
|
|
if EgtMdbSetCurrMachining( sCutting) then
|
|
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
|
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
|
|
dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam
|
|
end
|
|
end
|
|
-- calcolo extra taglio
|
|
local dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY(), 0) + BD.CUT_EXTRA
|
|
-- se necessari tagli in doppio, eseguo gli opposti
|
|
if bDoubleCut then
|
|
for i = nCuts, 1, -1 do
|
|
local dCutOffset = ( i - 1) * dOffsL
|
|
local sNotes = 'Cut'
|
|
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_BACK, dCutExtra, BD.CUT_SIC, dCutOffset, sNotes, b3Raw)
|
|
if not bOk then return false, true, sErr end
|
|
end
|
|
end
|
|
-- eseguo i tagli necessari
|
|
for i = nCuts, 1, -1 do
|
|
local dCutOffset = ( i - 1) * dOffsL
|
|
local sNotes
|
|
if not bSplit then
|
|
sNotes = EgtIf( i == 1, 'Cut', 'Precut')
|
|
end
|
|
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, dCutExtra, BD.CUT_SIC, dCutOffset, sNotes, b3Raw)
|
|
if not bOk then return false, true, sErr end
|
|
end
|
|
-- ritorno anche flag di passaggio a fase successiva
|
|
return true, true
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
return ProcessSplit
|