DataBeam :

- modifiche a tagli longitudinali per farli da sopra e sotto con due lame diverse su macchine dove possibile.
This commit is contained in:
DarioS
2021-09-10 09:24:00 +02:00
parent 75cafdbc9c
commit e9eaef3985
+224 -77
View File
@@ -403,6 +403,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus
local bCanUseBlade = false
local bCanUseUnderBlade = false
-- se lama abilitata per lavorare sopra e faccia da sopra
if nUseBlade == 1 and nSide == 1 then
bCanUseBlade = true
@@ -413,18 +414,23 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus
bCanUseBlade = true
end
end
-- se lama abilitata per lavorare i fianche e da sotto e c'è testa da sotto
if nUseBlade == 2 and BD.DOWN_HEAD then
-- se faccia da sotto o di lato ma con versore Z negativo che supera i 30° da Z-
if ( nSide == -1 or abs(nSide) == 2) and vtN:getZ() <= -0.5 then
bCanUseUnderBlade = true
end
-- se faccia da sotto o di lato ma con versore Z negativo abilito la lavorazione con lame mixate
if ( nSide == -1 or abs(nSide) == 2) and vtN:getZ() <= -0.0175 then
bCanUseUnderBlade = true
end
-- se faccia di lato ma con versore Z negativo verifico che abbia un angolo compatibile per non avere extracorsa
if ( nSide == 1 or abs(nSide) == 2) and vtN:getZ() >= -0.0175 then
if ( nSide == 1 or abs(nSide) == 2) and vtN:getZ() >= -0.5 then
bCanUseBlade = true
end
end
-- introduco messaggi di errore in caso sia settata la lama ma impossibile utilizzarla
-- se si toglie questa parte il processo continua utilizzandi però la fresa ma per il vincolo del parametro Q non è possibile
if nUseBlade == 2 and not BD.DOWN_HEAD and not bCanUseBlade then
@@ -442,33 +448,62 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus
end
-- Se non limitato o forzato uso lama e da sopra e richiesto con doppio taglio di lama e superiore al limite minimo
if ( ( not bLimXmin and not bLimXmax) or bForceUseBladeOnNotThruFace) and ( bCanUseUnderBlade or bCanUseBlade) and nUseBlade > 0 and b3Solid:getDimX() > dLimMinPiece - 1 then
if ( ( not bLimXmin and not bLimXmax) or bForceUseBladeOnNotThruFace) and ( bCanUseUnderBlade or bCanUseBlade) and nUseBlade > 0 and Proc.Box:getDimX() > dLimMinPiece - 1 then
-- recupero la lavorazione
local sCutting
if bCanUseUnderBlade then
sCutting = ML.FindCutting( 'HeadSide_H2')
else
sCutting = ML.FindCutting( 'HeadSide')
end
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 dThick = 0
if EgtMdbSetCurrMachining( sCutting) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam
dThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dThick
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
local sCuttingDn
local dToolDiamDn = 0
local dMaxDepthDn = 0
local dThickDn = 0
if bCanUseUnderBlade then
sCuttingDn = ML.FindCutting( 'HeadSide_H2')
if not sCuttingDn then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' sawing underneath not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- recupero i dati dell'utensile
if EgtMdbSetCurrMachining( sCuttingDn) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dToolDiamDn = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiamDn
dThickDn = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dThickDn
dMaxDepthDn = EgtTdbGetCurrToolMaxDepth() or dMaxDepthDn
end
end
end
if bCanUseBlade then
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
if EgtMdbSetCurrMachining( sCutting) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam
dThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dThick
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
end
end
end
-- se la fine (a sinistra) non è limitata e ho un pezzo successivo meno distante di metà raggio. setto la fine come limitata
if dDistToNextPiece < dToolDiam/2 and not bLimXmin then
if bCanUseBlade and dDistToNextPiece < dToolDiam/2 and not bLimXmin then
if bForceUseBladeOnNotThruFace then
bForcedLim = true
bLimXmin = true
else
sWarn = 'Warning on saw cut : Cut machining can damage next piece'
EgtOutLog( sWarn .. ' (process ' .. tostring( Proc.Id) .. ')')
end
end
-- se la fine (a sinistra) non è limitata e ho un pezzo successivo meno distante di metà raggio. setto la fine come limitata
if bCanUseUnderBlade and dDistToNextPiece < dToolDiamDn/2 and not bLimXmin then
if bForceUseBladeOnNotThruFace then
bForcedLim = true
bLimXmin = true
@@ -481,61 +516,141 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus
-- local dDimStrip = EgtIf( abs(nSide) == 1, BD.DIM_STRIP_SMALL, BD.DIM_STRIP) * EgtIf( nSide == -1, -1, 1)
local dDimStrip = BD.DIM_STRIP_SMALL * EgtIf( nSide == -1, -1, 1)
-- determino gli estremi
local dStartAccDist = BD.LONGCUT_ENDLEN
local dStartDist = 0
local bStartFixed
local dEndAccDist = BD.LONGCUT_ENDLEN
local dEndDist = 0
local bEndFixed
local dStartAccDist
local dStartDist
local dEndAccDist
local dEndDist
local dStartAccDistUp = BD.LONGCUT_ENDLEN
local dStartDistUp = 0
local dEndAccDistUp = BD.LONGCUT_ENDLEN
local dEndDistUp = 0
local dStartAccDistDn = BD.LONGCUT_ENDLEN
local dStartDistDn = 0
local dEndAccDistDn = BD.LONGCUT_ENDLEN
local dEndDistDn = 0
if bForceUseBladeOnNotThruFace then
bStartFixed = true
if bLimXmax then
local dRadius = dToolDiam / 2
local dCat1 = dRadius - ( ( dWidth - dDimStrip) / 2)
dStartDist = sqrt( ( dRadius * dRadius) - (dCat1 * dCat1))
dStartAccDist = BD.LONGCUT_MAXLEN
bStartFixed = false
if bCanUseBlade then
bStartFixed = true
if bLimXmax then
local dRadius = dToolDiam / 2
local dCat1 = dRadius - ( ( dWidth - dDimStrip) / 2)
dStartDistUp = sqrt( ( dRadius * dRadius) - (dCat1 * dCat1))
dStartAccDistUp = BD.LONGCUT_MAXLEN
bStartFixed = false
end
bEndFixed = true
if bLimXmin then
local dRadius = dToolDiam / 2
local dCat1 = dRadius - ( ( dWidth - dDimStrip) / 2)
dEndDistUp = sqrt( ( dRadius * dRadius) - (dCat1 * dCat1))
dEndAccDistUp = BD.LONGCUT_MAXLEN
bEndFixed = false
end
end
bEndFixed = true
if bLimXmin then
local dRadius = dToolDiam / 2
local dCat1 = dRadius - ( ( dWidth - dDimStrip) / 2)
dEndDist = sqrt( ( dRadius * dRadius) - (dCat1 * dCat1))
dEndAccDist = BD.LONGCUT_MAXLEN
bEndFixed = false
if bCanUseUnderBlade then
bStartFixed = true
if bLimXmax then
local dRadius = dToolDiamDn / 2
local dCat1 = dRadius - ( ( dWidth - dDimStrip) / 2)
dStartDistDn = sqrt( ( dRadius * dRadius) - (dCat1 * dCat1))
dStartAccDistDn = BD.LONGCUT_MAXLEN
bStartFixed = false
end
bEndFixed = true
if bLimXmin then
local dRadius = dToolDiamDn / 2
local dCat1 = dRadius - ( ( dWidth - dDimStrip) / 2)
dEndDistDn = sqrt( ( dRadius * dRadius) - (dCat1 * dCat1))
dEndAccDistDn = BD.LONGCUT_MAXLEN
bEndFixed = false
end
end
end
local nC
local dC
local nCUp
local dCUp
-- determino numero di parti
local nC = ceil( ( dLen - dStartAccDist - dEndAccDist) / BD.LONGCUT_MAXLEN)
local dC = 0
if nC > 0 then
dC = ( dLen - dStartAccDist - dEndAccDist) / nC
if dC < min( dStartAccDist, dEndAccDist) then
dC = dLen / ( nC + 2)
dStartAccDist = dC
dEndAccDist = dC
end
nC = nC + 2
else
if dLen > min( dStartAccDist, dEndAccDist) then
nC = 2
dStartAccDist = dLen/2
dEndAccDist = dStartAccDist
if bCanUseBlade then
nCUp = ceil( ( dLen - dStartAccDistUp - dEndAccDistUp) / BD.LONGCUT_MAXLEN)
dCUp = 0
if nCUp > 0 then
dCUp = ( dLen - dStartAccDistUp - dEndAccDistUp) / nCUp
if dCUp < min( dStartAccDistUp, dEndAccDistUp) then
dCUp = dLen / ( nCUp + 2)
dStartAccDistUp = dCUp
dEndAccDistUp = dCUp
end
nCUp = nCUp + 2
else
nC = 1
dStartAccDist = 0
dEndAccDist = 0
if dLen > min( dStartAccDistUp, dEndAccDistUp) then
nCUp = 2
dStartAccDistUp = dLen/2
dEndAccDistUp = dStartAccDistUp
else
nCUp = 1
dStartAccDistUp = 0
dEndAccDistUp = 0
end
end
end
-- determino l'utilizzo della faccia
local nFaceUse = EgtIf( abs( vtN: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:getY()) > 0.01, MCH_MILL_FU.ORTHO_DOWN, EgtIf( bFront, MCH_MILL_FU.ORTHO_FRONT, MCH_MILL_FU.ORTHO_BACK))
local nCDn
local dCDn
if bCanUseUnderBlade then
nCDn = ceil( ( dLen - dStartAccDistDn - dEndAccDistDn) / BD.LONGCUT_MAXLEN)
dCDn = 0
if nCDn > 0 then
dCDn = ( dLen - dStartAccDistDn - dEndAccDistDn) / nCDn
if dCDn < min( dStartAccDistDn, dEndAccDistDn) then
dCDn = dLen / ( nCDn + 2)
dStartAccDistDn = dCDn
dEndAccDistDn = dCDn
end
nCDn = nCDn + 2
else
if dLen > min( dStartAccDistDn, dEndAccDistDn) then
nCDn = 2
dStartAccDistDn = dLen/2
dEndAccDistDn = dStartAccDistDn
else
nCDn = 1
dStartAccDistDn = 0
dEndAccDistDn = 0
end
end
end
-- prendo il valore minimo di passi ( dato dal diametro utensile più grande)
if nCUp then
nC = nCUp
dC = dCUp
elseif nCDn then
nC = nCDn
dC = dCDn
end
local nFaceUse
local nFaceUse2
-- se ho solo lama da sotto
if bCanUseUnderBlade and not bCanUseBlade then
-- determino l'utilizzo della faccia
nFaceUse = EgtIf( abs( vtN:getY()) > 0.01, MCH_MILL_FU.ORTHO_TOP, EgtIf( bFront, MCH_MILL_FU.ORTHO_FRONT, MCH_MILL_FU.ORTHO_BACK))
nFaceUse2 = EgtIf( abs( vtN:getY()) > 0.01, MCH_MILL_FU.ORTHO_DOWN, EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT))
else
-- determino l'utilizzo della faccia
nFaceUse = EgtIf( abs( vtN:getY()) > 0.01, MCH_MILL_FU.ORTHO_TOP, EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT))
nFaceUse2 = EgtIf( abs( vtN:getY()) > 0.01, MCH_MILL_FU.ORTHO_DOWN, EgtIf( bFront, MCH_MILL_FU.ORTHO_FRONT, MCH_MILL_FU.ORTHO_BACK))
end
-- si percorrono i lati alto e basso della faccia
-- calcolo quanto è l'affondamento del taglio
local dOffset = ( dWidth + dDimStrip) / 2
-- se lama da sotto verifico se la componente Y della profondità di taglio supera la capacità della lama
if nSide == -1 then
if (( dWidth - dDimStrip) / 2) > dMaxDepth then
if ( nSide == -1 or abs(nSide) == 2) and bCanUseUnderBlade then
if (( dWidth - dDimStrip) / 2) > dMaxDepthDn then
local sErr = 'Error, side depth is bigger than underneath blade cut depth'
EgtOutLog( sErr)
return false, sErr
@@ -583,12 +698,12 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus
for j = 1, Proc.Fct - 1 do
local _, vtN = EgtSurfTmFacetCenter( Proc.Id, j, GDB_ID.ROOT)
if vtIni * vtN > 0 and nCountMilHead < 2 then
MakeSideFace( Proc.Id, j, nSide, sMilling, dToolDiam, nil, dStartDist, bCanUseUnderBlade)
MakeSideFace( Proc.Id, j, nSide, sMilling, dToolDiam, nil, max(dStartDistUp,dStartDistDn), bCanUseUnderBlade)
nCountMilHead = nCountMilHead + 1
end
end
if bForcedLim and nCountMilHead < 1 then
MakeSideFace( Proc.Id, 0, nSide, sMilling, dToolDiam, bForcedLim, dStartDist, bCanUseUnderBlade)
MakeSideFace( Proc.Id, 0, nSide, sMilling, dToolDiam, bForcedLim, max(dStartDistUp,dStartDistDn), bCanUseUnderBlade)
nCountMilHead = nCountMilHead + 1
end
end
@@ -599,12 +714,12 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus
for j = 1, Proc.Fct - 1 do
local _, vtN = EgtSurfTmFacetCenter( Proc.Id, j, GDB_ID.ROOT)
if vtFin * vtN > 0 and nCountMilHead < 2 then
MakeSideFace( Proc.Id, j, nSide, sMilling, dToolDiam, nil, dEndDist, bCanUseUnderBlade)
MakeSideFace( Proc.Id, j, nSide, sMilling, dToolDiam, nil, max(dEndDistUp,dEndDistDn), bCanUseUnderBlade)
nCountMilHead = nCountMilHead + 1
end
end
if bForcedLim and nCountMilHead < 2 then
MakeSideFace( Proc.Id, 0, nSide, sMilling, dToolDiam, bForcedLim, dEndDist, bCanUseUnderBlade)
MakeSideFace( Proc.Id, 0, nSide, sMilling, dToolDiam, bForcedLim, max(dEndDistUp,dEndDistDn), bCanUseUnderBlade)
nCountMilHead = nCountMilHead + 1
end
end
@@ -669,12 +784,35 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus
end
-- inserisco le parti di lavorazione
nM = nM + 1
local sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM)
local nMchFId = EgtAddMachining( sNameF, sCutting)
if not nMchFId then
local sErr = 'Error adding machining ' .. sNameF .. '-' .. sCutting
EgtOutLog( sErr)
return false, sErr
local sNameF
local nMchFId
if ( k == 1 and bCanUseBlade) or ( k == 2 and ( bCanUseBlade and not bCanUseUnderBlade)) then
sNameF = 'L2C_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM)
nMchFId = EgtAddMachining( sNameF, sCutting)
if not nMchFId then
local sErr = 'Error adding machining ' .. sNameF .. '-' .. sCutting
EgtOutLog( sErr)
return false, sErr
end
-- setto le variabili delle distanze dagli estremi
dEndDist = dEndDistUp
dEndAccDist = dEndAccDistUp
dStartDist = dStartDistUp
dStartAccDist = dStartAccDistUp
elseif ( k == 2 and bCanUseUnderBlade) or ( k == 1 and ( bCanUseUnderBlade and not bCanUseBlade)) then
sNameF = 'L2CD_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM)
nMchFId = EgtAddMachining( sNameF, sCuttingDn)
if not nMchFId then
local sErr = 'Error adding machining ' .. sNameF .. '-' .. sCuttingDn
EgtOutLog( sErr)
return false, sErr
end
-- setto le variabili delle distanze dagli estremi
dEndDist = dEndDistDn
dEndAccDist = dEndAccDistDn
dStartDist = dStartDistDn
dStartAccDist = dStartAccDistDn
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, 0}})
@@ -694,9 +832,20 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus
-- EgtSetMachiningParam( MCH_MP.DEPTH, dThick)
-- end
-- end
if bCanUseUnderBlade then
if bCanUseBlade and bCanUseUnderBlade then
EgtSetMachiningParam( MCH_MP.INVERT, true)
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
dSal, dEal = dEal, dSal
-- imposto uso della faccia
EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( k == 1, nFaceUse2, nFaceUse))
elseif bCanUseUnderBlade then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
-- imposto uso della faccia
EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( k == 1, nFaceUse, nFaceUse2))
else
-- imposto uso della faccia
EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( k == 1, nFaceUse, nFaceUse2))
end
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal)
@@ -710,13 +859,11 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus
EgtSetMachiningParam( MCH_MP.LOPERP, dLioPerp)
-- se il flag uso lama custom abilitato (indica che questo script è lanciato dal ProcessCut)
-- controllo se componente X versore è maggiore di un valore limite cambio la direzione della forcella
if bCustUseBlade and abs(vtN:getX()) > 0.009 + 5*GEO.EPS_SMALL then
if bCustUseBlade and abs(vtN:getX()) > 0.009 + 5 * GEO.EPS_SMALL then
nSCC = EgtIf( ( not bFront and k == 1) or ( bFront and k == 2), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM)
end
-- 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()