From 688b4e8e01d36a9e4a6f6f8e6c80c84f34e6469a Mon Sep 17 00:00:00 2001 From: DarioS Date: Tue, 22 Feb 2022 12:26:42 +0100 Subject: [PATCH] DataWall : - corretta gestione FreeContour per errore inserito in precedente rilascio - aggiunt gestione prefori (da parametri WD.PREDRILL_MINANGLE e WD.PREDRILL_DIAM). --- LuaLibs/WMachiningLib.lua | 30 ++++++++------- LuaLibs/WProcessDrill.lua | 66 ++++++++++++++++++++++++++++++++- LuaLibs/WProcessFreeContour.lua | 6 +-- LuaLibs/WallExec.lua | 2 + 4 files changed, 85 insertions(+), 19 deletions(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index 44807c6..ae106bc 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -126,20 +126,22 @@ function WMachiningLib.FindSawing( sType) end --------------------------------------------------------------------- -function WMachiningLib.FindDrilling( dDiam, dDepth, sHead) - -- ricerca sulle forature, dal diametro maggiore al minore - for i = #Drillings, 1, -1 do - local Drilling = Drillings[i] - if Drilling.On and Drilling.Type == 'Drill' and SetCurrMachiningAndTool( Drilling.Name) then - local nMchType = EgtMdbGetCurrMachiningParam( MCH_MP.TYPE) - local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - local dTMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) - local sMyHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) - if nMchType == MCH_MY.DRILLING and - dTDiam < dDiam + 10 * GEO.EPS_SMALL and dTDiam > dDiam - WD.DRILL_TOL - 10 * GEO.EPS_SMALL and - ( not dDepth or dTMaxMat > dDepth - GEO.EPS_SMALL) and - (( not sHead and sMyHead ~= 'H5' and sMyHead ~= 'H6') or sHead == sMyHead) then - return Drilling.Name, Drilling.Type, dTMaxMat +function WMachiningLib.FindDrilling( dDiam, dDepth, sHead, bOnlyPockets) + if bOnlyPockets == nil or not bOnlyPockets then + -- ricerca sulle forature, dal diametro maggiore al minore + for i = #Drillings, 1, -1 do + local Drilling = Drillings[i] + if Drilling.On and Drilling.Type == 'Drill' and SetCurrMachiningAndTool( Drilling.Name) then + local nMchType = EgtMdbGetCurrMachiningParam( MCH_MP.TYPE) + local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + local dTMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) + local sMyHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) + if nMchType == MCH_MY.DRILLING and + dTDiam < dDiam + 10 * GEO.EPS_SMALL and dTDiam > dDiam - WD.DRILL_TOL - 10 * GEO.EPS_SMALL and + ( not dDepth or dTMaxMat > dDepth - GEO.EPS_SMALL) and + (( not sHead and sMyHead ~= 'H5' and sMyHead ~= 'H6') or sHead == sMyHead) then + return Drilling.Name, Drilling.Type, dTMaxMat + end end end end diff --git a/LuaLibs/WProcessDrill.lua b/LuaLibs/WProcessDrill.lua index b48fe25..41dcba6 100644 --- a/LuaLibs/WProcessDrill.lua +++ b/LuaLibs/WProcessDrill.lua @@ -12,6 +12,7 @@ local WPD = {} -- Include require( 'EgtBase') +local WL = require( 'WallLib') EgtOutLog( ' WProcessDrill started', 1) @@ -421,11 +422,72 @@ function WPD.Make( Proc, nRawId, b3Raw) EgtSetOperationMode( nMchId, false) return false, sWarn else - return true, ( sMyWarn or sWarn) + sMyWarn = (sMyWarn or sWarn) end end - + + if WD.PREDRILL_DIAM > 0 and vtExtr:getZ() < WD.PREDRILL_MINANGLE then + -- gruppo ausiliario per preforo + local nAddGrpId = WL.GetAddGroup( Proc.PartId) + -- calcolo profondita' foro + local dLen = ( WD.PREDRILL_DIAM / 2) * sqrt( 1 - vtExtr:getZ() * vtExtr:getZ()) / vtExtr:getZ() + -- copio foro originale + local nPreHoleId = EgtCopyGlob( AuxId, nAddGrpId) + EgtModifyArcRadius( nPreHoleId, WD.PREDRILL_DIAM / 2) + EgtModifyCurveThickness( nPreHoleId, -dLen) --dLen = 10 + + -- se da invertire + if bToInvert then + -- lo sposto della lunghezza d'estrusione e ne inverto il versore + local dThickness = EgtCurveThickness( AuxId) + EgtMove( nPreHoleId, abs( dThickness) * vtExtr, GDB_RT.GLOB) + EgtModifyCurveExtrusion( nPreHoleId, vtExtr, GDB_RT.GLOB) + end + -- recupero lavorazione di pocket + local sDrilling = WM.FindDrilling( WD.PREDRILL_DIAM, dLen, nil, true) --dLen = 10 + + if not sDrilling then + local sErr = 'Error : prehole pocket not found in library' + EgtOutLog( sErr) + return false, sErr + end + + -- inserisco la lavorazione + local sName = 'PreDrill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchId = EgtAddMachining( sName, sDrilling) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sDrilling + EgtOutLog( sErr) + return false, sErr + end + EgtSetInfo( nMchId, 'Part', Proc.PartId) + -- setto la nota per spostarla prima della foratura + EgtSetInfo( nMchId, 'MOVE_BEFORE', 1) + -- aggiungo geometria + EgtSetMachiningGeometry( {{ nPreHoleId, -1}}) + --EgtSetMachiningParam( MCH_MP.TOOLINVERT, bToInvert) + + -- note utente, dichiarazione nessuna generazione sfridi per Vmill + local sUserNotes = 'VMRS=0;' + EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + else + local _, sWarn = EgtGetMachMgrWarning( 0) + if EgtIsMachiningEmpty() then + EgtSetOperationMode( nMchId, false) + return false, sWarn + else + sMyWarn = (sMyWarn or sWarn) + end + end + end + return true, sMyWarn + end --------------------------------------------------------------------- diff --git a/LuaLibs/WProcessFreeContour.lua b/LuaLibs/WProcessFreeContour.lua index f336a9f..3f86789 100644 --- a/LuaLibs/WProcessFreeContour.lua +++ b/LuaLibs/WProcessFreeContour.lua @@ -1230,9 +1230,9 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd if #vFace == 1 then dSal = -dMillDiam / 2 end -- se angolo interno prima if vFace[i].PrevAng < -30 then - local dSinA = -sin( vFace[OrigI].PlPrevAng + 90) - local dTanA = -tan( vFace[OrigI].PlPrevAng + 90) - dSal = -dMillDiam / 2 * ( 1 + ( 1 + dSinA) * dTanA) + min( 0, vFace[OrigI].Width * vFace[OrigI].Norm:getZ() * dTanA) + local dSinA = -sin( vFace[i].PlPrevAng + 90) + local dTanA = -tan( vFace[i].PlPrevAng + 90) + dSal = -dMillDiam / 2 * ( 1 + ( 1 + dSinA) * dTanA) + min( 0, vFace[i].Width * vFace[i].Norm:getZ() * dTanA) -- se faccia precedente inclinata verso il basso if j and vFace[j].Norm:getZ() < -0.017 then dSal = dSal + vFace[j].Width * vFace[j].Norm:getZ() diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 9e4ff0b..82994d3 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -534,6 +534,8 @@ local function SortMachinings( nPhase, PrevMch, nPartId) PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MORTISING, { 'Csaw_'}, false) -- Forature orizzontali con punte lunghe PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.DRILLING, { 'LhDrill_'}, true, 'MOVE_AFTER', false, true) + -- Preforature per fori inclinati + PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.POCKETING, { 'PreDrill_'}, true, nil, false, false) -- Forature e Svuotature PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.DRILLING + MCH_OY.POCKETING + MCH_OY.MILLING, { 'SideMill_', 'Clean_'}, false, 'MOVE_AFTER', false, false, true) -- -- Forature ***