From 570e41a40d39e2e95ab4e0613d1382fb1fa4021d Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Tue, 23 Dec 2025 16:42:04 +0100 Subject: [PATCH] =?UTF-8?q?-=20In=20ShortestPathSorting=20si=20settano=20o?= =?UTF-8?q?ra=20inizio=20e=20fine=20di=20ogni=20gruppo=20per=20ordine=20la?= =?UTF-8?q?vorazioni=20-=20In=20STR0010=20in=20caso=20che=20la=20strategia?= =?UTF-8?q?=20sia=20stata=20forzata=20da=20utente,=20non=20viene=20bocciat?= =?UTF-8?q?a=20a=20causa=20della=20sua=20posizione/forma.=20Se=20forzata?= =?UTF-8?q?=20il=20cliente=20si=20=C3=A8=20preso=20al=20responsabilit?= =?UTF-8?q?=C3=A0=20della=20sua=20scelta=20ed=20=C3=A8=20giusto=20che=20ve?= =?UTF-8?q?nga=20provata.=20Al=20massimo=20si=20avranno=20errori=20di=20ex?= =?UTF-8?q?tra-corsa=20o=20colisioni.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/MachiningLib.lua | 47 ++++++++++++++++++++++--- Strategies/Standard/STR0010/STR0010.lua | 20 +++++++---- 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 25124bf..5747f6b 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -1694,15 +1694,12 @@ end ------------------------------------------------------------------------------------------------------------- function MachiningLib.ShortestPathSorting() - -- verificare se serve settare prima e ultima lavorazione - -- EgtOptMachSetFirstMachining( int nId) - -- EgtOptMachSetLastMachining( int nId) - local nStartIndex local i = 1 while i <= #DB_MACH_APPLIED do local nMachInDisp = 0 local MachiningOptList = {} + local GroupInfo = {} -- se è una lavorazione if DB_MACH_APPLIED[i].sType ~= 'DISP' then @@ -1715,9 +1712,11 @@ function MachiningLib.ShortestPathSorting() -- tra gruppi (stage) non si può ottimizzare EgtOptMachSetAllGroupsDependencesAsMandatory( true) + EgtOptMachSetOptimizationForGroups( true) -- se è una lavorazione while DB_MACH_APPLIED[i] and DB_MACH_APPLIED[i].sType ~= 'DISP' do + local ptMinX, ptMaxX -- aggiungo lavorazioni local nToolIndex = MACHININGS[DB_MACH_APPLIED[i].nIndexInMachinings].Machining.nToolIndex EgtOptMachAddTool( nToolIndex, 2, 2) -- , [ num dTC_X, num dTC_Y, num dTC_Z, num dTC_A, num dTC_B, num dTC_C]) @@ -1729,6 +1728,29 @@ function MachiningLib.ShortestPathSorting() EgtOptMachAddMachining( i, nToolIndex, nGroup, MachStartAxesPos, MachEndAxesPos) table.insert( MachiningOptList, i) + -- si salvano i punti minimi e massimi tra tutte le lavorazioni di ogni gruppo + if MachStartAxesPos[1] < MachEndAxesPos[1] then + ptMinX = MachStartAxesPos + ptMaxX = MachEndAxesPos + else + ptMinX = MachEndAxesPos + ptMaxX = MachStartAxesPos + end + + -- si aggiungono le info di gruppo + local bFound = false + for t = 1, #GroupInfo do + if GroupInfo[t].nGroup == nGroup then + if GroupInfo[t].ptMin[1] > ptMinX[1] then GroupInfo[t].ptMin = ptMinX end + if GroupInfo[t].ptMax[1] < ptMaxX[1] then GroupInfo[t].ptMax = ptMaxX end + bFound = true + end + end + -- se non ho trovato, si aggiunge in lista + if not bFound then + table.insert( GroupInfo, { nGroup = nGroup, nStage = MACHININGS[DB_MACH_APPLIED[i].nIndexInMachinings].Machining.nStage, ptMin = ptMinX, ptMax = ptMaxX}) + end + nMachInDisp = nMachInDisp + 1 i = i + 1 end @@ -1754,6 +1776,23 @@ function MachiningLib.ShortestPathSorting() end end + -- definisco gruppo per gruppo la direzione preferita di ottimizzazione + for t = 1, #GroupInfo do + -- se gruppo "Taglio di coda" l'ordinamento è al contrario + if GroupInfo[t].nStage == 3 then + -- start point + EgtOptMachSetOpenBoundForGroups( GroupInfo[t].nGroup, true, SHP_OB.NEAR_PNT, GroupInfo[t].ptMin[1], GroupInfo[t].ptMin[2], GroupInfo[t].ptMin[3]) + -- end point + EgtOptMachSetOpenBoundForGroups( GroupInfo[t].nGroup, false, SHP_OB.NEAR_PNT, GroupInfo[t].ptMax[1], GroupInfo[t].ptMax[2], GroupInfo[t].ptMax[3]) + -- in tutti gli altri gruppi si ordina sempre dalla testa alla coda + else + -- start point + EgtOptMachSetOpenBoundForGroups( GroupInfo[t].nGroup, true, SHP_OB.NEAR_PNT, GroupInfo[t].ptMax[1], GroupInfo[t].ptMax[2], GroupInfo[t].ptMax[3]) + -- end point + EgtOptMachSetOpenBoundForGroups( GroupInfo[t].nGroup, false, SHP_OB.NEAR_PNT, GroupInfo[t].ptMin[1], GroupInfo[t].ptMin[2], GroupInfo[t].ptMin[3]) + end + end + -- calcolo ordine lavorazioni MachiningOptList = EgtOptMachCalculate( MachiningOptList) diff --git a/Strategies/Standard/STR0010/STR0010.lua b/Strategies/Standard/STR0010/STR0010.lua index 4f6b767..eda3fcb 100644 --- a/Strategies/Standard/STR0010/STR0010.lua +++ b/Strategies/Standard/STR0010/STR0010.lua @@ -83,7 +83,8 @@ end ------------------------------------------------------------------------------------------------------------- local function IsTopologyOk( Proc) if Proc.Topology.sFamily == 'Bevel' or Proc.Topology.sFamily == 'DoubleBevel' or - Proc.Topology.sName == 'VGroove-2-Through' or Proc.Topology.sName == 'Rabbet-2-Through' then + Proc.Topology.sName == 'VGroove-2-Through' or Proc.Topology.sName == 'Rabbet-2-Through' or + Proc.Topology.sName == 'Cut-1-Through' then return true else return false @@ -178,10 +179,12 @@ function STR0010.Make( bAddMachining, Proc, Part, CustomParameters) return false, Strategy.Result end - -- controllo dimensioni - if not IsPositionOK( Proc, Part) then - Strategy.Result = FeatureLib.GetStrategyResultNotApplicable( 'Feature not machinable in this position') - return false, Strategy.Result + -- controllo dimensioni solo se non è forzata + if not CustomParameters.bForcedStrategy then + if not IsPositionOK( Proc, Part) then + Strategy.Result = FeatureLib.GetStrategyResultNotApplicable( 'Feature not machinable in this position') + return false, Strategy.Result + end end -- volume della feature @@ -253,7 +256,12 @@ function STR0010.Make( bAddMachining, Proc, Part, CustomParameters) if bAddMachining and Strategy.Result.sStatus ~= 'Not-Applicable' then -- aggiunge lavorazione for j = 1, #Strategy.Machinings do - bAreAllMachiningsAdded = MachiningLib.AddMachinings( Proc, Strategy.Machinings[j]) + local AuxiliaryData = {} + -- se strategia forzata non considero area non pinzabile + if CustomParameters.bForcedStrategy then + AuxiliaryData.bIgnoreNotClampableLength = true + end + bAreAllMachiningsAdded = MachiningLib.AddMachinings( Proc, Strategy.Machinings[j], AuxiliaryData) end end else