-- ProcessStepJointNotch.lua by Egaltech s.r.l. 2022/11/03 -- Gestione calcolo tacca a gradino per Travi -- 2022/11/03 Correzione per riconoscimento testa da sotto su fresatura. -- 2024/06/28 In MakeFourFaces aggiunta copia del parametro PartId sulla nuova Proc -- Tabella per definizione modulo local ProcessStepJointNotch = {} -- Include require( 'EgtBase') local BL = require( 'BeamLib') local Fbs = require( 'FacesBySaw') local DC = require( 'DiceCut') local Cut = require( 'ProcessCut') local Topology = require( 'FeatureTopology') local LapJoint = require( 'ProcessLapJoint') EgtOutLog( ' ProcessStepJointNotch started', 1) -- Dati local BD = require( 'BeamData') local ML = require( 'MachiningLib') --------------------------------------------------------------------- -- Riconoscimento della feature function ProcessStepJointNotch.Identify( Proc) return ( ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 80) end --------------------------------------------------------------------- -- Verifica se feature di testa function ProcessStepJointNotch.IsHeadFeature( Proc, b3Raw, dCurrOvmH) return false end --------------------------------------------------------------------- -- Verifica se feature di coda function ProcessStepJointNotch.IsTailFeature( Proc, b3Raw) -- recupero box del pezzo local nPartId = EgtGetParent( EgtGetParent( Proc.Id) or GDB_ID.NULL) local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) -- verifico se è in coda local dEndDist = Proc.Box:getMin():getX() - b3Solid:getMin():getX() return ( dEndDist < BD.MAX_DIST_HTFEA) end --------------------------------------------------------------------- -- Classificazione della feature function ProcessStepJointNotch.Classify( Proc) -- numero delle facce local nFacetCnt = EgtSurfTmFacetCount( Proc.Id) -- gestisco solo 2 o 4 facce if nFacetCnt ~= 2 and nFacetCnt ~= 3 and nFacetCnt ~= 4 and nFacetCnt ~= 6 and nFacetCnt ~= 8 then return false, false end -- verifico le normali delle facce local bDown = false for i = 1, nFacetCnt do local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i-1, GDB_ID.ROOT) -- se faccia limite la salto if AreSameOrOppositeVectorApprox( vtN, Y_AX()) or AreSameOrOppositeVectorApprox( vtN, Z_AX()) then -- attualmente non gestita -- altrimenti faccia principale elseif vtN:getZ() < -0.1 then bDown = true end end return true, bDown end --------------------------------------------------------------------- local function MachineByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Solid, ptC, vtN, nBigInd, nSmaInd, bOnY, ptPs, b3Raw, dAng) -- delta negativo affondamento lama local dExtraUp = -0.3 -- abilitazione lavorazione da sotto (testa da sotto e direzione normale sotto -30deg) local bTopHead = ( BD.DOWN_HEAD and vtN[nBigInd]:getZ() > -0.5) local bDownHead = ( BD.DOWN_HEAD and vtN[nBigInd]:getZ() < -0.5) -- recupero la lavorazione local sCutType = 'HeadSide' local sCutting sCutting, bDownHead = ML.FindCutting( sCutType, bTopHead, bDownHead) if not sCutting then local sErr = 'Error : cutting not found in library' EgtOutLog( sErr) return false, sErr end -- recupero i dati dell'utensile local dSawDiam = 400 local dMaxDepth = 0 local dSawThick = 5 if EgtMdbSetCurrMachining( sCutting) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThick end end -- calcolo extra taglio local dCutExtra = dExtraUp if dAng < -90.5 and dAng > -179.5 then dCutExtra = - dSawThick / tan( 180 + dAng) + dExtraUp end -- recupero gruppo per geometria addizionale local nAddGrpId = BL.GetAddGroup( nPartId) if not nAddGrpId then local sErr = 'Error : missing AddGroup' EgtOutLog( sErr) return false, sErr end -- tagli delle facce local bOk, sErr = Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, 'HeadSide' .. EgtIf( bDownHead, '_H2', ''), nil, bDownHead) if not bOk then return bOk, sErr end return true end --------------------------------------------------------------------- local function MakePocket( Proc, nPartId, ptPs, vtN, nFaceRef, nDiffWidth, sMchFind, nUseRoughTool, tBHx) -- calcolo il elevazione dal punto medio local dElev local dLenIn, dLedOut = BL.GetPointDirDepth( nPartId, ptPs, vtN[nFaceRef]) if dLenIn > 0 then dElev = dLenIn elseif dLedOut then dElev = dLedOut end local dCollSic = 2 * BD.COLL_SIC local sTuuidMstr -- calcolo il diametro utensile local dDiamTool if nUseRoughTool == 1 then -- se feature passante prendo utensile più grande possibile if ( Proc.AffectedFaces.Top and Proc.AffectedFaces.Bottom) or ( Proc.AffectedFaces.Front and Proc.AffectedFaces.Back) then dDiamTool = nil else dDiamTool = max( 80, min( tBHx[nFaceRef][1], tBHx[nFaceRef][2])) end else -- se non uso truciolatore prendo il valore dalle dimensioni minime delle facce dDiamTool = min( tBHx[nFaceRef][1], tBHx[nFaceRef][2]) end -- abilitazione lavorazione da sotto (testa da sotto e direzione normale sotto -30deg) local bTopHead = ( BD.DOWN_HEAD and vtN[nFaceRef]:getZ() > -0.1) local bDownHead = ( BD.DOWN_HEAD and vtN[nFaceRef]:getZ() < 0.1) -- recupero la lavorazione local sPocketing, _, _, bDownHead = ML.FindPocketing( sMchFind.. EgtIf( bDownHead, '_H2', ''), dDiamTool, dElev + dCollSic, nil, bTopHead, bDownHead) if not sPocketing then local sErr = 'Error : pocketing not found in library' EgtOutLog( sErr) return false, sErr end -- recupero il diametro dell'utensile if EgtMdbSetCurrMachining( sPocketing) then sTuuidMstr = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuidMstr) or '') then dDiamTool = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dDiamTool end end -- inserisco la lavorazione di svuotatura local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. 'F' .. tostring( nFaceRef - 1) local nMchFId = EgtAddMachining( sName, sPocketing) if not nMchFId then local sErr = 'Error adding machining ' .. sName .. '-' .. sPocketing EgtOutLog( sErr) return false, sErr end -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, (nFaceRef-1)}}) -- imposto uso faccia EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_CONT) -- imposto posizione braccio porta testa if vtN[nFaceRef]:getY() < GEO.EPS_SMALL then EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM) else EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP) end -- La tasca ha sempre almeno un lato aperto, imposto opportuno attacco EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALIN) -- imposto elevazione local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) or '' sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', EgtNumToString( dElev, 1)) EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) if not ML.ApplyMachining( true, false) then -- provo ad allargare leggermente la tasca EgtSetMachiningParam( MCH_MP.OFFSR, -0.1) if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nMchFId, false) return false, sErr end end return true, '', sTuuidMstr end --------------------------------------------------------------------- local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, ptC, vtN, nBigInd, nSmaInd, ptPs, tBHx, b3Raw, nDiffWidth, nUseRoughTool, dAng) local sMchFind = 'Pocket' -- se feature é larga come trave imposto openpocket if nDiffWidth == 0 then sMchFind = 'OpenPocket' -- altrimenti se non è passante disabilito il truciolatore else nUseRoughTool = 0 end -- applico la svuotatura local bOk, sErr, sTuuidMstr = MakePocket( Proc, nPartId, ptPs, vtN, nBigInd, nDiffWidth, sMchFind, nUseRoughTool, tBHx) if not bOk then return bOk, sErr end -- se angolo tra le facce maggiore di 90, inserisco la contornatura o svuotatura del lato più corto if dAng > -90.1 then -- se la normale della faccia corta si discosta dalla trave di più di 40° utilizzo la svuotatura altrimenti la contornatura if abs( vtN[nSmaInd]:getX()) < 0.766 then -- applico la svuotatura local bOk, sErr = MakePocket( Proc, nPartId, ptPs, vtN, nSmaInd, nDiffWidth, sMchFind, nUseRoughTool, tBHx) if not bOk then return bOk, sErr end -- altrimenti contornatura else local bOpenStart = false local bOpenEnd = false if nDiffWidth == 0 then bOpenStart = true bOpenEnd = true else local vAdj2 = EgtSurfTmFacetAdjacencies( Proc.Id, (nBigInd-1))[1] for j = 1, #vAdj2 do if vAdj2[j] == (nSmaInd-1) then -- Se non esiste faccia adiacente a lato precedente -> inizio aperto local i = EgtIf( j > 1, j - 1, #vAdj2) while vAdj2[i] == (nSmaInd-1) do i = EgtIf( i > 1, i - 1, #vAdj2) end bOpenStart = ( vAdj2[i] < 0) -- Se non esiste faccia adiacente a lato successivo -> fine aperto local k = EgtIf( j < #vAdj2, j + 1, 1) while vAdj2[k] == (nSmaInd-1) do k = EgtIf( k < #vAdj2, k + 1, 1) end bOpenEnd = ( vAdj2[k] < 0) end end end -- abilitazione lavorazione da sotto (testa da sotto e direzione normale sotto -30deg) local bTopHead = ( BD.DOWN_HEAD and vtN[nBigInd]:getZ() > -0.1) local bDownHead = ( BD.DOWN_HEAD and vtN[nBigInd]:getZ() < 0.1) -- scelta lavorazione local sMilling local sTypeMill = EgtIf( nUseRoughTool > 0, 'Long2Cut', 'LongSmallCut') sMilling = ML.FindMilling( sTypeMill, nil, sTuuidMstr, nil, nil, bTopHead, bDownHead) if not sMilling then local sErr = 'Error : milling not found in library' EgtOutLog( sErr) return false, sErr end -- recupero i dati dell'utensile local dTDiam = 50 local bCW = true if EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam local dSpeed = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) or 0 bCW = ( dSpeed >= 0) end end -- Calcolo uso faccia local nFaceUse = BL.GetNearestParalOpposite( tBHx[nBigInd][3]:getVersZ()) -- inserisco la lavorazione di fresatura local sName = 'Mill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchFId = EgtAddMachining( sName, sMilling) if not nMchFId then local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling EgtOutLog( sErr) return false, sErr end -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, (nSmaInd-1)}}) -- imposto uso faccia EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) -- setto inversione del percorso e lato di lavoro EgtSetMachiningParam( MCH_MP.INVERT, EgtIf( bCW, true, false)) EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( bCW, MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT)) -- setto a 0 eventuali offset EgtSetMachiningParam( MCH_MP.OFFSR, 0) -- applico gli allungamenti o accorciamenti considerando che la lavorazione è invertita EgtSetMachiningParam( MCH_MP.STARTADDLEN, EgtIf( bOpenStart, dTDiam / 2 + 10, - dTDiam / 2)) EgtSetMachiningParam( MCH_MP.ENDADDLEN, EgtIf( bOpenEnd, dTDiam / 2 + 10, - dTDiam / 2)) -- attacchi e uscite lineari con parte tg nulla EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR) EgtSetMachiningParam( MCH_MP.LITANG, 0) EgtSetMachiningParam( MCH_MP.LIPERP, 20) EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.AS_LI) -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nMchFId, false) return false, sErr end end end return true end --------------------------------------------------------------------- -- Lavorazione di due facce local function MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, nDiffWidth) -- ingombro del grezzo local b3Raw = EgtGetRawPartBBox( nRawId) -- ingombro del pezzo local Ls = EgtGetFirstNameInGroup( nPartId, 'Box') local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD) if not b3Solid then local sErr = 'Error : part box not found' EgtOutLog( sErr) return false, sErr end -- dati delle facce local tBHx = {} local ptC = {} local vtN = {} ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT) -- angolo diedro local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT) local bOnY = true local ptPs = ( ptC[1] + ptC[2]) / 2 local bConvex if bAdj then local vtDir = ptP1 - ptP2 ; vtDir:normalize() bOnY = abs( vtDir:getZ()) > 0.5 and ( abs( vtDir:getZ()) + abs( vtDir:getX()) > abs( vtDir:getY())) ptPs = ( ptP1 + ptP2) / 2 bConvex = ( dAng > 0) end -- determino quale faccia è più grande local rfFac1, dH1, dV1 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 0, GDB_ID.ROOT) local rfFac2, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 1, GDB_ID.ROOT) local nBigInd = EgtIf( dV1 * dH1 >= dV2 * dH2, 1, 2) local nSmaInd = 3 - nBigInd tBHx[1] = {dH1, dV1, rfFac1} tBHx[2] = {dH2, dV2, rfFac2} -- verifico parametro Q per stabilire se deve essere lavorato con truciolatore -- o se larghezza inferiore del trave, utilizzare una svuotatura local nUseRoughTool = EgtGetInfo( Proc.Id, 'Q02', 'i') or 0 -- se feature non è larga come trave o è selezionato l'utilizzo del truciolatore utilizzo svuotatura if nDiffWidth > 0 or nUseRoughTool == 1 then -- se angolo compreso è >= di 90° applico svuotatura con fresa if not bConvex and dAng >= -90.1 then local bOk, sErr = MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, ptC, vtN, nBigInd, nSmaInd, ptPs, tBHx, b3Raw, nDiffWidth, nUseRoughTool, dAng) if not bOk then return bOk, sErr end else local sErr = 'Error : internal angle less than square angle' EgtOutLog( sErr) return false, sErr end -- altrimenti provo a lavorare con la lama else local bOk, sErr = MachineByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Solid, ptC, vtN, nBigInd, nSmaInd, bOnY, ptPs, b3Raw, dAng) if not bOk then return bOk, sErr end end return true end --------------------------------------------------------------------- -- Lavorazione di due facce local function MakeFourFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, nDiffWidth) -- Prime due facce local bOk, sErr = MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, nDiffWidth) if not bOk then return bOk, sErr end -- Seconde due facce -- recupero gruppo per geometria addizionale local nAddGrpId = BL.GetAddGroup( nPartId) if not nAddGrpId then local sErr = 'Error : missing AddGroup' EgtOutLog( sErr) return false, sErr end -- copio la superficie e scambio le facce local AddId = EgtCopyGlob( Proc.Id, nAddGrpId) if AddId then EgtSurfTmSwapFacets( AddId, 0, 2) EgtSurfTmSwapFacets( AddId, 1, 3) EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id)) -- applico lavorazione local NewProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, PartId = Proc.PartId} local b3Raw = EgtGetRawPartBBox( nRawId) Topology.Classify( NewProc, b3Raw) local bOk, sErr = MakeTwoFaces( NewProc, nPhase, nRawId, nPartId, dOvmHead, nDiffWidth) if not bOk then return bOk, sErr end end return true end --------------------------------------------------------------------- -- lavorazione smussi local function MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead) -- ingombro del grezzo local b3Raw = EgtGetRawPartBBox( nRawId) -- recupero e verifico l'entità curva associata local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') if AuxId then AuxId = AuxId + Proc.Id end if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then local sErr = 'Error : missing profile geometry' EgtOutLog( sErr) return false, sErr end -- recupero i dati della curva e del profilo local dWidth = abs( EgtCurveThickness( AuxId)) local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) -- prendo il boundig box della feature local bBoxExtr = EgtGetBBoxGlob( AuxId, GDB_BB.STANDARD ) local nTypePos = 0 -- determino se sborda da un lato if abs( vtExtr:getZ()) < 0.1 then -- se orizzontale -- se altezza percorso inferiore della larghezza trave if dWidth < b3Raw:getDimY() - 1 then nTypePos = 1 -- verifico se sborda verso y+ if abs( bBoxExtr:getMax():getY() - b3Raw:getMax():getY()) < 0.1 then nTypePos = 2 -- se sborda verso y- elseif abs( bBoxExtr:getMin():getY() - b3Raw:getMin():getY()) < 0.1 then nTypePos = 3 end end elseif abs( vtExtr:getZ()) > 0.9 then -- se verticale -- se altezza percorso inferiore della larghezza trave if dWidth < b3Raw:getDimZ() - 1 then nTypePos = 1 -- verifico se sborda verso z+ if abs( bBoxExtr:getMax():getZ() - b3Raw:getMax():getZ()) < 0.1 then nTypePos = 4 -- se sborda verso z- elseif abs( bBoxExtr:getMin():getZ() - b3Raw:getMin():getZ()) < 0.1 then nTypePos = 5 end end else -- altrimenti se altra direzione setto per non fare smussi nTypePos = 6 end -- verifico che lo smusso sia richiesto local dDepth = EgtGetInfo( Proc.Id, 'Q01', 'd') or 0 if dDepth < 0.1 then return true, '', nTypePos end -- disabilito smusso se feature non sborda dalla trave almeno da un lato if nTypePos == 1 then local sWarn = 'Warning : skipped chamfer (feature smaller than beam)' EgtOutLog( sWarn) return true, sWarn , nTypePos end -- salto lo smusso se sborda dal lato in Z- o una direzione diversa da Y e Z if nTypePos >= 5 then local sWarn = 'Warning : skipped chamfer (wrong side to apply)' EgtOutLog( sWarn) return true, sWarn, nTypePos end local bExeNormal = true local bExeOpposite = true -- controllo le lavorazioni quando la feature è orizzontale if abs( vtExtr:getY()) > 0.99 then -- se diretta verso Y+ if vtExtr:getY() > 0 then -- se sborda verso Y+ abilito solo la lavorazione della parte normale if nTypePos == 2 then bExeOpposite = false -- se sborda verso Y- abilito solo la lavorazione della parte opposta elseif nTypePos == 3 then bExeNormal = false end -- altrimenti diretta verso Y- else -- se sborda verso Y+ abilito solo la lavorazione della parte opposta if nTypePos == 2 then bExeNormal = false -- se sborda verso Y- abilito solo la lavorazione della parte normale elseif nTypePos == 3 then bExeOpposite = false end end -- se diretta verso Z elseif abs( vtExtr:getZ()) > 0.99 and not ( BD.DOWN_HEAD or nTypePos == 0) then -- se diretta verso Z+ if vtExtr:getZ() > 0 then -- se sborda verso Z+ abilito solo la lavorazione della parte normale if nTypePos == 4 or nTypePos == 0 then bExeOpposite = false else -- altrimenti disabilito entrambe bExeNormal = false bExeOpposite = false end -- altrimenti diretta verso Z- else -- se sborda verso Z+ abilito solo la lavorazione della parte opposta if nTypePos == 4 or nTypePos == 0 then bExeNormal = false else -- altrimenti disabilito entrambe bExeNormal = false bExeOpposite = false end end end local dExtra = 2 -- recupero la lavorazione local sMillType = 'Mark' local bDownHead = BD.DOWN_HEAD and vtExtr:getZ() < GEO.EPS_SMALL local sMilling, bH2 sMilling, _, _, bH2 = ML.FindMilling( sMillType, nil, nil, nil, nil, true, bDownHead) if not sMilling then local sErr = 'Error : milling not found in library' EgtOutLog( sErr) return false, sErr end bDownHead = ( bDownHead and bH2) if bExeNormal then -- Inserisco la lavorazione del lato standard local sName1 = 'SJN_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMch1Id = EgtAddMachining( sName1, sMilling) if not nMch1Id then local sErr = 'Error adding machining ' .. sName1 .. '-' .. sMilling EgtOutLog( sErr) return false, sErr end -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) -- assegno affondamento e offset radiale EgtSetMachiningParam( MCH_MP.DEPTH, dDepth + dExtra) EgtSetMachiningParam( MCH_MP.OFFSR, dExtra) -- assegno lato di lavoro EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nMch1Id, false) return false, sErr end end if bExeOpposite then bDownHead = BD.DOWN_HEAD and vtExtr:getZ() > - GEO.EPS_SMALL sMilling, _, _, bH2 = ML.FindMilling( sMillType, nil, nil, nil, nil, true, bDownHead) if not sMilling then local sErr = 'Error : milling not found in library' EgtOutLog( sErr) return false, sErr end bDownHead = ( bDownHead and bH2) -- Inserisco la lavorazione del lato opposto local sName2 = 'SJN_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMch2Id = EgtAddMachining( sName2, sMilling) if not nMch2Id then local sErr = 'Error adding machining ' .. sName2 .. '-' .. sMilling EgtOutLog( sErr) return false, sErr end -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) -- inverto direzione utensile EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) -- assegno affondamento e offset radiale EgtSetMachiningParam( MCH_MP.DEPTH, dDepth + dExtra) EgtSetMachiningParam( MCH_MP.OFFSR, dExtra) -- assegno lato di lavoro EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nMch2Id, false) return false, sErr end end return true, '', nTypePos end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessStepJointNotch.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) if Proc.Fct == 3 then return LapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- esecuzione eventuale smusso -- ottengo anche il flag che indica che la feature è larga come la trave local bOkc, sErrC, nDiffWidth = MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead) if not bOkc then return bOkc, sErrC end -- come fatto nella classify, conto solo le facce che non sono dirette in Y o Z local nFacetCnt = EgtSurfTmFacetCount( Proc.Id) local nUsableFaces = 0 for i = 1, nFacetCnt do local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i-1, GDB_ID.ROOT) -- se faccia limite la salto if AreSameOrOppositeVectorApprox( vtN, Y_AX()) or AreSameOrOppositeVectorApprox( vtN, Z_AX()) then -- altrimenti faccia principale else nUsableFaces = nUsableFaces + 1 end end -- se due facce if nUsableFaces == 2 then local bOk, sErr = MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, nDiffWidth) if not bOk then return bOk, sErr end -- se quattro facce elseif nUsableFaces == 4 then local bOk, sErr = MakeFourFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, nDiffWidth) if not bOk then return bOk, sErr end -- altrimenti errore else local sErr = 'Error : face number not allowed' EgtOutLog( sErr) return false, sErr end return true end --------------------------------------------------------------------- return ProcessStepJointNotch