- Lavorazione profili nella fase opportuna

- Migliorie varie
This commit is contained in:
andrea.villa
2024-06-21 17:15:37 +02:00
parent 66869aa0d8
commit 28e38b0441
6 changed files with 135 additions and 54 deletions
+12 -1
View File
@@ -124,7 +124,18 @@
"EgtApplyMachining",
"EgtSetCurrPhase",
"EgtApplyAllMachinings",
"EgtGetDebugLevel"
"EgtGetDebugLevel",
"EgtTdbGetCurrToolParam",
"EgtTdbGetCurrToolThDiam",
"EgtTdbGetCurrToolMaxDepth",
"EgtTdbGetCurrToolThLength",
"EgtFindToolInCurrSetup",
"EgtTdbGetFirstTool",
"EgtTdbGetNextTool",
"EgtMdbSave",
"EgtMoveRawPart",
"EgtCurveThickness",
"EgtSetCurrMachining"
],
"Lua.diagnostics.disable": [
"empty-block"
+5 -3
View File
@@ -37,7 +37,7 @@ end
-------------------------------------------------------------------------------------------------------------
-- Recupero dati foro
function FeatureData.GetMillingData( Proc)
return Proc
end
@@ -46,16 +46,18 @@ end
function FeatureData.GetProfilingData( Proc)
-- recupero utensili
Proc.nToolsToUse = EgtGetInfo( Proc.id, 'NTOOLS', 'i') or 0
Proc.sEntityName = EgtGetInfo( Proc.id, 'N', 's') or nil
Proc.bHeadProfile = Proc.sEntityName == 'Left' or Proc.sEntityName == 'Right'
Proc.bSideProfile = Proc.sEntityName == 'In' or Proc.sEntityName == 'Out'
Proc.Tools = {}
for t = 1, Proc.nToolsToUse do
local Data = {}
Data.sName = EgtGetInfo( Proc.id, 'TOOL_NAME_' .. tostring(t), 's') or 0
Data.dRadialOffset = EgtGetInfo( Proc.id, 'OFFR_' .. tostring(t), 'd') or 0
Data.dLongitudinalOffset = EgtGetInfo( Proc.id, 'OFFL_' .. tostring(t), 'd') or 0
Data.sSide = EgtGetInfo( Proc.id, 'N', 's') or 0
table.insert( Proc.Tools, Data)
end
Proc.ProfileType = EgtGetInfo( Proc.id, 'ProfileType', 's') or ''
return Proc
end
+14
View File
@@ -32,5 +32,19 @@ function Identity.IsProfiling( Proc)
return Proc.sType == 'Profiling'
end
---------------------------------------------------------------------
----------------------------- PIECES ------------------------------
---------------------------------------------------------------------
function Identity.GetPieceIndexPart( PARTS, idGeom)
local nIndexPart
for i = 1, #PARTS do
if PARTS[i].id == idGeom then
nIndexPart = i
break
end
end
return nIndexPart
end
---------------------------------------------------------------------
return Identity
+22 -2
View File
@@ -9,6 +9,7 @@ require( 'EgtBase')
-- Carico i dati globali
local WinData = require( 'WinData')
local ID = require( 'Identity')
EgtOutLog( ' MachiningLib started', 1)
@@ -125,14 +126,24 @@ function MachiningLib.FindDrill()
end
-------------------------------------------------------------------------------------------------------------
-- funzione per cercare utensile tipo PUNTA A FORARE con certe caratteristiche
-- funzione che ritorna fase di lavoro
function MachiningLib.GetPhaseMach( Proc)
local nPhase
-- se info già calcolata
if Proc.nPhase then
nPhase = Proc.nPhase
-- altrimenti si calcola il comportamento standard
else
if Proc.sEntityName == 'Left' or Proc.sEntityName == 'Out' then
nPhase = 1
end
if Proc.sEntityName == 'Right' or Proc.sEntityName == 'In' then
nPhase = 2
end
end
return nPhase
end
-------------------------------------------------------------------------------------------------------------
-- salva in lista globale la lavorazione appena calcolata
function MachiningLib.AddNewMachining( ProcToAdd, MachiningToAdd, AuxInfoToAdd)
@@ -183,6 +194,7 @@ function MachiningLib.AddOperation( OperationToInsert)
-- creazione lavorazione
local nOperationId = EgtCreateMachining( OperationToInsert.Machining.sOperationName, OperationToInsert.Machining.nType, OperationToInsert.Machining.sToolName)
EgtSetCurrMachining( nOperationId)
if nOperationId then
-- impostazione geometria
@@ -318,13 +330,21 @@ function MachiningLib.AddOperation( OperationToInsert)
end
EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes)
local b3MachEncumbrance = nil
local bIsApplyOk = MachiningLib.ApplyMachining( true, false)
if not bIsApplyOk then
bAreAllMachiningApplyOk = false
nErr, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nOperationId, false)
else
local nClId = EgtGetFirstNameInGroup( nOperationId, 'CL')
local ptMin = EgtGetInfo( nClId, 'MMIN', 'p')
local ptMax = EgtGetInfo( nClId, 'MMAX', 'p')
-- box percorso lavorazione
b3MachEncumbrance = BBox3d( ptMin, ptMax)
end
return bIsApplyOk, sErr
return bIsApplyOk, sErr, b3MachEncumbrance
else
return false, 'UNEXPECTED ERROR: Error on creating machining'
end
+53 -11
View File
@@ -272,6 +272,9 @@ local function GetFeatureInfoAndDependency( vProc, Part)
-- non si controlla la feature con se stessa
if i ~= j then
local ProcB = vProc[j]
-- TODO dipendenze da controllare :
-- * gruppo di forature con aggregato 2/3 uscite
-- * Se 'Left' e 'Out' hanno stesso profilo, vanno concatenati (anche 'Right' se consentito dalle dimensioni)
end
end
end
@@ -281,12 +284,14 @@ end
-------------------------------------------------------------------------------------------------------------
-- Ordina le feature in base a fase di lavorazione
-- L'ordine è indicativamente:
-- 1) Fori
-- 2) Scassi serratura/maniglia
-- 3) Profili testa
-- 4) Profili Lati
-- 5) Incontri/scontri
-- 1) Tagli di testa
-- 2) Fori
-- 3) Scassi serratura/maniglia
-- 4) Profili testa
-- 5) Profili longitudinali
-- 6) Incontri/scontri
-- TODO Ordinamento da fare
local function OrderMachining( MACHININGS)
@@ -375,6 +380,11 @@ local function PrintFeatures( vProc, PARTS)
end
end
-------------------------------------------------------------------------------------------------------------
local function CheckAndMovePawPart( nIdRawToMove, vtMove)
EgtMoveRawPart( nIdRawToMove, vtMove)
end
-------------------------------------------------------------------------------------------------------------
function WinExec.ProcessFeatures( PARTS)
-- ciclo sui pezzi
@@ -387,8 +397,8 @@ function WinExec.ProcessFeatures( PARTS)
for nPart = 1, #PARTS do
-- recupero le feature di lavorazione della trave
vProc = CollectFeatures( vProc, PARTS[nPart])
-- recupero informazioni ausiliarie feature e dipendenze tra feature stesse
-- recupero informazioni ausiliarie feature e dipendenze tra feature dello stesso pezzo
vProc = GetFeatureInfoAndDependency( vProc, PARTS[nPart])
end
@@ -409,17 +419,49 @@ function WinExec.ProcessFeatures( PARTS)
EgtSetCurrPhase( 1)
for i = 1, #MACHININGS do
if MACHININGS[i].AuxInfo.nPhase == 1 then
-- aggiunge effettivamente la lavorazione
MachiningLib.AddOperation( MACHININGS[i])
-- aggiunge effettivamente la lavorazione e restituisce gli ingombri
local bIsApplyOk, sErr, b3MachEncumbrance = MachiningLib.AddOperation( MACHININGS[i]) -- TODO ingombro lavorazione mi restituisce dati sbagliati. C'è un riferimento?
-- se feature di testa, sposto testa in base a ingombro lavorazione
if MACHININGS[i].Proc.bHeadProfile and b3MachEncumbrance then
local nIndexPart = ID.GetPieceIndexPart( PARTS, MACHININGS[i].Proc.idPart)
PARTS[nIndexPart].DispOffsets.Phase1.dOffsetX = b3MachEncumbrance:getMax():getX() - PARTS[nIndexPart].b3FinishedPart:getMin():getX() + 5
end
end
end
-- scrivo lavorazioni prima fase
-- TODO lo spostamento, oltre a controllare le collisioni con il profilo di testa, deve anche considerare il pinzaggio del pezzo nel suo insieme?
-- Es.: basterebbe aggiungere un offset di 50mm per la testa, ma se metto 60mm, posso utilizzare una morsa in più che altrimenti avrei dovuto togliere per una collisione con una svuotatura
-- sposto pezzo per permettere pinzaggio migliore e non aver colisione in testa
for i = 1, #PARTS do
-- TODO Sbaglia a calcolare ingombro!!
--local vtMove = Vector3d( - PARTS[nIndexPart].DispOffsets.Phase1.dOffsetX, - PARTS[nIndexPart].DispOffsets.Phase1.dOffsetY, PARTS[nIndexPart].DispOffsets.Phase1.dOffsetZ)
local vtMove = Vector3d( -60, 0, 0)
if vtMove ~= V_NULL() then
CheckAndMovePawPart( PARTS[i].idRaw, vtMove)
end
end
-- scrivo lavorazioni seconda fase
EgtSetCurrPhase( 2)
for i = 1, #MACHININGS do
if MACHININGS[i].AuxInfo.nPhase == 2 then
-- aggiunge effettivamente la lavorazione
MachiningLib.AddOperation( MACHININGS[i])
local bIsApplyOk, sErr, b3MachEncumbrance = MachiningLib.AddOperation( MACHININGS[i]) -- TODO ingombro lavorazione mi restituisce dati sbagliati. C'è un riferimento?
-- se feature di testa, sposto testa in base a ingombro lavorazione
if MACHININGS[i].Proc.bHeadProfile and b3MachEncumbrance then
local nIndexPart = ID.GetPieceIndexPart( PARTS, MACHININGS[i].Proc.idPart)
PARTS[nIndexPart].DispOffsets.Phase1.dOffsetX = PARTS[nIndexPart].b3FinishedPart:getMax():getX() - b3MachEncumbrance:getMin():getX() + 5
end
end
end
-- sposto pezzo per permettere pinzaggio migliore e non aver colisione in testa
for i = 1, #PARTS do
-- TODO Sbaglia a calcolare ingombro!!
-- local vtMove = Vector3d( PARTS[nIndexPart].DispOffsets.Phase2.dOffsetX, PARTS[nIndexPart].DispOffsets.Phase2.dOffsetY, PARTS[nIndexPart].DispOffsets.Phase2.dOffsetZ)
local vtMove = Vector3d( 60, 0, 0)
if vtMove ~= V_NULL() then
CheckAndMovePawPart( PARTS[i].idRaw, vtMove)
end
end
+29 -37
View File
@@ -43,24 +43,7 @@ _G.package.loaded.WinLib = nil
_G.package.loaded.FeatureData = nil
_G.package.loaded.MachiningLib = nil
-- TODO controllare se c'è un modo migliore per resettare librerie delle strategie caricate precedentemente
-- Per ottimizzare potremmo anche ciclare solo fino al numero di strategie raggiunto per il momento.
-- Infatti difficile ci siano 9999 strategie.
-- reset strategie caricate come librerie
for i = 1, 99 do
local IdSTRTemp = EgtReplaceString( tostring( i/10000, 4), '0.', '')
local sLibraryToReload = "STR" .. IdSTRTemp .. "\\STR" .. IdSTRTemp
local sLibraryConfigToReload = sLibraryToReload .. "Config"
if _G.package.loaded[sLibraryToReload] then
_G.package.loaded[sLibraryToReload] = nil
end
if _G.package.loaded[sLibraryConfigToReload] then
_G.package.loaded[sLibraryConfigToReload] = nil
end
end
local WinExec = require( 'WinExec')
local WinLib = require( 'WinLib')
-- Carico i dati globali
local WinData = require( 'WinData')
@@ -101,7 +84,7 @@ local function MyProcessInputData()
local sOut = ''
for i = 1, #PARTS do
PARTS[i].b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[i].id, 'Solid') or GDB_ID.NULL, GDB_BB.STANDARD)
PARTS[i].b3FinishedPiece = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[i].id, 'Geo') or GDB_ID.NULL, GDB_BB.STANDARD)
PARTS[i].b3FinishedPart = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[i].id, 'Geo') or GDB_ID.NULL, GDB_BB.STANDARD)
local idFrame = EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( PARTS[i].id, 'Geo'), 'AuxFrame') or EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( PARTS[i].id, 'Geo'), 'Frame')
PARTS[i].frame = EgtFR( idFrame)
sOut = sOut .. PARTS[i].sName .. ', '
@@ -124,20 +107,28 @@ local function GetDataConfig()
return true
end
-------------------------------------------------------------------------------------------------------------
local function UpdateRawPosition( PARTS)
for i = 1, #PARTS do
PARTS[i].b3FinishedPart = EgtGetBBoxGlob( PARTS[i].id or GDB_ID.NULL, GDB_BB.STANDARD)
PARTS[i].b3RawPart = EgtGetBBoxGlob( PARTS[i].idRaw or GDB_ID.NULL, GDB_BB.STANDARD)
end
end
-------------------------------------------------------------------------------------------------------------
local function GetDispOffsetFromNotes( nPieceIndex)
local bAllOffsetsAreOk = false
PARTS[nPieceIndex].DispOffset.Phase1.dOffsetX = 0 -- dovrà essere calcolato in base alle lavorazioni
PARTS[nPieceIndex].DispOffset.Phase1.dOffsetY = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFY_1', 'd')
PARTS[nPieceIndex].DispOffset.Phase1.dOffsetZ = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFZ_1', 'd')
PARTS[nPieceIndex].DispOffset.Phase2.dOffsetX = 0 -- dovrà essere calcolato in base alle lavorazioni
PARTS[nPieceIndex].DispOffset.Phase2.dOffsetY = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFY_2', 'd')
PARTS[nPieceIndex].DispOffset.Phase2.dOffsetZ = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFZ_2', 'd')
PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetX = 0 -- dovrà essere calcolato in base alle lavorazioni
PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetY = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFY_1', 'd')
PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetZ = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFZ_1', 'd')
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetX = 0 -- dovrà essere calcolato in base alle lavorazioni
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetY = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFY_2', 'd')
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetZ = EgtGetInfo( PARTS[nPieceIndex].id, 'OFFZ_2', 'd')
-- controllo se tutti gli offset siano settati
if PARTS[nPieceIndex].DispOffset.Phase1.dOffsetY and PARTS[nPieceIndex].DispOffset.Phase1.dOffsetZ and
PARTS[nPieceIndex].DispOffset.Phase2.dOffsetY and PARTS[nPieceIndex].DispOffset.Phase2.dOffsetZ then
if PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetY and PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetZ and
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetY and PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetZ then
bAllOffsetsAreOk = true
end
@@ -147,10 +138,10 @@ end
-------------------------------------------------------------------------------------------------------------
local function GetDispOffsetFromInput( nPieceIndex)
-- assegno alle stringhe i valori letti, in modo che vengano proposti quelli nel dialogo
local sOffYPh1 = EgtIf( PARTS[nPieceIndex].DispOffset.Phase1.dOffsetY, tostring( PARTS[nPieceIndex].DispOffset.Phase1.dOffsetY), tostring( PARTS[nPieceIndex].dPartWidth / 2))
local sOffZPh1 = EgtIf( PARTS[nPieceIndex].DispOffset.Phase1.dOffsetZ, tostring( PARTS[nPieceIndex].DispOffset.Phase1.dOffsetZ), '0')
local sOffYPh2 = EgtIf( PARTS[nPieceIndex].DispOffset.Phase2.dOffsetY, tostring( PARTS[nPieceIndex].DispOffset.Phase2.dOffsetY), tostring( PARTS[nPieceIndex].dPartWidth / 2))
local sOffZPh2 = EgtIf( PARTS[nPieceIndex].DispOffset.Phase2.dOffsetZ, tostring( PARTS[nPieceIndex].DispOffset.Phase2.dOffsetZ), '0')
local sOffYPh1 = EgtIf( PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetY, tostring( PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetY), tostring( PARTS[nPieceIndex].dPartWidth / 2))
local sOffZPh1 = EgtIf( PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetZ, tostring( PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetZ), '0')
local sOffYPh2 = EgtIf( PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetY, tostring( PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetY), tostring( PARTS[nPieceIndex].dPartWidth / 2))
local sOffZPh2 = EgtIf( PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetZ, tostring( PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetZ), '0')
local vInp = EgtDialogBox( 'Dati di disposizione pezzo: ' .. PARTS[nPieceIndex].sName,
{'Sporgenza laterale FASE1', sOffYPh1}, {'Posizione Z FASE1', sOffZPh1},
@@ -160,10 +151,10 @@ local function GetDispOffsetFromInput( nPieceIndex)
end
-- salvo input nei valori che utilizzerò dopo
PARTS[nPieceIndex].DispOffset.Phase1.dOffsetY = tonumber( vInp[1])
PARTS[nPieceIndex].DispOffset.Phase1.dOffsetZ = tonumber( vInp[2])
PARTS[nPieceIndex].DispOffset.Phase2.dOffsetY = tonumber( vInp[3])
PARTS[nPieceIndex].DispOffset.Phase2.dOffsetZ = tonumber( vInp[4])
PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetY = tonumber( vInp[1])
PARTS[nPieceIndex].DispOffsets.Phase1.dOffsetZ = tonumber( vInp[2])
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetY = tonumber( vInp[3])
PARTS[nPieceIndex].DispOffsets.Phase2.dOffsetZ = tonumber( vInp[4])
return true
end
@@ -280,9 +271,9 @@ local function MyProcessPieces()
-- recupero offset per posizionamento
for i = 1, #PARTS do
PARTS[i].DispOffset = {}
PARTS[i].DispOffset.Phase1 = {}
PARTS[i].DispOffset.Phase2 = {}
PARTS[i].DispOffsets = {}
PARTS[i].DispOffsets.Phase1 = {}
PARTS[i].DispOffsets.Phase2 = {}
local bInsertedAllOffs = GetDispOffsetFromNotes( i)
-- se non sono settati nelle note, li chiedo
@@ -297,6 +288,7 @@ local function MyProcessPieces()
-- si dispongono i pezzi sulla tavola
WinData.ExecDisposition( PARTS)
UpdateRawPosition( PARTS)
-- Impostazione dell'attrezzaggio di default
-- TODO se lascio il campo vuoto non mi carica il default!!!!!!!