diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 40b09fc..c47d786 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -145,7 +145,6 @@ local function AssignQValues( Proc) Q_CONTOUR_SMALL_TOOL = EgtGetInfo( Proc.Id, 'Q01', 'i') or 0 Q_ANTISPLINT_TYPE = EgtGetInfo( Proc.Id, 'Q06', 'i') or 0 end - end --------------------------------------------------------------------- @@ -237,6 +236,36 @@ local function InitGlob( Proc, nPhase, nRawId, nPartId, dOvmHead) return true, '' end +--------------------------------------------------------------------- +local function GetToolInfoForMachining( sMachiningName) + + local toolInfo = { sTuuid = nil, + dLength = nil, + dDiam = nil, + dThDiam = nil, + dMaxMat = nil, + dMaxDepth = nil, + dSideDepth = nil, + dCornerRad = nil, + dThick = nil } + + if EgtMdbSetCurrMachining( sMachiningName) then + toolInfo.sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( toolInfo.sTuuid) or '') then + toolInfo.dLength = EgtTdbGetCurrToolParam( MCH_TP.LEN) + toolInfo.dDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + toolInfo.dThDiam = EgtTdbGetCurrToolThDiam() + toolInfo.dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) + toolInfo.dMaxDepth = EgtTdbGetCurrToolMaxDepth() + toolInfo.dSideDepth = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') + toolInfo.dCornerRad = EgtTdbGetCurrToolParam( MCH_TP.CORNRAD) + toolInfo.dThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) + return toolInfo + end + end + return nil +end + --------------------------------------------------------------------- local function FormatWarning( sWarn, sWarn2) if sWarn2 then @@ -247,6 +276,7 @@ local function FormatWarning( sWarn, sWarn2) end --------------------------------------------------------------------- +-- Restituisce solo gli indici delle facce adiacenti esistenti (no -1) local function GetValidFacetAdjacencies( nSurfId, nFacet) local vValidAdj local vFacAdj = EgtSurfTmFacetAdjacencies( nSurfId, nFacet)[1] @@ -320,6 +350,7 @@ local function TestElleShape4( Proc) end --------------------------------------------------------------------- +--- Test per facce a forma di U o a forma di L local function TestUL( Proc) local bIsU = ( Proc.Fct == 3 and not TestElleShape3( Proc)) -- verifico se due facce o L con una o due facce di terminazione @@ -362,7 +393,7 @@ end local function VerifyChainSaw( Proc, dMinDim, dMaxDim) local bUseChainSaw = false local sMchFind = 'Sawing' - local sSawing = ML.FindSawing(sMchFind) + local sSawing = ML.FindSawing( sMchFind) local dMaxMat = 0 local dSawCornerRad = 0 local dSawThick = 0 @@ -374,19 +405,17 @@ local function VerifyChainSaw( Proc, dMinDim, dMaxDim) -- recupero i dati dell'utensile local dToolLength = 0 local dSawWidth = 75 - if EgtMdbSetCurrMachining( sSawing) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dToolLength = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dToolLength - dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat - dSawWidth = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawWidth - dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThick - dSawCornerRad = EgtTdbGetCurrToolParam( MCH_TP.CORNRAD) or dSawCornerRad - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth - end + local TI = GetToolInfoForMachining( sSawing) + if TI then + dToolLength = TI.dLength or dToolLength + dMaxMat = TI.dMaxMat or dMaxMat + dSawWidth = TI.dDiam or dSawWidth + dSawThick = TI.dThick or dSawThick + dSawCornerRad = TI.dCornerRad or dSawCornerRad + dMaxDepth = TI.dMaxDepth or dMaxDepth if dSawThick < dMinDim + 10 * GEO.EPS_SMALL and dSawWidth < dMaxDim + 10 * GEO.EPS_SMALL then bUseChainSaw = true - end + end end end return bUseChainSaw, sSawing, dMaxMat, dSawCornerRad, dSawThick, dMaxDepth @@ -414,12 +443,10 @@ local function VerifyPocket( Proc, dDiam, dDepth, dMaxTotLen, sMchFindMaster) local bUsePocketing = false local dMaxDepth = 0 local dToolDiam = 0 - if EgtMdbSetCurrMachining( sPocketing) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth - end + local TI = GetToolInfoForMachining( sPocketing) + if TI then + dToolDiam = TI.dDiam or dToolDiam + dMaxDepth = TI.dMaxDepth or dMaxDepth bUsePocketing = true end return bUsePocketing, sPocketing, dMaxDepth, dToolDiam @@ -461,7 +488,7 @@ local function VerifyBHSideMill( Proc, bSinglePart, bPrevBhSideMill) local bExit = false for i = 1, Proc.Fct do local _, vtN = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT) - if abs(vtN:getX()) > 0.001 and abs(vtN:getX()) < 0.999962 then + if abs( vtN:getX()) > 0.001 and abs( vtN:getX()) < 0.999962 then bExit = true break end @@ -484,14 +511,12 @@ local function VerifyBHSideMill( Proc, bSinglePart, bPrevBhSideMill) -- recupero i dati dell'utensile local dToolLength = 0 local dMaxDepth = 0 - if EgtMdbSetCurrMachining( sMilling) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dToolLength = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dToolLength - dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth - dThickTool = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dThickTool - end + local TI = GetToolInfoForMachining( sMilling) + if TI then + dToolLength = TI.dLength or dToolLength + dToolDiam = TI.dDiam or dToolDiam + dMaxDepth = TI.dMaxDepth or dMaxDepth + dThickTool = TI.dThick or dThickTool end -- verifico se la feature è abbastanza vicino a testa/coda da permettere la lavorazione con questo utensile if _b3Solid then @@ -622,7 +647,6 @@ function ProcessLapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH) if not InitGlob( Proc) then return false end - -- se una sola faccia if Proc.Fct == 1 then local _, vtN0 = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) @@ -668,7 +692,6 @@ function ProcessLapJoint.IsTailFeature( Proc, b3Raw) if not InitGlob( Proc) then return false end - -- se una sola faccia if Proc.Fct == 1 then local _, vtN0 = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) @@ -719,7 +742,6 @@ function ProcessLapJoint.Classify( Proc, b3Raw) if not InitGlob( Proc) then return false end - -- se 1 faccia if Proc.Fct == 1 then -- dati della faccia @@ -968,9 +990,9 @@ local function MakeTwoFacesByMill( Proc, bDownHead) end -- recupero i dati dell'utensile local dTDiam = 0 - if EgtMdbSetCurrMachining( sMilling) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam + local TI = GetToolInfoForMachining( sMilling) + if TI then + dTDiam = TI.dDiam or dTDiam end -- dati delle facce local ptC = {} @@ -983,7 +1005,7 @@ local function MakeTwoFacesByMill( Proc, bDownHead) local bFaceOk = {} bFaceOk[1] = ( vtN[1]:getZ() >= BD.NZ_MINB) bFaceOk[2] = ( vtN[2]:getZ() >= BD.NZ_MINB) - if not bDownHead and not bFaceOk[1] and not bFaceOk[2] then + if not bDownHead and not bFaceOk[1] and not bFaceOk[2] then local sErr = 'Error : LapJoint from bottom impossible' EgtOutLog( sErr) return false, sErr @@ -1138,12 +1160,10 @@ local function MakeByMill( Proc, nFacInd, rfFac, dH, dV, dElev, dCollSic, bSpeci -- recupero i dati dell'utensile local dTDiam = 50 local dMaxMat = 0 - if EgtMdbSetCurrMachining( sMilling) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam - dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat - end + local TI = GetToolInfoForMachining( sMilling) + if TI then + dTDiam = TI.dDiam or dTDiam + dMaxMat = TI.dMaxMat or dMaxMat end -- Se massimo materiale utensile è molto inferiore dell'elevazione non faccio la lavorazione e do un warning if dMaxMat > 0 and dMaxMat + 15 < dElev + dCollSic then @@ -1226,7 +1246,7 @@ local function ChooseCorner( Proc, nFacInd) local tFacAdj = {} for i = 1, #vAdj do if vAdj[i] >= 0 then - for j = i+1, #vAdj do + for j = i + 1, #vAdj do if vAdj[j] >= 0 then local _, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, vAdj[i], vAdj[j], GDB_ID.ROOT) if ptP1 and ptP2 and dAng < 0 then @@ -1318,17 +1338,20 @@ local function CheckToInvert( AuxId, bPositive) end --------------------------------------------------------------------- -local function TestPoints( nPathInt, i, dDiff, pPiniAxis, pPendAxis, b3SolidMinAxis, b3SolidMaxAxis) - if ( abs( pPiniAxis - b3SolidMaxAxis) < dDiff and abs( pPendAxis - b3SolidMaxAxis) < dDiff) or - ( abs( pPiniAxis - b3SolidMinAxis) < dDiff and abs( pPendAxis - b3SolidMinAxis) < dDiff) then +local function TestPoints( nPathInt, idx, dDiff, pP1, pP2, sAxis) + local pPini = EgtIf( sAxis == 'X', pP1:getX(), EgtIf( sAxis == 'Y', pP1:getY(), pP1:getZ())) + local pPend = EgtIf( sAxis == 'X', pP2:getX(), EgtIf( sAxis == 'Y', pP2:getY(), pP2:getZ())) + local b3SolidMin = EgtIf( sAxis == 'X', _b3Solid:getMin():getX(), EgtIf( sAxis == 'Y', _b3Solid:getMin():getY(), _b3Solid:getMin():getZ())) + local b3SolidMax = EgtIf( sAxis == 'X', _b3Solid:getMax():getX(), EgtIf( sAxis == 'Y', _b3Solid:getMax():getY(), _b3Solid:getMax():getZ())) + if ( abs( pPini - b3SolidMax) < dDiff and abs( pPend - b3SolidMax) < dDiff) or + ( abs( pPini - b3SolidMin) < dDiff and abs( pPend - b3SolidMin) < dDiff) then -- setto l'entità open local sActInfo = EgtGetInfo( nPathInt, 'OPEN', 's') or '' if #sActInfo > 0 then - EgtSetInfo( nPathInt, 'OPEN', sActInfo .. ',' .. (i - 1)) + EgtSetInfo( nPathInt, 'OPEN', sActInfo .. ',' .. idx) else - EgtSetInfo( nPathInt, 'OPEN', (i - 1)) + EgtSetInfo( nPathInt, 'OPEN', idx) end - -- prendo i punti per eventuale modifica del punto di inizio percorso return true else return false @@ -1347,47 +1370,47 @@ local function SetOpenSide( nPathInt, vtOrtho, nStartPoint) if nStartIdEnt then -- prendo i punti for i = 1, nNumEnt do - local pPini = EgtUP( nPathInt, (i-1), GDB_RT.GLOB) + local pPini = EgtUP( nPathInt, (i - 1), GDB_RT.GLOB) local pPend = EgtUP( nPathInt, EgtIf( i == nNumEnt, 0, i), GDB_RT.GLOB) -- Se normale lungo la Z considero il box in X e Y if abs(vtOrtho:getZ()) > 0.999 then - -- se corrisponde a X - if TestPoints(nPathInt, i, 10 * GEO.EPS_SMALL, pPini:getX(), pPend:getX(), _b3Solid:getMin():getX(), _b3Solid:getMax():getX()) then + -- se corrisponde a X prendo i punti per eventuale modifica del punto di inizio percorso + if TestPoints(nPathInt, i - 1, 10 * GEO.EPS_SMALL, pPini, pPend, 'X') then pLastPIni = pPini pLastPEnd = pPend - -- altrimenti se corrisponde a Y - elseif TestPoints(nPathInt, i, 10 * GEO.EPS_SMALL, pPini:getY(), pPend:getY(), _b3Solid:getMin():getY(), _b3Solid:getMax():getY()) then + -- altrimenti se corrisponde a Y prendo i punti per eventuale modifica del punto di inizio percorso + elseif TestPoints(nPathInt, i - 1, 10 * GEO.EPS_SMALL, pPini, pPend, 'Y') then pLastPIni = pPini pLastPEnd = pPend end -- altrimenti se normale lungo la Y considero il box in X e Z elseif abs(vtOrtho:getZ()) < 0.001 and abs(vtOrtho:getY()) > 0.999 then - -- se corrisponde a X - if TestPoints(nPathInt, i, 10 * GEO.EPS_SMALL, pPini:getX(), pPend:getX(), _b3Solid:getMin():getX(), _b3Solid:getMax():getX()) then + -- se corrisponde a X prendo i punti per eventuale modifica del punto di inizio percorso + if TestPoints(nPathInt, i - 1, 10 * GEO.EPS_SMALL, pPini, pPend, 'X') then pLastPIni = pPini pLastPEnd = pPend - -- altrimenti se corrisponde a Z - elseif TestPoints(nPathInt, i, 10 * GEO.EPS_SMALL, pPini:getZ(), pPend:getZ(), _b3Solid:getMin():getZ(), _b3Solid:getMax():getZ()) then + -- altrimenti se corrisponde a Z prendo i punti per eventuale modifica del punto di inizio percorso + elseif TestPoints(nPathInt, i - 1, 10 * GEO.EPS_SMALL, pPini, pPend, 'Z') then pLastPIni = pPini pLastPEnd = pPend end -- caso che non dovrebbe mai capitare ma gestito per completezza -- altrimenti se normale lungo la X considero il box in Y e Z elseif abs(vtOrtho:getZ()) < 0.001 and abs(vtOrtho:getX()) > 0.999 then - -- se corrisponde a Y - if TestPoints(nPathInt, i, 10 * GEO.EPS_SMALL, pPini:getY(), pPend:getY(), _b3Solid:getMin():getY(), _b3Solid:getMax():getY()) then + -- se corrisponde a Y prendo i punti per eventuale modifica del punto di inizio percorso + if TestPoints(nPathInt, i - 1, 10 * GEO.EPS_SMALL, pPini, pPend, 'Y') then pLastPIni = pPini pLastPEnd = pPend - -- altrimenti se corrisponde a Z - elseif TestPoints(nPathInt, i, 10 * GEO.EPS_SMALL, pPini:getZ(), pPend:getZ(), _b3Solid:getMin():getZ(), _b3Solid:getMax():getZ()) then + -- altrimenti se corrisponde a Z prendo i punti per eventuale modifica del punto di inizio percorso + elseif TestPoints(nPathInt, i - 1, 10 * GEO.EPS_SMALL, pPini, pPend, 'Z') then pLastPIni = pPini pLastPEnd = pPend end -- se asse Z orizzontale verifico se si avvicina piú a Y elseif abs(vtOrtho:getZ()) < 0.001 then if abs(vtOrtho:getY()) > 0.75 then - -- se corrisponde a Z - if TestPoints(nPathInt, i, 10 * GEO.EPS_SMALL, pPini:getZ(), pPend:getZ(), _b3Solid:getMin():getZ(), _b3Solid:getMax():getZ()) then + -- se corrisponde a Z prendo i punti per eventuale modifica del punto di inizio percorso + if TestPoints(nPathInt, i - 1, 10 * GEO.EPS_SMALL, pPini, pPend, 'Z') then pLastPIni = pPini pLastPEnd = pPend end @@ -1395,8 +1418,8 @@ local function SetOpenSide( nPathInt, vtOrtho, nStartPoint) -- se asse Y a 0 (fresa ne davanti ne dietro) verifico se si avvicina piú a Z+ elseif abs(vtOrtho:getY()) < 0.001 then if abs(vtOrtho:getZ()) > 0.75 then - -- se corrisponde a Y - if TestPoints(nPathInt, i, 10 * GEO.EPS_SMALL, pPini:getY(), pPend:getY(), _b3Solid:getMin():getY(), _b3Solid:getMax():getY()) then + -- se corrisponde a Y prendo i punti per eventuale modifica del punto di inizio percorso + if TestPoints(nPathInt, i - 1, 10 * GEO.EPS_SMALL, pPini, pPend, 'Y') then pLastPIni = pPini pLastPEnd = pPend end @@ -1436,10 +1459,10 @@ local function MakeRoundCleanCorner( Proc, nFacInd, dDiam, bMillDown, bDoubleSid -- recupero i dati dell'utensile local dTDiam = 50 local dTMaxDepth = 0 - if EgtMdbSetCurrMachining( sMilling) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam - dTMaxDepth = EgtTdbGetCurrToolMaxDepth() or dTMaxDepth + local TI = GetToolInfoForMachining( sMilling) + if TI then + dTDiam = TI.dDiam or dTDiam + dTMaxDepth = TI.dMaxDepth or dTMaxDepth end -- se il diametro trovato non è minore dei 3/4 del diametro utilizzato in precedenza, esco @@ -1615,11 +1638,11 @@ local function MakeRoundCleanContour( Proc, nFacInd, dDiam, nFunction, bMillDown -- recupero i dati dell'utensile local dTDiam = 50 local dTMaxDepth = 0 - if EgtMdbSetCurrMachining( sMilling) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam - dTMaxDepth = EgtTdbGetCurrToolMaxDepth() or dTMaxDepth - end + local TI = GetToolInfoForMachining( sMilling) + if TI then + dTDiam = TI.dDiam or dTDiam + dTMaxDepth = TI.dMaxDepth or dTMaxDepth + end local sMillingDn = ML.FindMilling( 'SmallToolContour' .. EgtIf( bMillDown and bDoubleSide, '_H2', '')) if not sMillingDn then @@ -1630,11 +1653,11 @@ local function MakeRoundCleanContour( Proc, nFacInd, dDiam, nFunction, bMillDown -- recupero i dati dell'utensile testa da sotto local dTDiamDn = 50 local dTMaxDepthDn = 0 - if EgtMdbSetCurrMachining( sMillingDn) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - dTDiamDn = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiamDn - dTMaxDepthDn = EgtTdbGetCurrToolMaxDepth() or dTMaxDepthDn - end + local TI = GetToolInfoForMachining( sMillingDn) + if TI then + dTDiamDn = TI.dDiam or dTDiamDn + dTMaxDepthDn = TI.dMaxDepth or dTMaxDepthDn + end -- se il diametro trovato non è minore dei 3/4 del diametro utilizzato in precedenza, esco if dTDiam > ( 0.75 * dDiam) then @@ -1964,7 +1987,7 @@ local function MakeSharpCleanCorner( Proc, nFacInd, dDiam) -- inserisco le prime tre linee if nIdIniPoint and nIdEndPoint then -- se fresatura da sotto salto la lavorazione - if vtExtr:getZ() < BD.DRILL_VZ_MIN then + if vtExtr:getZ() < BD.DRILL_VZ_MIN then local sErr = 'Error : clean corner milling from bottom impossible' EgtOutLog( sErr) return false, sErr @@ -1980,9 +2003,9 @@ local function MakeSharpCleanCorner( Proc, nFacInd, dDiam) return false, sErr end -- recupero i dati dell'utensile ( temporaneo, per compensare errore nella lavorazione) - if EgtMdbSetCurrMachining( sMilling) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - dMaxDepth = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxDepth + local TI = GetToolInfoForMachining( sMilling) + if TI then + dMaxDepth = TI.dMaxMat or dMaxDepth end -- l'altezza di taglio del tagliente corrisponde al raggio del raccordo che si riesce a coprire -- quindi confronto l'elevazione con il raggio utensile utilizzato per la svuotatura @@ -2159,18 +2182,16 @@ local function MakeDrillOnCorner( Proc, nFacInd, dDiam, bSpecialMach) local dDiamTool = 20 local dDiamTh = 35 local bIsDrilling - if EgtMdbSetCurrMachining( sDrilling) then + local TI = GetToolInfoForMachining( sDrilling) + if TI then bIsDrilling = ( EgtMdbGetCurrMachiningParam( MCH_MP.TYPE) == MCH_MY.DRILLING) - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - if bIsDrilling then - dMaxDepth = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxDepth - else - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth - end - dDiamTool = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - dDiamTh = EgtTdbGetCurrToolThDiam() + if bIsDrilling then + dMaxDepth = TI.dMaxMat or dMaxDepth + else + dMaxDepth = TI.dMaxDepth or dMaxDepth end + dDiamTool = TI.dDiam or dDiamTool + dDiamTh = TI.dThDiam or dDiamTh end -- se foro inclinato, limito il massimo affondamento local CosB = abs( vtExtr:getX()) @@ -2187,7 +2208,7 @@ local function MakeDrillOnCorner( Proc, nFacInd, dDiam, bSpecialMach) EgtSetGridFrame( Frame3d( tFacAdj[nIdLine][nIdIniPoint], vtExtr)) end -- creo geometria - local AuxId = EgtCircle( _nAddGrpId, {0, 0, 0}, EgtIf( bIsDrilling, dDiamTool/2, ( dDiamTool/2) + 0.1), GDB_RT.GRID) + local AuxId = EgtCircle( _nAddGrpId, {0, 0, 0}, EgtIf( bIsDrilling, dDiamTool / 2, ( dDiamTool / 2) + 0.1), GDB_RT.GRID) -- riporto la griglia a globale EgtSetGridFrame() -- calcolo spessore @@ -2774,11 +2795,9 @@ local function MakeByChainOrSaw( Proc, nFacInd, local dSawMaxDepth = 0 local sCutting = ML.FindCutting( 'HeadSide') if sCutting then - if EgtMdbSetCurrMachining( sCutting) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dSawMaxDepth = EgtTdbGetCurrToolMaxDepth() or dSawMaxDepth - end + local TI = GetToolInfoForMachining( sCutting) + if TI then + dSawMaxDepth = TI.dMaxDepth or dSawMaxDepth end end -- se lavorazione sulle teste e altezza trave supera il limite ( che causa collisione con la forcella) e direzione taglio lungo la Z @@ -2799,12 +2818,10 @@ local function MakeByChainOrSaw( Proc, nFacInd, -- recupero i dati dell'utensile local dSawDiam = 400 local dSawThick = 4 - if EgtMdbSetCurrMachining( sCutting) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam - dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThick - end + local TI = GetToolInfoForMachining( sCutting) + if TI then + dSawDiam = TI.dDiam or dSawDiam + dSawThick = TI.dThick end if dSawThick > dV + 10 * GEO.EPS_SMALL then local sErr = 'Error : sawblade too thick' @@ -2844,14 +2861,12 @@ local function MakeByChainOrSaw( Proc, nFacInd, -- Recupero i dati dell'utensile local dSawWidth = 75 local dSawThick = 8 - local dMaxDepth = 200 - if EgtMdbSetCurrMachining( sSawing) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dSawWidth = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawWidth - dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThick - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth - end + local dMaxDepth = 200 + local TI = GetToolInfoForMachining( sSawing) + if TI then + dSawWidth = TI.dDiam or dSawWidth + dSawThick = TI.dThick or dSawThick + dMaxDepth = TI.dMaxDepth or dMaxDepth end if dSawThick > dV + 10 * GEO.EPS_SMALL then local sErr = 'Error : chainsaw too thick' @@ -3079,13 +3094,11 @@ local function MakeAntiSplintBySaw( Proc, nFacet, vtN, nFacInd, bReduceDepth, bM local dSawDiam = 400 local dSawThick = 0 local dMaxDepth = 0 - if EgtMdbSetCurrMachining( sCutting) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam - dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThick - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth - end + local TI = GetToolInfoForMachining( sCutting) + if TI then + dSawDiam = TI.dDiam or dSawDiam + dSawThick = TI.dThick or dSawThick + dMaxDepth = TI.dMaxDepth or dMaxDepth end local dExtraOffs = 0 -- se profondità superiore al massimo lama modifico elevazione @@ -3334,11 +3347,9 @@ local function MachineByMill( Proc, tvtN, nBaseFace, nSideFace, ptPs, tDimAndRef end -- recupero i dati dell'utensile local dTDiam = 50 - if EgtMdbSetCurrMachining( sMilling) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam - end + local TI = GetToolInfoForMachining( sMilling) + if TI then + dTDiam = TI.dDiam or dTDiam end -- Calcolo uso faccia local nFaceUse = BL.GetNearestParalOpposite( tDimAndRef[1][3]:getVersZ()) @@ -4061,10 +4072,10 @@ local function ManageAntiSplintByMill( Proc, nFacInd, bMillDown, dDiam, bDoubleS -- recupero i dati dell'utensile local dTDiam = 50 local dMaxDepth = 0 - if EgtMdbSetCurrMachining( sMilling) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + local TI = GetToolInfoForMachining( sMilling) + if TI then + dTDiam = TI.dDiam or dTDiam + dMaxDepth = TI.dMaxDepth or dMaxDepth end -- se non ho la faccia aggiunta @@ -4110,7 +4121,7 @@ local function ManageAntiSplintByMill( Proc, nFacInd, bMillDown, dDiam, bDoubleS end end end - -- cotruisco il/i percorso/i + -- costruisco il/i percorso/i nFirstId, nNumId = EgtCurveCompoByReorder( _nAddGrpId, tPaths, ptIniPath, true, GDB_RT.GLOB) local bOkPath = true for i = 1, nNumId do @@ -4179,10 +4190,10 @@ local function ManageAntiSplintByMill( Proc, nFacInd, bMillDown, dDiam, bDoubleS ML.FindMilling( 'AntiSplintMillCut_H2') sMilling = sMillingDn -- controllo dati lavorazione - if EgtMdbSetCurrMachining( sMilling) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + local TI = GetToolInfoForMachining( sMilling) + if TI then + dTDiam = TI.dDiam or dTDiam + dMaxDepth = TI.dMaxDepth or dMaxDepth end end -- se lavorazione valida @@ -4907,14 +4918,12 @@ local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFa if sMillingOnSide then -- recupero i dati dell'utensile local dToolLength = 0 - if EgtMdbSetCurrMachining( sMillingOnSide) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dToolLength = EgtTdbGetCurrToolParam( MCH_TP.LEN) or dToolLength - dToolDiamOnSide = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiamOnSide - dThickMillOnSide = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dThickMillOnSide - dMaxDepthOnSide = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or dMaxDepthOnSide - end + local TI = GetToolInfoForMachining( sMillingOnSide) + if TI then + dToolLength = TI.dLength or dToolLength + dToolDiamOnSide = TI.dDiam or dToolDiamOnSide + dThickMillOnSide = TI.dMaxMat or dThickMillOnSide + dMaxDepthOnSide = TI.dSideDepth or dMaxDepthOnSide end -- 2021.09.17 Su conferma di Fabio Squaratti, se la gola è più stretta dell'utensile o la profondità della gole è maggiore -- del valore parametro SIDEDEPTH (preso dalle note utente dell'utensile) allora si prosegue come se non fosse abilitata @@ -5115,7 +5124,7 @@ local function MakeThreeFaces( Proc, bSinglePart, bPrevBhSideMill) end -- altrimenti lavoro con svuotatura else - local bSpecial3faces = false + local bSpecial3faces = false local bBoxF = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, rfFac) if dH * dV < 0.9 * ( bBoxF:getDimX() * bBoxF:getDimY()) then @@ -5271,7 +5280,7 @@ end --------------------------------------------------------------------- function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- inizializzo variabili globali al modulo - local bOk, sErr = InitGlob( Proc, nPhase, nRawId, nPartId, dOvmHead) + local bOk, sErr = InitGlob( Proc, nPhase, nRawId, nPartId, dOvmHead) if not bOk then return bOk, sErr @@ -5321,9 +5330,7 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) local b3Fac2 = EgtSurfTmGetFacetBBoxGlob( Proc.Id, 1, GDB_BB.STANDARD) if abs( b3Fac1:getDimX() - b3Fac2:getDimX()) < 50 then -- leggo i parametri Q per utilizzare la fresa di fianco e/o lama - local nUseSideTool = Q_SIDE_ROUGH_TOOL - local bUseBlade = Q_ANTISPLINT_TYPE == 1 - return Long2Cut.Make( Proc, _nPhase, _nRawId, _nPartId, bUseBlade, nUseSideTool) + return Long2Cut.Make( Proc, _nPhase, _nRawId, _nPartId, Q_ANTISPLINT_TYPE == 1, Q_SIDE_ROUGH_TOOL) elseif b3Fac1:getDimX() < 1 then -- la faccia 0 deve essere quella lunga EgtSurfTmSwapFacets( Proc.Id, 0, 1) @@ -5436,7 +5443,7 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) elseif Proc.Fct == 3 then return MakeThreeFaces( Proc, true) -- o più facce - else + else return MakeMoreFaces( Proc, true) end end