From cac9ec767c0d6656351879d7e03899dfaa600974 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Thu, 26 Jun 2025 17:30:21 +0200 Subject: [PATCH 1/3] Prima versione finitura con fresa piccola su profilo caudato --- LuaLibs/MachiningLib.lua | 4 +- LuaLibs/ProcessProfCamb.lua | 95 +++++++++++++++++++++++++++++++++---- 2 files changed, 89 insertions(+), 10 deletions(-) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 768a9fd..098bf49 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -501,8 +501,8 @@ function MachiningLib.FindAngleDrilling( dDiam, dDepth, bTopHead, bDownHead) end --------------------------------------------------------------------- -function MachiningLib.FindMilling( sType, dDepth, sTuuidMstr, dMaxDiam, dMaxTotLen, bTopHead, bDownHead, bExcludeH2, bExcludeH3) - return FindMachining( MCH_MY.MILLING, sType, { Depth = dDepth, TuuidMstr = sTuuidMstr, MaxDiam = dMaxDiam, MaxTotLen = dMaxTotLen}, bTopHead, bDownHead, bExcludeH2, bExcludeH3) +function MachiningLib.FindMilling( sType, dDepth, sTuuidMstr, dMaxDiam, dMaxTotLen, bTopHead, bDownHead, bExcludeH2, bExcludeH3, sSortingCriterion) + return FindMachining( MCH_MY.MILLING, sType, { Depth = dDepth, TuuidMstr = sTuuidMstr, MaxDiam = dMaxDiam, MaxTotLen = dMaxTotLen}, bTopHead, bDownHead, bExcludeH2, bExcludeH3, sSortingCriterion) end --------------------------------------------------------------------- diff --git a/LuaLibs/ProcessProfCamb.lua b/LuaLibs/ProcessProfCamb.lua index b2f8a72..1778090 100644 --- a/LuaLibs/ProcessProfCamb.lua +++ b/LuaLibs/ProcessProfCamb.lua @@ -33,6 +33,7 @@ local sEnableExtraBladeUpperFace = 'Q02' -- i local sDepthChamferMill = 'Q03' -- d local sOverMaterialForFinish = 'Q04' -- d local sPreemptiveChamfer = 'Q05' -- i +local bUseSmallMill = 'Q06' -- i -- abilitazioni extra local dMakeAntiSplintOnHead = 1 -- valore impronta antischeggia, per disattivare settare = nil o = 0 @@ -206,6 +207,41 @@ local function VerifyCham( Proc, AuxId, nRawId, bMakeVertCham, sDephtCham, sOnly return nChamfer, dDepth, sMilling, sMilling2 end +--------------------------------------------------------------------- +function VerifySmallMillCanFinish( dDiamCurrentTool, dDepthProfile, nSide) + local dToolMaxDepthSmall, dToolDiamSmall + -- abilitazione lavorazione da sotto + local sMillType = 'Prof' + local sMillingSmall, _, _, bH2Small = ML.FindMilling( sMillType, nil, nil, nil, nil, true, nil, nil, nil, 'Smallest') + if not sMillingSmall then + return false + end + -- Recupero i dati dell'utensile + if EgtMdbSetCurrMachining( sMillingSmall) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid)) then + dToolMaxDepthSmall = EgtTdbGetCurrToolMaxDepth() + dToolDiamSmall = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + -- se non ci sono almeno 5mm di differenza si fa con utensile standard + if dDiamCurrentTool - 5 < dToolDiamSmall then + return false + end + end + else + return false + end + local bDouble = ( dDepthProfile + BD.CUT_EXTRA > dToolMaxDepthSmall) + -- se lavorazione in doppio richiesta, si verifica se richiesta testa sotto + if bDouble and nSide == 0 then + return false -- TODO macchine con BD.DOWN_HEAD potrebbero lavorare in doppio in questo caso! + end + + if not bDouble or ( dDepthProfile + BD.MILL_OVERLAP < dToolMaxDepthSmall * 2) then + return true, sMillingSmall, bDouble + end + return false +end + --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) @@ -244,7 +280,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) if vtN:getZ() > 0.1 then nSide = 1 elseif vtN:getZ() < -0.1 then - nSide = -1 + nSide = -1 end -- abilitazione lavorazione da sotto local bMillDown = ( BD.DOWN_HEAD and nSide == -1) @@ -468,6 +504,15 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end end + + + local bUseSmallMillOnFinish = EgtGetInfo( Proc.Id, bUseSmallMill, 'i') == 1 + local sMillingSmall, bDoubleSmall + -- se serve fresa più piccola per finitura + if bUseSmallMillOnFinish then + bUseSmallMillOnFinish, sMillingSmall, bDoubleSmall = VerifySmallMillCanFinish( dMillDiam, dProfDepth, nSide) + end + -- se il chamfer non è esclusivo continuo con le altre lavorazioni if nChamfer < 2 then -- verifico se necessario lavorare in doppio @@ -477,7 +522,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) local sMillingDown if bDouble then if nSide == 0 then - if BD.DOWN_HEAD then + if BD.DOWN_HEAD then -- recupero la lavorazione sMillingDown = ML.FindMilling( 'Prof_H2', nil, nil, nil, nil, false, true) if not sMillingDown then @@ -537,10 +582,6 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) bFinish = true end - -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale precedente - if dOffsetPar > 0 then - EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) - end -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -567,7 +608,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) nMchId = nMch2Id end -- se abilitata, aggiungo lavorazione di finitura - if bFinish then + if bFinish and not bUseSmallMillOnFinish then -- inserisco la lavorazione local sNewName = 'ProfB_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) @@ -682,7 +723,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) nMchId = nMch2Id end -- se abilitata, aggiungo lavorazione di finitura - if bFinish then + if bFinish and not bUseSmallMillOnFinish then -- inserisco la lavorazione local sNewName = 'Prof_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) @@ -738,6 +779,44 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) return false, sErr end end + -- se finitura con fresa piccola + if bFinish and bUseSmallMillOnFinish then + local sDepthSmall = EgtIf( bDoubleSmall, ( dProfDepth+ BD.MILL_OVERLAP ) / 2, dProfDepth + BD.CUT_EXTRA) + local sMachName = 'Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + nMchId = EgtAddMachining( sMachName, sMillingSmall) + if not nMchId then + local sErr = 'Error adding machining ' .. sMachName .. '-' .. sMillingSmall + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ AuxId, -1}}) + + -- imposto l'affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, sDepthSmall) + -- posizione braccio porta testa + EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + + if bDoubleSmall then + local sNewName = 'FinB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) + + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + end + end end -- aggiorno ingombro testa o coda per presa if nSide ~= 1 then -- se feature di fianco o da sotto From a996d4beb34569558b83b4c5d2c7e15ca70827fa Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 30 Jun 2025 16:13:19 +0200 Subject: [PATCH 2/3] - in LapJoint correzioni a sega a catena con attacco laterale --- LuaLibs/BeamLib.lua | 21 +++++++++++++++++++++ LuaLibs/ProcessLapJoint.lua | 19 +++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 1d66881..72188fb 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -899,6 +899,27 @@ function BeamLib.FindFaceBestOrientedAsAxis( Proc, vtAx, fctExclude) return nFaceIndMax, ptC, vtN end +--------------------------------------------------------------------- +function BeamLib.GetEdgeToMachineFromVector( nSurfId, nFacet, vtOrtho) + local _, EdgesEgt = EgtSurfTmGetFacetOutlineInfo( nSurfId, nFacet, GDB_ID.ROOT) + + local nEdgeIndMax = 0 + local dMaxComp = - GEO.INFINITO + for i = 1, #EdgesEgt do + local vtN = EdgesEgt[i].Norm + if EdgesEgt[i].Open then + vtN = -vtN + end + local dComp = vtN * vtOrtho + if dComp > dMaxComp then + nEdgeIndMax = i -1 + dMaxComp = dComp + end + end + + return nEdgeIndMax +end + --------------------------------------------------------------------- function BeamLib.GetTunnelDimension( Proc, nPartId) -- sono necessarie almeno due facce diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 56de528..a932c2e 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -3224,6 +3224,8 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, vtRef = -Z_AX() nFaceZ = BL.FindFaceBestOrientedAsAxis( Proc, -Z_AX()) end + else + nFaceZ = nFacInd end dDepth = Proc.Face[ nFaceZ + 1].Elevation end @@ -3284,12 +3286,21 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, EgtOutLog( sWarn) end EgtSetMachiningParam( MCH_MP.DEPTH, dMachiningDepth) - local dStartAddLen = dSawWidth / 2 + EgtMdbGetGeneralParam( MCH_GP.SAFEZ) + EgtMdbGetGeneralParam( MCH_GP.SAFEAGGRBOTTZ) - local dEndAddLen = - dSawWidth / 2 - if vtRef:getZ() > 10 * GEO.EPS_SMALL then + -- si decidono lato di lavoro, inversione e estensione in base al lato aperto + local nEdgeIndex = BL.GetEdgeToMachineFromVector( Proc.Id, nFacAdj, vtRef) + local EdgesEgt = BL.GetEdgesInfo( Proc, Proc.Face[nFacAdj+1]) + local CurrentEdge = EdgesEgt[nEdgeIndex+1] + local dStartAddLen = 0 + local dEndAddLen = 0 + if CurrentEdge.IsStartOpen then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MORTISE_WS.RIGHT) + EgtSetMachiningParam( MCH_MP.INVERT, false) + else EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MORTISE_WS.LEFT) EgtSetMachiningParam( MCH_MP.INVERT, true) end + dStartAddLen = dSawWidth / 2 + EgtMdbGetGeneralParam( MCH_GP.SAFEZ) + EgtMdbGetGeneralParam( MCH_GP.SAFEAGGRBOTTZ) + dEndAddLen = - dSawWidth / 2 EgtSetMachiningParam( MCH_MP.STARTADDLEN, dStartAddLen) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEndAddLen) end @@ -3299,7 +3310,7 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, local dMachiningStep = EgtGetMachiningParam( MCH_MP.STEP) or 0 -- TODO qui sostituire con valore preciso da GetSetupInfo if BD.C_SIMM then - dMachiningStep = 165 + dMachiningStep = 175 if vtRef:getZ() < - 10 * GEO.EPS_SMALL then dMachiningStep = 250 end From ea64a9a3f4a1269cc0115f9ae34a578c18fd7dec Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Mon, 30 Jun 2025 17:39:18 +0200 Subject: [PATCH 3/3] =?UTF-8?q?In=20FindMachining,=20se=20c'=C3=A8=20un=20?= =?UTF-8?q?criterio=20di=20selezione=20utensile,=20allora=20non=20si=20ott?= =?UTF-8?q?imizzano=20le=20teste.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/MachiningLib.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 098bf49..167e9cb 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -331,6 +331,7 @@ end --------------------------------------------------------------------- local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, bExcludeH2, bExcludeH3, sSortingCriterion) + local bOptimizeHeads = BEAM and BEAM.BW and ( not sSortingCriterion or sSortingCriterion == '') if bTopHead == nil and bDownHead == nil then bTopHead = true bDownHead = false @@ -368,15 +369,15 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, ForEnd = 1 ForStep = -1 end - if ( BEAM and BEAM.BW) or MachineHeadType == ONE_HEAD or MachineHeadType == TWO_EQUAL_HEADS or ( MachineHeadType == TWO_UP_DOWN_HEADS and not bDownHead) then + if bOptimizeHeads or MachineHeadType == ONE_HEAD or MachineHeadType == TWO_EQUAL_HEADS or ( MachineHeadType == TWO_UP_DOWN_HEADS and not bDownHead) then _, sType = EgtEndsWith( sType, '_H2') - elseif not ( BEAM and BEAM.BW) and MachineHeadType == TWO_UP_DOWN_HEADS and not bTopHead and bDownHead then + elseif not bOptimizeHeads and MachineHeadType == TWO_UP_DOWN_HEADS and not bTopHead and bDownHead then if not EgtEndsWith( sType, '_H2') then sType = sType .. '_H2' end end local MachineHeadUse = MachineHeadType - if not ( BEAM and BEAM.BW) and MachineHeadUse == TWO_EQUAL_HEADS then + if not bOptimizeHeads and MachineHeadUse == TWO_EQUAL_HEADS then MachineHeadUse = ONE_HEAD end if MachineHeadUse == TWO_UP_DOWN_HEADS and bTopHead and bDownHead then @@ -388,7 +389,7 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, for i = ForStart, ForEnd, ForStep do local Machining = Machinings[i] local sMachiningType = Machining.Type - if ( BEAM and BEAM.BW) or MachineHeadUse == TWO_EQUAL_HEADS then + if bOptimizeHeads or MachineHeadUse == TWO_EQUAL_HEADS then _, sMachiningType = EgtEndsWith( Machining.Type, '_H2') end -- recupero dati utensile @@ -464,7 +465,7 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, end end local bH2, sOrigType = EgtEndsWith( sType, '_H2') - if ( not BEAM or not BEAM.BW) and MachineHeadType == TWO_UP_DOWN_HEADS and bH2 and bTopHead then + if not bOptimizeHeads and MachineHeadType == TWO_UP_DOWN_HEADS and bH2 and bTopHead then return FindMachining( MachiningType, sOrigType, Params, true, false) end end