da06e9b5b3
- modifiche a tagli di testa e coda per lavorare 400x400 su PF1250 - modifiche a LapJoint per lavorare meglio fessure longitudinali con fresa a disco.
299 lines
12 KiB
Lua
299 lines
12 KiB
Lua
-- ProcessSplit.lua by Egaltech s.r.l. 2021/10/26
|
|
-- Gestione calcolo tagli di separazione per Travi
|
|
|
|
-- Tabella per definizione modulo
|
|
local ProcessSplit = {}
|
|
|
|
-- Include
|
|
require( 'EgtBase')
|
|
local BL = require( 'BeamLib')
|
|
local Fbs = require( 'FacesBySaw')
|
|
|
|
EgtOutLog( ' ProcessSplit started', 1)
|
|
|
|
-- Dati
|
|
local BD = require( 'BeamData')
|
|
local ML = require( 'MachiningLib')
|
|
|
|
---------------------------------------------------------------------
|
|
-- Riconoscimento della feature
|
|
function ProcessSplit.Identify( Proc)
|
|
return ( Proc.Grp == 2 and Proc.Prc == 350)
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
-- verifica curva per smusso (-1=errore curva, 0=estrusione non va bene, 1=ok)
|
|
local function VerifyCurveForChamfer( AuxId)
|
|
if not AuxId then
|
|
return -2
|
|
end
|
|
if ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then
|
|
return -1
|
|
end
|
|
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
|
|
-- va bene solo se direzione estrusione orizzontale
|
|
if abs( vtExtr:getZ()) > 0.1 then
|
|
return 0
|
|
end
|
|
return 1
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
-- lavorazione smussi
|
|
local function MakeChamfer( nOriId, Proc, nPhase, nRawId, nPartId, dOvmHead)
|
|
-- verifico che lo smusso sia richiesto
|
|
local dDepth = EgtGetInfo( nOriId, 'Q06', 'd') or 0
|
|
if dDepth < 0.1 then return true end
|
|
-- ingombro del grezzo
|
|
local b3Raw = EgtGetRawPartBBox( nRawId)
|
|
-- recupero e verifico le entità curva associate (max 2)
|
|
local sVal = EgtGetInfo( nOriId, 'AUXID')
|
|
local vsAuxId = EgtSplitString( sVal)
|
|
local AuxId, Aux2Id
|
|
if vsAuxId and #vsAuxId >=1 then
|
|
AuxId = tonumber( vsAuxId[1])
|
|
end
|
|
if vsAuxId and #vsAuxId >=2 then
|
|
Aux2Id = tonumber( vsAuxId[2])
|
|
end
|
|
if AuxId then AuxId = AuxId + nOriId end
|
|
if Aux2Id then Aux2Id = Aux2Id + nOriId end
|
|
local nRes = VerifyCurveForChamfer( AuxId)
|
|
if nRes == 0 and Aux2Id then
|
|
AuxId = Aux2Id
|
|
nRes = VerifyCurveForChamfer( AuxId)
|
|
end
|
|
if nRes == -2 then
|
|
return true
|
|
end
|
|
if nRes == -1 then
|
|
local sErr = 'Error : missing profile geometry'
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
if nRes == 0 then
|
|
local sWarn = 'Warning : skipped not horizontal chamfer'
|
|
EgtOutLog( sWarn)
|
|
return true
|
|
end
|
|
-- recupero i dati della curva e del profilo
|
|
local dWidth = abs( EgtCurveThickness( AuxId))
|
|
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
|
|
-- eseguo lo smusso solo se feature larga come la trave
|
|
if dWidth < b3Raw:getDimY() - 1 then
|
|
local sWarn = 'Warning : skipped chamfer (feature smaller than beam)'
|
|
EgtOutLog( sWarn)
|
|
return true, sWarn
|
|
end
|
|
local dExtra = 2
|
|
-- recupero la lavorazione
|
|
local sMilling = ML.FindMilling( 'Mark')
|
|
if not sMilling then
|
|
local sErr = 'Error : milling not found in library'
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
-- Inserisco la lavorazione del lato standard
|
|
local sName1 = 'SJN_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
|
local nMch1Id = EgtAddMachining( sName1, sMilling)
|
|
if not nMch1Id then
|
|
local sErr = 'Error adding machining ' .. sName1 .. '-' .. sMilling
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
-- aggiungo geometria
|
|
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
|
-- assegno affondamento e offset radiale
|
|
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth + dExtra)
|
|
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
|
|
-- assegno lato di lavoro
|
|
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
|
|
-- eseguo
|
|
if not EgtApplyMachining( true, false) then
|
|
local _, sErr = EgtGetLastMachMgrError()
|
|
EgtSetOperationMode( nMchId, false)
|
|
return false, sErr
|
|
end
|
|
-- Inserisco la lavorazione del lato opposto
|
|
local sName2 = 'SJN_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
|
local nMch2Id = EgtAddMachining( sName2, sMilling)
|
|
if not nMch2Id then
|
|
local sErr = 'Error adding machining ' .. sName2 .. '-' .. sMilling
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
-- aggiungo geometria
|
|
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
|
-- inverto direzione utensile
|
|
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
|
|
-- assegno affondamento e offset radiale
|
|
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth + dExtra)
|
|
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
|
|
-- assegno lato di lavoro
|
|
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
|
-- eseguo
|
|
if not EgtApplyMachining( true, false) then
|
|
local _, sErr = EgtGetLastMachMgrError()
|
|
EgtSetOperationMode( nMchId, false)
|
|
return false, sErr
|
|
end
|
|
return true, nil
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
-- Applicazione della lavorazione
|
|
function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId)
|
|
-- ingombro del grezzo
|
|
local b3Raw = EgtGetRawPartBBox( nRawId)
|
|
-- inserimento smussi
|
|
local nOriId = EgtGetInfo( Proc.Id, 'ORI', 'i')
|
|
if nOriId then
|
|
local bOkc, sErrC = MakeChamfer( nOriId, Proc, nPhase, nRawId, nPartId, dOvmHead)
|
|
if not bOkc then return bOkc, sErrC end
|
|
end
|
|
-- recupero la lavorazione
|
|
local sCutting = ML.FindCutting( 'TailSide')
|
|
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
|
|
local dMaxVertDepth = dMaxDepth - ( BD.DECR_VERT_CUT or 0)
|
|
-- caratteristiche taglio
|
|
local bHorizCut = ( b3Raw:getDimY() > b3Raw:getDimZ() + 10 * GEO.EPS_SMALL and b3Raw:getDimZ() < dMaxVertDepth - BD.CUT_EXTRA)
|
|
local dDimYRef = EgtIf( b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL, max( dMaxDepth, BD.MAX_DIM_HTCUT), BD.MAX_DIM_HTCUT_HBEAM)
|
|
local bDoubleHorizCut = ( BD.DOWN_HEAD and not bHorizCut and b3Raw:getDimY() > 2 * dDimYRef - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL)
|
|
local bDoubleCut = ( not bHorizCut and b3Raw:getDimY() > dDimYRef - BD.CUT_EXTRA_MIN + 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_BACK)
|
|
-- 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
|
|
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
|
|
-- aggiorno ingombro del grezzo corrente con quello del successivo
|
|
b3Raw:Add( b3NextRaw)
|
|
end
|
|
end
|
|
-- se tagli standard
|
|
if not bDoubleHorizCut then
|
|
-- calcolo extra taglio ed accorciamento
|
|
local dCutExtra = 0
|
|
local dAccStart = 0
|
|
local dAccEnd = 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 / 2, BD.CUT_EXTRA)
|
|
else
|
|
dCutExtra = - ( b3Raw:getDimY() - dMaxDepth)
|
|
local dSawRad = dSawDiam / 2
|
|
local dKL = dSawRad - dMaxDepth + b3Raw:getDimY() / 2 + BD.CUT_EXTRA_MIN
|
|
if BD.C_SIMM then
|
|
dAccEnd = sqrt( dSawRad * dSawRad - dKL * dKL)
|
|
else
|
|
dAccStart = sqrt( dSawRad * dSawRad - dKL * dKL)
|
|
end
|
|
end
|
|
-- se necessari tagli in doppio, eseguo gli opposti
|
|
if bDoubleCut then
|
|
for i = nCuts, 1, -1 do
|
|
local dCutOffset = ( i - 1) * dOffsL
|
|
local sNotes = EgtIf( bSplit, 'Presplit;', 'Precut;')
|
|
local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_FRONT, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, dAccEnd, sNotes, 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 sNotes
|
|
if bSplit then
|
|
sNotes = EgtIf( i == 1, 'Split;', 'Presplit;')
|
|
else
|
|
sNotes = EgtIf( i == 1, 'Cut;', 'Precut;')
|
|
end
|
|
local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw)
|
|
if not bOk then return false, sErr end
|
|
end
|
|
-- altrimenti necessari tagli da sopra e sotto con testa opportuna
|
|
else
|
|
-- verifico di avere la testa da sotto
|
|
if not BD.DOWN_HEAD then
|
|
local sErr = 'Error : section too big for split cut'
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
-- recupero la lavorazione con lama da sotto
|
|
local sCutting2 = ML.FindCutting( 'TailSide_H2')
|
|
if not sCutting2 then
|
|
local sErr = 'Error : cutting not found in library'
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
-- recupero i dati della seconda lama
|
|
local dSawDiam2 = 400
|
|
local dMaxDepth2 = 50
|
|
if EgtMdbSetCurrMachining( sCutting2) then
|
|
local sTuuid2 = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
|
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid2) or '') then
|
|
dSawDiam2 = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam2
|
|
dMaxDepth2 = EgtTdbGetCurrToolMaxDepth() or dMaxDepth2
|
|
end
|
|
end
|
|
-- verifico che le due lame riescano a lavorare la sezione
|
|
local dDimZ = b3Raw:getDimZ()
|
|
local dExtra = dMaxVertDepth + dMaxDepth2 - dDimZ - BD.CUT_EXTRA_MIN + 10 * GEO.EPS_SMALL
|
|
if dExtra < 0 then
|
|
local sErr = 'Error : section too height for head cut'
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
-- calcolo extra taglio ed accorciamento
|
|
local dCutExtra = - dMaxDepth2 + dExtra / 2 + BD.CUT_EXTRA_MIN
|
|
local dCutExtra2 = - dMaxVertDepth + dExtra / 2 + BD.CUT_EXTRA_MIN
|
|
local dAccStart = 0
|
|
-- eseguo i tagli da sotto necessari
|
|
for i = nCuts, 1, -1 do
|
|
local dCutOffset = ( i - 1) * dOffsL
|
|
local sNotes = EgtIf( bSplit, 'Presplit;', 'Precut;')
|
|
local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting2, dSawDiam2, MCH_MILL_FU.ORTHO_TOP, nil, dCutExtra2, BD.CUT_SIC, dCutOffset, dAccStart, 0, sNotes, b3Raw)
|
|
if not bOk then return false, sErr end
|
|
end
|
|
-- eseguo i tagli necessari
|
|
for i = nCuts, 1, -1 do
|
|
local dCutOffset = ( i - 1) * dOffsL
|
|
local sNotes
|
|
if bSplit then
|
|
sNotes = EgtIf( i == 1, 'Split;', 'Presplit;')
|
|
else
|
|
sNotes = EgtIf( i == 1, 'Cut;', 'Precut;')
|
|
end
|
|
local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_DOWN, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, 0, sNotes, b3Raw)
|
|
if not bOk then return false, sErr end
|
|
end
|
|
end
|
|
return true
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
return ProcessSplit
|