diff --git a/LuaLibs/ProcessProfCamb.lua b/LuaLibs/ProcessProfCamb.lua index 6f01d8e..1aee37c 100644 --- a/LuaLibs/ProcessProfCamb.lua +++ b/LuaLibs/ProcessProfCamb.lua @@ -138,7 +138,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end -- verifico se necessario lavorare in doppio - local bDouble = ( nSide ~= 0 and dProfDepth > dToolMaxDepth) + local bDouble = ( nSide ~= 0 and dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP) -- inserisco la lavorazione local sName = 'Prof_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) diff --git a/LuaLibs/ProcessProfConcave.lua b/LuaLibs/ProcessProfConcave.lua index ab9ea43..b991649 100644 --- a/LuaLibs/ProcessProfConcave.lua +++ b/LuaLibs/ProcessProfConcave.lua @@ -122,7 +122,7 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end -- verifico se necessario lavorare in doppio - local bDouble = ( nSide ~= 0 and dProfDepth > dToolMaxDepth) + local bDouble = ( nSide ~= 0 and dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP) -- inserisco la lavorazione local sName = 'Prof_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) diff --git a/LuaLibs/ProcessProfConvex.lua b/LuaLibs/ProcessProfConvex.lua index 87e9dd8..2440c6f 100644 --- a/LuaLibs/ProcessProfConvex.lua +++ b/LuaLibs/ProcessProfConvex.lua @@ -122,7 +122,7 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end -- verifico se necessario lavorare in doppio - local bDouble = ( nSide ~= 0 and dProfDepth > dToolMaxDepth) + local bDouble = ( nSide ~= 0 and dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP) -- inserisco la lavorazione local sName = 'Prof_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) diff --git a/LuaLibs/ProcessProfFront.lua b/LuaLibs/ProcessProfFront.lua index fc596d6..bb732f9 100644 --- a/LuaLibs/ProcessProfFront.lua +++ b/LuaLibs/ProcessProfFront.lua @@ -111,7 +111,7 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end -- verifico se necessario lavorare in doppio - local bDouble = ( nSide ~= 0 and dProfDepth > dToolMaxDepth) + local bDouble = ( nSide ~= 0 and dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP) -- inserisco la lavorazione local sName = 'Prof_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) diff --git a/LuaLibs/ProcessProfHead.lua b/LuaLibs/ProcessProfHead.lua index b918d9c..c9a9183 100644 --- a/LuaLibs/ProcessProfHead.lua +++ b/LuaLibs/ProcessProfHead.lua @@ -1,4 +1,4 @@ --- ProcessProfHead.lua by Egaltech s.r.l. 2019/03/29 +-- ProcessProfHead.lua by Egaltech s.r.l. 2019/04/10 -- Gestione calcolo profilo caudato per Travi -- Tabella per definizione modulo @@ -34,16 +34,8 @@ end --------------------------------------------------------------------- local function GetSawCutData( AuxId, vtN) - -- comincio con la normale a 45deg + -- assegno la normale 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 = EgtMP( AuxId, GDB_ID.ROOT) local frOCS = Frame3d( ptStart, vtNP) ; @@ -67,17 +59,14 @@ function ProcessProfHead.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 nFirstFacet = 0 -- faccia iniziale local nLastFacet = EgtSurfTmFacetCount( Proc.Id) - 1 -- faccia finale - local nMidFacet = ( nLastFacet + 1) / 2 -- faccia a metà circa - local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nMidFacet, GDB_ID.ROOT) - if abs( vtN:getX()) < 0.5 then - local vtN1 = EgtSurfTmFacetNormVersor( Proc.Id, ( 0 + nMidFacet) / 2, GDB_ID.ROOT) - local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, ( nMidFacet + nLastFacet) / 2, GDB_ID.ROOT) - vtN = vtN1 + vtN2 ; vtN:normalize() - end + -- determino la normale media + local CvxHullId = EgtSurfTmConvexHullInBBox( EgtGetParent( Proc.Id), Proc.Id, b3Raw, GDB_ID.ROOT) + local vtN = EgtSurfTmFacetNormVersor( CvxHullId, 0, GDB_ID.ROOT) + EgtErase( CvxHullId) -- verifico se in testa o coda local bHead = ( vtN:getX() > 0) -- verifico se profilo orientato verso l'alto (1), il basso (-1) o di fianco (0) @@ -118,6 +107,17 @@ function ProcessProfHead.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 + BD.CUT_EXTRA > 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) @@ -128,11 +128,11 @@ function ProcessProfHead.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 ( 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 @@ -144,28 +144,60 @@ function ProcessProfHead.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.INVERT, true) end -- 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 + 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)) -- imposto parametri di attacco e uscita - local bInvert = EgtGetMachiningParam( MCH_MP.INVERT) - local dLiPerp = 0 - if ( not bInvert and not bFirstTrim) or ( bInvert and not bLastTrim) then dLiPerp = 5 end - local dLoPerp = 0 - if ( not bInvert and not bLastTrim) or ( bInvert and not bFirstTrim) then dLoPerp = 5 end - EgtSetMachiningParam( MCH_MP.LIPERP, dLiPerp) - EgtSetMachiningParam( MCH_MP.LOPERP, dLoPerp) + EgtSetMachiningParam( MCH_MP.LIPERP, 5) + EgtSetMachiningParam( MCH_MP.LOPERP, 5) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() 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)) + -- imposto parametri di attacco e uscita + EgtSetMachiningParam( MCH_MP.LIPERP, 5) + EgtSetMachiningParam( MCH_MP.LOPERP, 5) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + end -- eventuale finitura faccia finale (ortogonale alla trave) if nSide ~= -1 and bLastTrim then sName = 'ProfV_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))