DataWall :
- aggiunta ottimizzazione pe rutensile su fresature - corretti errori con fori inclinati
This commit is contained in:
+118
-37
@@ -351,31 +351,7 @@ local function MoveMachiningsAtEnd( nPhase, nType, sStartName, sProperty)
|
||||
end
|
||||
|
||||
------ Ordinamento dei tagli, delle fresature e delle forature -------
|
||||
local function SortMach( nPhase, PrevMch, nPartId, nType, sStartName, bExistName, sInfo, bExistInfo, bOneWay)
|
||||
-- dichiarazione tabella
|
||||
local TabCut = {}
|
||||
-- Recupero gli identificativi delle lavorazioni e annullo eventuali allungamenti e Id di altre lavorazioni rappresentate
|
||||
local nOperId = EgtGetNextOperation( PrevMch)
|
||||
while nOperId do
|
||||
-- Se appartiene alla fase corrente e taglio con lama non da sopra (sempre su 1 sola entità)
|
||||
if EgtGetOperationPhase( nOperId) == nPhase and EgtGetOperationType( nOperId) == nType and
|
||||
( not nPartId or EgtGetInfo( nOperId, 'Part', 'i') == nPartId) and
|
||||
( not sStartName or ( bExistName and string.sub( EgtGetName( nOperId), 1, #sStartName) == sStartName) or
|
||||
( not bExistName and string.sub( EgtGetName( nOperId), 1, #sStartName) ~= sStartName)) and
|
||||
( not sInfo or ( bExistInfo and EgtGetInfo( nOperId, sInfo, 'i') == 1) or
|
||||
( not bExistInfo and EgtGetInfo( nOperId, sInfo, 'i') ~= 1)) then
|
||||
-- non si deve cambiare lo stato di attivazione della lavorazione (se disabilitata errata)
|
||||
EgtSetCurrMachining( nOperId)
|
||||
if not EgtIsMachiningEmpty() then
|
||||
-- punto iniziale e finale e direzione della lavorazione
|
||||
local ptStart = EgtGetMachiningStartPoint()
|
||||
local ptEnd = EgtGetMachiningEndPoint()
|
||||
table.insert( TabCut, {Mch=nOperId, Ent=nEntId, Start=ptStart, End=ptEnd})
|
||||
end
|
||||
end
|
||||
-- Passo alla operazione successiva
|
||||
nOperId = EgtGetNextOperation( nOperId)
|
||||
end
|
||||
local function SpSorting( TabCut, PrevMch, nType, bOneWay)
|
||||
|
||||
-- ordino le lavorazioni (in gruppi di max 1000 entità se 32bit 10000 se 64bit)
|
||||
--EgtOutLog('Dati per ShortestPath :')
|
||||
@@ -392,7 +368,7 @@ local function SortMach( nPhase, PrevMch, nPartId, nType, sStartName, bExistName
|
||||
end
|
||||
EgtSpSetAngularParams( 1000, 40, 2000, 60)
|
||||
EgtSpSetOpenBound( true, SHP_OB.NEAR_PNT, 50000, 0, 0, 0, 0)
|
||||
if WD.BEAM_MACHINE and nType == MCH_OY.SAWING then
|
||||
if WD.BEAM_MACHINE and (nType & MCH_OY.SAWING) == MCH_OY.SAWING then
|
||||
EgtSpSetOpenBound( false, SHP_OB.NEAR_PNT, -50000, 0, 0, 0, 0)
|
||||
end
|
||||
EgtSpSetZzOwStep( 10)
|
||||
@@ -413,31 +389,136 @@ local function SortMach( nPhase, PrevMch, nPartId, nType, sStartName, bExistName
|
||||
return PrevMch
|
||||
end
|
||||
|
||||
local function ContainsStartName( nOperId, StartNames)
|
||||
local bFound = false
|
||||
for i = 1, #StartNames do
|
||||
local sStartName = StartNames[i]
|
||||
if string.sub( EgtGetName( nOperId), 1, #sStartName) == sStartName then
|
||||
bFound = true
|
||||
end
|
||||
end
|
||||
return bFound
|
||||
end
|
||||
|
||||
------ Ordinamento dei tagli, delle fresature e delle forature -------
|
||||
local function SortMach( nPhase, PrevMch, nPartId, nType, StartNames, bExistName, sInfo, bExistInfo, bOneWay, bByTool)
|
||||
-- dichiarazione tabella
|
||||
local TabCut = {}
|
||||
-- Recupero gli identificativi delle lavorazioni e annullo eventuali allungamenti e Id di altre lavorazioni rappresentate
|
||||
local nOperId = EgtGetNextOperation( PrevMch)
|
||||
while nOperId do
|
||||
local nOperType = EgtGetOperationType( nOperId)
|
||||
-- Se appartiene alla fase corrente e taglio con lama non da sopra (sempre su 1 sola entità)
|
||||
if EgtGetOperationPhase( nOperId) == nPhase and ( nType & nOperType) == nOperType and
|
||||
( not nPartId or EgtGetInfo( nOperId, 'Part', 'i') == nPartId) and
|
||||
( not StartNames or ( bExistName and ContainsStartName( nOperId, StartNames)) or
|
||||
( not bExistName and not ContainsStartName( nOperId, StartNames))) and
|
||||
( not sInfo or ( bExistInfo and EgtGetInfo( nOperId, sInfo, 'i') == 1) or
|
||||
( not bExistInfo and EgtGetInfo( nOperId, sInfo, 'i') ~= 1)) then
|
||||
-- non si deve cambiare lo stato di attivazione della lavorazione (se disabilitata errata)
|
||||
EgtSetCurrMachining( nOperId)
|
||||
if not EgtIsMachiningEmpty() then
|
||||
-- punto iniziale e finale e direzione della lavorazione
|
||||
local ptStart = EgtGetMachiningStartPoint()
|
||||
local ptEnd = EgtGetMachiningEndPoint()
|
||||
local sTUUID = ''
|
||||
local nToolType = 0
|
||||
local nToolDiam = 0
|
||||
if bByTool then
|
||||
sTUUID = EgtGetMachiningParam( MCH_MP.TUUID)
|
||||
local sToolName = EgtTdbGetToolFromUUID( sTUUID)
|
||||
if EgtTdbSetCurrTool( sToolName) then
|
||||
nToolType = EgtTdbGetCurrToolParam( MCH_TP.TYPE)
|
||||
nToolDiam = EgtTdbGetCurrToolParam( MCH_TP.TOTDIAM)
|
||||
else
|
||||
sTUUID = ''
|
||||
end
|
||||
end
|
||||
table.insert( TabCut, {Mch=nOperId, Ent=nEntId, Start=ptStart, End=ptEnd, Tool=sTUUID, ToolType=nToolType, ToolDiam=nToolDiam})
|
||||
end
|
||||
end
|
||||
-- Passo alla operazione successiva
|
||||
nOperId = EgtGetNextOperation( nOperId)
|
||||
end
|
||||
|
||||
if bByTool then
|
||||
function ToolCompare(a,b)
|
||||
local y = a.ToolType < b.ToolType and a.ToolDiam > b.ToolDiam and a.Tool < b.Tool
|
||||
if a.ToolType < b.ToolType then
|
||||
return true
|
||||
elseif a.ToolType == b.ToolType then
|
||||
if a.ToolDiam > b.ToolDiam then
|
||||
return true
|
||||
elseif a.ToolDiam == b.ToolDiam then
|
||||
if a.Tool < b.Tool then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
-- return a.ToolType < b.ToolType and a.ToolDiam > b.ToolDiam and a.Tool < b.Tool
|
||||
end
|
||||
table.sort(TabCut, ToolCompare)
|
||||
-- table.sort(TabCut, function(a,b) return a.ToolType < b.ToolType and a.ToolDiam > b.ToolDiam and a.Tool < b.Tool end)
|
||||
local SupportTabCut = {}
|
||||
local nPrevTUUID = 0
|
||||
for i = 1, #TabCut do
|
||||
-- se tuuid uguale al precedente, lo aggiungo alla lista
|
||||
if nPrevTUUID == TabCut[i].Tool then
|
||||
table.insert( SupportTabCut, TabCut[i])
|
||||
-- se tuuid diverso,
|
||||
else
|
||||
-- faccio calcolare la lista
|
||||
PrevMch = SpSorting( SupportTabCut, PrevMch, nType, bOneWay)
|
||||
-- cancello la lista e aggiorno tuuid corrente
|
||||
SupportTabCut = {}
|
||||
nPrevTUUID = TabCut[i].Tool
|
||||
table.insert( SupportTabCut, TabCut[i])
|
||||
end
|
||||
end
|
||||
-- calcolo ultima lista
|
||||
if #SupportTabCut > 0 then
|
||||
PrevMch = SpSorting( SupportTabCut, PrevMch, nType, bOneWay)
|
||||
end
|
||||
else
|
||||
PrevMch = SpSorting( TabCut, PrevMch, nType, bOneWay)
|
||||
end
|
||||
|
||||
return PrevMch
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function SortMachinings( nPhase, PrevMch, nPartId)
|
||||
-- Chiodature
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, 'Nail_', true)
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, { 'Nail_'}, true)
|
||||
-- Tagli con sega a catena che sono rifiniture di spigoli
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MORTISING, 'Csaw_', false)
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MORTISING, { 'Csaw_'}, false)
|
||||
-- Forature orizzontali con punte lunghe
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.DRILLING, 'LhDrill_', true, 'MOVE_AFTER', false, true)
|
||||
-- Forature
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.DRILLING, nil, nil, 'MOVE_AFTER', false)
|
||||
-- Svuotature
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.POCKETING, nil, nil, 'MOVE_AFTER', false)
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.DRILLING, { 'LhDrill_'}, true, 'MOVE_AFTER', false, true)
|
||||
-- Forature e Svuotature
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.DRILLING + MCH_OY.POCKETING + MCH_OY.MILLING, { 'SideMill_', 'Clean_'}, false, 'MOVE_AFTER', false, false, true)
|
||||
-- -- Forature ***
|
||||
-- PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.DRILLING, nil, nil, 'MOVE_AFTER', false)
|
||||
-- -- Svuotature ***
|
||||
-- PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.POCKETING, nil, nil, 'MOVE_AFTER', false)
|
||||
-- -- Fresature che sono rifiniture di spigoli
|
||||
-- PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, { 'Clean_'}, false, 'MOVE_AFTER', false, false, true)
|
||||
-- Lavorazioni di superficie
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_MY.SURFFINISHING, nil, nil, 'MOVE_AFTER', false)
|
||||
-- Fresature per gole
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, 'Gorge_', true, 'MOVE_AFTER', false)
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, { 'Gorge_'}, true, 'MOVE_AFTER', false)
|
||||
-- Fresature che sono rifiniture di spigoli
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, 'Clean_', false, 'MOVE_AFTER', false)
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, { 'SideMill_'}, true, 'MOVE_AFTER', false, false, true)
|
||||
-- Fresature che sono puliture di spigoli
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, 'Clean_', true, 'MOVE_AFTER', false)
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, { 'Clean_'}, true, 'MOVE_AFTER', false)
|
||||
-- Tagli con lama
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.SAWING)
|
||||
-- Qui rimozione sfridi (se ci sono lavorazioni successive)
|
||||
-- Tagli con sega a catena che vanno fatti dopo i tagli con lama
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MORTISING, 'Csaw_', true)
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MORTISING, { 'Csaw_'}, true)
|
||||
-- Fresature (puliture di spigoli) che vanno fatte dopo i tagli con lama
|
||||
PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, nil, nil, 'MOVE_AFTER', true)
|
||||
-- Forature che vanno fatte dopo i tagli con lama
|
||||
|
||||
Reference in New Issue
Block a user