From c2fe11a9108bd6df257bee72a4e5980d1dd0c539 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Fri, 26 Jun 2026 10:23:49 +0200 Subject: [PATCH] Piccole correzioni in simulazione per scarico motosega --- Common_ONE-PF.mlpe | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Common_ONE-PF.mlpe b/Common_ONE-PF.mlpe index 7d13c27..7131f65 100644 --- a/Common_ONE-PF.mlpe +++ b/Common_ONE-PF.mlpe @@ -616,8 +616,8 @@ function OnSimulToolDeselect( dPrevA) -- nascondo l'utensile sulla testa EgtSetMode( EgtGetHeadId( EMT.PREVHEAD_H1 or '') or GDB_ID.NULL, GDB_MD.HIDDEN) -- se non è chiamata per cambio angolo di presa della sega a catena - if not dPrevA then - local sTool, sHead, sTcPos = FindNextToolOnHeadSet( 1, false) + local sTool, sHead, sTcPos = FindNextToolOnHeadSet( 1, false) + if not dPrevA or not sTool then -- imposto correttamente i dati di testa local OrigEMC = EMC EMC = { HEAD = sHead, TOOL = sTool, TCPOS = sTcPos, TOTDIAM = 0} @@ -643,13 +643,13 @@ function OnSimulToolDeselect( dPrevA) -- nascondo l'utensile sulla testa EgtSetMode( EgtGetHeadId( EMT.PREVHEAD_H2 or '') or GDB_ID.NULL, GDB_MD.HIDDEN) -- se non è chiamata per cambio angolo di presa della sega a catena - if not dPrevA then + local sTool, sHead, sTcPos = FindNextToolOnHeadSet( 2, false) + if not dPrevA or not sTool then -- cambio utensile EgtSetAxisPos( 'C2', ParkC2) EgtSetAxisPos( 'B2', ParkB2) EgtSetAxisPos( 'Z2', MaxZ2) SimulMoveAxis( 'X2', ParkX2, MCH_SIM_STEP.RAPID) - local sTool, sHead, sTcPos = FindNextToolOnHeadSet( 2, false) local OrigEMC = EMC EMC = { HEAD = sHead or 'H21', TOOL = sTool, TCPOS = sTcPos, TOTDIAM = 0} OnSetHead() @@ -662,9 +662,7 @@ function OnSimulToolDeselect( dPrevA) end -- se utensile non cambia e non è sega a catena, esco - - -- if ( EMT.NEXTTOOL == EMT.PREVTOOL_H1 or EMT.NEXTTOOL == EMT.PREVTOOL_H2 or EMT.NEXTHEAD ~= EMT.HEAD) and not HeadIsChainSaw( EMT.NEXTHEAD) then return end - if ( EMT.NEXTTOOL == EMT.PREVTOOL_H1 or EMT.NEXTTOOL == EMT.PREVTOOL_H2) then return end + if ( EMT.NEXTTOOL == EMT.PREVTOOL_H1 or EMT.NEXTTOOL == EMT.PREVTOOL_H2) and not HeadIsChainSaw( EMT.NEXTHEAD) then return end -- deposito utensile EgtOutText( 'Tool change in progress...') -- se prossimo utensile sega a catena, devo mettere in home testa 1 e depositare l'utensile sulla testa 2 o viceversa @@ -680,13 +678,12 @@ function OnSimulToolDeselect( dPrevA) 'B2', EgtGetAxisHomePos( 'B2'), MCH_SIM_STEP.COLLROT, 'C2', EgtGetAxisHomePos( 'C2'), MCH_SIM_STEP.COLLROT) end - local dNextHeadSet = GetHeadSet( EMT.NEXTHEAD) - if dNextHeadSet == 1 then + if dHeadSet == 1 then -- visualizzo utensile su TcPos ShowToolInTcPos( EMT.PREVTCPOS_H1, true) -- nascondo l'utensile sulla testa EgtSetMode( EgtGetHeadId( EMT.PREVHEAD_H1 or '') or GDB_ID.NULL, GDB_MD.HIDDEN) - elseif dNextHeadSet == 2 then + else -- visualizzo utensile su TcPos ShowToolInTcPos( EMT.PREVTCPOS_H2, true) -- nascondo l'utensile sulla testa