DataBeam :

- modifiche per macchina PF1250.
This commit is contained in:
Dario Sassi
2020-11-09 08:48:28 +00:00
parent 1adb136219
commit 15649573c4
13 changed files with 374 additions and 86 deletions
+268 -13
View File
@@ -1,4 +1,4 @@
-- ProcessFreeContour.lua by Egaltech s.r.l. 2020/09/03
-- ProcessFreeContour.lua by Egaltech s.r.l. 2020/11/07
-- Gestione calcolo profilo libero per Travi
-- Tabella per definizione modulo
@@ -14,6 +14,11 @@ EgtOutLog( ' ProcessFreeContour started', 1)
local BD = require( 'BeamData')
local ML = require( 'MachiningLib')
-- variabili assegnazione parametri Q
local sDepthChamferMill = 'Q02' -- d
local sOverMaterialForFinish = 'Q03' -- d
local sPreemptiveChamfer = 'Q00' -- i
---------------------------------------------------------------------
-- Riconoscimento della feature
function ProcessFreeContour.Identify( Proc)
@@ -109,6 +114,58 @@ function ProcessFreeContour.Classify( Proc, b3Raw)
end
end
---------------------------------------------------------------------
local function VerifyCham( Proc, AuxId, nRawId, bMakeVertCham, sDephtCham, sOnlyCham)
local nChamfer = 0
-- ingombro del grezzo
local b3Raw = EgtGetRawPartBBox( nRawId)
-- verifico che lo smusso sia richiesto
local dDepth = EgtGetInfo( Proc.Id, sDephtCham, 'd') or 0
if dDepth > 0 then
nChamfer = 1
end
-- verifico se posso fare solo lo smusso
if EgtGetInfo( Proc.Id, sOnlyCham, 'i') == 1 then
if dDepth > 0 then
nChamfer = nChamfer + 1
-- altrimenti se non ho l'affondamento esco
else
local sErr = 'Error : no chamfer depth'
EgtOutLog( sErr)
return -1, dDepth, sErr
end
end
-- recupero i dati della curva e del profilo
local dWidth = abs( EgtCurveThickness( AuxId))
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
-- eseguo lo smusso solo se direzione orizzontale e il flag di lavorazione verticale è disabilitato
if abs( vtExtr:getZ()) > 0.1 then
if not bMakeVertCham then
if nChamfer == 2 then -- se devo fare solo smusso, genero errore
local sErr = 'Error : not horizontal chamfer'
EgtOutLog( sErr)
return -1, dDepth, sErr
else
local sWarn = 'Warning : skipped not horizontal chamfer'
EgtOutLog( sWarn)
return 0, dDepth
end
end
end
-- recupero la lavorazione
local sMilling
if nChamfer > 0 then
sMilling = ML.FindMilling( 'Mark')
if not sMilling then
local sErr = 'Error : Mark not found in library'
EgtOutLog( sErr)
return -1, 0, sErr
end
end
return nChamfer, dDepth, sMilling
end
---------------------------------------------------------------------
local function CalcSpecialAdd( nCrv, bStartVsEnd, dToolDiam)
-- recupero il dominio della curva
@@ -142,7 +199,7 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead)
local Ls = EgtGetFirstNameInGroup( nPartId, 'Box')
local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD)
if not b3Solid then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' part box not found'
local sErr = 'Error : part box not found'
EgtOutLog( sErr)
return false, sErr
end
@@ -150,7 +207,7 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead)
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0
if AuxId then AuxId = AuxId + Proc.Id end
if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry'
local sErr = 'Error : missing profile geometry'
EgtOutLog( sErr)
return false, sErr
end
@@ -160,10 +217,15 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead)
local b3Aux = EgtGetBBoxGlob( AuxId, GDB_BB.STANDARD)
local bToolInv = ( vtExtr:getZ() < -0.1)
local bDown = ( b3Aux:getMin():getZ() < b3Raw:getMin():getZ() + 5)
-- verifico se in testa o coda
local bHead = Proc.Head
-- verifico se sono presenti i parametri Q per la profondità smusso e
-- per eseguire in esclusiva solo lo smusso
local nChamfer, dDepthCham, sChamfer = VerifyCham( Proc, AuxId, nRawId, true, sDepthChamferMill, sPreemptiveChamfer)
-- recupero la lavorazione
local sMilling = ML.FindMilling( 'FreeContour')
if not sMilling then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library'
local sErr = 'Error : FreeContour not found in library'
EgtOutLog( sErr)
return false, sErr
end
@@ -189,6 +251,8 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead)
end
-- eventuale spezzatura sul tratto più lungo se curva chiusa
BL.PutStartOnLonger( AuxId)
-- verifico se profilo orientato verso l'alto (1), il basso (-1) o di fianco (0)
local nSide = 0
-- verifiche per affondamento ( possibili lavorazioni in doppio)
local bCross = false
if abs( vtExtr:getY()) > 0.707 then
@@ -196,12 +260,18 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead)
bCross = true
dDepth = min( dDepth, b3Raw:getDimY())
end
if bDown then
nSide = -1
else
nSide = 1
end
elseif abs( vtExtr:getZ()) > 0.707 then
if b3Aux:getDimZ() > b3Raw:getDimZ() - 1.0 then
bCross = true
dDepth = min( dDepth, b3Raw:getDimZ())
end
end
local dOriDepth = dDepth
local nDouble = 1
local bCanDouble = abs( vtExtr:getY()) > 0.707 and bCross
local bStripOnSide = false
@@ -238,16 +308,174 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead)
-- verifico se primo e ultimo tratti corti e con angolo
local dStartAddSpec = CalcSpecialAdd( AuxId, true, dToolDiam)
local dEndAddSpec = CalcSpecialAdd( AuxId, false, dToolDiam)
-- se devo inserire il chamfer
if nChamfer > 0 and Proc.Grp ~= 0 and dOriDepth > dDepthCham then
local bDoubleCham = false
local dExtra = 2
-- eseguo
for i = 1, nStep do
-- inserisco la lavorazione
local sNameCh = 'Cham_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchId = EgtAddMachining( sNameCh, sChamfer)
if not nMchId then
local sErr = 'Error adding machining ' .. sNameCh .. '-' .. sChamfer
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ AuxId, -1}})
-- se lavorazione da sopra o da sotto
if nSide ~= 0 then
bDoubleCham = true
end
if Proc.Grp == 3 then
if not bToolInv then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
EgtSetMachiningParam( MCH_MP.INVERT, true)
else
if vtExtr:getZ() < 0 then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
EgtSetMachiningParam( MCH_MP.INVERT, true)
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
else
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
end
end
if Proc.Grp == 4 then
if not bToolInv then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
EgtSetMachiningParam( MCH_MP.INVERT, true)
else
if vtExtr:getZ() < 0 then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
EgtSetMachiningParam( MCH_MP.INVERT, true)
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
else
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
end
end
end
-- assegno affondamento e offset radiale
EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra)
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
-- eventuale accorciamento di testa
if i > 1 then
local dStartAddLen = - ( i - 1) * dStep
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dStartAddLen + 1)
else
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dStartAddSpec + 1)
end
-- eventuale accorciamento di coda
if i < nStep then
local dEndAddLen = - ( nStep - i) * dStep
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEndAddLen + 1)
else
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEndAddSpec + 1)
end
-- posizione braccio porta testa
if Proc.Head then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP)
elseif Proc.Tail then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XM)
elseif AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
end
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
-- se lavorazione da due parti, aggiungo la seconda
if bDoubleCham then
-- inserisco la lavorazione
local sName = 'ChamB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchId = EgtAddMachining( sName, sChamfer)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sChamfer
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ AuxId, -1}})
if Proc.Grp == 3 then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, true)
elseif Proc.Grp == 4 then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
-- assegno affondamento e offset radiale
EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra)
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
-- eventuale accorciamento di testa
if i < nStep then
local dEndAddLen = - ( nStep - i) * dStep
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEndAddLen + 1)
else
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEndAddSpec + 1)
end
-- eventuale accorciamento di coda
if i > 1 then
local dStartAddLen = - ( i - 1) * dStep
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dStartAddLen + 1)
else
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dStartAddSpec + 1)
end
-- posizione braccio porta testa
if Proc.Head then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP)
elseif Proc.Tail then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XM)
elseif AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
end
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
end
end
end
-- verifico se devo fare sgrossatura più finitura
local dOffsetPar = EgtGetInfo( Proc.Id, sOverMaterialForFinish, 'i') or 0
-- eseguo
for i = 1, nStep do
for j = 1, nDouble do
-- inserisco la lavorazione
local sName = 'Free_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchId = EgtAddMachining( sName, sMilling)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
local sName
local nMchId
-- se ho smusso abilitato e gruppo 0 e profondità geometria minore della profondità smusso,
-- applico lavorazione smusso
if nChamfer > 0 and Proc.Grp == 0 and dOriDepth <= dDepthCham then
-- inserisco la lavorazione
sName = 'FreeCham_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
nMchId = EgtAddMachining( sName, sChamfer)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sChamfer
EgtOutLog( sErr)
return false, sErr
end
dOffsetPar = 0
-- assegno affondamento
EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham)
else
-- inserisco la lavorazione
sName = 'Free_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
nMchId = EgtAddMachining( sName, sMilling)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
end
-- assegno affondamento
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ AuxId, -1}})
@@ -273,8 +501,6 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead)
if j == 2 then
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
-- assegno affondamento
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
-- assegno lato di lavoro
if Proc.Grp == 0 then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.CENTER)
@@ -291,12 +517,41 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead)
elseif AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
end
-- acquisisco parametro sovramateriale
local bFinish
local dOriOffset = 0
-- se parametro sovramateriale è maggiore di 0 abilito la finitura extra
if dOffsetPar > 0 then
EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar))
bFinish = true
end
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
-- se abilitata, aggiungo lavorazione di finitura
if bFinish then
-- inserisco la lavorazione
local sNewName = 'Prof_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId))
if not nMch2Id then
local sErr = 'Error adding machining ' .. sNewName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
else
-- riporto il sovramateriale originale e tolgo i passi
EgtSetMachiningParam( MCH_MP.OFFSR, dOriOffset)
EgtSetMachiningParam( MCH_MP.STEP, 0)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMch2Id, false)
return false, sErr
end
end
end
end
end
-- eventuale segnalazione ingombro di testa o coda