DataBeam :- correzioni e migliorie varie.
This commit is contained in:
+96
-40
@@ -1,4 +1,4 @@
|
||||
-- ProcessLongCut.lua by Egaltech s.r.l. 2019/09/30
|
||||
-- ProcessLongCut.lua by Egaltech s.r.l. 2019/10/06
|
||||
-- Gestione calcolo taglio longitudinale per Travi
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
@@ -35,9 +35,49 @@ function ProcessLongCut.Classify( Proc)
|
||||
return true, false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function MakeSideFace( nId, nFac, nSide, sMilling, dToolDiam)
|
||||
-- inserisco la lavorazione
|
||||
local sNameF = 'L2C_' .. ( EgtGetName( nId) or tostring( nId)) .. '_' .. tostring( nFac)
|
||||
local nMchFId = EgtAddMachining( sNameF, sMilling)
|
||||
if not nMchFId then
|
||||
local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ nId, nFac}})
|
||||
-- lato di lavoro e inversione
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
-- uso della faccia
|
||||
local nFaceUse = MCH_MILL_FU.PARAL_DOWN
|
||||
if nSide == -2 then
|
||||
nFaceUse = MCH_MILL_FU.PARAL_BACK
|
||||
elseif nSide == 2 then
|
||||
nFaceUse = MCH_MILL_FU.PARAL_FRONT
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse)
|
||||
-- annullo offset radiale
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, 0)
|
||||
-- attacco e uscita
|
||||
EgtSetMachiningParam( MCH_MP.LIPERP, 0)
|
||||
EgtSetMachiningParam( MCH_MP.LITANG, dToolDiam / 2 + 30)
|
||||
EgtSetMachiningParam( MCH_MP.LOPERP, 0)
|
||||
EgtSetMachiningParam( MCH_MP.LOTANG, dToolDiam / 2 + 30)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchFId, false)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Applicazione della lavorazione
|
||||
function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
-- recupero l'ingombro del grezzo di appartenenza
|
||||
local b3Raw = EgtGetRawPartBBox( nRawId)
|
||||
-- dati della faccia
|
||||
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
|
||||
local dLen = Proc.Box:getDimX()
|
||||
@@ -66,6 +106,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
nSide = 2
|
||||
end
|
||||
|
||||
local sWarn
|
||||
-- Se non è sotto : lavorazione Long2Cut
|
||||
if nSide ~= - 1 then
|
||||
-- recupero la lavorazione
|
||||
@@ -75,14 +116,24 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- recupero il diametro dell'utensile
|
||||
-- recupero i dati dell'utensile
|
||||
local dToolDiam = 0
|
||||
local dMaxDepth = 0
|
||||
if EgtMdbSetCurrMachining( sMilling) then
|
||||
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
||||
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
|
||||
dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam
|
||||
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
|
||||
end
|
||||
end
|
||||
-- determino la massima elevazione
|
||||
local dElev = 0
|
||||
local ptT1 = b3Raw:getMax()
|
||||
local dDist1 = ( ptT1 - ptC) * vtN
|
||||
dElev = max( dElev, dDist1)
|
||||
local ptT2 = ptT1 - Y_AX() * b3Raw:getDimY()
|
||||
local dDist2 = ( ptT2 - ptC) * vtN
|
||||
dElev = max( dElev, dDist2)
|
||||
-- determino se lavorazione da davanti o da dietro
|
||||
local bFront = ( vtN:getY() < 0)
|
||||
-- determino gli estremi
|
||||
@@ -144,6 +195,13 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
-- si percorre il lato basso della faccia
|
||||
local nM = 0
|
||||
for i = 1, nC do
|
||||
-- Posizione braccio portatesta
|
||||
local nSCC
|
||||
if bFront then
|
||||
nSCC = EgtIf( ( i == 1 or i == nC - 1), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP)
|
||||
else
|
||||
nSCC = EgtIf( ( i == 1 or i == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)
|
||||
end
|
||||
-- ciclo sulle passate
|
||||
local nO = 1
|
||||
local dStep = 0
|
||||
@@ -170,10 +228,18 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal)
|
||||
local dEal = EgtIf( i == nC, -dEndDist, - dEndAccDist - ( nC - i - 1) * dC)
|
||||
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal)
|
||||
-- imposto offset radiale (nullo se concavo)
|
||||
-- imposto offset radiale
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, ( k - 1) * dStep - BD.CUT_EXTRA)
|
||||
-- imposto posizione braccio porta testa per non ingombrare agli estremi
|
||||
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
|
||||
-- imposto uso della faccia
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse)
|
||||
-- verifico massimo affondamento rispetto ad elevazione
|
||||
if dElev > dMaxDepth - BD.COLL_SIC then
|
||||
sWarn = 'Warning in LongCut : depth (' .. EgtNumToString( dElev, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth - BD.COLL_SIC, 1) .. ')'
|
||||
end
|
||||
local dDepth = min( 0, dMaxDepth - BD.COLL_SIC - dElev )
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
@@ -181,40 +247,26 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
-- eventuale lavorazione della faccia limitante l'inizio
|
||||
if i == 1 and not bStartFixed then
|
||||
local vtIni = EgtIf( bFront, X_AX(), -X_AX())
|
||||
for i = 1, Proc.Fct - 1 do
|
||||
local _, vtN = EgtSurfTmFacetCenter( Proc.Id, i, GDB_ID.ROOT)
|
||||
if vtIni * vtN > 0 then
|
||||
MakeSideFace( Proc.Id, i, nSide, sMilling, dToolDiam)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- se ci sono le facce limitanti
|
||||
for i = 1, Proc.Fct - 1 do
|
||||
-- inserisco la lavorazione
|
||||
local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i)
|
||||
local nMchFId = EgtAddMachining( sNameF, sMilling)
|
||||
if not nMchFId then
|
||||
local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ Proc.Id, i}})
|
||||
-- lato di lavoro e inversione
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
-- uso della faccia
|
||||
local nFaceUse = MCH_MILL_FU.PARAL_DOWN
|
||||
if nSide == -2 then
|
||||
nFaceUse = MCH_MILL_FU.PARAL_BACK
|
||||
elseif nSide == 2 then
|
||||
nFaceUse = MCH_MILL_FU.PARAL_FRONT
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse)
|
||||
-- attacco e uscita
|
||||
EgtSetMachiningParam( MCH_MP.LIPERP, 0)
|
||||
EgtSetMachiningParam( MCH_MP.LITANG, dToolDiam / 2 + 30)
|
||||
EgtSetMachiningParam( MCH_MP.LOPERP, 0)
|
||||
EgtSetMachiningParam( MCH_MP.LOTANG, dToolDiam / 2 + 30)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchFId, false)
|
||||
return false, sErr
|
||||
|
||||
-- eventuale lavorazione della faccia limitante la fine
|
||||
if not bEndFixed then
|
||||
local vtFin = EgtIf( bFront, -X_AX(), X_AX())
|
||||
for i = 1, Proc.Fct - 1 do
|
||||
local _, vtN = EgtSurfTmFacetCenter( Proc.Id, i, GDB_ID.ROOT)
|
||||
if vtFin * vtN > 0 then
|
||||
MakeSideFace( Proc.Id, i, nSide, sMilling, dToolDiam)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -230,11 +282,13 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
-- recupero i dati dell'utensile
|
||||
local dToolDiam = 0
|
||||
local dMaxDepth = 0
|
||||
local dThDiam = 0
|
||||
if EgtMdbSetCurrMachining( sMilling) then
|
||||
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
||||
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
|
||||
dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam
|
||||
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
|
||||
dThDiam = EgtTdbGetCurrToolThDiam() or dThDiam
|
||||
end
|
||||
end
|
||||
-- larghezza faccia
|
||||
@@ -285,10 +339,12 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
-- imposto lato di lavoro e inversione
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
if dWidth + dAgg > dMaxDepth - BD.COLL_SIC then
|
||||
sWarn = 'Warning in LongCut : depth (' .. EgtNumToString( dWidth + dAgg, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth - BD.COLL_SIC, 1) .. ')'
|
||||
-- verifico massimo affondamento (tengo conto dell'inclinazione utensile e della pinza con estremità conica)
|
||||
local dCollSic = max( BD.COLL_SIC, ( dThDiam - dToolDiam) / 2 * abs( vtN:getY() / vtN:getZ()) - 3)
|
||||
if dWidth + dAgg > dMaxDepth - dCollSic then
|
||||
sWarn = 'Warning in LongCut : depth (' .. EgtNumToString( dWidth + dAgg, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth - dCollSic, 1) .. ')'
|
||||
end
|
||||
local dDepth = min( dMaxDepth - BD.COLL_SIC, dWidth + dAgg)
|
||||
local dDepth = min( dMaxDepth - dCollSic, dWidth + dAgg)
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
@@ -299,7 +355,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
return true, sWarn
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user