Files
DataBeam/LuaLibs/ProcessHeadCut.lua
T
Dario Sassi 5d5732e142 DataBeam :
- aggiunta gestione sfrido di testa e coda da parametri utente TS3
- aggiunta gestione lavorazione tipo Mortise per mortasature
- tolto controllo non più utile da DtMortise.
2020-05-25 13:43:35 +00:00

91 lines
3.9 KiB
Lua

-- ProcessSplit.lua by Egaltech s.r.l. 2020/05/25
-- Gestione calcolo tagli di testa per Travi
-- Tabella per definizione modulo
local ProcessHeadCut = {}
-- Include
require( 'EgtBase')
local BL = require( 'BeamLib')
EgtOutLog( ' ProcessHeadCut started', 1)
-- Dati
local BD = require( 'BeamData')
local ML = require( 'MachiningLib')
---------------------------------------------------------------------
-- 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, bNeedHCut)
-- ingombro del grezzo
local b3Raw = EgtGetRawPartBBox( nRawId)
-- recupero la lavorazione
local sCutting = ML.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
local dMaxDepth = 50
if EgtMdbSetCurrMachining( sCutting) 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
-- caratteristiche taglio
local bHorizCut = ( b3Raw:getDimY() > b3Raw:getDimZ() + 10 * GEO.EPS_SMALL and b3Raw:getDimZ() < dMaxDepth - BD.CUT_EXTRA)
local dDimYRef = EgtIf( b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL, dMaxDepth - BD.CUT_EXTRA, BD.MAX_DIM_HTCUT_HBEAM)
local bDoubleCut = ( not bHorizCut and b3Raw:getDimY() > dDimYRef + 10 * GEO.EPS_SMALL)
-- dati geometrici del taglio
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
-- se non obbligatorio e coincide con inizio grezzo, non va fatto
if not bNeedHCut and 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 = max( ceil( dOvmHead / ( BD.MAX_LEN_SCRAP_START or BD.MAX_LEN_SCRAP)), 1)
local dOffsL = dOvmHead / nCuts
-- calcolo extra taglio ed accorciamento
local dCutExtra = 0
local dAccStart = 0
if b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL or b3Raw:getDimY() < 2 * BD.MAX_DIM_HTCUT_HBEAM + 10 * GEO.EPS_SMALL then
dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN, BD.CUT_EXTRA)
dAccStart = 0
else
dCutExtra = - ( b3Raw:getDimY() - dMaxDepth - BD.CUT_EXTRA)
local dSawRad = dSawDiam / 2
local dKL = dSawRad - dMaxDepth + b3Raw:getDimY() / 2 + BD.CUT_EXTRA_MIN
dAccStart = sqrt( dSawRad * dSawRad - dKL * dKL)
end
-- 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, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, '', 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, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, '', b3Raw)
if not bOk then return false, sErr end
end
return true
end
---------------------------------------------------------------------
return ProcessHeadCut