diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 1547b03..2f217f4 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -6,6 +6,7 @@ -- 2022/11/25 Per FindMilling implementata la possibilità di escludere la testa H3 dalla ricerca utensile. -- 2022/12/28 Per FindMilling e FindDrilling possibilità di escludere la testa H2 dalla ricerca utensile. -- 2023/01/31 Per FindPocketing implementata la possibilità di escludere le teste H2 o H3 dalla ricerca utensile. +-- 2023/03/13 Per FindPocketing implementata la scelta lavorazione da UUID dell'utensile. -- Tabella per definizione modulo local MachiningLib = {} @@ -162,13 +163,15 @@ function VerifyMill( dDepth, sTuuidMstr, dMaxDiam, dMaxTotLen, bH2) end --------------------------------------------------------------------- -function VerifyPocket( dMaxDiam, dDepth, dMaxTotLen, bH2) +function VerifyPocket( dMaxDiam, dDepth, dMaxTotLen, sTuuidMstr, bH2) + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) local dTMaxDepth = EgtTdbGetCurrToolMaxDepth() local dTTotLen = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) if ( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and - ( not dMaxTotLen or dTTotLen < dMaxTotLen + GEO.EPS_SMALL) then + ( not dMaxTotLen or dTTotLen < dMaxTotLen + GEO.EPS_SMALL) and + ( not sTuuidMstr or sTuuidMstr == sTuuid) then return true, { TDiam = dTDiam, TMaxDepth = dTMaxDepth, H2 = bH2} end end @@ -186,7 +189,7 @@ function VerifyTool( MachiningType, sType, Params, bH2) elseif MachiningType == MCH_MY.MILLING then return VerifyMill( Params.Depth, Params.TuuidMstr, Params.MaxDiam, Params.MaxTotLen, bH2) elseif MachiningType == MCH_MY.POCKETING then - return VerifyPocket( Params.MaxDiam, Params.Depth, Params.MaxTotLen, bH2) + return VerifyPocket( Params.MaxDiam, Params.Depth, Params.MaxTotLen, Params.TuuidMstr, bH2) elseif MachiningType == MCH_MY.MORTISING then return true, { H2 = bH2} else @@ -403,8 +406,8 @@ function MachiningLib.FindMilling( sType, dDepth, sTuuidMstr, dMaxDiam, dMaxTotL end --------------------------------------------------------------------- -function MachiningLib.FindPocketing( sType, dMaxDiam, dDepth, dMaxTotLen, bTopHead, bDownHead, bExcludeH2, bExcludeH3) - return FindMachining( MCH_MY.POCKETING, sType, { MaxDiam = dMaxDiam, Depth = dDepth, MaxTotLen = dMaxTotLen}, bTopHead, bDownHead, bExcludeH2, bExcludeH3) +function MachiningLib.FindPocketing( sType, dMaxDiam, dDepth, dMaxTotLen, bTopHead, bDownHead, bExcludeH2, bExcludeH3, sTuuidMstr) + return FindMachining( MCH_MY.POCKETING, sType, { MaxDiam = dMaxDiam, Depth = dDepth, MaxTotLen = dMaxTotLen, TuuidMstr = sTuuidMstr}, bTopHead, bDownHead, bExcludeH2, bExcludeH3) end --------------------------------------------------------------------- diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index e2a2996..3614d79 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -64,6 +64,7 @@ -- 2023/02/06 Alla MakeDrillOnCorner aggiunto controllo distanza di sicurezza minima. -- 2023/02/16 Piccola correzione alla scelta utensile di svuotatura. -- 2023/02/21 Piccola correzione alla MakeByPocket. +-- 2023/03/13 In MakeByPocket aggiunto Q11=Tool_ID per forzare la scelta utensile in casi con Q03=2/3. -- Tabella per definizione modulo local ProcessLapJoint = {} @@ -135,6 +136,7 @@ local function AssignQIdent( Proc) Q_SIDE_ROUGH_TOOL = '' Q_ANTISPLINT_TYPE = '' Q_MAX_ELEVATION = 'Q10' + Q_TOOL_ID = '' if ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 16 then Q_FORCE_BLADE = 'Q01' -- i @@ -158,10 +160,12 @@ local function AssignQIdent( Proc) Q_BLADE_ON_ALONG_FACE = 'Q04' -- i Q_ANTISPLINT_TYPE = 'Q06' -- i Q_DEPTH_CHAMFER = 'Q07' -- d + Q_TOOL_ID = 'Q11' -- i elseif ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 32 then Q_SIDE_ROUGH_TOOL = 'Q01' -- i Q_CONTOUR_SMALL_TOOL = 'Q02' -- i Q_ANTISPLINT_TYPE = 'Q06' -- i + Q_TOOL_ID = 'Q11' -- i elseif ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 33 then Q_ANTISPLINT_TYPE = 'Q06' -- i elseif ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 34 then @@ -317,12 +321,15 @@ local function VerifyChainSaw( Proc, dMinDim, dMaxDim) end --------------------------------------------------------------------- -local function VerifyPocket( Proc, dDiam, dDepth, dMaxTotLen, sMchFindMaster, bPocketUp, bPocketDown) +local function VerifyPocket( Proc, dDiam, dDepth, dMaxTotLen, sMchFindMaster, bPocketUp, bPocketDown, sChosenToolUuid) -- tipo di svuotatura local sMchFind = EgtIf( sMchFindMaster and #sMchFindMaster > 0, sMchFindMaster, 'Pocket') -- ricerca della svuotatura local sPocketing - if dDepth then + -- se viene specificato un utensile non guardo altro + if sChosenToolUuid then + sPocketing = ML.FindPocketing( sMchFind, dDiam, 0, dMaxTotLen, bPocketUp, bPocketDown, nil, nil, sChosenToolUuid) + elseif dDepth then sPocketing = ML.FindPocketing( sMchFind, dDiam, dDepth, dMaxTotLen, bPocketUp, bPocketDown) or ML.FindPocketing( sMchFind, dDiam, 0.8 * dDepth, dMaxTotLen, bPocketUp, bPocketDown) or ML.FindPocketing( sMchFind, dDiam, 0.7 * dDepth, dMaxTotLen, bPocketUp, bPocketDown) or @@ -3434,7 +3441,7 @@ local function GetUShapeWidth( Proc, nFacInd) end --------------------------------------------------------------------- -local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMchFindMaster, bIs3Faces, b3Solid, bOrthoFacesMaster, bMillDown, bSetOpenBorders, bIsU, bIsL) +local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMchFindMaster, bIs3Faces, b3Solid, bOrthoFacesMaster, bMillDown, bSetOpenBorders, bIsU, bIsL, dOvmHead) local nFirstMachId local bOrthoFaces @@ -3442,8 +3449,28 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha local sMchFind = 'Pocket' local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt local bBadMach = false + dOvmHead = dOvmHead or 10 + -- minima altezza della tasca sotto alla quale fa una contornatura invece di una svuotatura local dMinFaceElevForPocket = 20 + + -- se l'utente forza un utensile e la lavorazione è forzata dal lato modifico la minima altezza della tasca + local sChosenToolUuid + if ( ( EgtGetInfo( Proc.Id, Q_TOOL_ID, 'i') or 0) > 0 and ( EgtGetInfo( Proc.Id, Q_SIDE_ROUGH_TOOL, 'i') or 0) > 1) then + local nChosenToolUuid = EgtGetInfo( Proc.Id, Q_TOOL_ID, 'i') + local sToolName = EgtTdbGetFirstTool( MCH_TF.MILL) + while sToolName ~= '' do + EgtTdbSetCurrTool( sToolName) + local nToolId = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i') + local bIsToolActive = EgtTdbGetCurrToolParam( MCH_TP.ACTIVE) + if ( ( nChosenToolUuid == nToolId) and bIsToolActive) then break end + sToolName = EgtTdbGetNextTool( MCH_TF.MILL) + end + local dChosenToolDiameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + dMinFaceElevForPocket = dChosenToolDiameter / 2 + 10 * GEO.EPS_SMALL + sChosenToolUuid = EgtTdbGetCurrToolParam( MCH_TP.UUID) + end + if sMchFindMaster and #sMchFindMaster > 0 then sMchFind = sMchFindMaster end @@ -3489,10 +3516,10 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha -- ricalcolo se è lavorabile da sotto bMillDown = ( BD.DOWN_HEAD == true) -- verifico se può essere fatto con svuotatura - local bMakePocket, sPocketing, dMaxDepth, dDiamTool = VerifyPocket( Proc, dDimMin, dDepth / 2, nil, sMchFind) + local bMakePocket, sPocketing, dMaxDepth, dDiamTool = VerifyPocket( Proc, dDimMin, dDepth / 2, nil, sMchFind, nil, nil, sChosenToolUuid) local bMakePocketDn, sPocketingDn, dMaxDepthDn, dDiamToolDn if bMillDown then - bMakePocketDn, sPocketingDn, dMaxDepthDn, dDiamToolDn = VerifyPocket( Proc, dDimMin, dDepth / 2, nil, sMchFind, nil, true) + bMakePocketDn, sPocketingDn, dMaxDepthDn, dDiamToolDn = VerifyPocket( Proc, dDimMin, dDepth / 2, nil, sMchFind, nil, true, sChosenToolUuid) -- se è negativo inverto il versore e la faccia if vtOrtho:getZ() < 0 then vtOrtho = -vtOrtho @@ -3505,7 +3532,7 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha local sMilling if dFacElev < dMinFaceElevForPocket and ( bIsU or bIsL) and ( Proc.Fct == 2 or Proc.Fct == 3) and abs( vtN:getZ()) > 0.996 then -- recupero la lavorazione di contornatura - sMilling = ML.FindMilling( 'Prof', nil, nil, nil, nil, not bMillDown, bMillDown) + sMilling = ML.FindMilling( 'Prof', nil, sChosenToolUuid, nil, nil, not bMillDown, bMillDown) if not sMilling then local sMyWarn = 'Warning : Prof not found in library' EgtOutLog( sMyWarn) @@ -3516,8 +3543,8 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha if sMilling and EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dDiamTool = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam - dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dToolMaxDepth + dDiamTool = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dDiamTool + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth bMakeContour = true end end @@ -3672,17 +3699,17 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LI.LINEAR) EgtSetMachiningParam( MCH_MP.LITANG, 0) EgtSetMachiningParam( MCH_MP.LOTANG, 0) - EgtSetMachiningParam( MCH_MP.LIPERP, 30) - EgtSetMachiningParam( MCH_MP.LOPERP, 30) + EgtSetMachiningParam( MCH_MP.LIPERP, dMinFaceElevForPocket + 10) + EgtSetMachiningParam( MCH_MP.LOPERP, dMinFaceElevForPocket + 10) elseif bIsL then - EgtSetMachiningParam( MCH_MP.STARTADDLEN, 30) + EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dAddWorkWidth) EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.TANGENT) EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LI.LINEAR) - EgtSetMachiningParam( MCH_MP.LITANG, 30) + EgtSetMachiningParam( MCH_MP.LITANG, dOvmHead + ( dDiamTool / 2) + 10) EgtSetMachiningParam( MCH_MP.LOTANG, 0) EgtSetMachiningParam( MCH_MP.LIPERP, 0) - EgtSetMachiningParam( MCH_MP.LOPERP, 30) + EgtSetMachiningParam( MCH_MP.LOPERP, dMinFaceElevForPocket + 10) end end -- imposto elevazione e dichiaro non si generano sfridi per VMill @@ -3805,23 +3832,22 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha EgtSetMachiningParam( MCH_MP.LIELEV, 0) EgtSetMachiningParam( MCH_MP.LOELEV, 0) if bIsU then - EgtSetMachiningParam( MCH_MP.STARTADDLEN, dAddWorkWidth) EgtSetMachiningParam( MCH_MP.STARTADDLEN, dAddWorkWidth) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dAddWorkWidth) EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR) EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LI.LINEAR) EgtSetMachiningParam( MCH_MP.LITANG, 0) EgtSetMachiningParam( MCH_MP.LOTANG, 0) - EgtSetMachiningParam( MCH_MP.LIPERP, 30) - EgtSetMachiningParam( MCH_MP.LOPERP, 30) + EgtSetMachiningParam( MCH_MP.LIPERP, dMinFaceElevForPocket + 10) + EgtSetMachiningParam( MCH_MP.LOPERP, dMinFaceElevForPocket + 10) elseif bIsL then EgtSetMachiningParam( MCH_MP.STARTADDLEN, dAddWorkWidth) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, 30) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0) EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR) EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LI.TANGENT) EgtSetMachiningParam( MCH_MP.LITANG, 0) - EgtSetMachiningParam( MCH_MP.LOTANG, 30) - EgtSetMachiningParam( MCH_MP.LIPERP, 30) + EgtSetMachiningParam( MCH_MP.LOTANG, dOvmHead + ( dDiamTool / 2) + 10) + EgtSetMachiningParam( MCH_MP.LIPERP, dMinFaceElevForPocket + 10) EgtSetMachiningParam( MCH_MP.LOPERP, 0) end end @@ -3918,8 +3944,13 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha end end end - - return 0, sWarn, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, dDiamTool, bDoubleSide, nPathInt, nSurfInt, bOneShot, bMillDown, nFirstMachId, bOrthoFaces + if sChosenToolUuid then + local sErr = 'Error : no machining found with chosen Tool_ID' + EgtOutLog( sErr) + return -1, sErr + else + return 0, sWarn, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, dDiamTool, bDoubleSide, nPathInt, nSurfInt, bOneShot, bMillDown, nFirstMachId, bOrthoFaces + end end --------------------------------------------------------------------- @@ -5073,7 +5104,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa -- lavoro con svuotature (singola o doppia contrapposta) local sMyMchFind = 'Pocket' nOk, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, _, _, _, _, _, _, _, - bOrthoFaces = MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMyMchFind, true, b3Solid, nil, bMillDown) + bOrthoFaces = MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMyMchFind, true, b3Solid, nil, bMillDown, bSetOpenBorders, bIsU, bIsL, dOvmHead) -- se lavorazione non idonee ( asse della feature troppo inclinato e impossibile lavorare completamente da due parti) if nOk == -2 then if not sMchFind then @@ -5251,7 +5282,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa bSetOpenBorders = true end nOk, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, dDiamTool, bDoubleSide, nPathInt, nSurfInt, bOneShot, bMillDown, nFirstMachId, - bOrthoFaces = MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMyMchFind, bIs3Faces, b3Solid, bOrthoFacesMaster, bMillDown, bSetOpenBorders, bIsU, bIsL) + bOrthoFaces = MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMyMchFind, bIs3Faces, b3Solid, bOrthoFacesMaster, bMillDown, bSetOpenBorders, bIsU, bIsL, dOvmHead) if nOk == -3 then bTryWithBlades = true elseif nOk == -2 then