DataWall :

- sistemazioni varie durante prime prove con macchina S3.
This commit is contained in:
Dario Sassi
2020-07-11 09:40:28 +00:00
parent 1f752a05e0
commit 767e7287a5
7 changed files with 347 additions and 77 deletions
+159 -43
View File
@@ -1,4 +1,4 @@
-- ProcessFreeContour.lua by Egaltech s.r.l. 2020/07/01
-- ProcessFreeContour.lua by Egaltech s.r.l. 2020/07/08
-- Gestione calcolo profilo libero per Pareti
-- Tabella per definizione modulo
@@ -13,6 +13,7 @@ EgtOutLog( ' WProcessFreeContour started', 1)
-- Dati
local WD = require( 'WallData')
local WM = require( 'WMachiningLib')
local WHISK_OFFS = 0.1
local WHISK_SAFE = 5
local MIN_LEN_CUT = 5
@@ -119,7 +120,11 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw)
-- assegno lato di lavoro
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
-- posizione braccio porta testa
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP)
local nSCC = MCH_SCC.ADIR_ZP
if abs( vFace[i].Norm:getZ()) < GEO.EPS_SMALL then
nSCC = MCH_SCC.ADIR_YP
end
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
@@ -180,12 +185,105 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw)
return true
end
---------------------------------------------------------------------
local function AddSawings( sSawing, vFace, Proc, nRawId, b3Raw)
-- recupero i dati dell'utensile
local dSawDiam = 0
local dMaxDepth = 0
if EgtMdbSetCurrMachining( sSawing) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
end
end
-- ciclo di inserimento dei tagli con sega a catena
for i = 1, #vFace do
-- se inizio faccia non tagliato completamente, inserisco un ripasso con sega a catena
if ( vFace[i].Type & 1) ~= 0 then
-- inserisco la lavorazione
local sName = 'Free_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId))
local nMchId = EgtAddMachining( sName, sSawing)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sSawing
EgtOutLog( sErr)
return false, sErr
end
-- calcolo l'affondamento
local dDepth = min( vFace[i].Width + WD.CUT_EXTRA, dMaxDepth)
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, i - 1}})
local dSal = - dSawDiam / 2
local dEal = vFace[i].Whisk - vFace[i].Len - dSawDiam / 2
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.NONE)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
end
-- se fine faccia non tagliato completamente o faccia non tagliata completamente e abbastanza lunga, inserisco un ripasso con sega a catena
if ( vFace[i].Type & 1) ~= 0 or ( vFace[i].Type == 4 and vFace[i].Len > dSawDiam + 1) then
-- inserisco la lavorazione
local sName = 'Free_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId))
local nMchId = EgtAddMachining( sName, sSawing)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sSawing
EgtOutLog( sErr)
return false, sErr
end
-- calcolo l'affondamento
local dDepth = min( vFace[i].Width + WD.CUT_EXTRA, dMaxDepth)
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, i - 1}})
local dSal = - dSawDiam / 2
local dEal = - dSawDiam / 2
if ( vFace[i].Type & 2) ~= 0 then
dSal = vFace[i].Whisk - vFace[i].Len - dSawDiam / 2
end
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.NONE)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
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
-- indice del successivo
local j = EgtIf( i < #vFace, i + 1, 1)
-- inserisco la lavorazione
local sName = 'Cut_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) .. '_' .. tostring( i)
local nMchId = EgtAddMachining( sName, sCutting)
@@ -196,27 +294,36 @@ local function AddCuts( sCutting, vFace, Proc, nRawId, b3Raw)
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)
-- verifico se va invertita la direzione di lavorazione perchè faccia verso l'alto (angolo maggiore di 0.01 deg)
local bInvert = ( vFace[i].Norm:getZ() > 0.0001745)
-- imposto inversione
EgtSetMachiningParam( MCH_MP.INVERT, bInvert)
-- imposto lato di lavoro
EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( bInvert, MCH_SAW_WS.LEFT, MCH_SAW_WS.RIGHT))
-- lato mandrino sempre a sinistra (rotazione lama oraria)
EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.LEFT)
-- assegno i dati di attacco (sicurezza solo se angolo interno)
local nLeadIn = EgtIf( ( vFace[i].Type & 1) == 0, MCH_SAW_LI.CENT, MCH_SAW_LI.STRICT)
local nLeadIn = MCH_SAW_LI.CENT
if ( not bInvert and ( vFace[i].Type & 1) ~= 0) or ( bInvert and ( vFace[i].Type & 2) ~= 0) then
nLeadIn = MCH_SAW_LI.STRICT
end
EgtSetMachiningParam( MCH_MP.LEADINTYPE, nLeadIn)
if vFace[i].AngPrev < -0.1 then
if ( not bInvert and vFace[i].AngPrev < -0.1) or ( bInvert and vFace[j].AngPrev < -0.1) then
EgtSetMachiningParam( MCH_MP.STARTADDLEN, -WHISK_SAFE)
end
-- assegno i dati di uscita (sicurezza solo se angolo interno)
local nLeadOut = EgtIf( ( vFace[i].Type & 2) == 0, MCH_SAW_LO.CENT, MCH_SAW_LO.STRICT)
local nLeadOut = MCH_SAW_LO.CENT
if ( not bInvert and ( vFace[i].Type & 2) ~= 0) or ( bInvert and ( vFace[i].Type & 1) ~= 0) then
nLeadOut = MCH_SAW_LO.STRICT
end
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, nLeadOut)
local j = EgtIf( i < #vFace, i + 1, 1)
if vFace[j].AngPrev < -0.1 then
if ( not bInvert and vFace[j].AngPrev < -0.1) or ( bInvert and vFace[i].AngPrev < -0.1) then
EgtSetMachiningParam( MCH_MP.ENDADDLEN, -WHISK_SAFE)
end
-- posizione braccio porta testa
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP)
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
@@ -239,31 +346,21 @@ local function MakeByCut( Proc, nRawId, b3Raw)
return false, sErr
end
-- recupero la lavorazione di fresatura
local sMilling = WM.FindMilling( 'FreeContour')
local sMilling, dMillMaxDepth = WM.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 = WM.FindCutting( 'Standard')
-- recupero la lavorazione con sega a catena
local sSawing = WM.FindSawing( 'Sawing')
-- recupero la lavorazione di taglio con lama e i suoi parametri
local sCutting, dSawDiam, dSawThick, dSawMaxDepth = WM.FindCutting( 'Standard')
if not sCutting then
local sErr = 'Error : cutting not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- recupero i dati della lama
local dSawDiam = 400
local dSawThick = 10
local dSawMaxDepth = 0
if EgtMdbSetCurrMachining( sCutting) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam
dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThick
dSawMaxDepth = EgtTdbGetCurrToolMaxDepth() or dSawMaxDepth
end
end
-- recupero i dati di tutte le facce
local vFace = {}
for i = 1, Proc.Fct do
@@ -277,7 +374,12 @@ local function MakeByCut( Proc, nRawId, b3Raw)
vFace[i] = { Cen = ptCen, Norm = vtN, Len = dLen, Width = dWidth, AngPrev = EgtIf( bAdj, dAng, 0)}
end
-- analizzo le facce
local dMaxWidth = 0
for i = 1, #vFace do
-- aggiorno la massima larghezza
if vFace[i].Width > dMaxWidth then
dMaxWidth = vFace[i].Width
end
-- verifico l'affondamento
local dDepth = WD.CUT_EXTRA
if vFace[i].Width + WD.CUT_EXTRA > dSawMaxDepth then
@@ -313,10 +415,12 @@ local function MakeByCut( Proc, nRawId, b3Raw)
-- verifico il baffo iniziale
if vFace[i].Type ~= 4 and ( vFace[i].Type & 1) == 0 then
-- creo il rettangolo del baffo
local vtDir = Vector3d( vFace[i].Norm) ; vtDir:rotate( Z_AX(), -90)
local ptIni = vFace[i].Cen + vFace[i].Len / 2 * vtDir
local ptDir = ptIni + vFace[i].Whisk * vtDir
local ptCross = ptDir + dSawThick * vFace[i].Norm
local vtOrt = Vector3d( vFace[i].Norm:getX(), vFace[i].Norm:getY(), 0) ; vtOrt:normalize()
local vtDir = Vector3d( vtOrt) ; vtDir:rotate( Z_AX(), -90)
local vtUp = Vector3d( vtDir) ; vtUp:rotate( vFace[i].Norm, -90)
local ptIni = vFace[i].Cen + vFace[i].Width / 2 * vtUp + ( vFace[i].Len / 2 + WHISK_OFFS) * vtDir + WHISK_OFFS * vtOrt
local ptDir = ptIni + ( vFace[i].Whisk - WHISK_OFFS) * vtDir
local ptCross = ptDir + ( dSawThick - WHISK_OFFS) * vtOrt
local WhId = EgtSurfFrRectangle3P( nAddGrpId, ptIni, ptCross, ptDir, GDB_RT.GLOB)
local b3Wh = EgtGetBBoxGlob( WhId or GDB_ID.NULL, GDB_BB.STANDARD)
-- verifico se interferisce con gli altri pezzi
@@ -339,10 +443,12 @@ local function MakeByCut( Proc, nRawId, b3Raw)
-- verifico il baffo finale
if vFace[i].Type ~= 4 and ( vFace[i].Type & 2) == 0 then
-- creo il rettangolo del baffo
local vtDir = Vector3d( vFace[i].Norm) ; vtDir:rotate( Z_AX(), 90)
local ptIni = vFace[i].Cen + vFace[i].Len / 2 * vtDir
local ptDir = ptIni + vFace[i].Whisk * vtDir
local ptCross = ptDir + dSawThick * vFace[i].Norm
local vtOrt = Vector3d( vFace[i].Norm:getX(), vFace[i].Norm:getY(), 0) ; vtOrt:normalize()
local vtDir = Vector3d( vtOrt) ; vtDir:rotate( Z_AX(), 90)
local vtUp = Vector3d( vtDir) ; vtUp:rotate( vFace[i].Norm, 90)
local ptIni = vFace[i].Cen + vFace[i].Width / 2 * vtUp + ( vFace[i].Len / 2 + WHISK_OFFS) * vtDir + WHISK_OFFS * vtOrt
local ptDir = ptIni + ( vFace[i].Whisk - WHISK_OFFS) * vtDir
local ptCross = ptDir + ( dSawThick - WHISK_OFFS) * vtOrt
local WhId = EgtSurfFrRectangle3P( nAddGrpId, ptIni, ptCross, ptDir, GDB_RT.GLOB)
local b3Wh = EgtGetBBoxGlob( WhId or GDB_ID.NULL, GDB_BB.STANDARD)
-- verifico se interferisce con gli altri pezzi
@@ -366,9 +472,15 @@ local function MakeByCut( Proc, nRawId, b3Raw)
-- 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
-- se possibile, inserimento delle fresature
if dMaxWidth + WD.CUT_EXTRA < dMillMaxDepth then
local bMlOk, sMlErr = AddMillings( sMilling, vFace, Proc, nRawId, b3Raw)
if not bMlOk then return bMlOk, sMlErr end
-- altrimenti provo con la sega a catena
else
local bCsOk, sCSErr = AddSawings( sSawing, vFace, Proc, nRawId, b3Raw)
if not bCsOk then return bCsOk, sCsErr end
end
return true
end
@@ -446,7 +558,11 @@ local function MakeByMill( Proc, nRawId, b3Raw)
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
end
-- posizione braccio porta testa
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP)
local nSCC = MCH_SCC.ADIR_ZP
if AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then
nSCC = EgtIf( Proc.Box:getDimX() >= Proc.Box:getDimY(), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_XP)
end
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
@@ -498,11 +614,11 @@ local function MakeByPocket( Proc, nRawId, b3Raw)
-- aggiungo geometria
EgtSetMachiningGeometry( {{ AuxId, -1}})
-- imposto posizione braccio porta testa
if vtExtr:getY() <= 0 then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
else
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
local nSCC = MCH_SCC.ADIR_ZP
if AreSameVectorApprox( vtExtr, Z_AX()) then
nSCC = EgtIf( Proc.Box:getDimX() >= Proc.Box:getDimY(), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_XP)
end
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
-- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente
if dDepth > dMaxDepth + 10 * GEO.EPS_SMALL then
dDepth = dMaxDepth