diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index b8970c3..812ad32 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -481,8 +481,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/ProcessDtMortise.lua b/LuaLibs/ProcessDtMortise.lua index ad4e66a..74992bc 100644 --- a/LuaLibs/ProcessDtMortise.lua +++ b/LuaLibs/ProcessDtMortise.lua @@ -103,7 +103,7 @@ function ProcessDtMortise.GetCutPlane( Proc) end --------------------------------------------------------------------- -local function CalcTopPath( nProcId, AuxId, nAddGrpId, dAltMort, dSideAng, b3Solid) +local function CalcPathAtHeight( nProcId, AuxId, nAddGrpId, dHeight, dSideAng, b3Solid) -- copio la curva di base local NewAuxId = EgtCopyGlob( AuxId, nAddGrpId) if not NewAuxId then return end @@ -111,7 +111,7 @@ local function CalcTopPath( nProcId, AuxId, nAddGrpId, dAltMort, dSideAng, b3Sol EgtAddCurveCompoLineTg( NewAuxId, 100, false) EgtAddCurveCompoLineTg( NewAuxId, 100, true) EgtMergeCurvesInCurveCompo( NewAuxId) - local dOffset = dAltMort * tan( dSideAng) + local dOffset = dHeight * tan( dSideAng) if not EgtOffsetCurve( NewAuxId, dOffset) then return end -- la limito entro la trave local refBox = Frame3d( b3Solid:getMin()) @@ -119,7 +119,7 @@ local function CalcTopPath( nProcId, AuxId, nAddGrpId, dAltMort, dSideAng, b3Sol local nCount NewAuxId, nCount = EgtTrimFlatCurveWithBox( NewAuxId, refBox, vtBoxDiag, true, true, GDB_RT.GLOB) -- eseguo traslazione e offset per portarla sul top - local vtMove = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) * ( dAltMort - 10 * GEO.EPS_SMALL) + local vtMove = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) * ( dHeight - 10 * GEO.EPS_SMALL) EgtMove( NewAuxId, vtMove, GDB_RT.GLOB) -- se divisa in più parti, le unisco congiungendole con segmenti if nCount > 1 then @@ -136,6 +136,23 @@ local function CalcTopPath( nProcId, AuxId, nAddGrpId, dAltMort, dSideAng, b3Sol return NewAuxId end +--------------------------------------------------------------------- +local function GetVerticalSteps( dMachiningDepth, dStep ) + local MachiningSteps = {} + MachiningSteps.StepLength = 0 + + if dMachiningDepth <= 0 then + MachiningSteps.Count = 0 + return MachiningSteps + end + + MachiningSteps.Count = ceil( (dMachiningDepth - 10 * GEO.EPS_SMALL) / dStep ) + + MachiningSteps.StepLength = dMachiningDepth / MachiningSteps.Count + + return MachiningSteps +end + --------------------------------------------------------------------- -- verifica che il box includa il punto in XY function EnclosesPoint( b3Box, ptP) @@ -154,6 +171,7 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) + bMakeAntiSplitPath = true -- ingombro del pezzo local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) if not b3Solid then @@ -286,12 +304,56 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) bCW = ( dSpeed >= 0) end end - -- verifico che la profondità non superi il massimo materiale dell'utensile + local bMultipleZPasses = false + -- se necessario, cerco un utensile più lungo if dAltMort > dMaxMat + 10 * GEO.EPS_SMALL then - local sErr = 'Error : DtMortise Depth bigger than Tool Cutting edge' - EgtOutLog( sErr) - return false, sErr + -- recupero la lavorazione : prima ricerca per sola tipologia + sMilling = ML.FindMilling( sMillType..sMchExt, nil, nil, nil, nil, bMillUp, bMillDown, bExcludeH2, nil, 'Longest') + if not sMilling and bMillUp then + sMilling = ML.FindMilling( sMillType, nil, nil, nil, nil, bMillUp, bMillDown, bExcludeH2, nil, 'Longest') + end + if not sMilling then + local sErr = 'Milling not found in library : Error on DtMortise ' .. tostring( Proc.Id) + EgtOutLog( sErr) + return false, sErr + end + -- recupero la lavorazione : seconda ricerca con tipologia e diametro massimo + sMilling = ML.FindMilling( sMillType..sMchExt, nil, nil, 2 * dMinRad, nil, bMillUp, bMillDown, bExcludeH2, nil, 'Longest') + if not sMilling and bMillUp then + sMilling = ML.FindMilling( sMillType, nil, nil, 2 * dMinRad, nil, bMillUp, bMillDown, bExcludeH2, nil, 'Longest') + sMchExt = '' + end + if not sMilling then + local sErr = 'Radius too small : Error on DtMortise ' .. tostring( Proc.Id) + EgtOutLog( sErr) + return false, sErr + end + if not sMilling then + local sErr = 'Error : DtMortise Depth bigger than Tool Cutting edge' + EgtOutLog( sErr) + return false, sErr + end + -- riassegno dati utensile + dToolDiam = 100 + dMaxMat = 30 + dSideAng = 0 + bCW = true + bMillOnAggregate = sMchExt == '_AT' + if EgtMdbSetCurrMachining( sMilling) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam + dToolDiam = max( dToolDiam, 10) + dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat + dSideAng = EgtTdbGetCurrToolParam( MCH_TP.SIDEANG) or dSideAng + local dSpeed = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) or 0 + bCW = ( dSpeed >= 0) + end + end + + bMultipleZPasses = true end + -- se con tasca, la lavoro (mai in doppio) if bPocket then -- recupero il contorno della tasca (seconda curva ausiliaria) @@ -374,7 +436,7 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) return false, sErr end -- calcolo il percorso top mortise - local nAuxId1 = CalcTopPath( Proc.Id, AuxId, nAddGrpId, dAltMort, dSideAng, b3Solid) + local nAuxId1 = CalcPathAtHeight( Proc.Id, AuxId, nAddGrpId, dAltMort, dSideAng, b3Solid) -- se esiste il percorso if nAuxId1 then -- creo percorso sulla parte alta della mortasa @@ -433,6 +495,10 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.DEPTH, dAltMort) -- setto offset radiale con aggiunto un ulteriore allargamento di 1mm EgtSetMachiningParam( MCH_MP.OFFSR, dToolRadDelta - 1) + -- antischeggia sempre con una passata + if bMultipleZPasses then + EgtSetMachiningParam( MCH_MP.STEP, 0) + end -- sistemo il lato e la direzione di lavoro EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( bCW, MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT)) EgtSetMachiningParam( MCH_MP.INVERT, EgtIf( bCW, false, true)) @@ -476,6 +542,23 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) local nPass = ceil( dDist / ( 1.9 * dToolDiam)) local dStep = 0 if nPass > 1 then dStep = max( ( dDist - 2 * dToolDiam) / ( 2 * nPass - 2), 0.25 * dToolDiam) end + + local dVerticalStep = 0 + if bMultipleZPasses then + local dToolVerticalStep = 0 + if EgtMdbSetCurrMachining( sMilling) then + dToolVerticalStep = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) or 0 + end + if dToolVerticalStep < 10 * GEO.EPS_SMALL then + dToolVerticalStep = dMaxMat / 3 + else + dToolVerticalStep = min( dToolVerticalStep, dMaxMat / 3) + end + local VerticalSteps = GetVerticalSteps( dAltMort, dToolVerticalStep) + dVerticalStep = VerticalSteps.StepLength + nPass = VerticalSteps.Count + end + for i = nPass, 1, -1 do -- inserisco la lavorazione di contornatura local sNameF = 'DtMt_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nPass) @@ -486,10 +569,39 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) return false, sErr end -- aggiungo geometria - EgtSetMachiningGeometry( {{ AuxId, -1}}) + local GeomId = AuxId + if ( i > 1) and bMultipleZPasses then + local dCurrentHeight = dAltMort - ( ( nPass - i + 1) * dVerticalStep) + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error : missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end + local b3MortiseNoPocket = EgtGetBBoxGlob( AuxId, GDB_BB.STANDARD) + GeomId = CalcPathAtHeight( Proc.Id, AuxId, nAddGrpId, dCurrentHeight, dSideAng, b3MortiseNoPocket) + if not GeomId then + local sErr = 'Wrong geometry : Error on DtMortise ' .. tostring( Proc.Id) + EgtOutLog( sErr) + return false, sErr + end + end + EgtSetMachiningGeometry( {{ GeomId, -1}}) -- imposto offset local dOffs = ( i - 1) * dStep + if bMultipleZPasses then + if i > 1 then + dOffs = 1 + else + dOffs = 0 + end + end EgtSetMachiningParam( MCH_MP.OFFSR, dOffs) + -- in caso di passate in Z già calcolate lo step deve essere nullo per garantire passate singole + if bMultipleZPasses then + EgtSetMachiningParam( MCH_MP.STEP, 0) + end -- sistemo il lato e la direzione di lavoro EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( bCW, MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT)) EgtSetMachiningParam( MCH_MP.INVERT, EgtIf( bCW, false, true)) @@ -526,7 +638,11 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.SCC, nSCC) end -- dichiaro massima elevazione e assenza sfridi per VMill - local sUserNotes = EgtSetVal( 'MaxElev', EgtNumToString( dMaxMat - 0.1, 1)) .. ';' .. EgtSetVal( 'VMRS', 0) .. ';' + local dMaxElev = dMaxMat + if bMultipleZPasses then + dMaxElev = dVerticalStep + end + local sUserNotes = EgtSetVal( 'MaxElev', EgtNumToString( dMaxElev - 0.1, 1)) .. ';' .. EgtSetVal( 'VMRS', 0) .. ';' -- in presenza di pocket dichiaro che non sto entrando e uscendo nel grezzo if bPocket then sUserNotes = EgtSetValInNotes( sUserNotes, 'OutRaw', 3) diff --git a/LuaLibs/ProcessDtTenon.lua b/LuaLibs/ProcessDtTenon.lua index ce528d3..fe14138 100644 --- a/LuaLibs/ProcessDtTenon.lua +++ b/LuaLibs/ProcessDtTenon.lua @@ -236,11 +236,32 @@ function ProcessDtTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) bCW = ( dSpeed >= 0) end end - -- verifico che l'altezza non superi il massimo materiale dell'utensile + -- se necessario, cerco un utensile più lungo if dDtTenH > dMaxMat + 10 * GEO.EPS_SMALL then - local sErr = 'Error : DtTenon Height bigger than Tool Cutting edge' - EgtOutLog( sErr) - return false, sErr + sMilling = ML.FindMilling( sMillType .. EgtIf( bMillDown and not bMillUp, '_H2', ''), nil, nil, nil, nil, bMillUp, bMillDown, nil, nil, 'Longest') + if not sMilling then + local sErr = 'Error : milling not found in library' + EgtOutLog( sErr) + return false, sErr + end + if not sMilling then + local sErr = 'Error : DtTenon Height bigger than Tool Cutting edge' + EgtOutLog( sErr) + return false, sErr + end + -- riassegno dati utensile + dTDiam = 50 + dMaxMat = 30 + bCW = true + if EgtMdbSetCurrMachining( sMilling) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam + dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat + local dSpeed = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) or 0 + bCW = ( dSpeed >= 0) + end + end end -- calcolo distanza massima della curva dal punto più lontano della base tenone Dt (facet 0) local dMaxDist diff --git a/UpdateLog.txt b/UpdateLog.txt index c03e8fe..7ff2ec2 100644 --- a/UpdateLog.txt +++ b/UpdateLog.txt @@ -11,10 +11,10 @@ Versione 2.7e2 (23/05/2025) - Fixed : in Scarf Joint correzione alla scelta faccia da lavorare Versione 2.7e1 (05/05/2025) +- Modif : in LapJoint se tunnel verticale lavorato solo da sopra e l'utensile non arriva, si restituisce warning - Fixed : in taglio di separazione si riduce percorso di taglio solo se il pezzo è effettivamente alto - Fixed : in foratura corretto caso in cui non si sceglieva l'utensile più lungo disponibile - Fixed : In BatchProcess (Ts7) corretta generazione in caso di progetto senza ricalcolo -- Modif : in LapJoint se tunnel verticale lavorato solo da sopra e l'utensile non arriva, si restituisce warning Versione 2.7d3 (22/04/2025) - Fixed : in LapJoint corretta gestione errata Q04