diff --git a/LuaLibs/ProcessDovetail.lua b/LuaLibs/ProcessDovetail.lua index 081fe12..8c7c5f3 100644 --- a/LuaLibs/ProcessDovetail.lua +++ b/LuaLibs/ProcessDovetail.lua @@ -1,4 +1,4 @@ --- ProcessDovetail.lua by Egaltech s.r.l. 2020/04/23 +-- ProcessDovetail.lua by Egaltech s.r.l. 2020/05/02 -- Gestione calcolo giunzione coda di rondine -- Tabella per definizione modulo @@ -17,18 +17,7 @@ local BD = require( 'BeamData') local ML = require( 'MachiningLib') -- variabili assegnazione parametri Q -local sForceUseBlade = '' -- i -local sDepthChamferMill = '' -- d -local sPreemptiveChamfer = '' -- i -local sUseMill = '' -- i -local sUseRoughTool = '' -- i -local sUseRoughToolWithBAxis90 = '' -- i -local sUseRoughToolWithBAxis0 = '' -- i -local sInsertBoreOnCorner = '' -- 1 -local sMakeContourWithSmallTool = '' -- i -local sMakeOnlyContourOrFullPocket = '' -- i -local sMakeBySideRoughTool = '' -- i -local sAntisplintMode = '' -- i +local sUseRoughTool = '' -- i --------------------------------------------------------------------- -- Riconoscimento della feature @@ -40,49 +29,37 @@ end local function AssignQValues( Proc) -- reset delle variabili assegnazione parametri Q - sForceUseBlade = '' - sDepthChamferMill = '' - sPreemptiveChamfer = '' - sUseMill = '' - sUseRoughTool = '' - sUseRoughToolWithBAxis90 = '' - sUseRoughToolWithBAxis0 = '' - sInsertBoreOnCorner = '' - sMakeContourWithSmallTool = '' - sMakeOnlyContourOrFullPocket = '' - sMakeBySideRoughTool = '' - sAntisplintMode = '' + sUseRoughTool = '' if Proc.Prc == 138 then - sUseRoughTool = 'Q02' -- d + sUseRoughTool = 'Q02' -- d end end --------------------------------------------------------------------- local function EvaluateQParam( Proc, sUseRoughTool) - local nChamfer = 0 - local bForceUseRough = false + local bForceUseRough = false -- verifico se devo usare il truciolatore -- 2020-03-20 forzata disabilitazione uso truciolatore se parametro Q non è presente if #sUseRoughTool == 0 or EgtGetInfo( Proc.Id, sUseRoughTool, 'i') == 2 then bForceUseRough = true end - return nChamfer, bForceUseRough + return bForceUseRough end --------------------------------------------------------------------- -local function OrderFaces( Proc, nFacetCnt, vtN) +local function OrderFaces( Proc, vtN) - local dMinXFace = 1 + local dMinXFace = 0.99 local dPosXFace = 0 local dNegXFace = 0 local vFaceOrd = { 0, 0, 0} - if nFacetCnt <= 2 then - -- ordino le facce (1=faccia ausiliaria, 2=interna, 3=intermedia) - for i = 1, nFacetCnt do + -- se 2 facce : ordine (1=0, 2=interna, 3=intermedia) + if #vtN <= 2 then + for i = 1, #vtN do if abs( vtN[i]:getX()) < dMinXFace then dMinXFace = abs( vtN[i]:getX()) vFaceOrd[3] = i @@ -93,7 +70,7 @@ local function OrderFaces( Proc, nFacetCnt, vtN) EgtOutLog( sErr) return false, sErr end - for i = 1, nFacetCnt do + for i = 1, #vtN do if i ~= vFaceOrd[3] then local bTouch, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, i - 1, vFaceOrd[3] - 1, GDB_ID.ROOT) if bTouch and dAng < 0 then @@ -101,9 +78,10 @@ local function OrderFaces( Proc, nFacetCnt, vtN) end end end - elseif nFacetCnt == 3 then - -- ordino le facce (1=altra intermedia, 2=interna, 3=intermedia) - for i = 1, nFacetCnt do + + -- se 3 facce : ordine (1=altra intermedia, 2=interna, 3=intermedia) + elseif #vtN == 3 then + for i = 1, #vtN do if abs( vtN[i]:getX()) < dMinXFace then dMinXFace = abs( vtN[i]:getX()) vFaceOrd[3] = i @@ -123,7 +101,7 @@ local function OrderFaces( Proc, nFacetCnt, vtN) EgtOutLog( sErr) return false, sErr end - for i = 1, nFacetCnt do + for i = 1, #vtN do if i ~= vFaceOrd[3] and i ~= vFaceOrd[2] then local bTouch, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, i - 1, vFaceOrd[2] - 1, GDB_ID.ROOT) if bTouch and dAng < 0 then @@ -131,41 +109,42 @@ local function OrderFaces( Proc, nFacetCnt, vtN) end end end + + -- se 4 facce : ordine (1=altra intermedia, 2=interna, 3=intermedia, 4=esterna) else - -- ordino le facce (1=laterale positiva 2=altra intermedia, 3=intermedia, 4=laterale negativa) - for i = 1, nFacetCnt do + for i = 1, #vtN do if vtN[i]:getX() > dPosXFace then dPosXFace = vtN[i]:getX() - vFaceOrd[1] = i + vFaceOrd[2] = i end - if ( vtN[i]:getX()) < dNegXFace then + if vtN[i]:getX() < dNegXFace then dNegXFace = vtN[i]:getX() vFaceOrd[4] = i end end - if vFaceOrd[1] == 0 then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing side positive face' + if vFaceOrd[2] == 0 then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing internal face' EgtOutLog( sErr) return false, sErr end if vFaceOrd[4] == 0 then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing side negative face' + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing external face' EgtOutLog( sErr) return false, sErr end local nMidFace = 3 - for i = 1, nFacetCnt do - if i ~= vFaceOrd[1] and i ~= vFaceOrd[4] then + for i = 1, #vtN do + if i ~= vFaceOrd[2] and i ~= vFaceOrd[4] then vFaceOrd[nMidFace] = i - nMidFace = nMidFace - 1 + nMidFace = 1 end end - if vFaceOrd[2] == 0 or vFaceOrd[3] == 0 then + if vFaceOrd[1] == 0 or vFaceOrd[3] == 0 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing middle face' EgtOutLog( sErr) return false, sErr end - local bTouch, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, vFaceOrd[3] - 1, vFaceOrd[2] - 1, GDB_ID.ROOT) + local bTouch, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, vFaceOrd[3] - 1, vFaceOrd[1] - 1, GDB_ID.ROOT) if bTouch and dAng < 0 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' wrong angle between middle faces' EgtOutLog( sErr) @@ -176,25 +155,25 @@ local function OrderFaces( Proc, nFacetCnt, vtN) end --------------------------------------------------------------------- -local function VerifyIfRoughMill( dLargeface, vtN, bCalcElev, dAngOnSide) +local function VerifyIfRoughMill( dLargeFace, vtN, bCalcElev, dAngOnSide) local bUseRoughMill = false local sMilling -- recupero la lavorazione if dAngOnSide then if bCalcElev then local dCollSic = BD.COLL_SIC - -- se direzione tende verso una delle alle 3 direzioni azzero l'altezza extra + -- se direzione tende verso una delle 3 direzioni azzero l'altezza extra if abs( vtN:getX()) > 0.7 or abs( vtN:getY()) > 0.7 or abs( vtN:getZ()) > 0.7 then dCollSic = 0 end - sMilling = ML.FindMilling( 'ProfTCone', dLargeface + dCollSic) + sMilling = ML.FindMilling( 'ProfTCone', dLargeFace + dCollSic) else sMilling = ML.FindMilling( 'ProfTCone') end else if bCalcElev then local dCollSic = BD.COLL_SIC - -- se direzione tende verso una delle alle 3 direzioni azzero l'altezza extra + -- se direzione tende verso una delle 3 direzioni azzero l'altezza extra if abs( vtN:getX()) > 0.7 or abs( vtN:getY()) > 0.7 or abs( vtN:getZ()) > 0.7 then dCollSic = 0 end - sMilling = ML.FindMilling( 'Long2Cut', dLargeface + dCollSic) + sMilling = ML.FindMilling( 'Long2Cut', dLargeFace + dCollSic) else sMilling = ML.FindMilling( 'Long2Cut') end @@ -207,7 +186,7 @@ local function VerifyIfRoughMill( dLargeface, vtN, bCalcElev, dAngOnSide) local dMaxDepth = 0 local dMaxMat = 50 local dSideAngle = 0 - local dStepmach = 0 + local dMachStep = 0 if EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then @@ -217,22 +196,22 @@ local function VerifyIfRoughMill( dLargeface, vtN, bCalcElev, dAngOnSide) dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat dSideAngle = EgtTdbGetCurrToolParam( MCH_TP.SIDEANG) or dSideAngle -- ottengo il passo della lavorazione - dStepmach = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) or dStepmach + dMachStep = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) or dMachStep end end - if dStepmach <= 0.1 then - dStepmach = dMaxMat * 0.5 + if dMachStep <= 0.1 then + dMachStep = dMaxMat * 0.5 end -- se ho già fatto la ricerca lavorazione considerando l'elevazione controllo solo l'angolo if bCalcElev then -- se angolo spoglia compatibile if abs( dSideAngle - dAngOnSide) < GEO.EPS_SMALL then - return true, sMilling, dToolDiam, dToolLength, dMaxDepth, dMaxMat, dSideAngle, dStepmach + return true, sMilling, dToolDiam, dToolLength, dMaxDepth, dMaxMat, dSideAngle, dMachStep end else -- se altezza taglio utensile maggiore altezza faccia e angolo spoglia compatibile - if ( dMaxDepth >= dLargeface + 10 * GEO.EPS_SMALL) and ( abs( dSideAngle - dAngOnSide) < GEO.EPS_SMALL) then - return true, sMilling, dToolDiam, dToolLength, dMaxDepth, dMaxMat, dSideAngle, dStepmach + if ( dMaxDepth > dLargeFace + 10 * GEO.EPS_SMALL) and ( abs( dSideAngle - dAngOnSide) < GEO.EPS_SMALL) then + return true, sMilling, dToolDiam, dToolLength, dMaxDepth, dMaxMat, dSideAngle, dMachStep end end end @@ -330,49 +309,36 @@ function ProcessDovetail.Classify( Proc, b3Raw) -- in base al tipo di feature attribuisco il significato dei parametri Q AssignQValues( Proc) -- verifico se sono presenti i parametri Q per l'uso forzato del truciolatore - local _, bForceUseRough = EvaluateQParam( Proc, sUseRoughTool) + local bForceUseRough = EvaluateQParam( Proc, sUseRoughTool) -- verifico le normali delle facce - local nFacetCnt = EgtSurfTmFacetCount( Proc.Id) local nFlatFaceNeg local bDown = false - -- individuo se c'è faccia rastremata verso Z- - for i = 1, nFacetCnt do + -- individuo se c'è faccia rivolta verso Z- + for i = 1, Proc.Fct do local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i-1, GDB_ID.ROOT) - if vtN:getZ() < -1 + GEO.EPS_SMALL then - nFlatFaceNeg = i-1 + if vtN:getZ() < -0.99 then + nFlatFaceNeg = i - 1 break end end - -- se trovata faccia rastremata rivolta verso Z- - -- verifico se lunghezza faccia piatta è compatibile con il taglio di lama + -- se trovata faccia rivolta verso Z- if nFlatFaceNeg then - -- se >= a 3 facce sicuramente è gruppo 3 o 4, setto il ribaltamento senza ulteriori controlli - if nFacetCnt >= 3 then + -- se 3 o più facce sicuramente è in mezzo, setto il ribaltamento senza ulteriori controlli + if Proc.Fct >= 3 then bDown = true - -- altrimenti faccio controllo di lavorabilità da sotto e setto eventuale ribaltamento - -- ( può essere gruppi 1 o 2, oppure gruppo 3 o 4 ma spostati verso le teste) + -- altrimenti è in testa o coda e verifico se lavorabile da sotto else -- prendo le dimensioni della faccia - local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFlatFaceNeg, GDB_ID.ROOT) - local nOtherFace = EgtIf( nFlatFaceNeg == 0, nFlatFaceNeg + 1, nFlatFaceNeg - 1) + local nOtherFace = 1 - nFlatFaceNeg local bAdj , ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFlatFaceNeg, nOtherFace, GDB_ID.ROOT) -- se angolo tra le facce è maggiore di 90 non è raggiungibile dalla lama e non fattibile con truciolatore - -- quindi setto il ribaltamento - if dAng < 0 and dAng > -90 + 5 * GEO.EPS_SMALL then + if dAng > -89.99 and dAng < 0 then bDown = true + -- altrimenti, verifico se lunghezza faccia piatta è compatibile con il taglio di lama else - local dDist = dist( ptP1, ptP2) - local dLargeface - local dDeltadH = abs( dDist - dH) - local dDeltadV = abs( dDist - dV) - -- prendo la dimensione diversa dalla lunghezza di adiacenza - if dDeltadH < dDeltadV then - dLargeface = dV - else - dLargeface = dH - end - local bUseBlade = ( dLargeface <= BD.GetMaxLenRidgeLapFromBottom( b3Raw:getDimZ())) - local bUseRough = VerifyIfRoughMill( dLargeface, rfFac:getVersZ(), true) + local dLargeFace = Proc.Box:getDimX() + local bUseBlade = ( dLargeFace <= BD.GetMaxLenRidgeLapFromBottom( b3Raw:getDimZ())) + local bUseRough = VerifyIfRoughMill( dLargeFace, -Z_AX(), true) -- se forzato uso truciolatore if bForceUseRough then bDown = not bUseRough @@ -385,16 +351,16 @@ function ProcessDovetail.Classify( Proc, b3Raw) -- altrimenti controllo la componente in Z delle facce else local vtN = {} - for i = 1, nFacetCnt do - _, vtN[i] = EgtSurfTmFacetCenter( Proc.Id, i-1, GDB_ID.ROOT) + for i = 1, Proc.Fct do + vtN[i] = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT) end - for i = 1, nFacetCnt do - local nFacet = i-1 + for i = 1, Proc.Fct do + local nFacet = i - 1 -- se versore z è preponderante sulle altre componenti del vettore ed è verso il basso, - if abs(vtN[i]:getZ()) > abs(vtN[i]:getX()) and abs(vtN[i]:getZ()) > abs(vtN[i]:getY()) and vtN[i]:getZ() < -0.5 then + if abs( vtN[i]:getZ()) > abs( vtN[i]:getX()) and abs( vtN[i]:getZ()) > abs( vtN[i]:getY()) and vtN[i]:getZ() < -0.5 then -- se ho due facce e feature agli estremi verifico che la lunghezza faccia sia compatibile col taglio di lama -- o con truciolatore in base al valore del Q - if nFacetCnt == 2 and ( Proc.Head or Proc.Tail) then + if Proc.Fct == 2 and ( Proc.Head or Proc.Tail) then -- prendo le dimensioni della faccia local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT) local nOtherFace = EgtIf( nFacet == 0, nFacet + 1, nFacet - 1) @@ -446,9 +412,9 @@ function ProcessDovetail.Classify( Proc, b3Raw) end end end - elseif nFacetCnt == 3 and ( Proc.Head or Proc.Tail) then + elseif Proc.Fct == 3 and ( Proc.Head or Proc.Tail) then -- ordino le 3 facce: (1=altra intermedia, 2=interna, 3=intermedia) - local bOk1, sErr1, vFaceOrd = OrderFaces( Proc, nFacetCnt, vtN) + local bOk1, sErr1, vFaceOrd = OrderFaces( Proc, vtN) if not bOk1 then return bOk1 end -- se le due facce intermedie sono compatibili con la lunghezza lama da sotto -- prendo le dimensioni della facce @@ -475,12 +441,11 @@ function ProcessDovetail.Classify( Proc, b3Raw) end --------------------------------------------------------------------- -local function MakeCutsByDice( Proc, b3Raw, vCuts, nAddGrpId, bHead, vtRef, dFinalExtraTrim, dNullExtraTrim, dMiddleExtraTrim, sCutting, dSawDiam, dTrim) +local function MakeCutsByDice( Proc, b3Raw, vCuts, bHead, vtRef, dFinalExtraTrim, dNullExtraTrim, dMiddleExtraTrim, sCutting, dSawDiam, dTrim) -- sistemo posizione nel DB e nome for i = 1, #vCuts do for j = 1, #vCuts[i] do - EgtRelocateGlob( vCuts[i][j], nAddGrpId) EgtSetName( vCuts[i][j], 'AddCut_' .. tostring( Proc.Id)) EgtSetInfo( vCuts[i][j], 'TASKID', Proc.TaskId) end @@ -493,36 +458,23 @@ local function MakeCutsByDice( Proc, b3Raw, vCuts, nAddGrpId, bHead, vtRef, dFin if i % 2 == 1 then vtOrthoO = Vector3d( vtRef) else - if #vCuts[i-1] > 0 then - vtOrthoO = Vector3d( EgtIf( vtRef2, vtRef2, vtRef)) - else - local vtO - for j = 1, #vCuts[i-1] do - _, vtO = EgtSurfTmFacetCenter( vCuts[i-1][j], 0, GDB_ID.ROOT) - break - end - if vtO then - vtOrthoO = Vector3d( vtO) - else - vtOrthoO = Y_AX() - end - end + vtOrthoO = Vector3d( vtRef2) end local dExtraTrim = 0 -- lavoro la faccia for j = 1, #vCuts[i] do -- se ultimo taglio del penultimo gruppo o ultimo taglio dell'ultimo gruppo -- cioè non i tagli intermedi, aggiungo extratrim minimo - if ( ( i == (#vCuts-1)) or ( i == #vCuts)) and j == #vCuts[i] then + if ( i == ( #vCuts - 1) or i == #vCuts) and j == #vCuts[i] then dExtraTrim = dFinalExtraTrim -- se tagli non a contatto con le facce o tagli paralleli setto nessun extratrim - elseif i < (#vCuts-1) or (i == #vCuts) then + elseif i < ( #vCuts - 1) or i == #vCuts then dExtraTrim = dNullExtraTrim -- altrimenti tagli ortogonali a contatto con la faccia aggiungo extratrim else dExtraTrim = dMiddleExtraTrim end - local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, nil, -(dTrim+dExtraTrim), BD.CUT_SIC, 0, 0, nil, b3Raw) + local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, nil, -( dTrim + dExtraTrim), BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sErr end @@ -533,7 +485,7 @@ local function MakeCutsByDice( Proc, b3Raw, vCuts, nAddGrpId, bHead, vtRef, dFin end --------------------------------------------------------------------- -local function CutChainFacesByBlade( Proc, nCFaceSide, nCFaceInt1, nCFaceInt2, sCutting, bHead, vtRef, dTrim, dDepth) +local function MachChainFacesByBlade( Proc, nCFaceSide, nCFaceInt1, nCFaceInt2, sCutting, bHead, vtRef, dTrim, dDepth) -- inserisco la lavorazione di taglio per la laterale negativa local sName = 'Cut_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. EgtIf( nCFaceSide > 0, tostring( nCFaceSide) .. '_', '') .. tostring( nCFaceInt1) .. '-' .. tostring( nCFaceInt2) @@ -565,17 +517,17 @@ local function CutChainFacesByBlade( Proc, nCFaceSide, nCFaceInt1, nCFaceInt2, s end -- imposto attacco/uscita EgtSetMachiningParam( MCH_MP.LITANG, 0) - EgtSetMachiningParam( MCH_MP.LIPERP, 100) + EgtSetMachiningParam( MCH_MP.LIPERP, 180) EgtSetMachiningParam( MCH_MP.LOTANG, 0) - EgtSetMachiningParam( MCH_MP.LOPERP, 100) + EgtSetMachiningParam( MCH_MP.LOPERP, 180) local vtN1 = EgtSurfTmFacetNormVersor( Proc.Id, nCFaceInt1 - 1, GDB_ID.ROOT) local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, nCFaceInt2 - 1, GDB_ID.ROOT) local dNyMax = EgtIf( abs( vtN1:getY()) > abs( vtN2:getY()), vtN1:getY(), vtN2:getY()) local dNzMax = EgtIf( abs( vtN1:getZ()) > abs( vtN2:getZ()), vtN1:getZ(), vtN2:getZ()) - if dNzMax < 0 and dNyMax < 0 then + if dNzMax < 0 and bHead == ( dNyMax < 0) then EgtSetMachiningParam( MCH_MP.LITANG, 340) EgtSetMachiningParam( MCH_MP.LIPERP, -100) - elseif dNzMax < 0 and dNyMax > 0 then + elseif dNzMax < 0 and bHead == ( dNyMax > 0) then EgtSetMachiningParam( MCH_MP.LOTANG, 340) EgtSetMachiningParam( MCH_MP.LOPERP, -100) end @@ -593,39 +545,27 @@ local function CutChainFacesByBlade( Proc, nCFaceSide, nCFaceInt1, nCFaceInt2, s end --------------------------------------------------------------------- -local function MakeMachByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt) +local function MakeByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid) -- dati delle facce local ptC = {} local vtN = {} - for i = 1, nFacetCnt do + for i = 1, Proc.Fct do ptC[i], vtN[i] = EgtSurfTmFacetCenter( Proc.Id, i-1, GDB_ID.ROOT) end - -- recupero la geometria ausiliaria - local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') - if AuxId then AuxId = AuxId + Proc.Id end - -- ordino le facce, se 2 facce: (1=faccia ausiliaria, 2=interna, 3=intermedia) - -- ordino le facce, se 3 facce: (1=altra intermedia, 2=interna, 3=intermedia) - local bOk1, sErr1, vFaceOrd = OrderFaces( Proc, nFacetCnt, vtN) + local bOk1, sErr1, vFaceOrd = OrderFaces( Proc, vtN) if not bOk1 then return bOk1, sErr1 end - -- determino se di testa o di coda - local bHead - if vtN[vFaceOrd[2]] then - bHead = ( vtN[vFaceOrd[2]]:getX() > 0) - else - if AuxId then - local vtNx = EgtSurfTmFacetNormVersor( AuxId, 0, GDB_ID.ROOT) - bHead = ( vtNx:getX() > 0) - end - end + ---- determino se di testa o di coda + local bHead = ( vtN[vFaceOrd[2]]:getX() > 0) -- vettore di riferimento per le facce ortogonali all'asse trave local vtRef = Vector3d( 0, vtN[vFaceOrd[3]]:getY(), vtN[vFaceOrd[3]]:getZ()) vtRef:normalize() local vtRef2nd - if nFacetCnt > 2 and vFaceOrd[1] ~= 0 then + if Proc.Fct > 2 and vFaceOrd[1] ~= 0 then vtRef2nd = Vector3d( 0, vtN[vFaceOrd[1]]:getY(), vtN[vFaceOrd[1]]:getZ()) vtRef2nd:normalize() end + -- recupero la lavorazione local sCutting = ML.FindCutting( 'HeadSide') if not sCutting then @@ -643,46 +583,12 @@ local function MakeMachByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, dToolThick = EgtTdbGetCurrToolParam(MCH_TP.THICK) or dToolThick end end - -- recupero gruppo per geometria addizionale - local nAddGrpId = BL.GetAddGroup( nPartId) - if not nAddGrpId then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' - EgtOutLog( sErr) - return false, sErr - end - -- cerco se nelle note del layer c'è già la nota che indica che l'aux è già stato lavorato - local bAuxMachined = EgtGetInfo( nAddGrpId, 'AuxId.'..tostring(AuxId or 0), 'b') - -- taglio sulla faccia esterna - if AuxId and not bAuxMachined then - -- in generale va fatto - local bCut = true - local ptCAux, vtNAux = EgtSurfTmFacetCenter( AuxId, 0, GDB_ID.ROOT) - -- se di testa e coincide con inizio grezzo, non va fatto - if bHead and AreSameVectorApprox( vtNAux, X_AX()) and abs( ptCAux:getX() - b3Raw:getMax():getX() + dOvmHead) < 10 * GEO.EPS_SMALL then - bCut = false - end - -- se di coda e coincide con taglio di separazione, non va fatto - if not bHead and AreSameVectorApprox( vtNAux, - X_AX()) and abs( ptCAux:getX() - b3Raw:getMin():getX()) < BD.OVM_MID + 10 * GEO.EPS_SMALL then - bCut = false - end - -- se va fatto, inserisco la lavorazione - if bCut then - local CutProc = { Id = AuxId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) - -- se taglio applicato setto la nota al gruppo Mach per non doverla lavorare una seconda volta - if bOk then - bAuxMachined = true - EgtSetInfo( nAddGrpId, 'AuxId.'..tostring(AuxId or 0), true) - else - return bOk, sErr - end - end - end - -- calcolo da distanza di arretramento della lama per non incidere nelle superfici di arrivo dei tagli + + -- calcolo la distanza di arretramento della lama per non incidere nelle superfici di arrivo dei tagli -- se angolo tra le due facce ottuso la distanza può essere messa a 0 local dTrim local bTouch, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, vFaceOrd[3] - 1, vFaceOrd[2] - 1, GDB_ID.ROOT) - if bTouch and dAng < 0 and dAng > -90 - 5 * GEO.EPS_SMALL then + if bTouch and dAng < 0 and dAng > -89.9 then dTrim = 0 else dTrim = ((dToolThick* vtN[vFaceOrd[3]]) * vtN[vFaceOrd[2]] * vtN[vFaceOrd[2]]):len() @@ -690,137 +596,96 @@ local function MakeMachByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, local dFinalExtraTrim = 0.1 local dMiddleExtraTrim = 0.3 local dNullExtraTrim = 0 + + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end + -- se esistono faccia interna ed intermedia, verifico se richiedono taglio a cubetti local vCuts = {} if vFaceOrd[2] ~= 0 and vFaceOrd[3] ~= 0 then - vCuts = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC[vFaceOrd[3]], vtN[vFaceOrd[3]], false, ptC[vFaceOrd[2]], vtN[vFaceOrd[2]]) + vCuts = DC.GetDice( nAddGrpId, b3Solid, ptC[vFaceOrd[3]], vtN[vFaceOrd[3]], false, ptC[vFaceOrd[2]], vtN[vFaceOrd[2]]) elseif vFaceOrd[3] ~= 0 then - vCuts = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC[vFaceOrd[3]], vtN[vFaceOrd[3]], true) + vCuts = DC.GetDice( nAddGrpId, b3Solid, ptC[vFaceOrd[3]], vtN[vFaceOrd[3]], true) end if #vCuts > 0 then - local bOk, sErr = MakeCutsByDice( Proc, b3Raw, vCuts, nAddGrpId, bHead, vtRef, dFinalExtraTrim, dNullExtraTrim, dMiddleExtraTrim, sCutting, dSawDiam, dTrim) + local bOk, sErr = MakeCutsByDice( Proc, b3Raw, vCuts, bHead, vtRef, dFinalExtraTrim, dNullExtraTrim, dMiddleExtraTrim, sCutting, dSawDiam, dTrim) if not bOk then return false, sErr end end if vFaceOrd[1] ~= 0 then bTouch, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, vFaceOrd[1] - 1, vFaceOrd[2] - 1, GDB_ID.ROOT) - if bTouch and dAng < 0 and dAng > -90 - 5 * GEO.EPS_SMALL then + if bTouch and dAng < 0 and dAng > -89.9 then dTrim = 0 else dTrim = ((dToolThick* vtN[vFaceOrd[1]]) * vtN[vFaceOrd[2]] * vtN[vFaceOrd[2]]):len() end end + + -- se esistono faccia interna ed altra intermedia, verifico se richiedono taglio a cubetti local vCuts2 = {} if vFaceOrd[2] ~= 0 and vFaceOrd[1] ~= 0 then - vCuts2 = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC[vFaceOrd[1]], vtN[vFaceOrd[1]], false, ptC[vFaceOrd[2]], vtN[vFaceOrd[2]]) + vCuts2 = DC.GetDice( nAddGrpId, b3Solid, ptC[vFaceOrd[1]], vtN[vFaceOrd[1]], false, ptC[vFaceOrd[2]], vtN[vFaceOrd[2]]) elseif vFaceOrd[1] ~= 0 then - vCuts2 = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC[vFaceOrd[1]], vtN[vFaceOrd[1]], true) + vCuts2 = DC.GetDice( nAddGrpId, b3Solid, ptC[vFaceOrd[1]], vtN[vFaceOrd[1]], true) end if #vCuts2 > 0 then - local bOk, sErr = MakeCutsByDice( Proc, b3Raw, vCuts2, nAddGrpId, bHead, vtRef, dFinalExtraTrim, dNullExtraTrim, dMiddleExtraTrim, sCutting, dSawDiam, dTrim) + local bOk, sErr = MakeCutsByDice( Proc, b3Raw, vCuts2, bHead, vtRef, dFinalExtraTrim, dNullExtraTrim, dMiddleExtraTrim, sCutting, dSawDiam, dTrim) if not bOk then return false, sErr end end - -- se una parte non ha fatto tagli - if #vCuts == 0 or #vCuts2 == 0 then - -- taglio sulla faccia esterna - if AuxId and not bAuxMachined then - -- in generale va fatto - local bCut = true - local ptCAux, vtNAux = EgtSurfTmFacetCenter( AuxId, 0, GDB_ID.ROOT) - -- se di testa e coincide con inizio grezzo, non va fatto - if bHead and AreSameVectorApprox( vtNAux, X_AX()) and abs( ptCAux:getX() - b3Raw:getMax():getX() + dOvmHead) < 10 * GEO.EPS_SMALL then - bCut = false - end - -- se di coda e coincide con taglio di separazione, non va fatto - if not bHead and AreSameVectorApprox( vtNAux, - X_AX()) and abs( ptCAux:getX() - b3Raw:getMin():getX()) < BD.OVM_MID + 10 * GEO.EPS_SMALL then - bCut = false - end - -- se va fatto, inserisco la lavorazione - if bCut then - local CutProc = { Id = AuxId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) - -- se taglio applicato setto la nota al gruppo Mach per non doverla lavorare una seconda volta - if bOk then - bAuxMachined = true - EgtSetInfo( nAddGrpId, 'AuxId.'..tostring(AuxId or 0), true) - else - return bOk, sErr - end - end + + -- se non ha fatto nessun taglio a cubetti e ho 3 facce + if #vCuts == 0 and #vCuts2 == 0 and Proc.Fct > 2 then + -- lavoro la faccia interna (di fondo) indirettamente lavorando le due facce intermedie + local bOk, sErr = MachChainFacesByBlade( Proc, 0, vFaceOrd[3], vFaceOrd[1], sCutting, bHead, vtRef, ( dTrim + dFinalExtraTrim)) + if not bOk then return false, sErr end + -- taglio sulla faccia intermedia + if vFaceOrd[3] ~= 0 then + -- calcolo secondo testa o coda + local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) + -- inserisco la lavorazione + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, vtRef2, nil, -(dTrim + dFinalExtraTrim), BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then return bOk, sErr end end + -- taglio sulla seconda faccia intermedia + if vFaceOrd[1] ~= 0 then + -- calcolo secondo testa o coda + local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) + -- inserisco la lavorazione + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, vtRef2, nil, -(dTrim + dFinalExtraTrim), BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then return bOk, sErr end + end + -- se altrimenti non ha fatto una parte dei tagli a cubetti + elseif #vCuts == 0 and #vCuts2 == 0 then local bIntCut = false - -- se non ha fatto nessun taglio a cubetti e ho 3 facce - -- taglio sulla faccia interna ( concatenando le due facce intermedie e lama che contorna queste) - if #vCuts == 0 and #vCuts2 == 0 and nFacetCnt > 2 then - -- lavoro la faccia interna (di fondo) indirettamente lavorando le due facce intermedie - local bOk, sErr = CutChainFacesByBlade( Proc, 0, vFaceOrd[3], vFaceOrd[1], sCutting, bHead, vtRef, ( dTrim + dFinalExtraTrim)) - if not bOk then return false, sErr end - -- taglio sulla faccia intermedia - if vFaceOrd[3] ~= 0 then - -- calcolo secondo testa o coda - local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) - -- inserisco la lavorazione - local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, vtRef2, nil, -(dTrim + dFinalExtraTrim), BD.CUT_SIC, 0, 0, nil, b3Raw) - if not bOk then return bOk, sErr end - end - -- taglio sulla seconda faccia intermedia - if vFaceOrd[1] ~= 0 then - -- calcolo secondo testa o coda - local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) - -- inserisco la lavorazione - local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, vtRef2, nil, -(dTrim + dFinalExtraTrim), BD.CUT_SIC, 0, 0, nil, b3Raw) - if not bOk then return bOk, sErr end - end - else - if vFaceOrd[2] ~= 0 then - -- inserisco la lavorazione - local nDirVect = BL.GetNearestOrthoOpposite( vtRef) - local bOk, sNameOrErr - bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[2] - 1, sCutting, dSawDiam, nDirVect, nil, -(dTrim + dFinalExtraTrim), BD.CUT_SIC, 0, 0, nil, b3Raw) - if not bOk then return bOk, sNameOrErr end - if #sNameOrErr > 0 then bIntCut = true end - end - -- taglio sulla faccia intermedia - if vFaceOrd[3] ~= 0 then - -- calcolo secondo testa o coda - local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) - -- se non ho il taglio sulla faccia interna - if not bIntCut then - local frHV, DimH, DimV = BL.GetFaceHvRefDim( Proc.Id, vFaceOrd[3] - 1) - if DimV > DimH then - vtRef2 = Vector3d( frHV:getVersX()) - end + if vFaceOrd[2] ~= 0 then + -- inserisco la lavorazione + local nDirVect = BL.GetNearestOrthoOpposite( vtRef) + local bOk, sNameOrErr + bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[2] - 1, sCutting, dSawDiam, nDirVect, nil, -(dTrim + dFinalExtraTrim), BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then return bOk, sNameOrErr end + if #sNameOrErr > 0 then bIntCut = true end + end + -- taglio sulla faccia intermedia + if vFaceOrd[3] ~= 0 then + -- calcolo secondo testa o coda + local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) + -- se non ho il taglio sulla faccia interna + if not bIntCut then + local frHV, DimH, DimV = BL.GetFaceHvRefDim( Proc.Id, vFaceOrd[3] - 1) + if DimV > DimH then + vtRef2 = Vector3d( frHV:getVersX()) end - -- inserisco la lavorazione - local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, vtRef2, nil, -(dTrim + dFinalExtraTrim), BD.CUT_SIC, 0, 0, nil, b3Raw) - if not bOk then return bOk, sErr end end + -- inserisco la lavorazione + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, vtRef2, nil, -(dTrim + dFinalExtraTrim), BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then return bOk, sErr end end end - -- aggiornamento ingombro di testa o coda - if Proc.Head and AuxId then - local dHCI = 00 - -- se la feature è orientata sopra o sotto, la componente Z (del versore della faccia intermedia) è preponderante sulle altre 2 - if ( abs( vtN[vFaceOrd[3]]:getZ()) > abs( vtN[vFaceOrd[3]]:getX())) and ( abs( vtN[vFaceOrd[3]]:getZ()) > abs( vtN[vFaceOrd[3]]:getY())) then - local b3Fac1 = EgtGetBBoxGlob( AuxId, GDB_BB.STANDARD) - if b3Fac1 then dHCI = b3Raw:getMax():getX() - dOvmHead - b3Fac1:getMin():getX() end - -- altrimenti di fianco - else - dHCI = b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX() - end - BL.UpdateHCING( nRawId, dHCI) - elseif Proc.Tail and AuxId then - local dTCI = 0 - -- se la feature è orientata sopra o sotto, la componente Z (del versore della faccia intermedia) è preponderante sulle altre 2 - if ( abs( vtN[vFaceOrd[3]]:getZ()) > abs( vtN[vFaceOrd[3]]:getX())) and ( abs( vtN[vFaceOrd[3]]:getZ()) > abs( vtN[vFaceOrd[3]]:getY())) then - local b3Fac1 = EgtGetBBoxGlob( AuxId, GDB_BB.STANDARD) - if b3Fac1 then dTCI = b3Fac1:getMax():getX() - b3Solid:getMin():getX() end - -- altrimenti di fianco - else - dTCI = Proc.Box:getMax():getX() - b3Solid:getMin():getX() - end - BL.UpdateTCING( nRawId, dTCI) - end return true end @@ -870,7 +735,7 @@ local function MakeMillCut( Proc, i, j, k, sMilling, else -- aggiungo geometria e imposto uso faccia EgtSetMachiningGeometry( {{ Proc.Id, nFacInd}}) - local nFaceUse = BL.GetNearestOrthoOpposite( Vector3d( TabNAD[j][1]:getX(), 0, 0)) + local nFaceUse = BL.GetNearestOrthoOpposite( TabNAD[j][1]) EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) -- setto vettore direzione per posizione braccio porta testa vtDirRef = rfFac:getVersZ() @@ -903,8 +768,8 @@ local function MakeMillCut( Proc, i, j, k, sMilling, -- imposto gli attacchi EgtSetMachiningParam( MCH_MP.LEADINTYPE, 0) EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, 0) - EgtSetMachiningParam( MCH_MP.STARTADDLEN, ( dToolDiam * 0.75)) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, ( dToolDiam * 0.75)) + EgtSetMachiningParam( MCH_MP.STARTADDLEN, ( 60 + 0.5 * dToolDiam)) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, ( 60 + 0.5 * dToolDiam)) -- Note utente con dichiarazione nessuna generazione sfridi per Vmill solo in ultima passata in Z locale local sUserNotes if i < nStep then @@ -932,29 +797,29 @@ end local function MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, bUseBlade, bForceMakeMill, bUCut, bOCut, bJoinFaces, vFaceOrd, bHead, sMillingMaster, dToolDiamMaster, dMaxMatMaster, - dSideAngleMaster, dStepmachMaster, nMainFace, dElevMain) - + dSideAngleMaster, dMachStepMaster, nMainFace, dElevMain) local sWarn = '' local sMilling local dToolDiam = 100 - local dMaxMat = 50 local dSideAngle = 0 - local dStepmach = 0 + local dMaxMat = 50 + local dMaxDepth = 50 + local dMachStep = 0 local bUCutMax -- dati della facce local vtN = {} local ptC = {} for i = 1, nFacetCnt do - ptC[i], vtN[i] = EgtSurfTmFacetCenter( Proc.Id, i-1, GDB_ID.ROOT) + ptC[i], vtN[i] = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT) end -- se non ho passato la lavorazione ( già verificata) if not sMillingMaster then - -- se il flg del sottosquadra è nil, cerco se tra le facce c'è un angolo sottosquadra + -- se il flag del sottosquadra è nil, cerco se tra le facce c'è un angolo sottosquadra if bUCut == nil then for i = 1, nFacetCnt do - for j = i+1, nFacetCnt do + for j = i + 1, nFacetCnt do local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, (i-1), (j-1), GDB_ID.ROOT) - if bAdj and dAng and dAng < -90 - ( 10 * GEO.EPS_SMALL) then + if bAdj and dAng and dAng < -90.1 then bUCut = true break end @@ -974,29 +839,25 @@ local function MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, return false, sErr end -- recupero i dati dell'utensile - dToolDiam = 100 - dMaxMat = 50 - dSideAngle = 0 - dStepmach = 0 if EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam - dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat dSideAngle = EgtTdbGetCurrToolParam( MCH_TP.SIDEANG) or dSideAngle - -- ottengo il passo della lavorazione - dStepmach = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) or dStepmach + dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + dMachStep = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) or dMachStep end end - if dStepmach <= 0.1 then - dStepmach = dMaxMat * 0.5 + if dMachStep <= 0.1 then + dMachStep = dMaxMat * 0.5 end else sMilling = sMillingMaster dToolDiam = dToolDiamMaster dMaxMat = dMaxMatMaster dSideAngle = dSideAngleMaster - dStepmach = dStepmachMaster + dMachStep = dMachStepMaster end local nFacInd, dFacElev if nMainFace and dElevMain then @@ -1007,11 +868,11 @@ local function MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, if bJoinFaces then nFacInd = vFaceOrd[2] - 1 -- calcolo l'elevazione - local dLenIn, dLedOut = BL.GetPointDirDepth( nPartId, ptC[vFaceOrd[2]], vtN[vFaceOrd[2]]) + local dLenIn, dLenOut = BL.GetPointDirDepth( nPartId, ptC[vFaceOrd[2]], vtN[vFaceOrd[2]]) if dLenIn > 0 then dFacElev = dLenIn - elseif dLedOut then - dFacElev = dLedOut + elseif dLenOut then + dFacElev = dLenOut end else -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa @@ -1049,7 +910,7 @@ local function MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam - dToolThick = EgtTdbGetCurrToolParam(MCH_TP.THICK) or dToolThick + dToolThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dToolThick end end -- controllo versore faccia di riferimento, è lungo l'asse trave @@ -1080,7 +941,7 @@ local function MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, end -- inserisco la lavorazione local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtRef) - local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, (i-1), sCutting, dSawDiam, nOrthoOpposite, nil, -(dTrim + dExtraZed), BD.CUT_SIC, 0, 0, nil, b3Raw) + local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, ( i - 1), sCutting, dSawDiam, nOrthoOpposite, nil, -( dTrim + dExtraZed), BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sNameOrErr end bPrevByBlade = true end @@ -1106,7 +967,7 @@ local function MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, vtRef:normalize() end -- creo percorsi di lavorazione - local nStep = ceil( ( dFacElev - 10 * GEO.EPS_SMALL) / dStepmach) + local nStep = ceil( ( dFacElev - 10 * GEO.EPS_SMALL) / dMachStep) local dStep = dFacElev / nStep local dLargeVal local nLenSideMax @@ -1119,7 +980,7 @@ local function MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, local dDelta = 100000 local dElevface for j = 1, nFacetCnt do - if (j-1) ~= nFacInd then + if ( j - 1) ~= nFacInd then local dParzElev = dOffs -- calcolo la larghezza (solo 1 volta) if i == 1 then @@ -1129,11 +990,11 @@ local function MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, end if bJoinFaces then -- calcolo l'elevazione di ogni singola faccia dal punto medio - local dLenIn, dLedOut = BL.GetPointDirDepth( nPartId, ptC[j], vtN[j]) + local dLenIn, dLenOut = BL.GetPointDirDepth( nPartId, ptC[j], vtN[j]) if dLenIn > 0 then dElevface = dLenIn - elseif dLedOut then - dElevface = dLedOut + elseif dLenOut then + dElevface = dLenOut end if not dLargeVal or dElevface > dLargeVal then dLargeVal = dElevface @@ -1209,7 +1070,7 @@ local function MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, end -- se lato lavorato è il più lungo e la larghezza cava consente passi laterali extra if j == nLenSideMax and ( dLargeVal - dOffsSide) > dRefLarge then - local nStepSide = ceil( ( ( dLargeVal - dOffsSide - dRefLarge) - 10 * GEO.EPS_SMALL) / dToolDiam * 0.5) + local nStepSide = ceil( ( ( dLargeVal - dOffsSide - dRefLarge) - 10 * GEO.EPS_SMALL) / ( dToolDiam * 0.5)) local dStepSide = ( dLargeVal - dOffsSide - dRefLarge) / nStepSide for k = nStepSide, 1, -1 do local dAddOffsRad = ( k * dStepSide) + EgtIf( k == nStepSide, ( dToolDiam * 0.1), 0) @@ -1248,39 +1109,27 @@ local function MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, end --------------------------------------------------------------------- -local function Mach2Faces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt, bForceUseRough) +local function Make2Faces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, bForceUseRough) -- verifico le normali delle facce - -- individuo se c'è faccia rastremata verso Z- + -- individuo se c'è faccia rivolta verso Z- local nFlatFaceNeg local vtN = {} local ptC = {} - for i = 1, nFacetCnt do - ptC[i], vtN[i] = EgtSurfTmFacetCenter( Proc.Id, i-1, GDB_ID.ROOT) - if vtN[i]:getZ() < -1 + GEO.EPS_SMALL then - nFlatFaceNeg = i-1 + for i = 1, Proc.Fct do + ptC[i], vtN[i] = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT) + if vtN[i]:getZ() < -0.99 then + nFlatFaceNeg = i - 1 end end - -- se trovata faccia rastremata rivolta verso Z- faccio controllo di lavorabilità da sotto + -- se trovata faccia rivolta verso Z- faccio controllo di lavorabilità da sotto if nFlatFaceNeg then -- prendo le dimensioni della faccia - local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFlatFaceNeg, GDB_ID.ROOT) - local nOtherFace = EgtIf( nFlatFaceNeg == 0, nFlatFaceNeg + 1, nFlatFaceNeg - 1) - local bAdj , ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFlatFaceNeg, nOtherFace, GDB_ID.ROOT) - local dDist = dist( ptP1, ptP2) - local dLargeface - local dDeltadH = abs( dDist - dH) - local dDeltadV = abs( dDist - dV) - -- prendo la dimensione diversa dalla lunghezza di adiacenza - if dDeltadH < dDeltadV then - dLargeface = dV - else - dLargeface = dH - end - local bUseBlade = ( dLargeface <= BD.GetMaxLenRidgeLapFromBottom( b3Raw:getDimZ())) - local bUseRough, sMilling = VerifyIfRoughMill( dLargeface, rfFac:getVersZ(), true) + local dLargeFace = Proc.Box:getDimX() + local bUseBlade = ( dLargeFace <= BD.GetMaxLenRidgeLapFromBottom( b3Raw:getDimZ())) + local bUseRough, sMilling = VerifyIfRoughMill( dLargeFace, -Z_AX(), true) -- se non forzato truciolatore provo la lama if not bForceUseRough and bUseBlade then - return MakeMachByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt, bForceUseRough) + return MakeByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid) -- altrimenti provo con il truciolatore else -- se non ho la lavorazione esco @@ -1298,20 +1147,23 @@ local function Mach2Faces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Sol return false, sErr end -- Calcolo uso faccia - local nFaceUse = BL.GetNearestParalOpposite( rfFac:getVersZ()) + local nOtherInd = 2 - nFlatFaceNeg + local nFaceUse = BL.GetNearestParalOpposite( vtN[nOtherInd]) -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, nFlatFaceNeg}}) -- imposto uso faccia EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) - -- imposto posizione braccio porta testa - local nSCC = MCH_SCC.ADIR_YM - if rfFac:getVersZ():getY() > 100 * GEO.EPS_ZERO then - nSCC = MCH_SCC.ADIR_YP - end - EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- imposto inversione e lato correzione + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + -- annullo offset radiale + EgtSetMachiningParam( MCH_MP.OFFSR, 0) -- applico allungamento iniziale e finale EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0) EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0) + -- imposto posizione braccio porta testa + local nSCC = MCH_SCC.ADIR_YP + EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -1321,23 +1173,23 @@ local function Mach2Faces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Sol end -- altrimenti non ho faccia (antivento) da sotto else - for i = 1, nFacetCnt do - local nFacet = i-1 + for i = 1, Proc.Fct do + local nFacet = i - 1 -- se versore z è preponderante sulle altre componenti del vettore ed è verso il basso, - if abs(vtN[i]:getZ()) > abs(vtN[i]:getX()) and abs(vtN[i]:getZ()) > abs(vtN[i]:getY()) and vtN[i]:getZ() < -0.5 then + if abs( vtN[i]:getZ()) > abs( vtN[i]:getX()) and abs( vtN[i]:getZ()) > abs( vtN[i]:getY()) and vtN[i]:getZ() < -0.5 then -- lavoro con lama o truciolatore in base al Q -- prendo le dimensioni della faccia local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT) - local nOtherFace = EgtIf( nFacet == 0, nFacet + 1, nFacet - 1) + local nOtherFace = 1 - nFacet local bAdj , ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacet, nOtherFace, GDB_ID.ROOT) - local dLargeface = Proc.Box:getDimX() - local bUseBlade = ( dLargeface <= BD.GetMaxLenRidgeLapFromBottom( b3Raw:getDimZ())) + local dLargeFace = Proc.Box:getDimX() + local bUseBlade = ( dLargeFace <= BD.GetMaxLenRidgeLapFromBottom( b3Raw:getDimZ())) local bUCut = ( dAng < 0) and ( dAng < -90 - 5 * GEO.EPS_SMALL) local bOCut = ( dAng < 0) and ( dAng > -90 + 5 * GEO.EPS_SMALL) local bForceMakeMill = bUCut or bForceUseRough -- 2020.04.18 da indicazioni di Fabio Sq. : se angolo interno acuto lo lavoro con utensile a tronco di cono -- e, se consentito uso lama, preceduto anche due tagli antischeggia (solo in caso di 3 facce, con 2 facce disattivo gli antischeggia) - local bUseRough, sMilling, dToolDiam, dToolLength, dMaxDepth, dMaxMat, dSideAngle, dStepmach = VerifyIfRoughMill( dLargeface, X_AX(), true, EgtIf( bUCut, ( 90 + dAng), nil)) + local bUseRough, sMilling, dToolDiam, dToolLength, dMaxDepth, dMaxMat, dSideAngle, dMachStep = VerifyIfRoughMill( dLargeFace, X_AX(), true, EgtIf( bUCut, ( 90 + dAng), nil)) -- se devo farlo con fresatura if bForceMakeMill then -- se non ho lavorazione (se per esempio l'angolo di spoglia utensile non è uguale a quello tra le due facce) do errore @@ -1347,20 +1199,20 @@ local function Mach2Faces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Sol return false, sErr end -- genero lavorazioni - local bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, + local bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, Proc.Fct, bForceUseRough, bUseBlade, bForceMakeMill, bUCut, bOCut, false, nil, nil, sMilling, dToolDiam, dMaxMat, - dSideAngle, dStepmach, nOtherFace, dLargeface) + dSideAngle, dMachStep, nOtherFace, dLargeFace) if not bOk then return false, sErr end elseif bUseBlade then - local bOk, sErr = MakeMachByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt, bForceUseRough) + local bOk, sErr = MakeByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid) -- se fallita di lama e di fresa è fattibile, eseguo con la fresa if not bOk and sMilling then -- genero lavorazioni - bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, + bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, Proc.Fct, bForceUseRough, bUseBlade, true, bUCut, bOCut, false, nil, nil, sMilling, dToolDiam, dMaxMat, - dSideAngle, dStepmach, nOtherFace, dLargeface) + dSideAngle, dMachStep, nOtherFace, dLargeFace) if not bOk then return false, sErr end else return false, sErr @@ -1370,13 +1222,13 @@ local function Mach2Faces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Sol -- altrimenti non in Z negativa else -- se nessuna entità ha z negativa - if i == nFacetCnt then + if i == Proc.Fct then -- verifico angolo tra le facce local nOtherFace = nFacet - 1 local bAdj , ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacet, nOtherFace, GDB_ID.ROOT) - local dLargeface = Proc.Box:getDimX() - -- ordino le facce, se 2 facce: (1=faccia ausiliaria, 2=interna, 3=intermedia) - local bOk, sErr, vFaceOrd = OrderFaces( Proc, nFacetCnt, vtN) + local dLargeFace = Proc.Box:getDimX() + -- ordino le facce, se 2 facce: (1=0, 2=interna, 3=intermedia) + local bOk, sErr, vFaceOrd = OrderFaces( Proc, vtN) if not bOk then return bOk, sErr end local bUCut = ( dAng < 0) and ( dAng < -90 - 5 * GEO.EPS_SMALL) local bOCut = ( dAng < 0) and ( dAng > -90 + 5 * GEO.EPS_SMALL) @@ -1394,24 +1246,24 @@ local function Mach2Faces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Sol -- prendo l'elevazione sul punto medio della prima faccia local dLenIn, dLedOut = BL.GetPointDirDepth( nPartId, ptPs, vtN[vFaceOrd[2]]) if dLenIn > 0 then - dLargeface = dLenIn + dLargeFace = dLenIn elseif dLedOut then - dLargeface = dLedOut + dLargeFace = dLedOut end -- verifico la possibilità di lavorare con utensile - local bUseRough, sMilling, dToolDiam, dToolLength, dMaxDepth, dMaxMat, dSideAngle, dStepmach = VerifyIfRoughMill( dLargeface, vtN[vFaceOrd[2]], true) + local bUseRough, sMilling, dToolDiam, dToolLength, dMaxDepth, dMaxMat, dSideAngle, dMachStep = VerifyIfRoughMill( dLargeFace, vtN[vFaceOrd[2]], true) -- se ho trovato lavorazione applicata a faccia definita if sMilling then -- genero lavorazioni - bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, + bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, Proc.Fct, bForceUseRough, true, bForceMakeMill, bUCut, bOCut, false, nil, nil, sMilling, dToolDiam, dMaxMat, - dSideAngle, dStepmach, vFaceOrd[2]-1, dLargeface) + dSideAngle, dMachStep, vFaceOrd[2]-1, dLargeFace) end -- se fallito provo sempre con la lavorazione calcolata sull'elevazioe minima if not bOk then -- genero lavorazioni - bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, + bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, Proc.Fct, bForceUseRough, true, bForceMakeMill, bUCut, bOCut, false) end if not bOk then return false, sErr end @@ -1419,48 +1271,48 @@ local function Mach2Faces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Sol -- prendo l'elevazione sul punto medio della seconda faccia dLenIn, dLedOut = BL.GetPointDirDepth( nPartId, ptPs, vtN[vFaceOrd[3]]) if dLenIn > 0 then - dLargeface = dLenIn + dLargeFace = dLenIn elseif dLedOut then - dLargeface = dLedOut + dLargeFace = dLedOut end -- verifico la possibilità di lavorare con utensile - bUseRough, sMilling, dToolDiam, dToolLength, dMaxDepth, dMaxMat, dSideAngle, dStepmach = VerifyIfRoughMill( dLargeface, vtN[vFaceOrd[3]], true) + bUseRough, sMilling, dToolDiam, dToolLength, dMaxDepth, dMaxMat, dSideAngle, dMachStep = VerifyIfRoughMill( dLargeFace, vtN[vFaceOrd[3]], true) -- se ho trovato lavorazione applicata a faccia definita if sMilling then -- genero lavorazioni - bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, + bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, Proc.Fct, bForceUseRough, true, bForceMakeMill, bUCut, bOCut, false, nil, nil, sMilling, dToolDiam, dMaxMat, - dSideAngle, dStepmach, vFaceOrd[3]-1, dLargeface) + dSideAngle, dMachStep, vFaceOrd[3]-1, dLargeFace) end -- se fallito provo sempre con la lavorazione calcolata sull'elevazioe minima if not bOk then -- genero lavorazioni - bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, + bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, Proc.Fct, bForceUseRough, true, bForceMakeMill, bUCut, bOCut, false) end if not bOk then return false, sErr end else -- verifico la possibilità di lavorare con utensile (orizzontale) - local bUseRough, sMilling, dToolDiam, dToolLength, dMaxDepth, dMaxMat, dSideAngle, dStepmach = VerifyIfRoughMill( dLargeface, X_AX(), true, EgtIf( bUCut, ( 90 + dAng), nil)) + local bUseRough, sMilling, dToolDiam, dToolLength, dMaxDepth, dMaxMat, dSideAngle, dMachStep = VerifyIfRoughMill( dLargeFace, X_AX(), true, EgtIf( bUCut, ( 90 + dAng), nil)) -- se ho trovato lavorazione applicata a faccia definita if sMilling then -- genero lavorazioni - bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, + bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, Proc.Fct, bForceUseRough, true, bForceMakeMill, bUCut, bOCut, false, nil, nil, sMilling, dToolDiam, dMaxMat, - dSideAngle, dStepmach, vFaceOrd[2]-1, dLargeface) + dSideAngle, dMachStep, vFaceOrd[2]-1, dLargeFace) end -- se fallito provo sempre con la lavorazione calcolata sull'elevazioe minima if not bOk then -- genero lavorazioni - bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, + bOk, sErr = MachSideFaces( Proc, nPartId, b3Raw, Proc.Fct, bForceUseRough, true, bForceMakeMill, bUCut, bOCut, false) end if not bOk then return false, sErr end end else - return MakeMachByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt, bForceUseRough) + return MakeByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid) end end end @@ -1471,106 +1323,63 @@ local function Mach2Faces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Sol end --------------------------------------------------------------------- -local function MakeMachByMill( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt, bForceUseRough, bSkipHead) - -- settaggio flag adatti per il concatenamento delle facce intermedie - local bUseBlade = false - local bForceMakeMill = bForceUseRough - local bUCut = false - local bOCut = false - local bJoinFaces = true - local vFaceOrd - local bHead - -- dati delle facce - local vtN = {} - for i = 1, nFacetCnt do - _, vtN[i] = EgtSurfTmFacetCenter( Proc.Id, i-1, GDB_ID.ROOT) - end - if not bSkipHead then - -- recupero la geometria ausiliaria - local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') - if AuxId then AuxId = AuxId + Proc.Id end - -- ordino le facce, se 2 facce: (1=faccia ausiliaria, 2=interna, 3=intermedia) - -- ordino le facce, se 3 facce: (1=altra intermedia, 2=interna, 3=intermedia) - local bOk1, sErr1 - bOk1, sErr1, vFaceOrd = OrderFaces( Proc, nFacetCnt, vtN) - if not bOk1 then return bOk1, sErr1 end - -- determino se di testa o di coda - if vtN[vFaceOrd[2]] then - bHead = ( vtN[vFaceOrd[2]]:getX() > 0) - else - if AuxId then - local vtNx = EgtSurfTmFacetNormVersor( AuxId, 0, GDB_ID.ROOT) - bHead = ( vtNx:getX() > 0) - end - end - -- recupero la lavorazione per lavorare la geometria ausiliaria - local sCutting = ML.FindCutting( 'HeadSide') - if not sCutting then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library' - EgtOutLog( sErr) - return false, sErr - end - -- recupero i dati dell'utensile - local dSawDiam = 400 - local dToolThick = 0 - if EgtMdbSetCurrMachining( sCutting) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam - dToolThick = EgtTdbGetCurrToolParam(MCH_TP.THICK) or dToolThick - end - end - -- recupero gruppo per geometria addizionale - local nAddGrpId = BL.GetAddGroup( nPartId) - if not nAddGrpId then - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' - EgtOutLog( sErr) - return false, sErr - end - -- cerco se nelle note del layer c'è già la nota che indica che l'aux è già stato lavorato - local bAuxMachined = EgtGetInfo( nAddGrpId, 'AuxId.'..tostring( AuxId or 0), 'b') - -- taglio sulla faccia esterna - if AuxId and not bAuxMachined then - -- in generale va fatto - local bCut = true - local ptCAux, vtNAux = EgtSurfTmFacetCenter( AuxId, 0, GDB_ID.ROOT) - -- se di testa e coincide con inizio grezzo, non va fatto - if bHead and AreSameVectorApprox( vtNAux, X_AX()) and abs( ptCAux:getX() - b3Raw:getMax():getX() + dOvmHead) < 10 * GEO.EPS_SMALL then - bCut = false - end - -- se di coda e coincide con taglio di separazione, non va fatto - if not bHead and AreSameVectorApprox( vtNAux, - X_AX()) and abs( ptCAux:getX() - b3Raw:getMin():getX()) < BD.OVM_MID + 10 * GEO.EPS_SMALL then - bCut = false - end - -- se va fatto, inserisco la lavorazione - if bCut then - local CutProc = { Id = AuxId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail} - local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) - -- se taglio applicato setto la nota al gruppo Mach per non doverla lavorare una seconda volta - if bOk then - bAuxMachined = true - EgtSetInfo( nAddGrpId, 'AuxId.'..tostring(AuxId or 0), true) - else - return bOk, sErr - end - end - end - -- altrimenti non sono di testa - else - -- abilito la lama per i tagli antischeggia - bUseBlade = true - -- abilito la fresatura - bForceMakeMill = true - -- disabilito il concatenamento delle facce intermedie - bJoinFaces = false - -- annullo il flag del sottosquadra per forzare la ricerca all'interno della funzione - bUCut = nil - end - -- lavoro le restanti facce - return MachSideFaces( Proc, nPartId, b3Raw, nFacetCnt, bForceUseRough, - bUseBlade, bForceMakeMill, bUCut, bOCut, bJoinFaces, - vFaceOrd, bHead) +local function MakeAuxCut( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid) + -- recupero la geometria ausiliaria + local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') + if not AuxId then return true end + AuxId = AuxId + Proc.Id + -- recupero il centro e la normale della faccia ausiliaria + local ptC, vtN = EgtSurfTmFacetCenter( AuxId, 0, GDB_ID.ROOT) + if not vtN then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' wrong Normal of AuxSurface' + EgtOutLog( sErr) + return false, sErr + end + -- verifico se di testa o coda + local bHead = ( vtN:getX() > 0) + -- recupero la lavorazione per la geometria ausiliaria + local sCutting = ML.FindCutting( 'HeadSide') + if not sCutting then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + local dSawDiam = 400 + local dToolThick = 0 + if EgtMdbSetCurrMachining( sCutting) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam + dToolThick = EgtTdbGetCurrToolParam(MCH_TP.THICK) or dToolThick + end + end + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end + -- verifico se già fatto con altro componente della stessa feature + local bAuxMachined = EgtGetInfo( nAddGrpId, 'AuxId.'..tostring( AuxId), 'b') + if bAuxMachined then return true end + -- verifico se coincide con taglio di testa + if bHead and AreSameVectorApprox( vtN, X_AX()) and abs( ptC:getX() - b3Raw:getMax():getX() + dOvmHead) < 10 * GEO.EPS_SMALL then + return true + end + -- verifico se coincide con taglio di coda + if not bHead and AreSameVectorApprox( vtN, - X_AX()) and abs( ptC:getX() - b3Raw:getMin():getX()) < BD.OVM_MID + 10 * GEO.EPS_SMALL then + return true + end + -- inserisco la lavorazione + local CutProc = { Id = AuxId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail} + local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0) + if not bOk then return bOk, sErr end + -- imposto la nota nel gruppo aggiuntivo di lavorazione per evitare di tagliare una seconda volta + EgtSetInfo( nAddGrpId, 'AuxId.'..tostring(AuxId or 0), true) + return true end --------------------------------------------------------------------- @@ -1589,7 +1398,7 @@ local function MachUFaces( Proc, nPartId, b3Raw, vtN, ptC, nSidePosFct, nMiddleF local dToolDiam = 100 local dMaxMat = 50 local dSideAngle = 0 - local dStepmach = 0 + local dMachStep = 0 if EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then @@ -1597,25 +1406,25 @@ local function MachUFaces( Proc, nPartId, b3Raw, vtN, ptC, nSidePosFct, nMiddleF dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat dSideAngle = EgtTdbGetCurrToolParam( MCH_TP.SIDEANG) or dSideAngle -- ottengo il passo della lavorazione - dStepmach = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) or dStepmach + dMachStep = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) or dMachStep end end - if dStepmach <= 0.1 then - dStepmach = dMaxMat * 0.5 + if dMachStep <= 0.1 then + dMachStep = dMaxMat * 0.5 end local nFacInd = nMiddleFct - 1 local dFacElev -- calcolo elevazione - local dLenIn, dLedOut = BL.GetPointDirDepth( nPartId, ptC[nMiddleFct], vtN[nMiddleFct]) + local dLenIn, dLenOut = BL.GetPointDirDepth( nPartId, ptC[nMiddleFct], vtN[nMiddleFct]) if dLenIn > 0 then dFacElev = dLenIn - elseif dLedOut then - dFacElev = dLedOut + elseif dLenOut then + dFacElev = dLenOut end local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) local TabNAD = {} TabNAD[nMiddleFct] = { vtN[nMiddleFct]} - local bTouch, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, (nSideNegFct-1), GDB_ID.ROOT) + local bTouch, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, ( nSideNegFct or 0) - 1, GDB_ID.ROOT) if dAng then TabNAD[nSideNegFct] = { vtN[nSideNegFct], dAng, dist( ptP1, ptP2)} end @@ -1624,7 +1433,7 @@ local function MachUFaces( Proc, nPartId, b3Raw, vtN, ptC, nSidePosFct, nMiddleF TabNAD[nSidePosFct] = { vtN[nSidePosFct], dAng, dist( ptP1, ptP2)} end -- creo percorsi di lavorazione - local nStep = ceil( ( dFacElev - 10 * GEO.EPS_SMALL) / dStepmach) + local nStep = ceil( ( dFacElev - 10 * GEO.EPS_SMALL) / dMachStep) local dStep = dFacElev / nStep local dLargeVal local nLenSideMax @@ -1659,7 +1468,7 @@ local function MachUFaces( Proc, nPartId, b3Raw, vtN, ptC, nSidePosFct, nMiddleF dOffsSide = dOffsSide + ( tan( 90 + TabNAD[j][2]) * dParzElev) end end - local dRefLarge = ( 2 * dToolDiam) + local dRefLarge = EgtIf( nSideNegFct, ( 2 * dToolDiam), dToolDiam) -- se la larghezza è più grande dell'utensile allora posso lavorare il passo if ( dLargeVal - dOffsSide) >= dToolDiam then for j = 1, nFacetCnt do @@ -1668,7 +1477,7 @@ local function MachUFaces( Proc, nPartId, b3Raw, vtN, ptC, nSidePosFct, nMiddleF local dOffrRad = ( tan( 90 + TabNAD[j][2]) * dOffs) -- se lato lavorato è il più lungo e la larghezza cava consente passi laterali extra if j == nLenSideMax and ( dLargeVal - dOffsSide) > dRefLarge then - local nStepSide = ceil( ( ( dLargeVal - dOffsSide - dRefLarge) - 10 * GEO.EPS_SMALL) / dToolDiam * 0.5) + local nStepSide = ceil( ( ( dLargeVal - dOffsSide - dRefLarge) - 10 * GEO.EPS_SMALL) / dToolDiam * EgtIf( nSideNegFct, 0.5, 1)) local dStepSide = ( dLargeVal - dOffsSide - dRefLarge) / nStepSide for k = nStepSide, 1, -1 do local dAddOffsRad = ( k * dStepSide) + EgtIf( k == nStepSide, ( dToolDiam * 0.1), 0) @@ -1706,21 +1515,21 @@ local function MachUFaces( Proc, nPartId, b3Raw, vtN, ptC, nSidePosFct, nMiddleF end --------------------------------------------------------------------- -local function MakeMoreFces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt, bForceUseRough, bUseBlade) +local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, bForceUseRough, bUseBlade) local ptC = {} local vtN = {} -- dati delle facce e ordinamento facce { } - for i = 1, nFacetCnt do + for i = 1, Proc.Fct do ptC[i], vtN[i] = EgtSurfTmFacetCenter( Proc.Id, i-1, GDB_ID.ROOT) end - -- ordino le 4 facce: ( 1=laterale positiva 2=altra intermedia, 3=intermedia, 4=laterale negativa) - local bOk1, sErr1, vFaceOrd = OrderFaces( Proc, nFacetCnt, vtN) - if not bOk1 then return bOk1 end + -- ordino le 4 facce : ordine (1=altra intermedia, 2=interna, 3=intermedia, 4=esterna) + local bOk1, sErr1, vFaceOrd = OrderFaces( Proc, vtN) + if not bOk1 then return bOk1, sErr1 end -- vettori di riferimento per le facce ortogonali all'asse trave local vtRef = Vector3d( 0, vtN[vFaceOrd[3]]:getY(), vtN[vFaceOrd[3]]:getZ()) vtRef:normalize() - local vtRef2nd = Vector3d( 0, vtN[vFaceOrd[2]]:getY(), vtN[vFaceOrd[2]]:getZ()) + local vtRef2nd = Vector3d( 0, vtN[vFaceOrd[1]]:getY(), vtN[vFaceOrd[1]]:getZ()) vtRef2nd:normalize() -- se non forzato uso truciolatore e abilitato il taglio di lama faccio le due pareti con antischeggia -- lavoro le facce laterali indirettamente lavorando le due facce intermedie @@ -1746,25 +1555,25 @@ local function MakeMoreFces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3S -- se ho la faccia laterale negativa if vFaceOrd[4] ~= 0 then -- inserisco la lavorazione di taglio per la faccia laterale negativa, faccio in modo che la testa rimanga nella stessa posizione per entrambe i tagli - local bOk, sErr = CutChainFacesByBlade( Proc, vFaceOrd[4], vFaceOrd[3], vFaceOrd[2], sCutting, true, vtRef, dTrim, dToolThick) + local bOk, sErr = MachChainFacesByBlade( Proc, vFaceOrd[4], vFaceOrd[3], vFaceOrd[1], sCutting, true, vtRef, dTrim, dToolThick) if not bOk then return false, sErr end end -- se ho la faccia laterale positiva - if vFaceOrd[1] ~= 0 then + if vFaceOrd[2] ~= 0 then -- inserisco la lavorazione di taglio per la faccia laterale positiva - local bOk, sErr = CutChainFacesByBlade( Proc, vFaceOrd[1], vFaceOrd[3], vFaceOrd[2], sCutting, true, vtRef, dTrim) + local bOk, sErr = MachChainFacesByBlade( Proc, vFaceOrd[2], vFaceOrd[3], vFaceOrd[1], sCutting, true, vtRef, dTrim) if not bOk then return false, sErr end end end -- lavoro le facce intermedie if vFaceOrd[3] ~= 0 then -- inserisco la lavorazione di fresatura per la faccia intermedia - local bOk, sErr = MachUFaces( Proc, nPartId, b3Raw, vtN, ptC, vFaceOrd[1], vFaceOrd[3], vFaceOrd[4], vtRef, nFacetCnt) + local bOk, sErr = MachUFaces( Proc, nPartId, b3Raw, vtN, ptC, vFaceOrd[2], vFaceOrd[3], vFaceOrd[4], vtRef, Proc.Fct) if not bOk then return false, sErr end end - if vFaceOrd[2] ~= 0 then + if vFaceOrd[1] ~= 0 then -- inserisco la lavorazione di fresatura per la faccia intermedia - local bOk, sErr = MachUFaces( Proc, nPartId, b3Raw, vtN, ptC, vFaceOrd[1], vFaceOrd[2], vFaceOrd[4], vtRef, nFacetCnt) + local bOk, sErr = MachUFaces( Proc, nPartId, b3Raw, vtN, ptC, vFaceOrd[2], vFaceOrd[1], vFaceOrd[4], vtRef, Proc.Fct) if not bOk then return false, sErr end end @@ -1772,19 +1581,74 @@ local function MakeMoreFces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3S end --------------------------------------------------------------------- -local function Mach_3_MoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt, bForceUseRoughm, bSkipHead) - - -- se non sono in testa o coda - if bSkipHead then - local bUseBlade = true - return MakeMoreFces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt, bForceUseRough, bUseBlade) - else - if bForceUseRough then - return MakeMachByMill( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt, bForceUseRough) - else - return MakeMachByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt) +local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, bForceUseRough, bInMiddle) + -- flag per lavorazioni sulla testa o coda + local bUseBlade = false + local bForceMakeMill = bForceUseRough + local bUCut = false + local bOCut = false + local bJoinFaces = true + -- modifiche ai flag per lavorazione in mezzo + if bInMiddle then + -- abilito la lama per i tagli antischeggia + bUseBlade = true + -- abilito la fresatura + bForceMakeMill = true + -- disabilito il concatenamento delle facce intermedie + bJoinFaces = false + -- annullo il flag del sottosquadra per forzare la ricerca all'interno della funzione + bUCut = nil + end + -- dati delle facce + local ptC = {} + local vtN = {} + for i = 1, Proc.Fct do + ptC[i], vtN[i] = EgtSurfTmFacetCenter( Proc.Id, i-1, GDB_ID.ROOT) + end + -- ordino le facce, se 3 facce: (1=altra intermedia, 2=interna, 3=intermedia) + local bOk1, sErr1, vFaceOrd = OrderFaces( Proc, vtN) + if not bOk1 then return bOk1, sErr1 end + -- verifica se di testa o coda + local bHead = false + if not bInMiddle then + bHead = ( vtN[vFaceOrd[2]]:getX() > 0) + end + -- se non in mezzo può essere necessario lavorare come in mezzo + if not bInMiddle then + -- calcolo l'elevazione + local dSideElev = 0 + local dLenIn, dLenOut = BL.GetPointDirDepth( nPartId, ptC[vFaceOrd[2]], vtN[vFaceOrd[2]]) + if dLenIn > 0 then + dSideElev = dLenIn + elseif dLenOut then + dSideElev = dLenOut + end + -- determino il massimo affondamento con l'utensile + local sMchFind = 'Long2Cut' + sMilling = ML.FindMilling( sMchFind) + if not sMilling then + local sErr = 'Milling not found in library : Error on Dovetail ' .. tostring( Proc.Id) + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + local dMaxDepth = 10 + if EgtMdbSetCurrMachining( sMilling) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end + -- se l'elevazione supera l'affondamento, lavoro perpendicolare all'asse trave + if dSideElev > dMaxDepth then + return MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, bForceUseRough, bUseBlade) end end + + -- lavoro le restanti facce in modo standard + return MachSideFaces( Proc, nPartId, b3Raw, Proc.Fct, bForceUseRough, + bUseBlade, bForceMakeMill, bUCut, bOCut, bJoinFaces, + vFaceOrd, bHead) end --------------------------------------------------------------------- @@ -1795,7 +1659,7 @@ function ProcessDovetail.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- in base al tipo di feature attribuisco il significato dei parametri Q AssignQValues( Proc) -- verifico se sono presenti i parametri Q per l'uso forzato del truciolatore - local _, bForceUseRough = EvaluateQParam( Proc, sUseRoughTool) + local bForceUseRough = EvaluateQParam( Proc, sUseRoughTool) -- ingombro del pezzo local Ls = EgtGetFirstNameInGroup( nPartId, 'Box') local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD) @@ -1805,22 +1669,50 @@ function ProcessDovetail.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) return false, sErr end -- verifico che ci siano almeno due facce (altrimenti non è da lavorare) - local nFacetCnt = EgtSurfTmFacetCount( Proc.Id) - if nFacetCnt < 2 then + if Proc.Fct < 2 then local sErr = 'Not executed ' .. tostring( Proc.Id) .. ' number of faces not enough' EgtOutLog( sErr) return false, sErr end - -- se ho due facce ( allora è di testa) - if nFacetCnt == 2 then - return Mach2Faces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt, bForceUseRough) - -- altrimenti se ha 3 facce ma è di testa - elseif nFacetCnt == 3 and ( Proc.Head or Proc.Tail) then - return Mach_3_MoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt, bForceUseRough) - elseif nFacetCnt == 3 then - return MakeMachByMill( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt, bForceUseRough, true) + + -- se ha due facce ( allora è di testa o coda) + if Proc.Fct == 2 then + -- eventuale taglio di testa o coda + local bAuxOk, sAuxErr = MakeAuxCut( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid) + if not bAuxOk then return bAuxOk, sAuxErr end + -- lavorazione della feature + local bOk, sErr = Make2Faces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, bForceUseRough) + if not bOk then return bOk, sErr end + -- se ha 3 facce ed è di testa o coda + elseif Proc.Fct == 3 and ( Proc.Head or Proc.Tail) then + -- eventuale taglio di testa o coda + local bAuxOk, sAuxErr = MakeAuxCut( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid) + if not bAuxOk then return bAuxOk, sAuxErr end + -- lavorazione della feature + if bForceUseRough then + local bOk, sErr = MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, bForceUseRough) + if not bOk then return bOk, sErr end + else + local bOk, sErr = MakeByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid) + if not bOk then return bOk, sErr end + end + -- se ha 3 facce (e interna) + elseif Proc.Fct == 3 then + local bOk, sErr = MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, bForceUseRough, true) + if not bOk then return bOk, sErr end + -- altrimenti 4 facce (e interna) else - return Mach_3_MoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt, bForceUseRough, true) + local bOk, sErr = MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, bForceUseRough, true) + if not bOk then return bOk, sErr end + end + + -- aggiornamento ingombro di testa o coda + if Proc.Head then + local dHCI = b3Solid:getMax():getX() - Proc.Box:getMin():getX() + BL.UpdateHCING( nRawId, dHCI) + elseif Proc.Tail then + local dTCI = Proc.Box:getMax():getX() - b3Solid:getMin():getX() + BL.UpdateTCING( nRawId, dTCI) end return true diff --git a/LuaLibs/ProcessFrenchRidgeLap.lua b/LuaLibs/ProcessFrenchRidgeLap.lua index 824d3cc..7d81804 100644 --- a/LuaLibs/ProcessFrenchRidgeLap.lua +++ b/LuaLibs/ProcessFrenchRidgeLap.lua @@ -249,7 +249,7 @@ function ProcessFrenchRidgeLap.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- aggiornamento ingombro di testa o coda if Proc.Head then - local dHCI = 00 + local dHCI = 0 -- se la feature è orientata sopra o sotto, la componente Z (del versore della faccia intermedia) è preponderante sulle altre 2 if ( abs( vtN[vFaceOrd[3]]:getZ()) > abs( vtN[vFaceOrd[3]]:getX())) and ( abs( vtN[vFaceOrd[3]]:getZ()) > abs( vtN[vFaceOrd[3]]:getY())) then local b3Fac1 = EgtSurfTmGetFacetBBoxGlob( Proc.Id, vFaceOrd[1] - 1, GDB_BB.STANDARD) diff --git a/LuaLibs/ProcessTyroleanDovetail.lua b/LuaLibs/ProcessTyroleanDovetail.lua index 23190aa..d1d8125 100644 --- a/LuaLibs/ProcessTyroleanDovetail.lua +++ b/LuaLibs/ProcessTyroleanDovetail.lua @@ -1,4 +1,4 @@ --- ProcessTyroleanDovetail.lua by Egaltech s.r.l. 2020/04/23 +-- ProcessTyroleanDovetail.lua by Egaltech s.r.l. 2020/04/28 -- Gestione calcolo giunzione tirolese -- Tabella per definizione modulo @@ -17,18 +17,7 @@ local BD = require( 'BeamData') local ML = require( 'MachiningLib') -- variabili assegnazione parametri Q -local sForceUseBlade = '' -- i -local sDepthChamferMill = '' -- d -local sPreemptiveChamfer = '' -- i -local sUseMill = '' -- i -local sUseRoughTool = '' -- i -local sUseRoughToolWithBAxis90 = '' -- i -local sUseRoughToolWithBAxis0 = '' -- i -local sInsertBoreOnCorner = '' -- 1 -local sMakeContourWithSmallTool = '' -- i -local sMakeOnlyContourOrFullPocket = '' -- i -local sMakeBySideRoughTool = '' -- i -local sAntisplintMode = '' -- i +local sDepthChamferMill = '' -- d --------------------------------------------------------------------- -- Riconoscimento della feature @@ -40,21 +29,10 @@ end local function AssignQValues( Proc) -- reset delle variabili assegnazione parametri Q - sForceUseBlade = '' - sDepthChamferMill = '' - sPreemptiveChamfer = '' - sUseMill = '' - sUseRoughTool = '' - sUseRoughToolWithBAxis90 = '' - sUseRoughToolWithBAxis0 = '' - sInsertBoreOnCorner = '' - sMakeContourWithSmallTool = '' - sMakeOnlyContourOrFullPocket = '' - sMakeBySideRoughTool = '' - sAntisplintMode = '' + sDepthChamferMill = '' if Proc.Prc == 136 then - sDepthChamferMill = 'Q01' -- d + sDepthChamferMill = 'Q01' -- d end end @@ -147,8 +125,6 @@ end --------------------------------------------------------------------- local function EvaluateQParam( Proc, sDephtCham) local nChamfer = 0 - local bForceUseBlade = false - local sErr -- verifico che lo smusso sia richiesto local dDepth = EgtGetInfo( Proc.Id, sDephtCham, 'd') or 0 if dDepth > 0 then @@ -541,7 +517,7 @@ local function MakeMachByMill( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b end -- verifico se sono presenti i parametri Q per la profondità smusso e -- per eseguire in esclusiva solo lo smusso - local nChamfer, dDepthCham, sErrCham = EvaluateQParam( Proc, sDepthChamferMill) + local nChamfer, dDepthCham = EvaluateQParam( Proc, sDepthChamferMill) -- dati della faccia local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) @@ -711,9 +687,20 @@ function ProcessTyroleanDovetail.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- se ho due facce allora è di testa if nFacetCnt == 2 then - return MakeMachByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt) + local bOk, sErr = MakeMachByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt) + if not bOk then return bOk, sErr end else - return MakeMachByMill( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt) + local bOk, sErr = MakeMachByMill( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Raw, b3Solid, nFacetCnt) + if not bOk then return bOk, sErr end + end + + -- aggiornamento ingombro di testa o coda + if Proc.Head then + local dHCI = b3Solid:getMax():getX() - Proc.Box:getMin():getX() + BL.UpdateHCING( nRawId, dHCI) + elseif Proc.Tail then + local dTCI = Proc.Box:getMax():getX() - b3Solid:getMin():getX() + BL.UpdateTCING( nRawId, dTCI) end return true