DataBeam :
- correzioni e migliorie varie.
This commit is contained in:
+175
-94
@@ -1,4 +1,4 @@
|
||||
-- ProcessLongCut.lua by Egaltech s.r.l. 2019/07/22
|
||||
-- ProcessLongCut.lua by Egaltech s.r.l. 2019/07/25
|
||||
-- Gestione calcolo taglio longitudinale per Travi
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
@@ -6,6 +6,7 @@ local ProcessLongCut = {}
|
||||
|
||||
-- Include
|
||||
require( 'EgtBase')
|
||||
local BL = require( 'BeamLib')
|
||||
|
||||
EgtOutLog( ' ProcessLongCut started', 1)
|
||||
|
||||
@@ -22,13 +23,14 @@ end
|
||||
---------------------------------------------------------------------
|
||||
-- Classificazione della feature
|
||||
function ProcessLongCut.Classify( Proc)
|
||||
-- verifico le normali delle facce
|
||||
local nFacetCnt = EgtSurfTmFacetCount( Proc.Id)
|
||||
for i = 1, nFacetCnt do
|
||||
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i-1, GDB_ID.ROOT)
|
||||
if vtN:getZ() < - 0.707 then
|
||||
return true, true
|
||||
end
|
||||
-- se una sola faccia non ci sono limiti
|
||||
if Proc.Fct == 1 then
|
||||
return true, false
|
||||
end
|
||||
-- verifico la normale della faccia principale
|
||||
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, 0, GDB_ID.ROOT)
|
||||
if vtN:getZ() < - 0.5 then
|
||||
return true, true
|
||||
end
|
||||
return true, false
|
||||
end
|
||||
@@ -54,58 +56,164 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
bLimXmax = true
|
||||
end
|
||||
end
|
||||
-- verifico che il taglio longitudinale non sia orientato verso il basso
|
||||
if vtN:getZ() < 0.0 then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Longitudinal Cut from bottom impossible'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- recupero la lavorazione
|
||||
local sMilling = ML.FindMilling( 'Long2Cut')
|
||||
if not sMilling then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- recupero il diametro dell'utensile
|
||||
local dToolDiam = 0
|
||||
if EgtMdbSetCurrMachining( sMilling) then
|
||||
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
||||
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
|
||||
dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam
|
||||
-- Verifico se lavorazione da sotto
|
||||
local nSide = 1
|
||||
if vtN:getZ() < - 0.5 then nSide = -1 end
|
||||
|
||||
-- Se non è sotto : lavorazione Long2Cut
|
||||
if nSide ~= - 1 then
|
||||
-- recupero la lavorazione
|
||||
local sMilling = ML.FindMilling( 'Long2Cut')
|
||||
if not sMilling then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
local dStartDist = 0
|
||||
if ( bLimXmin and vtN:getY() < 0) or ( bLimXmax and vtN:getY() > 0) then
|
||||
dStartDist = dToolDiam / 2
|
||||
end
|
||||
local dEndDist = 0
|
||||
if ( bLimXmin and vtN:getY() > 0) or ( bLimXmax and vtN:getY()< 0) then
|
||||
dEndDist = dToolDiam / 2
|
||||
end
|
||||
-- determino numero di parti
|
||||
local nC = ceil( ( dLen - 2 * BD.LONGCUT_ENDLEN) / BD.LONGCUT_MAXLEN)
|
||||
local dC = ( dLen - 2 * BD.LONGCUT_ENDLEN) / nC
|
||||
local dAccDist = BD.LONGCUT_ENDLEN
|
||||
if nC > 0 then
|
||||
nC = nC + 2
|
||||
else
|
||||
nC = EgtIf( dLen > BD.LONGCUT_ENDLEN, 2, 1)
|
||||
dAccDist = EgtIf( nC == 2, dLen / 2, 0)
|
||||
end
|
||||
-- si percorre il lato basso della faccia
|
||||
local nM = 0
|
||||
for i = 1, nC do
|
||||
-- ciclo sulle passate
|
||||
local nO = 1
|
||||
local dStep = 0
|
||||
if dWidth + 2 * BD.CUT_EXTRA > dToolDiam then
|
||||
nO = ceil(( dWidth + 2 * BD.CUT_EXTRA) / dToolDiam)
|
||||
if nO > 1 then
|
||||
dStep = ( dWidth + 2 * BD.CUT_EXTRA - dToolDiam) / ( nO - 1)
|
||||
-- recupero il diametro dell'utensile
|
||||
local dToolDiam = 0
|
||||
if EgtMdbSetCurrMachining( sMilling) then
|
||||
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
||||
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
|
||||
dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam
|
||||
end
|
||||
end
|
||||
for k = nO, 1, -1 do
|
||||
local dStartDist = 0
|
||||
if ( bLimXmin and vtN:getY() < 0) or ( bLimXmax and vtN:getY() > 0) then
|
||||
dStartDist = dToolDiam / 2
|
||||
end
|
||||
local dEndDist = 0
|
||||
if ( bLimXmin and vtN:getY() > 0) or ( bLimXmax and vtN:getY()< 0) then
|
||||
dEndDist = dToolDiam / 2
|
||||
end
|
||||
-- determino numero di parti
|
||||
local nC = ceil( ( dLen - 2 * BD.LONGCUT_ENDLEN) / BD.LONGCUT_MAXLEN)
|
||||
local dC = ( dLen - 2 * BD.LONGCUT_ENDLEN) / nC
|
||||
local dAccDist = BD.LONGCUT_ENDLEN
|
||||
if nC > 0 then
|
||||
nC = nC + 2
|
||||
else
|
||||
nC = EgtIf( dLen > BD.LONGCUT_ENDLEN, 2, 1)
|
||||
dAccDist = EgtIf( nC == 2, dLen / 2, 0)
|
||||
end
|
||||
-- si percorre il lato basso della faccia
|
||||
local nM = 0
|
||||
for i = 1, nC do
|
||||
-- ciclo sulle passate
|
||||
local nO = 1
|
||||
local dStep = 0
|
||||
if dWidth + 2 * BD.CUT_EXTRA > dToolDiam then
|
||||
nO = ceil(( dWidth + 2 * BD.CUT_EXTRA) / dToolDiam)
|
||||
if nO > 1 then
|
||||
dStep = ( dWidth + 2 * BD.CUT_EXTRA - dToolDiam) / ( nO - 1)
|
||||
end
|
||||
end
|
||||
for k = nO, 1, -1 do
|
||||
-- inserisco le parti di lavorazione
|
||||
nM = nM + 1
|
||||
local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM)
|
||||
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, 0}})
|
||||
-- limito opportunamente la lavorazione
|
||||
local dSal = EgtIf( i == 1, -dStartDist, - dAccDist - ( i - 2) * dC)
|
||||
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal)
|
||||
local dEal = EgtIf( i == nC, -dEndDist, - dAccDist - ( nC - i - 1) * dC)
|
||||
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal)
|
||||
-- imposto offset radiale (nullo se concavo)
|
||||
if k >1 then
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, ( k - 1) * dStep)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, - BD.CUT_EXTRA)
|
||||
end
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchFId, false)
|
||||
return false, sErr
|
||||
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
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN)
|
||||
-- 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
|
||||
|
||||
-- altrimenti è sotto : lavorazione Long2CutDown
|
||||
else
|
||||
-- recupero la lavorazione
|
||||
local sMilling = ML.FindMilling( 'Long2CutDown')
|
||||
if not sMilling then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- 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
|
||||
-- larghezza faccia
|
||||
local _, _, dWidth = BL.GetFaceHvRefDim( Proc.Id, 0)
|
||||
-- aggiuntivo sull'affondamento
|
||||
local dAgg = BD.CUT_EXTRA
|
||||
-- determino il numero di parti in cui dividere la lavorazione
|
||||
local dEndLen = BD.LONGCUT_ENDLEN
|
||||
if dLen < 2 * dEndLen + BD.LONGCUT_MAXLEN then
|
||||
dEndLen = dLen / 3
|
||||
end
|
||||
local nC = ceil( ( dLen - 2 * dEndLen) / BD.LONGCUT_MAXLEN)
|
||||
local dC = 0
|
||||
if nC > 0 then dC = ( dLen - 2 * dEndLen) / nC end
|
||||
nC = nC + 2
|
||||
-- ciclo sulle parti
|
||||
local nM = 0
|
||||
for j = 1, nC do
|
||||
-- Limitazioni della lavorazione
|
||||
local nPos = EgtIf( vtN:getY() < 0, j, nC - j + 1)
|
||||
local dSal = EgtIf( nPos == 1, 0, - dEndLen - ( nPos - 2) * dC)
|
||||
local dEal = EgtIf( nPos == nC, 0, - dEndLen - ( nC - nPos - 1) * dC)
|
||||
-- Posizione braccio portatesta
|
||||
local nSCC
|
||||
if vtN:getY() < 0 then
|
||||
nSCC = EgtIf( ( j == 1 or j == nC - 1), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP)
|
||||
else
|
||||
nSCC = EgtIf( ( j == 1 or j == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)
|
||||
end
|
||||
-- inserisco le parti di lavorazione
|
||||
nM = nM + 1
|
||||
local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM)
|
||||
@@ -118,16 +226,17 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ Proc.Id, 0}})
|
||||
-- limito opportunamente la lavorazione
|
||||
local dSal = EgtIf( i == 1, -dStartDist, - dAccDist - ( i - 2) * dC)
|
||||
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal)
|
||||
local dEal = EgtIf( i == nC, -dEndDist, - dAccDist - ( nC - i - 1) * dC)
|
||||
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal)
|
||||
-- imposto offset radiale (nullo se concavo)
|
||||
if k >1 then
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, ( k - 1) * dStep)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, - BD.CUT_EXTRA)
|
||||
end
|
||||
-- imposto posizione braccio porta testa per non ingombrare agli estremi
|
||||
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
|
||||
-- imposto uso faccia
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN)
|
||||
-- imposto lato di lavoro e inversione
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
local dDepth = min( dMaxDepth, dWidth + dAgg)
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
@@ -136,35 +245,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
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
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN)
|
||||
-- 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
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user