diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index 3701aba..1595e2c 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -9,6 +9,7 @@ -- 2023/10/30 In FindPocketing aggiunto parametro per poter escludere le frese che non lavorano di testa. -- 2023/10/31 In IsToolDoubleOk permessa una lunghezza lievemente inferiore dell'utensile secondario rispetto al principale. -- 2023/10/31 In FindPocketing le lavorazioni con attacco speciale (rampa molto lunga e step basso) ignorano il flag per escludere le frese che non lavorano di testa. +-- 2023/11/06 In FindPocketing aggiunto parametro dDistanceToNearestPart per ridurre il massimo diametro in caso di altro pezzo troppo vicino. -- Tabella per definizione modulo local WMachiningLib = {} @@ -106,7 +107,8 @@ function WMachiningLib.FindNailing( nType) end --------------------------------------------------------------------- -function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID, sHead, bExcludeNoTipFeed) +function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID, sHead, bExcludeNoTipFeed, dDistanceToNearestPart) + if not dMaxDiam then dMaxDiam = 999 end for i = 1, #Pocketings do local Pocketing = Pocketings[i] if Pocketing.On and Pocketing.Type == sType and SetCurrMachiningAndTool( Pocketing.Name) then @@ -116,9 +118,15 @@ function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID, sHead, local nMyTool_ID = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i') local sMyHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) local bHasTipFeed = ( EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) ~= 0) + -- attacco con rampa molto lunga e step basso, utilizzabile anche con frese che non lavorano di testa local bIsSpecialLeadIn = ( EgtMdbGetCurrMachiningParam( MCH_MP.LEADINTYPE) == MCH_POCK_LI.ZIGZAG or MCH_POCK_LI.HELIX) and - ( ( EgtMdbGetCurrMachiningParam( MCH_MP.LITANG) or 0) > dTDiam - 10 * GEO.EPS_SMALL) and + ( ( EgtMdbGetCurrMachiningParam( MCH_MP.LITANG) or 0) > dTDiam - 1 - 10 * GEO.EPS_SMALL) and ( ( EgtMdbGetCurrMachiningParam( MCH_MP.LIELEV) or 999) <= 2) + local bIsSpiralOut = EgtMdbGetCurrMachiningParam( MCH_MP.SUBTYPE) == MCH_POCK_SUB.SPIRALOUT + -- se ho un altro pezzo troppo vicino riduco il diametro massimo utensile + if dDistanceToNearestPart then + dMaxDiam = min( dMaxDiam, EgtIf( bIsSpiralOut, dDistanceToNearestPart * 2 + 5, dDistanceToNearestPart + 5)) + end if nMchType == MCH_MY.POCKETING and ( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 224bea3..fa463d4 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -32,7 +32,10 @@ -- 2023/10/02 Aggiunta segnalazione lavorazione tipo Side non trovata. -- 2023/10/30 In VerifyPocket, per tasche in doppio forzata ricerca fresa che possa lavorare di testa. -- 2023/10/31 In VerifyPocket, se topologia pocket, forzata ricerca fresa che possa lavorare di testa. - +-- 2023/11/06 In VerifyPocket controllo massimo diametro in base a distanza pezzo più vicino demandato a FindPocketing. +-- 2023/11/07 In MakeByPocketing, se tasca che guarda davanti, aggiunta possibilità di attaccare fuori dal grezzo fino ad uno spessore di 75 mm. +-- In MakeByPocketing calcolo del massimo diametro utensile spostato in VerifyPocketing. +-- In MakeByPocketing il doppio viene ora disattivato se una tasca deve essere forzata chiusa e l'altra no. -- Tabella per definizione modulo local WPL = {} @@ -1290,7 +1293,7 @@ local function IsMachiningDamagingOtherParts( Proc, dMillDiameter, nRawId) local ptMin = b3ProcExtended:getMin() local ptMax = b3ProcExtended:getMax() -- estensione aggiunta ai box - local dBoxExtensionLength = dMillDiameter / 2 + 10 + local dBoxExtensionLength = dMillDiameter / 2 + 5 -- check box verso X- if Proc.AffectedFaces.Left then local vtMove = Vector3d( -dBoxExtensionLength, 0, 0) @@ -2183,30 +2186,76 @@ end --------------------------------------------------------------------- -- trova la migliore lavorazione tasca in base a diametro utensile, elevazione, doppio e eventuale interferenza di parti vicine -- se necessario forza la tasca a chiusa -local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) - local dStartDiameter = dMaxDiameter - if Proc.AffectedFaces.Front then - dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Front) - end - if Proc.AffectedFaces.Back then - dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Back) - end - if Proc.AffectedFaces.Left then - dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Left) - end - if Proc.AffectedFaces.Right then - dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Right) - end +local function VerifyPocket( Proc, nFacet, dElev, nRawId) local bForceClosedPocket = false - local bExcludeNoTipFeed = Proc.Topology == 'Pocket' + local b3Raw = EgtGetRawPartBBox( nRawId) + -- verifico se la feature è sul bordo (non ci sono altri pezzi davanti alla tasca). Se è sul bordo, l'utensile potrà attaccare da fuori. + local bIsFeatureOnEdge = ( Proc.Topology == 'Groove' and Proc.Fct == 4 and Proc.DistanceToNearestParts.Front > b3Raw:getDimY()) + + -- trovo il massimo diametro utensile ammissibile per la tasca + local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT) + local dStartDiameter = min( dH, dV) + local dMaxDiameter = dStartDiameter + -- se una sola faccia posso usare un utensile più grande della faccia + if Proc.Fct == 1 then + dMaxDiameter = 2 * dMaxDiameter + end + -- se forma ad L posso usare un utensile più grande della faccia + local bIsL = ( Proc.Fct == 2 or WL.TestElleShape3( Proc.Id, Proc.Fct) or WL.TestElleShape4( Proc.Id, Proc.Fct) == 2) + if bIsL then + dMaxDiameter = 2 * dMaxDiameter + end + -- se forma ad U riduco il diametro se necessario + local bIsU = ( Proc.Fct == 3 and not WL.TestElleShape3( Proc.Id, Proc.Fct)) + if bIsU then + -- prendo la linea di base + local dMiddleFacetLength = 0 + if abs( dElev - dH) < 1 and abs( dElev - dV) > 1 then + dMiddleFacetLength = dV + elseif abs( dElev - dV) < 1 and abs( dElev - dH) > 1 then + dMiddleFacetLength = dH + end + if dMiddleFacetLength > dMaxDiameter then + dMaxDiameter = min( 2 * dMaxDiameter, dMiddleFacetLength) + end + end + -- in presenza di angoli interni, limito secondo impostazione globale il diametro massimo utensile + if Proc.Fct == 3 and bIsL then + dMaxDiameter = min( dMaxDiameter, WD.MAXDIAM_POCK_CORNER or 1000) + elseif Proc.Fct >= 4 then + dMaxDiameter = min( dMaxDiameter, WD.MAXDIAM_POCK_CORNER or 1000) + end + + -- verifico la distanza minima dalle parti vicine e nel caso il FindPocketing limiterà il diametro massimo dell'utensile + local dDistanceToNearestPart = GEO.INFINITO + if Proc.AffectedFaces.Front then + dDistanceToNearestPart = Proc.DistanceToNearestParts.Front + end + if Proc.AffectedFaces.Back then + dDistanceToNearestPart = min( dDistanceToNearestPart, Proc.DistanceToNearestParts.Back) + end + if Proc.AffectedFaces.Left then + dDistanceToNearestPart = min( dDistanceToNearestPart, Proc.DistanceToNearestParts.Left) + end + if Proc.AffectedFaces.Right then + dDistanceToNearestPart = min( dDistanceToNearestPart, Proc.DistanceToNearestParts.Right) + end + -- se la distanza è inferiore ad un valore minimo forzo la tasca chiusa per evitare che la ricerca utensile fallisca + local dMinToolDiameter = 25 + if dDistanceToNearestPart < dMinToolDiameter / 2 - 10 * GEO.EPS_SMALL then + bForceClosedPocket = true + dDistanceToNearestPart = dMaxDiameter + end + + local bExcludeNoTipFeed = ( Proc.Topology == 'Pocket') -- recupero la lavorazione local bUseDElevToFindPocketing = true - local sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed) + local sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed, dDistanceToNearestPart) -- se tasca troppo profonda cerco senza elevazione e limiterò la profondità if not sPocketing then bUseDElevToFindPocketing = false - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed) + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed, dDistanceToNearestPart) end local dMillDiam = 20 local dMaxDepth = 0 @@ -2217,7 +2266,7 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) -- se doppio cerco una lavorazione adatta if Proc.Double and Proc.Double == 2 then local sPocketingBackup = sPocketing - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1', true) + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1', true, dDistanceToNearestPart) if not WM.IsMachiningOkForDouble( sPocketing) then Proc.Double = 0 sPocketing = sPocketingBackup @@ -2230,11 +2279,18 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam end end - -- verifico se la lavorazione (o il suo eventuale doppio) potrebbe danneggiare le parti limitrofe e devo quindi forzare una tasca chiusa - if IsMachiningDamagingOtherParts( Proc, dMillDiam, nRawId) or - Proc.Double and Proc.Double > 0 and IsMachiningDamagingOtherParts( Proc.Mirror, dMillDiam, nRawId) then + -- verifico se la lavorazione (o il suo eventuale mirror) potrebbe danneggiare le parti limitrofe e devo quindi forzare una tasca chiusa + local bIsMachiningDamagingOtherParts = IsMachiningDamagingOtherParts( Proc, dMillDiam, nRawId) + if bIsMachiningDamagingOtherParts then bForceClosedPocket = true end + -- disattivo il doppio se devo forzare una tasca chiusa ma l'altra no + if Proc.Double and Proc.Double > 0 then + local bIsMirrorMachiningDamagingOtherParts = IsMachiningDamagingOtherParts( Proc.Mirror, dMillDiam, nRawId) + if bIsMachiningDamagingOtherParts ~= bIsMirrorMachiningDamagingOtherParts then + Proc.Double = 0 + end + end -- altrimenti diametro utensile troppo piccolo: devo forzare tasca chiusa else bForceClosedPocket = true @@ -2242,17 +2298,17 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) -- se tasca chiusa cerco lavorazione con diametro massimo pari a dimensione tasca e riverifico per eventuale doppio if bForceClosedPocket then - dMaxDiameter = min( dH, dV) + dMaxDiameter = dStartDiameter bUseDElevToFindPocketing = true - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed) + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed, dDistanceToNearestPart) if not sPocketing then bUseDElevToFindPocketing = false - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed) + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed, dDistanceToNearestPart) end -- se doppio cerco una lavorazione adatta if Proc.Double and Proc.Double == 2 then local sPocketingBackup = sPocketing - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1', true) + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1', true, dDistanceToNearestPart) if not WM.IsMachiningOkForDouble( sPocketing) then Proc.Double = 0 sPocketing = sPocketingBackup @@ -2270,50 +2326,18 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) end end - return sPocketing, bForceClosedPocket, sTuuid, dMillDiam, dMaxDepth, dThDiam + return sPocketing, bForceClosedPocket, bIsFeatureOnEdge, sTuuid, dMillDiam, dMaxDepth, dThDiam end --------------------------------------------------------------------- local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) -- dati della faccia local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacet, GDB_ID.ROOT) local dElev = WL.GetFaceElevation( Proc.Id, nFacet, nRawId) - local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT) - local dDiam = min( dH, dV) -- gruppo ausiliario local nAddGrpId = WL.GetAddGroup( Proc.PartId) - local nNewProc, nNumFacet = RemoveBottomFaceAndReorder( Proc, nAddGrpId, nFacet) - -- se una sola faccia - if Proc.Fct == 1 then - dDiam = 2 * dDiam - end - -- se forma ad L - local bIsL = ( Proc.Fct == 2 or WL.TestElleShape3( Proc.Id, Proc.Fct) or WL.TestElleShape4( Proc.Id, Proc.Fct) == 2) - if bIsL then - dDiam = 2 * dDiam - end - -- se forma ad U - local bIsU = ( Proc.Fct == 3 and not WL.TestElleShape3( Proc.Id, Proc.Fct)) - if bIsU then - local _, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT) - -- prendo la linea di base - local dMiddleFacetLength = 0 - if abs( dElev - dH2) < 1 and abs( dElev - dV2) > 1 then - dMiddleFacetLength = dV2 - elseif abs( dElev - dV2) < 1 and abs( dElev - dH2) > 1 then - dMiddleFacetLength = dH2 - end - if dMiddleFacetLength > dDiam then - dDiam = min( 2 * dDiam, dMiddleFacetLength) - end - end - -- in presenza di angoli interni, limito secondo impostazione globale il diametro massimo utensile - if Proc.Fct == 3 and bIsL then - dDiam = min( dDiam, WD.MAXDIAM_POCK_CORNER or 1000) - elseif Proc.Fct >= 4 then - dDiam = min( dDiam, WD.MAXDIAM_POCK_CORNER or 1000) - end + local nNewProc = RemoveBottomFaceAndReorder( Proc, nAddGrpId, nFacet) -- cerco lavorazione adatta e recupero i dati utensile - local sPocketing, bForceClosedPocket, sTuuid, dMillDiam, dMaxDepth, dThDiam = VerifyPocket( Proc, dDiam, dElev, nRawId, dH, dV) + local sPocketing, bForceClosedPocket, bIsFeatureOnEdge, sTuuid, dMillDiam, dMaxDepth, dThDiam = VerifyPocket( Proc, nFacet, dElev, nRawId) if not sPocketing then local sErr = 'Error : pocketing not found in library' EgtOutLog( sErr) @@ -2366,6 +2390,9 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) end -- setto eventuale nota per forzare tasca chiusa if bForceClosedPocket then sUserNotes = EgtSetValInNotes( sUserNotes, 'Open', 0) end + -- setto eventuale nota per forzare attacco esterno, fino ad un certo spessore del grezzo + local dMaxRawThicknessToStartOut = 75 + if bIsFeatureOnEdge and ( not Proc.Double or Proc.Double == 0) then sUserNotes = EgtSetValInNotes( sUserNotes, 'OpenMinSafe', dMaxRawThicknessToStartOut) end -- scrivo le note della lavorazione EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- eseguo @@ -2374,7 +2401,9 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) EgtSetOperationMode( nMchFId, false) return false, sErr end + -- verifica parametro Q per pulitura spigoli + local bIsU = ( Proc.Fct == 3 and not WL.TestElleShape3( Proc.Id, Proc.Fct)) if bCheckQPar and not ( bIsU and AreSameOrOppositeVectorApprox( vtN, Z_AX())) then -- lettura parametri (probabile/i parametro/i Q) local nConeCut = EvaluateQParam( Proc) @@ -2382,7 +2411,7 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) local vFace, dMaxWidth = GetFacesData( nNewProc, false, false, dMillDiam, dMaxDepth, (dMillDiam/2), nAddGrpId, Proc.PartId) -- se abilitata la lavorazione corner con stop macchina if nConeCut == 1 then - local bMcok, sMcErr = AddMillCorner( nConeCut, vFace, Proc, nRawId, b3Raw, + local bMcok, sMcErr = AddMillCorner( nConeCut, vFace, Proc, nRawId, b3Raw, dMillDiam, nAddGrpId, dMaxWidth, nNewProc, dDepth) if not bMcok then return bMcok, sMcErr end elseif nConeCut == 2 then diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index fecc960..d0ee2ca 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -5,7 +5,6 @@ -- 2023/06/27 Aggiunte origini TN e BN. -- 2023/07/04 Se c'è funzione di macchina WD.GetOrigCorner si lascia scegliere posizione default a questa impostando 0 se non c'è 'REFPOS'. -- 2023/10/16 Aggiunta gestione Aree vietate (LockOut) per chiodature. --- 2023/10/30 In SetMirroredFeatures permesso il doppio per groove con specchiata non sul fianco se settate per essere lavorate come pocket. -- Tabella per definizione modulo local WallExec = {} @@ -797,7 +796,7 @@ local function SetMirroredFeatures( vProc, b3Raw) end end -- corrispondenza nella posizione delle feature. Se di fianco il lato master è sempre quello verso l'operatore, se sopra nessun vincolo - local bIsMirrorSideOk = ( bLapVsTop and ProcMirror.AffectedFaces.Back and bIsFeatureOnEdge and ( bIsMirrorFeatureOnEdge or nDoubleType == 1)) or + local bIsMirrorSideOk = ( bLapVsTop and ProcMirror.AffectedFaces.Back and bIsFeatureOnEdge and bIsMirrorFeatureOnEdge) or Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Left or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Right and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Right or diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index f696beb..55e465e 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -506,7 +506,7 @@ function WallLib.GetProcessDistanceToNearestParts( Proc) end ------------------------------------------------------------------------------------------------------------- --- restituisce le distanze XY tra la feature Proc e il grezzo, secondo le direzioni Y-/Y+/X-/X+ +-- restituisce le distanze XY tra la feature Proc e il termine del grezzo, secondo le direzioni Y-/Y+/X-/X+ function WallLib.GetProcessDistanceToRawPart( Proc, b3Raw) local b3Proc = Proc.Box local ptMinProc = b3Proc:getMin()