DataBeam :

- migliorato riconoscimento taglio doppio longitudinale con numero di facce longitudinali e di limitazione
- aggiunta lavorazione di lama sui tagli doppi longitudinali
- migliorato LongCut con svuotature se molto corti e non fattibili altrimenti.
This commit is contained in:
Dario Sassi
2020-01-29 11:21:16 +00:00
parent 4dbb32be98
commit 20b05935fb
3 changed files with 208 additions and 23 deletions
+202 -19
View File
@@ -1,4 +1,4 @@
-- ProcessLongDoubleCut.lua by Egaltech s.r.l. 2019/11/25
-- ProcessLongDoubleCut.lua by Egaltech s.r.l. 2020/01/28
-- Gestione calcolo doppio taglio longitudinale per Travi
-- Tabella per definizione modulo
@@ -23,17 +23,36 @@ end
---------------------------------------------------------------------
-- Classificazione della feature
function ProcessLong2Cut.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
--end
return true, false
end
---------------------------------------------------------------------
-- Classificazione della feature, calcolo il numero di facce longitudinali e limite.
-- Ritorna due valori :
-- il primo indica il numero di facce longitudinali
-- il secondo indica quante e quali facce limite sono presenti con questa codifica
-- 0: nessuna faccia limite; 1: faccia limite a destra (X+); 2: faccia limite a sinistra (X-); 3: due facce limite.
function ProcessLong2Cut.IdentifyFaces( Proc)
-- verifico le normali delle facce
local nFaceLong = 0
local nFaceLimit = 0
local nFacetCnt = EgtSurfTmFacetCount( Proc.Id)
for i = 1, nFacetCnt do
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i-1, GDB_ID.ROOT)
-- se è una faccia limite a sinistra
if vtN:getX() > GEO.EPS_SMALL then
nFaceLimit = nFaceLimit + 2
-- se è una faccia limite a destra
elseif vtN:getX() < -GEO.EPS_SMALL then
nFaceLimit = nFaceLimit + 1
-- altrimenti è una faccia longitudinale
else
nFaceLong = nFaceLong + 1
end
end
return nFaceLong, nFaceLimit
end
---------------------------------------------------------------------
-- Applicazione della lavorazione
function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId)
@@ -41,15 +60,14 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId)
local nFc = {0,1}
local ptC = {}
local vtN = {}
ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
if Proc.Fct == 3 then
if abs( vtN[1]:getX()) > 0.5 then
nFc = {2,1}
ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 2, GDB_ID.ROOT)
elseif abs( vtN[2]:getX()) > 0.5 then
nFc = {0,2}
ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 2, GDB_ID.ROOT)
-- ciclo sulle facce per identificare le facce longitudinali
local nLongFct = 0
for j = 1, Proc.Fct do
local ptCen, vtNrm = EgtSurfTmFacetCenter( Proc.Id, (j-1), GDB_ID.ROOT)
if abs( vtNrm:getX()) < GEO.EPS_SMALL then
nLongFct = nLongFct + 1
ptC[nLongFct] = Point3d( ptCen)
vtN[nLongFct] = Vector3d( vtNrm)
end
end
local dLen = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD):getDimX()
@@ -99,8 +117,173 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId)
_, _, vWidth[2] = BL.GetFaceHvRefDim( Proc.Id, nFc[2])
local sWarn
-- Se ho 2 face longitudinali e non limitato da altre facce e da sopra e richiesto con doppio taglio di lama
if nLongFct == 2 and Proc.Fct == 2 and nSide == 1 and EgtGetInfo( Proc.Id, 'Q01', 'i') == 1 then
-- recupero la lavorazione
local sCutting = ML.FindCutting( 'HeadSide')
if not sCutting then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' sawing not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- recupero i dati dell'utensile
local dToolDiam = 0
local dMaxDepth = 0
local dToolThick = 0
if EgtMdbSetCurrMachining( sCutting) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
dToolThick = EgtTdbGetCurrToolParam(MCH_TP.THICK) or dToolThick
end
end
-- determino numero di parti
local dStartAccDist = BD.LONGCUT_ENDLEN
local dEndAccDist = BD.LONGCUT_ENDLEN
local nC = ceil( ( dLen - dStartAccDist - dEndAccDist) / BD.LONGCUT_MAXLEN)
local dC = 0
if nC > 0 then
dC = dLen / ( nC + 2)
dStartAccDist = dC
dEndAccDist = dC
nC = nC + 2
else
if dLen > min( dStartAccDist, dEndAccDist) then
nC = 2
dStartAccDist = dLen/2
dEndAccDist = dStartAccDist
else
nC = 1
dStartAccDist = 0
dEndAccDist = 0
end
end
local nM = 0
-- se convesso lavoro ogni faccia in due metà lasciando attaccata la parte centrale
if bConvex then
-- si percorrono i lati alto e basso della faccia
for i = 1, nC do
-- Posizione braccio portatesta
local nSCC = EgtIf( ( i == 1 or i == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)
-- ciclo sulle due facce
for j = 1, #vOrd do
-- determino se lavorazione da davanti o da dietro
local bFront = ( vtN[vOrd[j]]:getY() < 0)
-- determino l'utilizzo della faccia
local nFaceUse = EgtIf( abs( vtN[vOrd[j]]:getY()) > 0.01, MCH_MILL_FU.ORTHO_TOP, EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT))
local nFaceUse2 = EgtIf( abs( vtN[vOrd[j]]:getY()) > 0.01, MCH_MILL_FU.ORTHO_DOWN, EgtIf( bFront, MCH_MILL_FU.ORTHO_FRONT, MCH_MILL_FU.ORTHO_BACK))
-- ciclo sulle passate
local dOffset = ( vWidth[vOrd[j]] + BD.DIM_STRIP_SMALL) / 2 ;
local dLioTang = 0
local dLioPerp = ( vWidth[vOrd[j]] - BD.DIM_STRIP_SMALL) / 2 + BD.CUT_SIC ;
for k = 1, 2 do
-- inserisco le parti di lavorazione
nM = nM + 1
local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM) .. '_' .. tostring(j)
local nMchFId = EgtAddMachining( sNameF, sCutting)
if not nMchFId then
local sErr = 'Error adding machining ' .. sNameF .. '-' .. sCutting
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, vOrd[j]-1}})
-- limito opportunamente la lavorazione
local dSal = EgtIf( i == nC, 0, - dEndAccDist - ( nC - i - 1) * dC)
local dEal = EgtIf( i == 1, 0, - dStartAccDist - ( i - 2) * dC)
if ( not bFront and k == 1) or ( bFront and k == 2) then
dSal, dEal = dEal, dSal
end
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal)
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal)
-- imposto offset radiale
EgtSetMachiningParam( MCH_MP.OFFSR, dOffset)
-- imposto attacco/uscita
EgtSetMachiningParam( MCH_MP.LITANG, dLioTang)
EgtSetMachiningParam( MCH_MP.LIPERP, dLioPerp)
EgtSetMachiningParam( MCH_MP.LOTANG, dLioTang)
EgtSetMachiningParam( MCH_MP.LOPERP, dLioPerp)
-- imposto posizione braccio porta testa per non ingombrare agli estremi
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
-- imposto uso della faccia
EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( k == 1, nFaceUse, nFaceUse2))
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
end
end
end
-- altrimenti concavo
else
-- si percorrono i lati alto e basso della faccia
for i = 1, nC do
-- Posizione braccio portatesta
local nSCC = EgtIf( ( i == 1 or i == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)
-- ciclo sulle due facce
for j = 1, #vOrd do
-- determino se lavorazione da davanti o da dietro
local bFront = ( vtN[vOrd[j]]:getY() < 0)
-- determino l'utilizzo della faccia
local nFaceUse = EgtIf( abs( vtN[vOrd[j]]:getY()) > 0.01, MCH_MILL_FU.ORTHO_TOP, EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT))
local nFaceUse2 = EgtIf( abs( vtN[vOrd[j]]:getY()) > 0.01, MCH_MILL_FU.ORTHO_DOWN, EgtIf( bFront, MCH_MILL_FU.ORTHO_FRONT, MCH_MILL_FU.ORTHO_BACK))
-- ciclo sulle passate
local dOffset
local dLioPerp
if j == 1 then -- il primo taglio lo faccio completo
dOffset = 0
dLioPerp = vWidth[vOrd[j]] + BD.CUT_SIC
else -- il secondo ridotto della distanza minima e della componente spessore della lama
dOffset = BD.DIM_STRIP_SMALL + ((dToolThick* vtN[vOrd[1]]) - (dToolThick* vtN[vOrd[1]]) * vtN[vOrd[2]] * vtN[vOrd[2]]):len()
dLioPerp = vWidth[vOrd[j]] - dOffset + BD.CUT_SIC
end
local dLioTang = 0
local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring(j)
local nMchFId = EgtAddMachining( sNameF, sCutting)
if not nMchFId then
local sErr = 'Error adding machining ' .. sNameF .. '-' .. sCutting
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, vOrd[j]-1}})
-- limito opportunamente la lavorazione
local dSal = EgtIf( i == nC, 0, - dEndAccDist - ( nC - i - 1) * dC)
local dEal = EgtIf( i == 1, 0, - dStartAccDist - ( i - 2) * dC)
if ( bFront) then
dSal, dEal = dEal, dSal
end
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal)
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal)
-- imposto offset radiale
EgtSetMachiningParam( MCH_MP.OFFSR, dOffset)
-- imposto attacco/uscita
EgtSetMachiningParam( MCH_MP.LITANG, dLioTang)
EgtSetMachiningParam( MCH_MP.LIPERP, dLioPerp)
EgtSetMachiningParam( MCH_MP.LOTANG, dLioTang)
EgtSetMachiningParam( MCH_MP.LOPERP, dLioPerp)
-- imposto posizione braccio porta testa per non ingombrare agli estremi
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
-- imposto uso della faccia
EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse2)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
end
end
end
-- Se non è sotto : lavorazione Long2Cut
if nSide ~= - 1 then
elseif nSide ~= - 1 then
-- recupero la lavorazione
local sMilling = ML.FindMilling( 'Long2Cut')
if not sMilling then