diff --git a/LuaLibs/ProcessProfCamb.lua b/LuaLibs/ProcessProfCamb.lua index 6a23606..6f01d8e 100644 --- a/LuaLibs/ProcessProfCamb.lua +++ b/LuaLibs/ProcessProfCamb.lua @@ -1,4 +1,4 @@ --- ProcessProfCamb.lua by Egaltech s.r.l. 2019/04/08 +-- ProcessProfCamb.lua by Egaltech s.r.l. 2019/04/10 -- Gestione calcolo profilo caudato per Travi -- Tabella per definizione modulo @@ -153,8 +153,8 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- 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 + if ( bHead and vtExtr:getY() < -0.1) or + ( not bHead and vtExtr:getY() > 0.1) then EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) EgtSetMachiningParam( MCH_MP.INVERT, true) end @@ -166,8 +166,8 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.INVERT, true) end -- se lavorazione a destra da dietro o sinistra di fronte, inverto - if ( vtNF:getX() > 0 and vtNF:getY() > 0.1) or - ( vtNF:getX() < 0 and vtNF:getY() < -0.1) then + if ( bHead and vtNF:getY() > 0.1) or + ( not bHead and vtNF:getY() < -0.1) then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) EgtSetMachiningParam( MCH_MP.INVERT, true) end @@ -198,8 +198,8 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) 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 + if ( bHead and vtExtr:getY() > 0.1) or + ( not bHead and vtExtr:getY() < -0.1) then EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) EgtSetMachiningParam( MCH_MP.INVERT, true) end diff --git a/LuaLibs/ProcessProfConcave.lua b/LuaLibs/ProcessProfConcave.lua index 03dbb7c..a95315a 100644 --- a/LuaLibs/ProcessProfConcave.lua +++ b/LuaLibs/ProcessProfConcave.lua @@ -137,8 +137,8 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- 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 + if ( bHead and vtExtr:getY() < -0.1) or + ( not bHead and vtExtr:getY() > 0.1) then EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) EgtSetMachiningParam( MCH_MP.INVERT, true) end @@ -185,8 +185,8 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningGeometry( {{ AuxId, -1}}) -- 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 + if ( bHead and vtExtr:getY() > 0.1) or + ( not bHead and vtExtr:getY() < -0.1) then EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) EgtSetMachiningParam( MCH_MP.INVERT, true) end diff --git a/LuaLibs/ProcessProfConvex.lua b/LuaLibs/ProcessProfConvex.lua index a41f47d..69e0fee 100644 --- a/LuaLibs/ProcessProfConvex.lua +++ b/LuaLibs/ProcessProfConvex.lua @@ -137,8 +137,8 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- 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 + if ( bHead and vtExtr:getY() < -0.1) or + ( not bHead and vtExtr:getY() > 0.1) then EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) EgtSetMachiningParam( MCH_MP.INVERT, true) end @@ -185,8 +185,8 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningGeometry( {{ AuxId, -1}}) -- 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 + if ( bHead and vtExtr:getY() > 0.1) or + ( not bHead and vtExtr:getY() < -0.1) then EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) EgtSetMachiningParam( MCH_MP.INVERT, true) end diff --git a/LuaLibs/ProcessProfFront.lua b/LuaLibs/ProcessProfFront.lua index f0984e0..fc596d6 100644 --- a/LuaLibs/ProcessProfFront.lua +++ b/LuaLibs/ProcessProfFront.lua @@ -1,4 +1,4 @@ --- ProcessProfFront.lua by Egaltech s.r.l. 2019/04/01 +-- ProcessProfFront.lua by Egaltech s.r.l. 2019/04/10 -- Gestione calcolo profilo caudato per Travi -- Tabella per definizione modulo @@ -34,41 +34,12 @@ end --------------------------------------------------------------------- local function GetSawCutData( AuxId, vtN) - -- comincio con la normale a 45deg local vtNP = Vector3d( vtN) - for i = 1, 3 do - if vtNP[i] > GEO.EPS_SMALL then - vtNP[i] = 1 - elseif vtNP[i] < -GEO.EPS_SMALL then - vtNP[i] = -1 - end - end - vtNP:normalize() -- assegno un punto di passaggio - local ptStart = EgtSP( AuxId, GDB_ID.ROOT) + vtNP * 5.0 - -- determino asse di rotazione - local vtRot = - Y_AX() - if vtN:getX() < 0 then vtRot = - vtRot end - if vtN:getZ() < -0.1 then - vtRot = - vtRot - elseif vtN:getY() < -0.1 then - vtRot:rotate( X_AX(), 90) - elseif vtN:getY() > 0.1 then - vtRot:rotate( X_AX(), -90) - end - -- miglioro l'inclinazione (ripartendo da faccia perpendicolare asse trave) - vtNP[2] = 0 vtNP[3] = 0 - local dRot = 45 - for i = 1, 4 do - local vtNP2 = Vector3d( vtNP) - vtNP2:rotate( vtRot, dRot) - local frRef = Frame3d( ptStart, vtNP2) - local b3Box = EgtGetBBoxRef( AuxId, GDB_BB.STANDARD, frRef) - if b3Box:getMax():getZ() < -3 then - vtNP = Vector3d( vtNP2) - end - dRot = dRot / 2 - end + local ptStart = EgtMP( AuxId, GDB_ID.ROOT) + local frOCS = Frame3d( ptStart, vtNP) ; + local b3Box = EgtGetBBoxRef( AuxId, GDB_BB.STANDARD, frOCS) + ptStart = ptStart + vtNP * ( b3Box:getMax():getZ() + 10.0) -- restituisco i dati del piano return ptStart, vtNP end @@ -87,7 +58,7 @@ function ProcessProfFront.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 @@ -131,6 +102,17 @@ function ProcessProfFront.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) @@ -141,8 +123,8 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) - -- se lavorazione da sopra - if nSide == 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 ( bHead and vtExtr:getY() < -0.1) or ( not bHead and vtExtr:getY() > 0.1) then @@ -157,12 +139,16 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.INVERT, true) end -- se lavorazione a destra da dietro o sinistra di fronte, inverto - if ( bHead and vtExtr:getY() > 0.1) or - ( not bHead and vtExtr:getY() < -0.1) then + if ( bHead and vtN:getY() > 0.1) or + ( not bHead and vtN:getY() < -0.1) then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) 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 @@ -171,6 +157,36 @@ function ProcessProfFront.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 ( bHead and vtExtr:getY() > 0.1) or + ( not bHead 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))