diff --git a/LuaLibs/ProcessDtMortise.lua b/LuaLibs/ProcessDtMortise.lua index 2d44d8a..d0d22e7 100644 --- a/LuaLibs/ProcessDtMortise.lua +++ b/LuaLibs/ProcessDtMortise.lua @@ -172,6 +172,7 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) + local sWarn bMakeAntiSplitPath = true -- ingombro del pezzo local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) @@ -447,94 +448,98 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) local nAuxId1 = CalcPathAtHeight( Proc.Id, AuxId, nAddGrpId, dAltMort, dSideAng, b3Solid) -- se esiste il percorso if nAuxId1 then - -- creo percorso sulla parte alta della mortasa - local dToolRadDelta = dAltMort * tan( dSideAng) - local dTopDiam = dToolDiam + 2 * dToolRadDelta - -- recupero punto iniziale e finale del percorso - local ptStart = EgtSP( nAuxId1, GDB_RT.GLOB) - local ptEnd = EgtEP( nAuxId1, GDB_RT.GLOB) - if ptStart and ptEnd then - local nId1 - -- se richiesti due segmenti di linea - if not bMakeAsByArc then - -- determino il punto comune dei due segmenti - local vtDelta = ( ptEnd - ptStart) / 4 - vtDelta:rotate( vtExtr, -90) - local ptMid = ( ptStart + ptEnd) / 2 + vtDelta - -- creo la spezzata formata dai due segmenti - nId1 = EgtCurveCompoFromPoints( nAddGrpId, { ptStart, ptMid, ptEnd}, GDB_RT.GLOB) - -- altrimenti richiesto arco + if EgtCurveIsFlat( nAuxId1) then + -- creo percorso sulla parte alta della mortasa + local dToolRadDelta = dAltMort * tan( dSideAng) + local dTopDiam = dToolDiam + 2 * dToolRadDelta + -- recupero punto iniziale e finale del percorso + local ptStart = EgtSP( nAuxId1, GDB_RT.GLOB) + local ptEnd = EgtEP( nAuxId1, GDB_RT.GLOB) + if ptStart and ptEnd then + local nId1 + -- se richiesti due segmenti di linea + if not bMakeAsByArc then + -- determino il punto comune dei due segmenti + local vtDelta = ( ptEnd - ptStart) / 4 + vtDelta:rotate( vtExtr, -90) + local ptMid = ( ptStart + ptEnd) / 2 + vtDelta + -- creo la spezzata formata dai due segmenti + nId1 = EgtCurveCompoFromPoints( nAddGrpId, { ptStart, ptMid, ptEnd}, GDB_RT.GLOB) + -- altrimenti richiesto arco + else + -- direzione del segmento + local vtDir = ptEnd - ptStart ; + local dLen = vtDir:len() + vtDir:normalize() + -- direzioni tangenti iniziale e finale + local vtStart = EgtSV( nAuxId1, GDB_RT.GLOB) + local vtEnd = EgtEV( nAuxId1, GDB_RT.GLOB) + -- angoli + local dAngStart = acos( vtStart * vtDir) + local dAngEnd = acos( vtEnd * vtDir) + local dMaxAng = min( 30, dAngStart, dAngEnd) + if dLen < dTopDiam then + dMaxAng = min( dMaxAng, asin( dLen / dTopDiam)) + end + local vtTg = vtDir ; vtTg:rotate( vtExtr, -dMaxAng) + -- creo l'arco + nId1 = EgtArc2PV( nAddGrpId, ptStart, ptEnd, vtTg, GDB_RT.GLOB) + end + if not nId1 then + local sErr = 'Wrong geometry : Error on DtMortise ' + EgtOutLog( sErr) + return false, sErr + end + EgtModifyCurveExtrusion( nId1, vtExtr, GDB_RT.GLOB) + -- inserisco la lavorazione di contornatura anti splint + local sNameF = 'DtMtAS_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchFId = EgtAddMachining( sNameF, sMilling) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ nId1, -1}}) + -- setto affondamento pari all'altezza della mortsasa + EgtSetMachiningParam( MCH_MP.DEPTH, dAltMort) + -- setto offset radiale con aggiunto un ulteriore allargamento di 1mm + EgtSetMachiningParam( MCH_MP.OFFSR, dToolRadDelta - 1) + -- antischeggia sempre con una passata + if bMultipleZPasses then + EgtSetMachiningParam( MCH_MP.STEP, 0) + end + -- sistemo il lato e la direzione di lavoro + EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( bCW, MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT)) + EgtSetMachiningParam( MCH_MP.INVERT, EgtIf( bCW, false, true)) + -- se necessario, imposto SCC + if nSCC then + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + end + -- dichiaro non si generano sfridi per VMill + local sUserNotes = 'MaxElev='.. EgtNumToString( dAltMort, 1) .. '; VMRS=0;' + -- se lavorazione in doppio + if Proc.Double and Proc.Double > 0 then + sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', Proc.Double) + if Proc.Double ~= nMyPrevDouble then + nMyPrevDouble = Proc.Double + sUserNotes = EgtSetValInNotes( sUserNotes, 'StartZmax', 2) + end + end + EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end else - -- direzione del segmento - local vtDir = ptEnd - ptStart ; - local dLen = vtDir:len() - vtDir:normalize() - -- direzioni tangenti iniziale e finale - local vtStart = EgtSV( nAuxId1, GDB_RT.GLOB) - local vtEnd = EgtEV( nAuxId1, GDB_RT.GLOB) - -- angoli - local dAngStart = acos( vtStart * vtDir) - local dAngEnd = acos( vtEnd * vtDir) - local dMaxAng = min( 30, dAngStart, dAngEnd) - if dLen < dTopDiam then - dMaxAng = min( dMaxAng, asin( dLen / dTopDiam)) - end - local vtTg = vtDir ; vtTg:rotate( vtExtr, -dMaxAng) - -- creo l'arco - nId1 = EgtArc2PV( nAddGrpId, ptStart, ptEnd, vtTg, GDB_RT.GLOB) - end - if not nId1 then - local sErr = 'Wrong geometry : Error on DtMortise ' + local sErr = 'Wrong geometry : Error on DtMortise ' .. tostring( Proc.Id) EgtOutLog( sErr) return false, sErr end - EgtModifyCurveExtrusion( nId1, vtExtr, GDB_RT.GLOB) - -- inserisco la lavorazione di contornatura anti splint - local sNameF = 'DtMtAS_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMchFId = EgtAddMachining( sNameF, sMilling) - if not nMchFId then - local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling - EgtOutLog( sErr) - return false, sErr - end - -- aggiungo geometria - EgtSetMachiningGeometry( {{ nId1, -1}}) - -- setto affondamento pari all'altezza della mortsasa - EgtSetMachiningParam( MCH_MP.DEPTH, dAltMort) - -- setto offset radiale con aggiunto un ulteriore allargamento di 1mm - EgtSetMachiningParam( MCH_MP.OFFSR, dToolRadDelta - 1) - -- antischeggia sempre con una passata - if bMultipleZPasses then - EgtSetMachiningParam( MCH_MP.STEP, 0) - end - -- sistemo il lato e la direzione di lavoro - EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( bCW, MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT)) - EgtSetMachiningParam( MCH_MP.INVERT, EgtIf( bCW, false, true)) - -- se necessario, imposto SCC - if nSCC then - EgtSetMachiningParam( MCH_MP.SCC, nSCC) - end - -- dichiaro non si generano sfridi per VMill - local sUserNotes = 'MaxElev='.. EgtNumToString( dAltMort, 1) .. '; VMRS=0;' - -- se lavorazione in doppio - if Proc.Double and Proc.Double > 0 then - sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', Proc.Double) - if Proc.Double ~= nMyPrevDouble then - nMyPrevDouble = Proc.Double - sUserNotes = EgtSetValInNotes( sUserNotes, 'StartZmax', 2) - end - end - EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) - -- eseguo - if not ML.ApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr - end else - local sErr = 'Wrong geometry : Error on DtMortise ' .. tostring( Proc.Id) - EgtOutLog( sErr) - return false, sErr + sWarn = 'Warning : skipped DoveTail mortise antisplint' end else local sErr = 'Wrong geometry : Error on DtMortise ' .. tostring( Proc.Id) @@ -675,7 +680,7 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) return false, sErr end end - return true + return true, sWarn end ---------------------------------------------------------------------