diff --git a/LuaLibs/ProcessProfCamb.lua b/LuaLibs/ProcessProfCamb.lua index 2bca9b7..6a23606 100644 --- a/LuaLibs/ProcessProfCamb.lua +++ b/LuaLibs/ProcessProfCamb.lua @@ -1,4 +1,4 @@ --- ProcessProfCamb.lua by Egaltech s.r.l. 2019/04/01 +-- ProcessProfCamb.lua by Egaltech s.r.l. 2019/04/08 -- Gestione calcolo profilo caudato per Travi -- Tabella per definizione modulo @@ -87,7 +87,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) return false, sErr end -- recupero i dati della curva e del profilo - local dDepth = abs( EgtCurveThickness( AuxId)) + local dProfDepth = abs( EgtCurveThickness( AuxId)) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) local nLastFacet = EgtSurfTmFacetCount( Proc.Id) - 1 -- ultima faccia local nRefFacet = nLastFacet - 1 -- penultima faccia @@ -129,6 +129,17 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtOutLog( sErr) return false, sErr end + -- Recupero i dati dell'utensile + local dToolMaxDepth = 0 + if EgtMdbSetCurrMachining( sMilling) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dToolMaxDepth = EgtTdbGetCurrToolMaxDepth() + end + end + -- verifico se necessario lavorare in doppio + local bDouble = ( nSide ~= 0 and dProfDepth > dToolMaxDepth) + local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP) -- inserisco la lavorazione local sName = 'Prof_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchId = EgtAddMachining( sName, sMilling) @@ -139,8 +150,8 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) - -- se lavorazione da sopra - if vtN:getZ() > 0.1 then + -- se lavorazione da sopra o da sotto + if nSide ~= 0 then -- se lavorazione a destra di fronte o sinistra da dietro, inverto if ( vtNF:getX() > 0 and vtExtr:getY() < -0.1) or ( vtNF:getX() < 0 and vtExtr:getY() > 0.1) then @@ -161,6 +172,10 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.INVERT, true) end end + -- se in doppio, imposto l'affondamento + if bDouble then + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + end -- posizione braccio porta testa EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) -- eseguo @@ -169,6 +184,36 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetOperationMode( nMchId, false) return false, sErr end + -- se lavorazione da due parti, aggiungo la seconda + if bDouble then + -- inserisco la lavorazione + local sName = 'ProfB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchId = EgtAddMachining( sName, sMilling) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ AuxId, -1}}) + -- sempre lavorazione da sopra o da sotto + -- se lavorazione a destra di fronte o sinistra da dietro, inverto + if ( vtNF:getX() > 0 and vtExtr:getY() > 0.1) or + ( vtNF:getX() < 0 and vtExtr:getY() < -0.1) then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) + end + -- imposto l'affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + -- posizione braccio porta testa + EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + end -- se non da sotto, inserisco lavorazione finitura angolo if nSide ~= -1 then sName = 'ProfV_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) diff --git a/LuaLibs/ProcessProfConcave.lua b/LuaLibs/ProcessProfConcave.lua index e342d5b..03dbb7c 100644 --- a/LuaLibs/ProcessProfConcave.lua +++ b/LuaLibs/ProcessProfConcave.lua @@ -71,7 +71,7 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) local nFirstFacet = 0 -- faccia iniziale local nLastFacet = EgtSurfTmFacetCount( Proc.Id) - 1 -- faccia finale - local nMidFacet = ( nLastFacet + 1) / 2 -- faccia a metà circa + local nMidFacet = ( nLastFacet + 1) // 2 -- faccia a metà circa local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nMidFacet, GDB_ID.ROOT) -- verifico se in testa o coda local bHead = ( vtN:getX() > 0) @@ -123,7 +123,7 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end -- verifico se necessario lavorare in doppio local bDouble = ( nSide ~= 0 and dProfDepth > dToolMaxDepth) - local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP ) + local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP) -- inserisco la lavorazione local sName = 'Prof_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchId = EgtAddMachining( sName, sMilling) @@ -183,22 +183,12 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) - -- se lavorazione da sopra o da sotto - if nSide ~= 0 then - -- se lavorazione a destra di fronte o sinistra da dietro, inverto - if ( vtN:getX() > 0 and vtExtr:getY() > 0.1) or - ( vtN:getX() < 0 and vtExtr:getY() < -0.1) then - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - EgtSetMachiningParam( MCH_MP.INVERT, true) - end - -- altrimenti lavorazione da sotto - else - -- se lavorazione a destra da dietro o sinistra di fronte, inverto - if ( vtN:getX() > 0 and vtN:getY() > 0.1) or - ( vtN:getX() < 0 and vtN:getY() < -0.1) then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - EgtSetMachiningParam( MCH_MP.INVERT, true) - end + -- sempre lavorazione da sopra o da sotto + -- se lavorazione a destra di fronte o sinistra da dietro, inverto + if ( vtN:getX() > 0 and vtExtr:getY() > 0.1) or + ( vtN:getX() < 0 and vtExtr:getY() < -0.1) then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) end -- imposto l'affondamento EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) diff --git a/LuaLibs/ProcessProfConvex.lua b/LuaLibs/ProcessProfConvex.lua index 2e5c7fa..a41f47d 100644 --- a/LuaLibs/ProcessProfConvex.lua +++ b/LuaLibs/ProcessProfConvex.lua @@ -71,7 +71,7 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) local nFirstFacet = 0 -- faccia iniziale local nLastFacet = EgtSurfTmFacetCount( Proc.Id) - 1 -- faccia finale - local nMidFacet = ( nLastFacet + 1) / 2 -- faccia a metà circa + local nMidFacet = ( nLastFacet + 1) // 2 -- faccia a metà circa local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nMidFacet, GDB_ID.ROOT) -- verifico se in testa o coda local bHead = ( vtN:getX() > 0) @@ -123,7 +123,7 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end -- verifico se necessario lavorare in doppio local bDouble = ( nSide ~= 0 and dProfDepth > dToolMaxDepth) - local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP ) + local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP) -- inserisco la lavorazione local sName = 'Prof_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchId = EgtAddMachining( sName, sMilling) @@ -183,22 +183,12 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) - -- se lavorazione da sopra o da sotto - if nSide ~= 0 then - -- se lavorazione a destra di fronte o sinistra da dietro, inverto - if ( vtN:getX() > 0 and vtExtr:getY() > 0.1) or - ( vtN:getX() < 0 and vtExtr:getY() < -0.1) then - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - EgtSetMachiningParam( MCH_MP.INVERT, true) - end - -- altrimenti lavorazione da sotto - else - -- se lavorazione a destra da dietro o sinistra di fronte, inverto - if ( vtN:getX() > 0 and vtN:getY() > 0.1) or - ( vtN:getX() < 0 and vtN:getY() < -0.1) then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - EgtSetMachiningParam( MCH_MP.INVERT, true) - end + -- sempre lavorazione da sopra o da sotto + -- se lavorazione a destra di fronte o sinistra da dietro, inverto + if ( vtN:getX() > 0 and vtExtr:getY() > 0.1) or + ( vtN:getX() < 0 and vtExtr:getY() < -0.1) then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) end -- imposto l'affondamento EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)