- modifiche varie per gestione MultiDrill, al momento per Cabinet

This commit is contained in:
luca.mazzoleni
2025-02-11 18:46:10 +01:00
parent 36ddc182f9
commit a27566031b
4 changed files with 157 additions and 34 deletions
+103 -26
View File
@@ -27,6 +27,9 @@ local WM = require( 'WMachiningLib')
-- Parametri Q
local sContourOnly = 'Q01' -- 0=no, 1=si
-- Per forature MultiDrill, lista lavorazioni già provate
local TriedDrillings = {}
---------------------------------------------------------------------
-- Riconoscimento della feature
@@ -56,7 +59,7 @@ end
---------------------------------------------------------------------
-- Classificazione della feature
function WPD.Classify( Proc, b3Raw)
function WPD.Classify( Proc, b3Raw, bUseMultiDrill)
-- recupero e verifico l'entità foro
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0
@@ -75,6 +78,10 @@ function WPD.Classify( Proc, b3Raw)
-- è lavorabile se non troppo inclinato
return ( abs( vtExtr:getZ()) >= WD.DRILL_VZ_MIN)
end
-- multiforatore (cabinet)
if bUseMultiDrill then
return true
end
-- se con direzione asse Y e macchina con foratore orizzontale del giusto diametro
if WD.HOR_DRILL_DIAM and abs( dDiam - WD.HOR_DRILL_DIAM) < WD.DRILL_TOL and AreSameOrOppositeVectorApprox( vtExtr, Y_AX()) then
return true
@@ -255,7 +262,7 @@ end
---------------------------------------------------------------------
-- Applicazione della lavorazione
function WPD.Make( Proc, nRawId, b3Raw)
function WPD.Make( Proc, nRawId, b3Raw, bUseMultiDrill, DrillingsToAvoid)
-- recupero e verifico l'entità foro
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0
if AuxId then AuxId = AuxId + Proc.Id end
@@ -299,27 +306,35 @@ function WPD.Make( Proc, nRawId, b3Raw)
end
end
end
local bUseDLenToFindDrilling = true
local sDrilling, nType = WM.FindDrilling( dDiam, dLen, sHead)
if not sDrilling then
bUseDLenToFindDrilling = false
sDrilling, nType = WM.FindDrilling( dDiam, nil, sHead)
end
-- se Proc è settata per essere specchiata cerco la lavorazione adatta e verifico possa essere effettivamente specchiata
if Proc.Double and Proc.Double == 2 then
local sDrillingBackup = sDrilling
sDrilling = WM.FindDrilling( dDiam, EgtIf( bUseDLenToFindDrilling, dLen, nil), 'H1')
if not IsMachiningOkForDouble( sDrilling) then
Proc.Double = 0
sDrilling = sDrillingBackup
end
end
if sHead and not sDrilling then
sDrilling, nType = WM.FindDrilling( dDiam, dLen)
local sDrilling, nType
if bUseMultiDrill then
sDrilling, nType = WM.FindDrilling( nil, nil, nil, nil, true, TriedDrillings)
if not sDrilling then
sDrilling, nType = WM.FindDrilling( dDiam)
return false
end
else
local bUseDLenToFindDrilling = true
sDrilling, nType = WM.FindDrilling( dDiam, dLen, sHead)
if not sDrilling then
bUseDLenToFindDrilling = false
sDrilling, nType = WM.FindDrilling( dDiam, nil, sHead)
end
-- se Proc è settata per essere specchiata cerco la lavorazione adatta e verifico possa essere effettivamente specchiata
if Proc.Double and Proc.Double == 2 then
local sDrillingBackup = sDrilling
sDrilling = WM.FindDrilling( dDiam, EgtIf( bUseDLenToFindDrilling, dLen, nil), 'H1')
if not IsMachiningOkForDouble( sDrilling) then
Proc.Double = 0
sDrilling = sDrillingBackup
end
end
if sHead and not sDrilling then
sDrilling, nType = WM.FindDrilling( dDiam, dLen)
if not sDrilling then
sDrilling, nType = WM.FindDrilling( dDiam)
end
if sDrilling then sHead = '' end
end
if sDrilling then sHead = '' end
end
local bAngledContourDrill = false
local nAngledContourDrillId = GDB_ID.NULL
@@ -446,11 +461,27 @@ function WPD.Make( Proc, nRawId, b3Raw)
-- aggiungo geometria
if bAngledContourDrill then
EgtSetMachiningGeometry( nAngledContourDrillId)
elseif bUseMultiDrill then
if Proc.SkippedGeometries and #Proc.SkippedGeometries > 0 then
EgtSetMachiningGeometry( Proc.SkippedGeometries)
elseif Proc.OtherGeometries and #Proc.OtherGeometries > 0 then
local HolesGeometries = {}
-- aggiungo foro principale
table.insert( HolesGeometries, { AuxId, -1})
-- aggiungo altre geometrie connesse
for i = 1, #Proc.OtherGeometries do
-- recupero geometria da lavorare
local OtherAuxId = Proc.OtherGeometries[i].Id + EgtGetInfo( Proc.OtherGeometries[i].Id, 'AUXID', 'i')
local Geometry = { OtherAuxId, -1}
table.insert( HolesGeometries, Geometry)
end
EgtSetMachiningGeometry( HolesGeometries)
end
else
EgtSetMachiningGeometry( {{ AuxId, -1}})
end
-- eventuale inversione
if nType == 'Drill' then
if nType == 'Drill' or nType == 'MultiDrill' then
EgtSetMachiningParam( MCH_MP.INVERT, bToInvert)
else
EgtSetMachiningParam( MCH_MP.TOOLINVERT, bToInvert)
@@ -488,7 +519,9 @@ function WPD.Make( Proc, nRawId, b3Raw)
end
-- imposto posizione braccio porta testa
local nSCC = MCH_SCC.ADIR_ZP
if AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then
if bUseMultiDrill then
nSCC = MCH_SCC.ADIR_NEAR
elseif AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then
nSCC = MCH_SCC.ADIR_YP
end
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
@@ -502,8 +535,13 @@ function WPD.Make( Proc, nRawId, b3Raw)
EgtOutLog( sMyWarn .. ' (process ' .. tostring( Proc.Id) .. ')')
end
end
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
-- leggo eventuali note esistenti della lavorazione
if bUseMultiDrill then
local sDepth = 'TH'
EgtSetMachiningParam( MCH_MP.DEPTH_STR, sDepth)
else
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
end
-- leggo eventuali note esistenti della lavorazione
local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES)
-- se foratura o svuotatura, dichiarazione nessuna generazione sfridi per Vmill
if nType == 'Drill' or nType == 'Pocket' then
@@ -536,7 +574,45 @@ function WPD.Make( Proc, nRawId, b3Raw)
EgtSetMachiningParam( MCH_MP.TABMAX, 3)
end
-- eseguo
if not EgtApplyMachining( true, false) then
local bOk = EgtApplyMachining( true, false)
-- in caso di fori raggruppati vengono restituiti gli eventuali fori saltati
local SkippedGeometries = {}
SkippedGeometries = EgtGetMachiningSkippedGeometry()
if bUseMultiDrill and SkippedGeometries and #SkippedGeometries > 0 then
if ( Proc.SkippedGeometries and ( #SkippedGeometries == #Proc.SkippedGeometries))
or ( #SkippedGeometries == #Proc.OtherGeometries + 1) then
EgtRemoveOperation( nMchId)
end
Proc.SkippedGeometries = SkippedGeometries
table.insert( TriedDrillings, sDrilling)
-- per provare tutte le MultiDrill disponibili si passano quelle già fatte come lavorazioni da ignorare
bOk = WPD.Make( Proc, nRawId, b3Raw, true, TriedDrillings)
-- non trovata lavorazione, si prova con le lavorazioni singole
if not bOk then
for i = 1, #Proc.SkippedGeometries do
for j = 1, #Proc.OtherGeometries do
local AuxIdOtherGeometry = EgtGetInfo( Proc.OtherGeometries[j].Id, 'AUXID', 'i') or 0
if AuxIdOtherGeometry then AuxIdOtherGeometry = AuxIdOtherGeometry + Proc.OtherGeometries[j].Id end
local AuxIdProc = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0
if AuxIdProc then AuxIdProc = AuxIdProc + Proc.Id end
if Proc.SkippedGeometries[i][1] == AuxIdOtherGeometry then
bOk = WPD.Make( Proc.OtherGeometries[j], nRawId, b3Raw, false)
elseif Proc.SkippedGeometries[i][1] == AuxIdProc then
bOk = WPD.Make( Proc, nRawId, b3Raw, false)
end
end
if bOk then
table.remove( Proc.SkippedGeometries, i)
end
end
end
-- TODO va gestito meglio l'output degli errorri
local _, sWarn = EgtGetMachMgrWarning( 0)
return true, sWarn
end
if not bOk then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
@@ -549,6 +625,7 @@ function WPD.Make( Proc, nRawId, b3Raw)
sMyWarn = (sMyWarn or sWarn)
end
end
-- se preforo inclinato impostato, inclinazione oltre limite impostato e foro non orizzontale
if WD.PREDRILL_DIAM and WD.PREDRILL_DIAM > 0 and vtExtr:getZ() < ( WD.PREDRILL_MINANGLE or 0.707) and vtExtr:getZ() > 0.1 then
-- gruppo ausiliario per preforo