DataBeam :
- migliorato ordinamento fori - riunite FindMilling, .... in una unica libreria - altre piccole migliorie.
This commit is contained in:
+112
-235
@@ -11,7 +11,7 @@ EgtOutLog( ' ProcessLongDoubleCut started', 1)
|
||||
|
||||
-- Dati
|
||||
local BD = require( 'BeamData')
|
||||
local Millings = require( 'MillingData')
|
||||
local ML = require( 'MachiningLib')
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Riconoscimento della feature
|
||||
@@ -23,25 +23,14 @@ 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
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function FindMilling( sType)
|
||||
for i = 1, #Millings do
|
||||
local Milling = Millings[i]
|
||||
if Milling.Type == sType then
|
||||
return i, Milling.Name
|
||||
end
|
||||
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 0
|
||||
return true, false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
@@ -54,13 +43,12 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
|
||||
local dLen = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD):getDimX()
|
||||
-- verifico che il doppio taglio longitudinale non sia orientato verso il basso
|
||||
-- if vtN[1]:getZ() < - 0.707 or vtN[2]:getZ() < - 0.707 then
|
||||
-- local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Longitudinal Double Cut from bottom impossible'
|
||||
-- EgtOutLog( sErr)
|
||||
-- return false, sErr
|
||||
-- end
|
||||
|
||||
-- verifico se sopra o no
|
||||
if vtN[1]:getZ() < - 0.707 or vtN[2]:getZ() < - 0.707 then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Longitudinal Double Cut from bottom impossible'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- verifico se sopra o sui lati
|
||||
local bTop = ( vtN[1]:getZ() > 0 and vtN[2]:getZ() > 0)
|
||||
-- angolo diedro per stabilire se taglio convesso
|
||||
local _, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT)
|
||||
@@ -69,221 +57,110 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId)
|
||||
-- analisi del taglio
|
||||
local vOrd = {}
|
||||
local vFaceUse = {}
|
||||
local bDownCut = false
|
||||
if bTop then
|
||||
vOrd = EgtIf( ptC[1]:getY() < ptM:getY(), { 1, 2}, { 2, 1})
|
||||
vFaceUse = {[vOrd[1]] = MCH_MILL_FU.ORTHO_BACK, [vOrd[2]] = MCH_MILL_FU.ORTHO_FRONT}
|
||||
else
|
||||
-- verifico se sotto o sui lati
|
||||
if ( vtN[1]:getZ() < 0 and vtN[2]:getZ() < 0) then
|
||||
bDownCut = true
|
||||
vOrd = EgtIf( ptC[1]:getY() < ptM:getY(), { 1, 2}, { 2, 1})
|
||||
vFaceUse = {[vOrd[1]] = MCH_MILL_FU.PARAL_BACK, [vOrd[2]] = MCH_MILL_FU.PARAL_FRONT}
|
||||
else
|
||||
local bFront = ( vtN[1]:getY() < 0)
|
||||
if bFront then
|
||||
vOrd = EgtIf( ptC[1]:getZ() < ptM:getZ(), { 1, 2}, { 2, 1})
|
||||
vFaceUse = {[vOrd[1]] = MCH_MILL_FU.ORTHO_TOP, [vOrd[2]] = MCH_MILL_FU.ORTHO_DOWN}
|
||||
else
|
||||
vOrd = EgtIf( ptC[1]:getZ() < ptM:getZ(), { 2, 1}, { 1, 2})
|
||||
vFaceUse = {[vOrd[1]] = MCH_MILL_FU.ORTHO_DOWN, [vOrd[2]] = MCH_MILL_FU.ORTHO_TOP}
|
||||
end
|
||||
end
|
||||
local bFront = ( vtN[1]:getY() < 0)
|
||||
if bFront then
|
||||
vOrd = EgtIf( ptC[1]:getZ() < ptM:getZ(), { 1, 2}, { 2, 1})
|
||||
vFaceUse = {[vOrd[1]] = MCH_MILL_FU.ORTHO_TOP, [vOrd[2]] = MCH_MILL_FU.ORTHO_DOWN}
|
||||
else
|
||||
vOrd = EgtIf( ptC[1]:getZ() < ptM:getZ(), { 2, 1}, { 1, 2})
|
||||
vFaceUse = {[vOrd[1]] = MCH_MILL_FU.ORTHO_DOWN, [vOrd[2]] = MCH_MILL_FU.ORTHO_TOP}
|
||||
end
|
||||
end
|
||||
-- se non è sotto: taglio Long2Cut
|
||||
if not bDownCut then
|
||||
local vWidth = {}
|
||||
local vtDiff1 = ptC[vOrd[1]] - ptM
|
||||
vWidth[vOrd[1]] = 2 * sqrt( vtDiff1:getY() * vtDiff1:getY() + vtDiff1:getZ() * vtDiff1:getZ())
|
||||
local vtDiff2 = ptC[vOrd[2]] - ptM
|
||||
vWidth[vOrd[2]] = 2 * sqrt( vtDiff2:getY() * vtDiff2:getY() + vtDiff2:getZ() * vtDiff2:getZ())
|
||||
-- recupero la lavorazione
|
||||
local nMill, sMilling = 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 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 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
|
||||
-- su entrambe le facce
|
||||
for i = 1, 2 do
|
||||
-- Limitazioni della lavorazione
|
||||
local nPos = EgtIf( i == 1, 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 = EgtIf( ( j == 1 or j == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)
|
||||
-- ciclo sulle passate
|
||||
local nO = 1
|
||||
local dStep = 0
|
||||
local dAgg = EgtIf( bConvex, 2 * BD.CUT_EXTRA, BD.CUT_EXTRA)
|
||||
if vWidth[vOrd[i]] + dAgg > dToolDiam then
|
||||
nO = ceil(( vWidth[vOrd[i]] + dAgg) / dToolDiam)
|
||||
if nO > 1 then
|
||||
dStep = ( vWidth[vOrd[i]] + dAgg - dToolDiam) / ( nO - 1)
|
||||
end
|
||||
end
|
||||
for k = 1, nO do
|
||||
-- determino direzione di movimento
|
||||
local bToLeft = ( i == 1)
|
||||
-- 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, vOrd[i] - 1}})
|
||||
-- limito opportunamente la lavorazione
|
||||
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal)
|
||||
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal)
|
||||
-- imposto posizione braccio porta testa per non ingombrare agli estremi
|
||||
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
|
||||
-- imposto uso faccia
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, vFaceUse[vOrd[i]])
|
||||
-- imposto lato di lavoro e inversione
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, false)
|
||||
-- imposto offset radiale (nullo se concavo)
|
||||
if k < nO then
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, ( nO - k) * dStep)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, EgtIf( bConvex, - BD.CUT_EXTRA, 0))
|
||||
end
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchFId, false)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- altrimenti (se è sotto): taglio Prof
|
||||
else
|
||||
local vWidth = {}
|
||||
local vtDiff1 = ptC[vOrd[1]] - ptM
|
||||
vWidth[vOrd[1]] = 2 * sqrt( vtDiff1:getY() * vtDiff1:getY() + vtDiff1:getZ() * vtDiff1:getZ())
|
||||
local vtDiff2 = ptC[vOrd[2]] - ptM
|
||||
vWidth[vOrd[2]] = 2 * sqrt( vtDiff2:getY() * vtDiff2:getY() + vtDiff2:getZ() * vtDiff2:getZ())
|
||||
-- recupero la lavorazione
|
||||
local nMill, sMilling = FindMilling( 'Prof')
|
||||
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
|
||||
-- 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
|
||||
-- su entrambe le facce
|
||||
for i = 1, 2 do
|
||||
-- Limitazioni della lavorazione
|
||||
local nPos = EgtIf( i == 1, 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 = EgtIf( ( j == 1 or j == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)
|
||||
-- ciclo sulle passate
|
||||
local nO = 1
|
||||
local dStep = 0
|
||||
local dAgg = EgtIf( bConvex, 2 * BD.CUT_EXTRA, BD.CUT_EXTRA)
|
||||
if vWidth[vOrd[i]] + dAgg > dMaxDepth then
|
||||
nO = ceil(( vWidth[vOrd[i]] + dAgg) / dMaxDepth)
|
||||
if nO > 1 then
|
||||
dStep = ( vWidth[vOrd[i]] + dAgg - dMaxDepth) / ( nO - 1)
|
||||
end
|
||||
end
|
||||
for k = 1, nO do
|
||||
-- determino direzione di movimento
|
||||
local bToLeft = ( i == 1)
|
||||
-- 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, vOrd[i] - 1}})
|
||||
-- limito opportunamente la lavorazione
|
||||
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal)
|
||||
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal)
|
||||
-- imposto posizione braccio porta testa per non ingombrare agli estremi
|
||||
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
|
||||
-- imposto uso faccia
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, vFaceUse[vOrd[i]])
|
||||
-- imposto lato di lavoro e inversione
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
|
||||
local dDepth = min( dMaxDepth, vWidth[vOrd[i]] + BD.MILL_OVERLAP)
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
|
||||
-- EgtSetMachiningParam( MCH_MP.DEPTH_STR, 'TH')
|
||||
EgtSetMachiningParam( MCH_MP.STEP, 0)
|
||||
|
||||
-- imposto offset radiale (nullo se concavo)
|
||||
if k < nO then
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, ( nO - k) * dStep)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, EgtIf( bConvex, - BD.CUT_EXTRA, 0))
|
||||
end
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchFId, false)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local vWidth = {}
|
||||
local vtDiff1 = ptC[vOrd[1]] - ptM
|
||||
vWidth[vOrd[1]] = 2 * sqrt( vtDiff1:getY() * vtDiff1:getY() + vtDiff1:getZ() * vtDiff1:getZ())
|
||||
local vtDiff2 = ptC[vOrd[2]] - ptM
|
||||
vWidth[vOrd[2]] = 2 * sqrt( vtDiff2:getY() * vtDiff2:getY() + vtDiff2:getZ() * vtDiff2:getZ())
|
||||
-- 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 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 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
|
||||
-- su entrambe le facce
|
||||
for i = 1, 2 do
|
||||
-- Limitazioni della lavorazione
|
||||
local nPos = EgtIf( i == 1, 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 = EgtIf( ( j == 1 or j == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)
|
||||
-- ciclo sulle passate
|
||||
local nO = 1
|
||||
local dStep = 0
|
||||
local dAgg = EgtIf( bConvex, 2 * BD.CUT_EXTRA, BD.CUT_EXTRA)
|
||||
if vWidth[vOrd[i]] + dAgg > dToolDiam then
|
||||
nO = ceil(( vWidth[vOrd[i]] + dAgg) / dToolDiam)
|
||||
if nO > 1 then
|
||||
dStep = ( vWidth[vOrd[i]] + dAgg - dToolDiam) / ( nO - 1)
|
||||
end
|
||||
end
|
||||
for k = 1, nO do
|
||||
-- determino direzione di movimento
|
||||
local bToLeft = ( i == 1)
|
||||
-- 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, vOrd[i] - 1}})
|
||||
-- limito opportunamente la lavorazione
|
||||
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal)
|
||||
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal)
|
||||
-- imposto posizione braccio porta testa per non ingombrare agli estremi
|
||||
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
|
||||
-- imposto uso faccia
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, vFaceUse[vOrd[i]])
|
||||
-- imposto lato di lavoro e inversione
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, false)
|
||||
-- imposto offset radiale (nullo se concavo)
|
||||
if k < nO then
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, ( nO - k) * dStep)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, EgtIf( bConvex, - BD.CUT_EXTRA, 0))
|
||||
end
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchFId, false)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user