diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 1d18f37..1eb9a96 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -1,4 +1,4 @@ --- BeamLib.lua by Egaltech s.r.l. 2020/02/26 +-- BeamLib.lua by Egaltech s.r.l. 2020/03/19 -- Libreria globale per Travi -- Tabella per definizione modulo @@ -684,7 +684,7 @@ function BeamLib.MakeOneFaceBySaw( nSurfId, nFacet, sCutting, dSawDiam, Par5, dV local vtTg2 = ptP2 - ptPm ; vtTg2:normalize() local dDist1 = dist( ptP1, ptPm) local dDist2 = dist( ptP2, ptPm) - --if dDist1 >= dDist2 then + --if dDist1 * ( vtTg1 ^ vtOrthO):len() > dDist2 * ( vtTg2 ^ vtOrthO):len() then if abs( vtTg1 * vtOrthO) < abs( vtTg2 * vtOrthO) then ptP2 = Point3d( ptPm) dAllEnd = - dDist2 - 10 * GEO.EPS_SMALL @@ -730,7 +730,7 @@ function BeamLib.MakeOneFaceBySaw( nSurfId, nFacet, sCutting, dSawDiam, Par5, dV local dLiTang, dLiPerp, dLoTang, dLoPerp local ptP1act = ptP1 + vtN * dCutOffset local ptP2act = ptP2 + vtN * dCutOffset - if ( vtV1:getZ() > -0.1 or vtV2:getZ() > -0.1) and ( abs( vtV1:getY()) > 0.707 or abs( vtV2:getY()) > 0.707 or vtN:getZ() < 0.95) then + if ( vtV1:getZ() > -0.5 or vtV2:getZ() > -0.5) and ( abs( vtV1:getY()) > 0.707 or abs( vtV2:getY()) > 0.707 or vtN:getZ() < 0.95) then dLiTang, dLiPerp, dLoTang, dLoPerp = BeamLib.CalcLeadInOutGeom( ptP1act, ptP2act, vtV1, vtV2, vtN, dSawDiam/2, vtRef, dCutExtra, b3Box) else dLiTang, dLiPerp, dLoTang, dLoPerp = BeamLib.CalcLeadInOutTangGeom( ptP1act, ptP2act, vtN, dSawDiam/2, vtRef, dCutExtra, b3Box) diff --git a/LuaLibs/ProcessCut.lua b/LuaLibs/ProcessCut.lua index 81a108d..b9b440a 100644 --- a/LuaLibs/ProcessCut.lua +++ b/LuaLibs/ProcessCut.lua @@ -1,4 +1,4 @@ --- ProcessCut.lua by Egaltech s.r.l. 2020/03/16 +-- ProcessCut.lua by Egaltech s.r.l. 2020/03/19 -- Gestione calcolo singoli tagli di lama per Travi -- Tabella per definizione modulo @@ -73,11 +73,13 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom) end -- recupero i dati dell'utensile local dSawDiam = 400 + local dSawThick = 2 local dMaxDepth = 0 if EgtMdbSetCurrMachining( sCutting) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam + dSawThick = EgtTdbGetCurrToolParam(MCH_TP.THICK) or dSawThick dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth end end @@ -100,11 +102,20 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom) return false, sErr end -- sistemo posizione nel DB e nome + local bOrthInv = false 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) + if ( i % 2) == 1 then + local vtO = EgtSurfTmFacetNormVersor( vCuts[i][j], 0, GDB_ID.ROOT) + if ( vtN:getY() > 0.707 and vtO:getY() < -0.05) or + ( vtN:getY() < -0.707 and vtO:getY() > 0.05) then + EgtInvertSurf( vCuts[i][j]) + bOrthInv = true + end + end end end -- eseguo @@ -115,12 +126,11 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom) vtOrthoO = Vector3d( vtN) else local vtO - for j = 1, #vCuts[i-1] do - _, vtO = EgtSurfTmFacetCenter( vCuts[i-1][j], 0, GDB_ID.ROOT) - break + if #vCuts[i-1] > 0 then + vtO = EgtSurfTmFacetNormVersor( vCuts[i-1][1], 0, GDB_ID.ROOT) end if vtO then - vtOrthoO = Vector3d( vtO) + vtOrthoO = Vector3d( vtO) * EgtIf( bOrthInv, -1, 1) else if bHorizCut then vtOrthoO = Z_AX() @@ -136,7 +146,7 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom) -- se taglio dal basso if bDownCut then -- se strato pari composto da 1 o 2 elementi - if i % 2 == 0 and #vCuts[i] <= 2 then + if ( i % 2) == 0 and #vCuts[i] <= 2 then -- il primo elemento prende la direzione prevista, il secondo quella opposta local vtNewOrthoO = Vector3d( vtOrthoO) local dVzLimDwnUp = dNzLimDwnUp @@ -152,7 +162,9 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom) -- tutti gli altri casi vengono saltati -- caso generale else - local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, dNzLimDwnUp, -0.1, BD.CUT_SIC, 0, 0, nil, b3Raw) + -- se invertiti tagli ortogonali devo approfondire tagli paralleli dello spessore lama + local dExtraCut = EgtIf( ( i % 2) == 0 and bOrthInv, dSawThick, -0.1) + local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, dNzLimDwnUp, dExtraCut, BD.CUT_SIC, 0, 0, nil, b3Raw) if not bOk then return bOk, sErr end diff --git a/LuaLibs/ProcessDoubleCut.lua b/LuaLibs/ProcessDoubleCut.lua index 374e198..b84632d 100644 --- a/LuaLibs/ProcessDoubleCut.lua +++ b/LuaLibs/ProcessDoubleCut.lua @@ -156,18 +156,23 @@ function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- eseguo for i = 1, #vCuts do -- determino il modo di tagliare - local k, l = nBigInd, nSmaInd - if ( i % 2) == 1 then - k, l = l, k - end - local nOrthoOpposite - if bOnY then - local bFront = ( ptC[k]:getY() < ptPs:getY()) - nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT) - else - local bOver = ( ptC[k]:getZ() > ptC[l]:getZ()) - nOrthoOpposite = EgtIf( bOver, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_TOP) + --local k, l = nBigInd, nSmaInd + --if ( i % 2) == 1 then + -- k, l = l, k + --end + --local nOrthoOpposite + --if bOnY then + -- local bFront = ( ptC[k]:getY() < ptPs:getY()) + -- nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT) + --else + -- local bOver = ( ptC[k]:getZ() > ptC[l]:getZ()) + -- nOrthoOpposite = EgtIf( bOver, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_TOP) + --end + local vtOrthOpp = EgtIf( ( i % 2) == 1, vtN[nBigInd], vtN[nSmaInd]) + if not bOnY then + vtOrthOpp[2] = 0 ; vtOrthOpp:normalize() end + local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtOrthOpp) -- lavoro la faccia for j = 1, #vCuts[i] do local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) diff --git a/LuaLibs/ProcessDtMortise.lua b/LuaLibs/ProcessDtMortise.lua index aa05f47..42d3330 100644 --- a/LuaLibs/ProcessDtMortise.lua +++ b/LuaLibs/ProcessDtMortise.lua @@ -1,4 +1,4 @@ --- ProcessMortise.lua by Egaltech s.r.l. 2020/03/18 +-- ProcessMortise.lua by Egaltech s.r.l. 2020/03/19 -- Gestione calcolo mortase a coda di rondice per Travi -- Tabella per definizione modulo @@ -67,24 +67,25 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId) EgtOutLog( sErr) return false, sErr end - local sMillingAs + -- recupero la lavorazione + local sMilling = ML.FindMilling( 'DtMortise') + if not sMilling then + local sErr = 'Milling not found in library : Error on DtMortise ' .. tostring( Proc.Id) + EgtOutLog( sErr) + return false, sErr + end + -- recupero il diametro dell'utensile + local dToolDiam = 100 + local dMaxMat = 30 + 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 + end + end -- se parametro interno abilitato e il percorso non è chiuso, aggiungo percorso e lavorazione antischeggia if bMakeAntiSplitPath and not EgtCurveIsClosed( AuxId) then - -- recupero la lavorazione - sMillingAs = ML.FindMilling( 'DtMortise') - if not sMillingAs then - local sErr = 'Milling not found in library : Error on DtMortise ' .. tostring( Proc.Id) - EgtOutLog( sErr) - return false, sErr - end - -- recupero il diametro dell'utensile - local dToolDiam = 100 - if EgtMdbSetCurrMachining( sMillingAs) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam - end - end -- recupero punto iniziale e finale del percorso local pStartP = EgtSP( AuxId, GDB_RT.GLOB) local pEndP = EgtEP( AuxId, GDB_RT.GLOB) @@ -146,14 +147,17 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId) end -- inserisco la lavorazione di contornatura anti splint local sNameF = 'DtMtAS_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMchFId = EgtAddMachining( sNameF, sMillingAs) + local nMchFId = EgtAddMachining( sNameF, sMilling) if not nMchFId then - local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMillingAs + local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling EgtOutLog( sErr) return false, sErr end -- aggiungo geometria EgtSetMachiningGeometry( {{ nId1, -1}}) + -- dichiaro non si generano sfridi per VMill + local sUserNotes = 'MaxElev='.. EgtNumToString( dMaxMat - 0.1, 1) .. 'VMRS=0;' + EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -166,21 +170,6 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId) return false, sErr end end - -- recupero la lavorazione, se antischeggia già inserita prendo quella - local sMilling = EgtIf( sMillingAs, sMillingAs, ML.FindMilling( 'DtMortise')) - if not sMilling then - local sErr = 'Milling not found in library : Error on DtMortise ' .. tostring( Proc.Id) - EgtOutLog( sErr) - return false, sErr - end - -- recupero il diametro dell'utensile - local dToolDiam = 10 - if EgtMdbSetCurrMachining( sMilling) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam - end - end dToolDiam = max( dToolDiam, 10) -- verifico se raggio troppo piccolo per l'utensile local nSt, nEnd = EgtCurveDomain( AuxId) @@ -219,6 +208,9 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId) EgtSetMachiningParam( MCH_MP.OFFSR, dOffs) -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) + -- dichiaro non si generano sfridi per VMill + local sUserNotes = 'MaxElev='.. EgtNumToString( dMaxMat - 0.1, 1) .. 'VMRS=0;' + EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 8ca3289..2b1ca09 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2020/03/17 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/03/19 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. @@ -54,6 +54,20 @@ end --------------------------------------------------------------------- local function AssignQValues( Proc) + -- reset delle variabili assegnazione parametri Q + sForceUseBlade = '' + sDepthChamferMill = '' + sPreemptiveChamfer = '' + sUseMill = '' + sUseRoughTool = '' + sUseRoughToolWithBAxis90 = '' + sUseRoughToolWithBAxis0 = '' + sInsertBoreOnCorner = '' + sMakeContourWithSmallTool = '' + sMakeOnlyContourOrFullPocket = '' + sMakeBySideRoughTool = '' + sAntisplintMode = '' + if ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 16 then sForceUseBlade = 'Q01' -- i sDepthChamferMill = 'Q04' -- d @@ -76,8 +90,8 @@ local function AssignQValues( Proc) sDepthChamferMill = 'Q07' -- d elseif ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 32 then sMakeBySideRoughTool = 'Q01' -- i - -- le altre features gestite non hanno parametri Q nei parametri globali end + -- le altre features gestite non hanno parametri Q nei parametri globali end --------------------------------------------------------------------- @@ -788,6 +802,12 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV end -- 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 accorciamento iniziale/finale per estremi aperti/chiusi if bSpecialApp then -- applico gli allungamenti o accorciamenti considerando che la lavorazione è invertita @@ -825,7 +845,7 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV end --------------------------------------------------------------------- -local function ChoseCorner( Proc, nFacInd) +local function ChooseCorner( Proc, nFacInd) -- Recupero le facce adiacenti alla principale local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1] local tFacAdj = {} @@ -879,7 +899,7 @@ local function MakeCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, n local dMaxDepth = 0 -- ottengo l'angolo di riferimento dove applicare il percorso di pulitura - local dMaxLen, nIdLine, tFacAdj = ChoseCorner( Proc, nFacInd) + local dMaxLen, nIdLine, tFacAdj = ChooseCorner( Proc, nFacInd) -- prendo il primo versore local _, vtN1 = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) local _, vtN2 = EgtSurfTmFacetCenter( Proc.Id, tFacAdj[nIdLine][1], GDB_ID.ROOT) @@ -1036,7 +1056,7 @@ end local function MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiam, bSpecialMach) local sMyWarn -- ottengo l'angolo dove applicare il foro - local dMaxLen, nIdLine, tFacAdj = ChoseCorner( Proc, nFacInd) + local dMaxLen, nIdLine, tFacAdj = ChooseCorner( Proc, nFacInd) if not tFacAdj then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' geometry not found for drilling' EgtOutLog( sErr) @@ -1417,7 +1437,7 @@ local function EvaluateQParam( Proc, nRawId, bMakeVertCham, sDephtCham, sOnlyCha end end -- verifico se devo usare lama invece della sega-catena - if EgtGetInfo( Proc.Id, sUseBlade, 'i') == 1 then + if #sUseBlade == 0 or EgtGetInfo( Proc.Id, sUseBlade, 'i') == 1 then bForceUseBlade = true end @@ -1425,11 +1445,11 @@ local function EvaluateQParam( Proc, nRawId, bMakeVertCham, sDephtCham, sOnlyCha end --------------------------------------------------------------------- -local function MakePocket( Proc, nPartId, ptPs, vtN, nFaceRef, nDiffWidth, sMchFind, nUseRoughTool, tBHx, sMasterPocket) +local function MakePocket( Proc, nPartId, ptPs, tvtN, nFaceRef, sMchFind, nUseRoughTool, sMasterPocket, dPrevFaceElev, tDimAndRef, dAng) - -- calcolo il elevazione dal punto medio + -- calcolo l'elevazione dal punto medio local dElev - local dLenIn, dLedOut = BL.GetPointDirDepth( nPartId, ptPs, vtN[2]) + local dLenIn, dLedOut = BL.GetPointDirDepth( nPartId, ptPs, tvtN[2]) if dLenIn > 0 then dElev = dLenIn elseif dLedOut then @@ -1438,11 +1458,15 @@ local function MakePocket( Proc, nPartId, ptPs, vtN, nFaceRef, nDiffWidth, sMchF local dCollSic = 2 * BD.COLL_SIC -- calcolo il diametro utensile local dDiamTool - if nUseRoughTool == 1 then - dDiamTool = max( 80, min( tBHx[2][1], tBHx[2][2])) - else + if nUseRoughTool == 1 and tDimAndRef then + dDiamTool = max( 80, min( tDimAndRef[2][1], tDimAndRef[2][2])) + elseif tDimAndRef then -- se non uso truciolatore prendo il valore dalle dimensioni minime delle facce - dDiamTool = min( tBHx[2][1], tBHx[2][2]) + dDiamTool = min( tDimAndRef[2][1], tDimAndRef[2][2]) + end + -- se ho lavorazione precedente ricalcolo grossolanamente l'elevazione + if dPrevFaceElev and dPrevFaceElev > 0 and dAng then + dElev = dElev + ( sqrt( ( dElev * dElev) - ( dPrevFaceElev * dPrevFaceElev)) * sin(dAng)) end local sPocketing if sMasterPocket then @@ -1455,6 +1479,16 @@ local function MakePocket( Proc, nPartId, ptPs, vtN, nFaceRef, nDiffWidth, sMchF EgtOutLog( sErr) return false, sErr end + dDiamTool = 20 + local dMaxDepth = 0 + local sTuuidPk + if EgtMdbSetCurrMachining( sPocketing) then + sTuuidPk = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuidPk) or '') then + dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth) + dDiamTool = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + end + end -- inserisco la lavorazione di svuotatura local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. 'F' .. tostring( nFaceRef) local nMchFId = EgtAddMachining( sName, sPocketing) @@ -1468,7 +1502,7 @@ local function MakePocket( Proc, nPartId, ptPs, vtN, nFaceRef, nDiffWidth, sMchF -- imposto uso faccia EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_CONT) -- imposto posizione braccio porta testa - if vtN[2]:getY() < GEO.EPS_SMALL then + if tvtN[2]:getY() < GEO.EPS_SMALL then EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM) else EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP) @@ -1477,8 +1511,17 @@ local function MakePocket( Proc, nPartId, ptPs, vtN, nFaceRef, nDiffWidth, sMchF if sMchFind == 'OpenPocket' and nUseRoughTool == 0 then EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALIN) end - -- imposto elevazione + -- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente + local sWarn + if dElev > dMaxDepth + 10 * GEO.EPS_SMALL then + EgtSetMachiningParam( MCH_MP.DEPTH, dMaxDepth - dElev) + dElev = dMaxDepth + sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : elevation bigger than max tool depth' + EgtOutLog( sWarn) + end + -- imposto elevazione e dichiaro non si generano sfridi per VMill local sNotes = 'MaxElev=' .. EgtNumToString( dElev, 1) .. ';' + sNotes = sNotes .. 'VMRS=0;' EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) if not EgtApplyMachining( true, false) then -- provo ad allargare leggermente la tasca @@ -1489,27 +1532,31 @@ local function MakePocket( Proc, nPartId, ptPs, vtN, nFaceRef, nDiffWidth, sMchF return false, sErr end end - return true + return true, sWarn, sTuuidPk, dDiamTool end --------------------------------------------------------------------- -local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, ptC, vtN, nBaseFace, nSideFace, ptPs, tBHx, b3Raw, nDiffWidth, nUseRoughTool, dAng, sPocketing) +local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, tvtN, nBaseFace, nSideFace, ptPs, tDimAndRef, + b3Raw, nDiffWidth, nUseRoughTool, dAng, sPocketing, sTuuidPk, dPrevFaceElev) local sMchFind = 'Pocket' - -- se feature non larga come trave provo a verificare se sborda da un lato o è completamente dentro la faccia del trave - if nDiffWidth ~= 1 then sMchFind = 'OpenPocket' end - -- se feature non passante disabilito eventuale sgrossatore - if nDiffWidth ~= 0 then nUseRoughTool = 0 end + local dAngLimit = 30 + -- se feature é larga come trave imposto openpocket + if nDiffWidth == 0 then + sMchFind = 'OpenPocket' + -- altrimenti non è passante disabilito il truciolatore e amplio il limite angolare + -- per la differenza di lunghezza tra il truciolatore e la fresa più lunga + else + nUseRoughTool = 0 + dAngLimit = 40 + end -- se angolo tra le facce maggiore di 90, inserisco la contornatura o svuotatura del lato più corto if ( 180 + dAng) > 90.1 then -- se la normale della faccia corta si discosta dalla trave di più di 45° utilizzo la svutatura altrimenti la contornatura - if abs( vtN[2]:getX()) < 0.707 then -- se si discosta di più di 45° applico svuotatura + if abs( tvtN[2]:getX()) < cos(dAngLimit) then -- se si discosta di più di 30° applico svuotatura -- applico la svuotatura - local bOk, sErr = MakePocket( Proc, nPartId, ptPs, vtN, nSideFace, nDiffWidth, sMchFind, nUseRoughTool, tBHx, sPocketing) - if not bOk then - return bOk, sErr - end + return MakePocket( Proc, nPartId, ptPs, tvtN, nSideFace, sMchFind, nUseRoughTool, sPocketing, dPrevFaceElev, tDimAndRef, dAng) -- altrimenti contornatura else local bOpenStart = false @@ -1536,7 +1583,12 @@ local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, ptC, vtN, end end end - local sMilling = ML.FindMilling( 'LongSmallCut') + local sMilling + if nUseRoughTool > 0 then + sMilling = ML.FindMilling( 'Long2Cut', nil, sTuuidPk) + else + sMilling = ML.FindMilling( 'LongSmallCut', nil, sTuuidPk) + end if not sMilling then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library' EgtOutLog( sErr) @@ -1551,7 +1603,7 @@ local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, ptC, vtN, end end -- Calcolo uso faccia - local nFaceUse = BL.GetNearestParalOpposite( tBHx[1][3]:getVersZ()) + local nFaceUse = BL.GetNearestParalOpposite( tDimAndRef[1][3]:getVersZ()) -- inserisco la lavorazione di fresatura local sName = 'Mill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchFId = EgtAddMachining( sName, sMilling) @@ -1564,9 +1616,35 @@ local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, ptC, vtN, EgtSetMachiningGeometry( {{ Proc.Id, (nSideFace)}}) -- imposto uso faccia EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) - -- applico gli allungamenti o accorciamenti considerando che la lavorazione è invertita - EgtSetMachiningParam( MCH_MP.STARTADDLEN, EgtIf( bOpenStart, dTDiam / 2, - dTDiam / 2)) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, EgtIf( bOpenEnd, dTDiam / 2, - dTDiam / 2)) + -- setto inversione del percorso + EgtSetMachiningParam( MCH_MP.INVERT, true) + -- setto a 0 eventuali offset + EgtSetMachiningParam( MCH_MP.OFFSR, 0) + -- calcolo elevazione per allungamenti attacchi con fianchi chiusi + local dElev + local dLenIn, dLedOut = BL.GetPointDirDepth( nPartId, ptPs, tvtN[2]) + if dLenIn > 0 then + dElev = dLenIn + elseif dLedOut then + dElev = dLedOut + end + -- applico gli allungamenti o accorciamenti + if bOpenStart then + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dTDiam / 2) + else + EgtSetMachiningParam( MCH_MP.STARTADDLEN, -dTDiam / 2) + if dElev > 0 then + EgtSetMachiningParam( MCH_MP.LIPERP, dElev) + end + end + if bOpenEnd then + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dTDiam / 2) + else + EgtSetMachiningParam( MCH_MP.ENDADDLEN, -dTDiam / 2) + if dElev > 0 then + EgtSetMachiningParam( MCH_MP.LOPERP, dElev) + end + end -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -1692,7 +1770,7 @@ local function SetOpenSide( nPathInt, vtOrtho, b3Solid, nAddGrpId, bStartPoint) end --------------------------------------------------------------------- -local function MakeByPocket( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMchFindMaster, b3FacesUsed, b3Solid, bOrthoFacesMaster) +local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMchFindMaster, b3FacesUsed, b3Solid, bOrthoFacesMaster) local bOrthoFaces local sWarn @@ -1708,7 +1786,7 @@ local function MakeByPocket( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham if nFacInd == -1 then bOrthoFaces = nFacInd2 else - local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' MakeByPocket could not find reference face' + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' MakeByPockets could not find reference face' EgtOutLog( sErr) return -1, sErr end @@ -2007,8 +2085,8 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) -- se è un tunnel provo a vedere se è possibile lavorarlo di con la svuotatura o con la sega catena if bClosedOrthoFaces then local bTryWithBlades = true - -- lavoro fessura con svuotatura - local nOk, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace = MakeByPocket( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, 'Pocket', false, b3Solid, bClosedOrthoFaces) + -- lavoro fessura con svuotature (singola o doppia contrapposta) + local nOk, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace = MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, 'Pocket', false, b3Solid, bClosedOrthoFaces) if nOk < 0 then return false, sErr elseif nOk > 0 then @@ -2234,7 +2312,8 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) end -- se abilitato dal parametro Q inserisco foro sullo spigolo if EgtGetInfo( Proc.Id, sInsertBoreOnCorner, 'i') == 1 then - local bOk, sWarn = MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, 0, nAddGrpId, dDiamTool, true) + local bOk + bOk, sWarn = MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, 0, nAddGrpId, dDiamTool, true) if not bOk then return false, sWarn end end -- altrimenti lavorazione di svuotatura o contornatura @@ -2259,8 +2338,13 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) if not bOk then return false, sErr end end -- recupero la lavorazione + local nUseRoughTool = 0 local sMchFind = 'Pocket' - if Proc.Fct < 3 or bIsU then sMchFind = 'OpenPocket' end + if Proc.Fct < 3 or bIsU then + sMchFind = 'OpenPocket' + -- abilito il truciolatore + nUseRoughTool = 1 + end local dDiam = min( dH, dV) local dCollSic = 2 * BD.COLL_SIC if abs( vtN:getX()) > 0.996 or abs( vtN:getY()) > 0.996 or abs( vtN:getZ()) > 0.996 then dCollSic = 0 end @@ -2279,7 +2363,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) -- se non è possibile allora provo in seguito con lama o segacatena -- o passare subito dalla lavorazione con lama/sega catena if bTrySidePocketAtFirst and Proc.Fct == 3 and bIsU then - nOk, sErr = MakeByPocket( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, 'OpenPocket', true, b3Solid) + nOk, sErr = MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, 'OpenPocket', true, b3Solid) if nOk < 0 then return false, sErr elseif nOk > 0 then @@ -2320,60 +2404,16 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) end end end - -- recupero i dati dell'utensile: utilizzo il diametro utensile per il foro opzionale - local dMaxDepth = 0 - local dDiamTool = 20 - if EgtMdbSetCurrMachining( sPocketing) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth) - dDiamTool = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - end - end - -- inserisco la lavorazione di svuotatura - local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - 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, nFacInd}}) - -- imposto uso faccia - EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_CONT) - -- imposto posizione braccio porta testa - if vtN:getY() < GEO.EPS_SMALL then - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM) - else - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP) - end - -- se tasca aperta, imposto opportuno attacco - if sMchFind == 'OpenPocket' then - EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALIN) - end - -- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente - if dFacElev > dMaxDepth + 10 * GEO.EPS_SMALL then - EgtSetMachiningParam( MCH_MP.DEPTH, dMaxDepth - dFacElev) - dFacElev = dMaxDepth - sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : elevation bigger than max tool depth' - EgtOutLog( sWarn) - end - -- imposto elevazione e dichiaro non si generano sfridi per VMill - local sNotes = 'MaxElev=' .. EgtNumToString( dFacElev, 1) .. ';' - sNotes = sNotes .. 'VMRS=0;' - EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) - -- eseguo - if not EgtApplyMachining( true, false) then - -- provo ad allargare leggermente la tasca - EgtSetMachiningParam( MCH_MP.OFFSR, -0.1) - if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr - end - end - -- se ho più di 3 facce e non di forma ad u e non sono stati inseriti antischeggia di lama + + -- eseguo la svuotatura della faccia principale, mi restituisce id utensile, il diametro utensile per il foro opzionale + local tvtNx = {} + tvtNx[2] = vtN + local bOk + bOk, sWarn, sTuuidPk, dDiamTool = MakePocket( Proc, nPartId, ptC, tvtNx, nFacInd, sMchFind, nUseRoughTool, sPocketing, dFacElev) + if not bOk then return false, sWarn end + + -- se ho più di 3 facce e non di forma ad u oppure ho 3 facce e di forma ad u + -- e non sono stati inseriti antischeggia di lama -- controllo se c'è una faccia non ortogonale alla principale e la lavoro con una contornatura o svuotatura if ( ( Proc.Fct > 3 and not bIsU) or ( Proc.Fct == 3 and bIsU)) and not bMadeASbyBld then -- Recupero le facce adiacenti alla principale @@ -2385,34 +2425,34 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId) end -- Cerco una faccia adiacente alla principale con angolo > 90 local nFacAdj - local tBHx = {} - local ptCx = {} - local vtNx = {} - ptCx[1], vtNx[1] = ptC, vtN - tBHx[1] = {dH, dV, rfFac} + local tDimAndRef = {} + tvtNx = {} + tvtNx[1] = vtN + tDimAndRef[1] = {dH, dV, rfFac} for i = 1, #vAdj do if vAdj[i] >= 0 then local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) if bAdj and dAng < 0 and 180 + dAng > 90.1 then local rfFac2, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, vAdj[i], GDB_ID.ROOT) - local ptC2, vtN2 = EgtSurfTmFacetCenter( Proc.Id, vAdj[i], GDB_ID.ROOT) - ptCx[2], vtNx[2] = ptC2, vtN2 - tBHx[2] = {dH2, dV2, rfFac2} + _, tvtNx[2] = EgtSurfTmFacetCenter( Proc.Id, vAdj[i], GDB_ID.ROOT) + tDimAndRef[2] = {dH2, dV2, rfFac2} local ptPs = ( ptP1 + ptP2) / 2 - local bOk, sErr = MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, ptCx, vtNx, nFacInd, vAdj[i], ptPs, tBHx, b3Raw, 2, 0, dAng, sPocketing) - if not bOk then - return bOk, sErr - end + local bOk + bOk, sWarn = MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, tvtNx, nFacInd, vAdj[i], ptPs, tDimAndRef, + b3Raw, EgtIf( ( Proc.Fct == 3 and bIsU), 0, 2), nUseRoughTool, dAng, sPocketing, sTuuidPk, dFacElev) + if not bOk then return bOk, sWarn end end end end end -- se abilitato dal parametro Q inserisco foro sullo spigolo if EgtGetInfo( Proc.Id, sInsertBoreOnCorner, 'i') == 1 then - local bOk, sWarn = MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiamTool) + local bOk + bOk, sWarn = MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiamTool) if not bOk then return false, sWarn end elseif EgtGetInfo( Proc.Id, sInsertBoreOnCorner, 'i') == 2 then - local bOk, sWarn = MakeCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiamTool) + local bOk + bOk, sWarn = MakeCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiamTool) if not bOk then return false, sWarn end end end diff --git a/LuaLibs/ProcessStepJointNotch.lua b/LuaLibs/ProcessStepJointNotch.lua index d177ed6..7c08571 100644 --- a/LuaLibs/ProcessStepJointNotch.lua +++ b/LuaLibs/ProcessStepJointNotch.lua @@ -1,4 +1,4 @@ --- ProcessStepJointNotch.lua by Egaltech s.r.l. 2020/03/18 +-- ProcessStepJointNotch.lua by Egaltech s.r.l. 2020/03/19 -- Gestione calcolo tacca a gradino per Travi -- Tabella per definizione modulo @@ -276,6 +276,8 @@ local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, ptC, vtN, EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) -- setto inversione del percorso EgtSetMachiningParam( MCH_MP.INVERT, true) + -- 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, - dTDiam / 2)) EgtSetMachiningParam( MCH_MP.ENDADDLEN, EgtIf( bOpenEnd, dTDiam / 2, - dTDiam / 2))