DataWall :

- in lavorazione Outline, FreeContour e Aperture aggiunta gestione lavorazione con fresa parti non tagliate con lama.
This commit is contained in:
Dario Sassi
2020-06-29 14:10:42 +00:00
parent f800eab2ab
commit 96e3d29fb9
2 changed files with 159 additions and 55 deletions
+142 -43
View File
@@ -47,6 +47,116 @@ function ProcessFreeContour.Classify( Proc, b3Raw)
end
end
---------------------------------------------------------------------
local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw)
-- recupero i dati dell'utensile
local dMaxDepth = 0
if EgtMdbSetCurrMachining( sMilling) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
end
end
-- ciclo di inserimento delle fresate sulle facce del contorno in esame, partendo da prima faccia non di tipo 4
local i = 1
while i <= #vFace and vFace[i].Type == 4 do
i = i + 1
end
while i <= #vFace do
-- se tutta la faccia o la sua fine senza taglio, inserisco una fresatura
if ( vFace[i].Type & 2) ~= 0 or vFace[i].Type == 4 then
-- inserisco la lavorazione
local sName = 'Free_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId))
local nMchId = EgtAddMachining( sName, sMilling)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
end
-- calcolo l'affondamento
local dDepth = min( vFace[i].Width + WD.CUT_EXTRA, dMaxDepth)
-- aggiungo geometria
local vGeom = {{ Proc.Id, i - 1}}
local dSal = EgtIf( ( vFace[i].Type & 2) ~= 0, vFace[i].Whisk - vFace[i].Len, 0)
local dEal = 0
i = i + 1
local j = EgtIf( i <= #vFace, i, 1)
while ( vFace[j].Type & 1) ~= 0 or vFace[j].Type == 4 do
table.insert( vGeom, { Proc.Id, j - 1})
dEal = EgtIf( ( vFace[j].Type & 1) ~= 0, vFace[j].Whisk - vFace[j].Len, 0)
if ( vFace[j].Type & 1) ~= 0 then
break
end
i = i + 1
j = EgtIf( i <= #vFace, i, 1)
end
EgtSetMachiningGeometry( vGeom)
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal)
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal)
-- percorso da non invertire
EgtSetMachiningParam( MCH_MP.INVERT, false)
-- assegno utilizzo faccia
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN)
-- assegno affondamento
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
-- assegno lato di lavoro
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
-- posizione braccio porta testa
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
else
i = i + 1
end
end
return true
end
---------------------------------------------------------------------
local function AddCuts( sCutting, vFace, Proc, nRawId, b3Raw)
-- ciclo di inserimento dei tagli sulle facce del contorno in esame
for i = 1, #vFace do
-- se non è faccia da saltare, inserisco il taglio di lama
if vFace[i].Type ~= 4 then
-- inserisco la lavorazione
local sName = 'Cut_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) .. '_' .. tostring( i)
local nMchId = EgtAddMachining( sName, sCutting)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sCutting
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( { { Proc.Id, i - 1}})
-- percorso da non invertire
EgtSetMachiningParam( MCH_MP.INVERT, false)
-- assegno affondamento
EgtSetMachiningParam( MCH_MP.DEPTH, vFace[i].Depth)
-- assegno il lato di lavoro
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
-- assegno il tipo di attacco
local nLeadIn = EgtIf( ( vFace[i].Type & 1) == 0, MCH_SAW_LI.CENT, MCH_SAW_LI.STRICT)
EgtSetMachiningParam( MCH_MP.LEADINTYPE, nLeadIn)
-- assegno il tipo di uscita
local nLeadOut = EgtIf( ( vFace[i].Type & 2) == 0, MCH_SAW_LO.CENT, MCH_SAW_LO.STRICT)
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, nLeadOut)
-- posizione braccio porta testa
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
end
end
return true
end
---------------------------------------------------------------------
local function MakeByCut( Proc, nRawId, b3Raw)
-- ingombro del pezzo
@@ -57,7 +167,14 @@ local function MakeByCut( Proc, nRawId, b3Raw)
EgtOutLog( sErr)
return false, sErr
end
-- recupero la lavorazione
-- recupero la lavorazione di fresatura
local sMilling = ML.FindMilling( 'FreeContour')
if not sMilling then
local sErr = 'Error : milling not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- recupero la lavorazione di taglio con lama
local sCutting = ML.FindCutting( 'Standard')
if not sCutting then
local sErr = 'Error : cutting not found in library'
@@ -81,13 +198,13 @@ local function MakeByCut( Proc, nRawId, b3Raw)
local ptCen, vtN = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT)
-- recupero le dimensioni della faccia
local _, dLen, dWidth = WL.GetFaceHvRefDim( Proc.Id, i - 1)
-- recupero l'angolo con la faccia successiva
-- recupero l'angolo con la faccia precedente
local bAdj, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, EgtIf( i == 1, Proc.Fct - 1, i - 2), i -1, GDB_ID.ROOT)
-- salvo i dati
vFace[i] = { Cen = ptCen, Norm = vtN, Len = dLen, Width = dWidth, AngPrev = EgtIf( bAdj, dAng, 0)}
end
-- ciclo sulle facce del contorno in esame
for i = 1, Proc.Fct do
-- analizzo le facce
for i = 1, #vFace do
-- verifico l'affondamento
local dDepth = WD.CUT_EXTRA
if vFace[i].Width + WD.CUT_EXTRA > dMaxDepth then
@@ -98,47 +215,29 @@ local function MakeByCut( Proc, nRawId, b3Raw)
local dWhisk = dElev * sqrt( dSawDiam / dElev - 1)
-- determino la lunghezza del taglio passante e il tipo di attacco e uscita
local dLen = vFace[i].Len
local nLeadIn = MCH_SAW_LI.CENT
local nLeadOut = MCH_SAW_LO.CENT
local nType = 0
if vFace[i].AngPrev < -0.1 then
dLen = dLen - dWhisk
nLeadIn = MCH_SAW_LI.STRICT
nType = nType + 1
end
if vFace[EgtIf( i < Proc.Fct, i + 1, 1)].AngPrev < -0.1 then
dLen = dLen - dWhisk
nLeadOut = MCH_SAW_LO.STRICT
nType = nType + 2
end
-- se lunghezza significativa, inserisco la lavorazione
if dLen > 1 then
local sName = 'Cut_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) .. '_' .. tostring( i)
local nMchId = EgtAddMachining( sName, sCutting)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sCutting
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( { { Proc.Id, i - 1}})
-- percorso da non invertire
EgtSetMachiningParam( MCH_MP.INVERT, false)
-- assegno affondamento
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
-- assegno il lato di lavoro
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
-- assegno il tipo di attacco
EgtSetMachiningParam( MCH_MP.LEADINTYPE, nLeadIn)
-- assegno il tipo di uscita
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, nLeadOut)
-- posizione braccio porta testa
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
-- se lunghezza non significativa, non va inserito il taglio
if dLen < 1 then
nType = 4
end
vFace[i].Depth = dDepth
vFace[i].Whisk = dWhisk
vFace[i].Type = nType
end
-- inserimento dei tagli di lama
local bCtOk, sCtErr = AddCuts( sCutting, vFace, Proc, nRawId, b3Raw)
if not bCtOk then return bCtOk, sCtErr end
-- inserimento delle fresature
local bMlOk, sMlErr = AddMillings( sMilling, vFace, Proc, nRawId, b3Raw)
if not bMlOk then return bMlOk, sMlErr end
return true
end
@@ -148,7 +247,7 @@ local function MakeByMill( Proc, nRawId, b3Raw)
local Ls = EgtGetFirstNameInGroup( Proc.PartId, '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
@@ -156,7 +255,7 @@ local function MakeByMill( Proc, nRawId, b3Raw)
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
@@ -168,7 +267,7 @@ local function MakeByMill( Proc, nRawId, b3Raw)
-- 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 : milling not found in library'
EgtOutLog( sErr)
return false, sErr
end
@@ -232,7 +331,7 @@ local function MakeByPocket( Proc, nRawId, b3Raw)
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
@@ -243,7 +342,7 @@ local function MakeByPocket( Proc, nRawId, b3Raw)
-- recupero la lavorazione
local sPocketing = ML.FindPocketing( 'Pocket', nil, dDepth)
if not sPocketing then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library'
local sErr = 'Error : pocketing not found in library'
EgtOutLog( sErr)
return false, sErr
end
@@ -276,7 +375,7 @@ local function MakeByPocket( Proc, nRawId, b3Raw)
-- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente
if dDepth > dMaxDepth + 10 * GEO.EPS_SMALL then
dDepth = dMaxDepth
local sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : elevation bigger than max tool depth'
local sWarn = 'Warning : elevation bigger than max tool depth'
EgtOutLog( sWarn)
end
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)