Files
DataBeam/LuaLibs/ProcessHeadCut.lua
T
Dario Sassi 6eaba8a577 DataBeam :
- primo rilascio.
2019-04-01 15:18:51 +00:00

88 lines
3.3 KiB
Lua

-- ProcessSplit.lua by Egaltech s.r.l. 2018/11/22
-- Gestione calcolo tagli di testa per Travi
-- Tabella per definizione modulo
local ProcessHeadCut = {}
-- 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 ProcessHeadCut.Identify( Proc)
return ( Proc.Grp == 1 and Proc.Prc == 340)
end
---------------------------------------------------------------------
-- Applicazione della lavorazione
function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
-- 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)
-- se coincide con inizio grezzo, non va fatto
if AreSameVectorApprox( vtN, X_AX()) and abs( ptC:getX() - b3Raw:getMax():getX()) < 10 * GEO.EPS_SMALL then
return true
end
-- flag di lavorazione faccia
local nOrthoOpposite = EgtIf( bHorizCut, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_FRONT)
-- determino se più tagli con offset
local nCuts = ceil( dOvmHead / BD.MAX_LEN_SCRAP)
local dOffsL = dOvmHead / nCuts
-- recupero la lavorazione
local _, sCutting = FindCutting( 'HeadSide')
if not sCutting then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library'
EgtOutLog( sErr)
return false, 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 bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_BACK, dCutExtra, BD.CUT_SIC, dCutOffset, '', b3Raw)
if not bOk then return false, sErr end
end
end
-- eseguo i tagli necessari
for i = nCuts, 1, -1 do
local dCutOffset = ( i - 1) * dOffsL
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, dCutExtra, BD.CUT_SIC, dCutOffset, '', b3Raw)
if not bOk then return false, sErr end
end
return true
end
---------------------------------------------------------------------
return ProcessHeadCut