From 7ccf3f888f0de15cc91f854ec35faf600a4b1650 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 27 Feb 2025 12:54:16 +0100 Subject: [PATCH] =?UTF-8?q?-=20nei=20parametri=20opzionali=20di=20tipo=20d?= =?UTF-8?q?ouble=20('d')=20ora=20se=20la=20stringa=20=C3=A8=20vuota=20si?= =?UTF-8?q?=20considera=20come=20parametro=20non=20passato=20(nil)=20-=20a?= =?UTF-8?q?lcune=20modifiche=20all'angolo=20min/max=20testa=20da=20GetSetu?= =?UTF-8?q?pInfo=20di=20macchina=20-=20in=20MachiningLib=20->=20FindBlade?= =?UTF-8?q?=20ora=20si=20controlla=20se=20la=20normale=20della=20faccia=20?= =?UTF-8?q?da=20lavorare=20=C3=A8=20compatibile=20con=20eventuali=20angoli?= =?UTF-8?q?=20Max/Min=20da=20SetupInfo;=20si=20passa=20vtN=20e=20non=20pi?= =?UTF-8?q?=C3=B9=20vtToolDirection=20-=20in=20tutte=20le=20strategia=20si?= =?UTF-8?q?stemati=20i=20parametri=20Config=20di=20tipo=20combo=20-=20in?= =?UTF-8?q?=20STR0005=20->=20codolo=20si=20verifica=20che=20le=202=20lavor?= =?UTF-8?q?azioni=20siano=20state=20fatte=20altrimenti=20si=20restituisce?= =?UTF-8?q?=20non=20applicabile=20-=20aggiunta=20GetBestBladeForDicing=20p?= =?UTF-8?q?er=20scelta=20lama=20in=20caso=20di=20cubetti=20-=20in=20FACEBY?= =?UTF-8?q?BLADE=20se=20ToolInvert=20si=20passa=20la=20vtN=20invertita=20a?= =?UTF-8?q?lla=20ricerca=20lama?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/BeamLib.lua | 18 ++-- LuaLibs/MachiningLib.lua | 15 +++- Strategies/Standard/HEADCUT/HEADCUT.lua | 2 +- Strategies/Standard/STR0003/STR0003Config.lua | 6 +- Strategies/Standard/STR0004/STR0004Config.lua | 6 +- Strategies/Standard/STR0005/STR0005.lua | 50 +++++++---- Strategies/Standard/STR0005/STR0005Config.lua | 14 +-- StrategyLibs/BLADETOWASTE.lua | 90 ++++++++++++++++--- StrategyLibs/FACEBYBLADE.lua | 27 +++--- StrategyLibs/SPLITCUT.lua | 2 +- 10 files changed, 164 insertions(+), 66 deletions(-) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 6661f23..1cd4304 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -91,16 +91,11 @@ function BeamLib.AddPartEndFace( PartId, b3Solid) end ------------------------------------------------------------------------------------------------------------- -function BeamLib.GetPartSplittingPoints( Part, OptionalParameters) +function BeamLib.GetPartSplittingPoints( Part) local PartSplittingPoints = {} local dPartLength = Part.b3Part:getDimX() - - -- parametri opzionali - if not OptionalParameters then - OptionalParameters = {} - end - local dMaxSegmentLength = OptionalParameters.dMaxSegmentLength or BeamData.LONGCUT_MAXLEN - local dMaxSegmentLengthOnEdges = OptionalParameters.dMaxSegmentLengthOnEdges or BeamData.LONGCUT_ENDLEN + local dMaxSegmentLength = BeamData.LONGCUT_MAXLEN + local dMaxSegmentLengthOnEdges = BeamData.LONGCUT_ENDLEN if dPartLength < dMaxSegmentLength + 10 * GEO.EPS_SMALL then return {} @@ -447,7 +442,12 @@ function BeamLib.LoadCustomParametersInStrategy( CustomParameters) if CustomParameters[i].sType == 'b' then Parameters[CustomParameters[i].sName] = CustomParameters[i].sValue == 'true' elseif CustomParameters[i].sType == 'd' then - Parameters[CustomParameters[i].sName] = tonumber( CustomParameters[i].sValue) + if #CustomParameters[i].sValue > 0 then + Parameters[CustomParameters[i].sName] = tonumber( CustomParameters[i].sValue) + -- stringa vuota equivale a non passare alcun valore (deciderà la strategia) + else + Parameters[CustomParameters[i].sName] = nil + end else --CustomParameters[i].sType == 's' or CustomParameters[i].sType == 'combo' Parameters[CustomParameters[i].sName] = CustomParameters[i].sValue end diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 79befe3..a28bc02 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -216,9 +216,9 @@ function MachiningLib.FindMill( Proc, ToolSearchParameters) -- controlli standard elseif TOOLS[i].dDiameter > ToolSearchParameters.dMaxToolDiameter then bIsToolCompatible = false - elseif TOOLS[i].SetupInfo.HeadType.bTop and ToolSearchParameters.vtToolDirection:getZ() < TOOLS[i].SetupInfo.dMaxNegativeAngle then + elseif TOOLS[i].SetupInfo.dMinNz and ToolSearchParameters.vtToolDirection:getZ() < TOOLS[i].SetupInfo.dMinNz - GEO.EPS_ZERO then bIsToolCompatible = false - elseif TOOLS[i].SetupInfo.HeadType.bBottom and ToolSearchParameters.vtToolDirection:getZ() > TOOLS[i].SetupInfo.dMaxPositiveAngle then + elseif TOOLS[i].SetupInfo.dMaxNz and ToolSearchParameters.vtToolDirection:getZ() > TOOLS[i].SetupInfo.dMaxNz + GEO.EPS_ZERO then bIsToolCompatible = false elseif ToolSearchParameters.sMillShape == 'STANDARD' and ( TOOLS[i].dSideAngle ~= 0 or TOOLS[i].bIsPen) then bIsToolCompatible = false @@ -297,12 +297,11 @@ end -- funzione per cercare utensile tipo LAMA con certe caratteristiche -- TODO da completare -- TODO il FindBlade dovrà restituire di utilizzare sempre la lama sopra se l'angolo lo permette, ma avendo un'altezza massima (da macchina) oltre cui il DownUp non sarà fattibile (evita collisioni tra asse e pezzo) --- TODO bisogna leggere vtToolDirection in arrivo e confrontarlo con il SetupInfo function MachiningLib.FindBlade( Proc, ToolSearchParameters) local ToolInfo = {} -- parametri obbligatori - if type( ToolSearchParameters.vtToolDirection) ~= 'table' then + if type( ToolSearchParameters.vtN) ~= 'table' then error( 'FindBlade : missing tool direction') end if type( ToolSearchParameters.bAllowTopHead) ~= 'boolean' then @@ -334,6 +333,14 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) end end + -- check angolo limite lama + if TOOLS[i].SetupInfo.dMinNz and ToolSearchParameters.vtN:getZ() < TOOLS[i].SetupInfo.dMinNz - GEO.EPS_ZERO then + bIsToolCompatible = false + end + if TOOLS[i].SetupInfo.dMaxNz and ToolSearchParameters.vtN:getZ() > TOOLS[i].SetupInfo.dMaxNz + GEO.EPS_ZERO then + bIsToolCompatible = false + end + if bIsToolCompatible then -- TODO gestire accorciamento massimo materiale per inclinazione local dCurrentResidualDepth = ToolSearchParameters.dElevation - TOOLS[i].dMaxDepth diff --git a/Strategies/Standard/HEADCUT/HEADCUT.lua b/Strategies/Standard/HEADCUT/HEADCUT.lua index d689743..ab1a7a9 100644 --- a/Strategies/Standard/HEADCUT/HEADCUT.lua +++ b/Strategies/Standard/HEADCUT/HEADCUT.lua @@ -67,7 +67,7 @@ local function GetSplitStrategy( Proc, Part) Machining.sTypeMachining = 'None' local Splitting = {} local ToolSearchParameters = {} - ToolSearchParameters.vtToolDirection = Proc.Faces[1].vtN + ToolSearchParameters.vtN = Proc.Faces[1].vtN -- ===== RICERCA UTENSILE ===== diff --git a/Strategies/Standard/STR0003/STR0003Config.lua b/Strategies/Standard/STR0003/STR0003Config.lua index 7228d07..dfb5d14 100644 --- a/Strategies/Standard/STR0003/STR0003Config.lua +++ b/Strategies/Standard/STR0003/STR0003Config.lua @@ -4,15 +4,15 @@ local STR0003Data = { sStrategyId = 'STR0003', Parameters = { { sName = 'bFinishWithChainSaw', sNameNge = 'ALLOW_FINISH_CHAINSAW', sValue = 'true', sDescriptionShort = 'Finish with chainsaw if needed', sDescriptionLong = 'Finish with chainsaw if needed', sType = 'b', sMessageId = '', sMinUserLevel = '1'}, - { sName = 'dExtendAfterTail', sNameNge = 'EXTEND_AFTER_TAIL', sValue = 'false', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'dExtendAfterTail', sNameNge = 'EXTEND_AFTER_TAIL', sValue = '', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, { sName = 'bForceLongcutBlade', sNameNge = 'USE_LONGCUT_BLADE', sValue = 'false', sDescriptionShort = 'Force ripping blade', sDescriptionLong = 'Force the use of ripping blade, designed for cuts parallel to the grain', sType = 'b', sMessageId = '', sMinUserLevel = '1'}, { sName = 'bNotCompleteWithBladeRadius', sNameNge = 'NOT_COMPLETE_WITH_BLADE_RADIUS', sValue = 'true', sDescriptionShort = '', sDescriptionLong = '', sType = 'b', sMessageId = '', sMinUserLevel = '1'}, { sName = 'bUseZigZagMortising', sNameNge = 'USE_ZIGZAG_CHAINSAW', sValue = 'false', sDescriptionShort = '', sDescriptionLong = '', sType = 'b', sMessageId = '', sMinUserLevel = '1'}, { sName = 'bSortBySegment', sNameNge = 'SORT_BY_SEGMENT', sValue = 'true', sDescriptionShort = '', sDescriptionLong = '', sType = 'b', sMessageId = '', sMinUserLevel = '1'}, { sName = 'sCanDamageNextPiece', sNameNge = 'DAMAGE_NEXT_PIECE', sValue = 'NEVER', sType = 'combo', sMinUserLevel = '1', - Choices = { sValue = 'NEVER', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, + Choices = { { sValue = 'NEVER', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, { sValue = 'ONLY_IF_RAWPART', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, - { sValue = 'ALWAYS', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}} + { sValue = 'ALWAYS', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}} } } diff --git a/Strategies/Standard/STR0004/STR0004Config.lua b/Strategies/Standard/STR0004/STR0004Config.lua index 924b46f..7e9e6f6 100644 --- a/Strategies/Standard/STR0004/STR0004Config.lua +++ b/Strategies/Standard/STR0004/STR0004Config.lua @@ -4,11 +4,11 @@ local STR0004Data = { sStrategyId = 'STR0004', Parameters = { { sName = 'bUseZigZagMortising', sNameNge = 'USE_ZIGZAG_CHAINSAW', sValue = 'false', sDescriptionShort = '', sDescriptionLong = '', sType = 'b', sMessageId = '', sMinUserLevel = '1'}, - { sName = 'dExtendAfterTail', sNameNge = 'EXTEND_AFTER_TAIL', sValue = 'false', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'dExtendAfterTail', sNameNge = 'EXTEND_AFTER_TAIL', sValue = '', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, { sName = 'sCanDamageNextPiece', sNameNge = 'DAMAGE_NEXT_PIECE', sValue = 'NEVER', sType = 'combo', sMinUserLevel = '1', - Choices = { sValue = 'NEVER', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, + Choices = { { sValue = 'NEVER', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, { sValue = 'ONLY_IF_RAWPART', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, - { sValue = 'ALWAYS', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}} + { sValue = 'ALWAYS', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}} } } diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 7662d10..dd52f1a 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -180,27 +180,45 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) table.sort( Blade.Result.Sorted, SortMachiningsBySegment) -- calcolo parametri per la stima della velocità di asportazione - MRRParameters1 = { - dStep = TOOLS[Cutting1.nToolIndex].dThickness, - dSideStep = min( TOOLS[Cutting1.nToolIndex].dSideStep, dDepthToMachine), - dFeed = TOOLS[Cutting1.nToolIndex].Feeds.dFeed} - - MRRParameters2 = { - dStep = TOOLS[Cutting2.nToolIndex].dThickness, - dSideStep = min( TOOLS[Cutting2.nToolIndex].dSideStep, dDepthToMachine), - dFeed = TOOLS[Cutting2.nToolIndex].Feeds.dFeed} - - local dMRRBlade1 = MachiningLib.GetToolMRR( MRRParameters1) - local dMRRBlade2 = MachiningLib.GetToolMRR( MRRParameters2) - dMRRBlade = ( dMRRBlade1 + dMRRBlade2) / 2 + if Cutting1.bIsApplicable and Cutting2.bIsApplicable then + MRRParameters1 = { + dStep = TOOLS[Cutting1.nToolIndex].dThickness, + dSideStep = min( TOOLS[Cutting1.nToolIndex].dSideStep, dDepthToMachine), + dFeed = TOOLS[Cutting1.nToolIndex].Feeds.dFeed} + + MRRParameters2 = { + dStep = TOOLS[Cutting2.nToolIndex].dThickness, + dSideStep = min( TOOLS[Cutting2.nToolIndex].dSideStep, dDepthToMachine), + dFeed = TOOLS[Cutting2.nToolIndex].Feeds.dFeed} + + local dMRRBlade1 = MachiningLib.GetToolMRR( MRRParameters1) + local dMRRBlade2 = MachiningLib.GetToolMRR( MRRParameters2) + dMRRBlade = ( dMRRBlade1 + dMRRBlade2) / 2 - dCompletionPercentage = Cutting2.dCompletionPercentage + dCompletionPercentage = Cutting2.dCompletionPercentage + else + dMRRBlade = 0 + dCompletionPercentage = 0 + end end -- lavorazione a cubetti / taglio singolo if #Blade.Result == 0 and not bLeaveWasteAttached then - local bDropWholeWaste = Strategy.Parameters.sCuttingStrategy == 'DROP_WHOLE_WASTE' - local OptionalParameters = { bDropWholeWaste = bDropWholeWaste, dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume, dMaxWasteLength = Strategy.Parameters.dMaxWasteLength} + local bDropWholeWaste = ( Strategy.Parameters.sCuttingStrategy == 'DROP_WHOLE_WASTE') + local dMinZTopBlade + local dMaxNyTopBlade + if Strategy.Parameters.dMinZAngleTopBlade then + dMinZTopBlade = sin( Strategy.Parameters.dMinZAngleTopBlade) + end + if Strategy.Parameters.dMaxYAngleTopBlade then + dMaxNyTopBlade = sin( Strategy.Parameters.dMaxYAngleTopBlade) + end + local OptionalParameters = { bDropWholeWaste = bDropWholeWaste, + dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume, + dMaxWasteLength = Strategy.Parameters.dMaxWasteLength, + dMinNzTopBlade = dMinZTopBlade, + dMaxNyTopBlade = dMaxNyTopBlade + } Blade.Result.Sorted, dCompletionPercentage = BladeToWaste.Make( Proc, Part, OptionalParameters) end diff --git a/Strategies/Standard/STR0005/STR0005Config.lua b/Strategies/Standard/STR0005/STR0005Config.lua index 85edf67..1702e91 100644 --- a/Strategies/Standard/STR0005/STR0005Config.lua +++ b/Strategies/Standard/STR0005/STR0005Config.lua @@ -6,18 +6,20 @@ local STR0005Data = { sStrategyId = 'STR0005', Parameters = { { sName = 'bForceLongcutBlade', sNameNge = 'USE_LONGCUT_BLADE', sValue = 'false', sDescriptionShort = 'Force ripping blade', sDescriptionLong = 'Force the use of ripping blade, designed for cuts parallel to the grain', sType = 'b', sMessageId = '', sMinUserLevel = '1'}, - { sName = 'dExtendAfterTail', sNameNge = 'EXTEND_AFTER_TAIL', sValue = 'false', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'dExtendAfterTail', sNameNge = 'EXTEND_AFTER_TAIL', sValue = '', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, { sName = 'sCanDamageNextPiece', sNameNge = 'DAMAGE_NEXT_PIECE', sValue = 'NEVER', sType = 'combo', sMinUserLevel = '1', - Choices = { sValue = 'NEVER', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, + Choices = { { sValue = 'NEVER', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, { sValue = 'ONLY_IF_RAWPART', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, - { sValue = 'ALWAYS', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}, + { sValue = 'ALWAYS', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}}, { sName = 'sCuttingStrategy', sNameNge = 'CUTTING_STRATEGY', sValue = 'AUTO', sType = 'combo', sMinUserLevel = '1', - Choices = { sValue = 'AUTO', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, + Choices = { { sValue = 'AUTO', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, { sValue = 'DROP_WHOLE_WASTE', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, - { sValue = 'LEAVE_WASTE_ATTACHED', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}, + { sValue = 'LEAVE_WASTE_ATTACHED', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}}, { sName = 'dMaxWasteLength', sNameNge = 'MAX_WASTE_LENGTH', sValue = '300', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, { sName = 'dMaxWasteVolume', sNameNge = 'MAX_WASTE_VOLUME', sValue = '6000000', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, - { sName = 'dStripWidth', sNameNge = 'STRIP_WIDTH', sValue = '5', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'} + { sName = 'dStripWidth', sNameNge = 'STRIP_WIDTH', sValue = '5', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'dMinZAngleTopBlade', sNameNge = 'MIN_Z_ANGLE_TOP_BLADE', sValue = '', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'dMaxYAngleTopBlade', sNameNge = 'MAX_Y_ANGLE_TOP_BLADE', sValue = '1', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'} } } diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index 4eb3edb..cbd52f7 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -20,6 +20,70 @@ EgtOutLog( ' BLADETOWASTE started', 1) ------------------------------------------------------------------------------------------------------------- +local function GetBestBladeForDicing( Proc, Part, Face, OptionalParameters) + local nChosenToolIndex + + -- parametri opzionali + local dMinNzTopBladeIfEqual = OptionalParameters.dMinNzTopBlade or sin(-5) + local dMaxNyTopBlade = OptionalParameters.dMaxNyTopBlade or sin(1) + local dShortPartLength = OptionalParameters.dShortPartLength or BeamData.LEN_SHORT_PART + + -- ricerca lama testa sopra + local ToolSearchParameters = {} + ToolSearchParameters.vtN = Face.vtN + ToolSearchParameters.bAllowTopHead = true + ToolSearchParameters.bAllowBottomHead = false + ToolSearchParameters.bForceLongcutBlade = false + ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) + local nToolIndexTop = ToolInfo.nToolIndex + + -- ricerca lama testa sotto + ToolSearchParameters = {} + ToolSearchParameters.vtN = Face.vtN + ToolSearchParameters.bAllowTopHead = false + ToolSearchParameters.bAllowBottomHead = true + ToolSearchParameters.bForceLongcutBlade = false + ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) + local nToolIndexBottom = ToolInfo.nToolIndex + + -- lama sopra e sotto + if nToolIndexTop and nToolIndexBottom then + -- angolo minimo che determina la preferenza tra lama sopra e sotto + local dMinNzTopBlade + -- entrambe le lame senza aggregato o entrambe con aggregato + if TOOLS[nToolIndexTop].SetupInfo.bIsCSymmetrical == TOOLS[nToolIndexBottom].SetupInfo.bIsCSymmetrical then + dMinNzTopBlade = dMinNzTopBladeIfEqual + -- lama sopra con aggregato - preferenza testa sopra + elseif not TOOLS[nToolIndexTop].SetupInfo.bIsCSymmetrical then + dMinNzTopBlade = OptionalParameters.dMinNzTopBlade or TOOLS[nToolIndexTop].SetupInfo.dMinNz / 2 + -- lama sotto con aggregato - preferenza testa sotto + elseif not TOOLS[nToolIndexBottom].SetupInfo.bIsCSymmetrical then + dMinNzTopBlade = OptionalParameters.dMinNzTopBlade or TOOLS[nToolIndexBottom].SetupInfo.dMaxNz / 2 + else + error( 'GetBestBladeForDicing : unknown blade type') + end + + -- se la Z della faccia è sotto all'angolo minimo e inclinata in Y oppure il pezzo è corto, si preferisce la lama sotto + if Face.vtN:getZ() < dMinNzTopBlade - GEO.EPS_SMALL + and ( abs( Face.vtN:getY()) > dMaxNyTopBlade or Part.b3Raw:getDimX() < dShortPartLength - 10 * GEO.EPS_SMALL) then + nChosenToolIndex = nToolIndexBottom + else + nChosenToolIndex = nToolIndexTop + end + + -- solo lama sopra + elseif nToolIndexTop then + nChosenToolIndex = nToolIndexTop + -- solo lama sotto + elseif nToolIndexBottom then + nChosenToolIndex = nToolIndexBottom + end + + -- se non trovata alcuna lama ritorna nil + return nChosenToolIndex +end + + function BLADETOWASTE.Make( Proc, Part, OptionalParameters) local Result = {} local dCompletionPercentage = 0 @@ -34,6 +98,9 @@ function BLADETOWASTE.Make( Proc, Part, OptionalParameters) end -- parametri opzionali e default + if not OptionalParameters then + OptionalParameters = {} + end local nToolIndex = OptionalParameters.nToolIndex local bDropWholeWaste = OptionalParameters.bDropWholeWaste or false local dMaxWasteVolume = OptionalParameters.dMaxWasteVolume or 0 @@ -61,7 +128,7 @@ function BLADETOWASTE.Make( Proc, Part, OptionalParameters) end dDepthToMachine = EdgeToMachine.dElevation + BeamData.CUT_EXTRA ToolSearchParameters.dElevation = dDepthToMachine - ToolSearchParameters.vtToolDirection = EdgeToMachine.vtN + ToolSearchParameters.vtN = Proc.Faces[1].vtN ToolSearchParameters.bAllowTopHead = true -- TODO bisognerà implementare anche la lama da sotto ToolSearchParameters.bAllowBottomHead = false @@ -70,6 +137,7 @@ function BLADETOWASTE.Make( Proc, Part, OptionalParameters) nToolIndex = ToolInfo.nToolIndex end + -- TODO qui gestire il caso in cui si può tagliare da due lati (inizialmente solo se vtN:Y è ~= 0?) if ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then local OptionalParametersFaceByBlade = { dDepthToMachine = dDepthToMachine, nToolIndex = nToolIndex} Cutting = FaceByBlade.Make( Proc, Part, Proc.Faces[1], EdgeToMachine, OptionalParametersFaceByBlade) @@ -89,19 +157,15 @@ function BLADETOWASTE.Make( Proc, Part, OptionalParameters) if Proc.nFct == 2 then Face2 = Proc.Faces[2] end - -- direzione migliore di lavoro, per la ricerca utensile - local _, dCutH, dCutV = BeamLib.GetFaceHvRefDim( Proc.Id, 0, Part.b3Raw) - -- ricerca utensile - local ToolSearchParameters = {} - ToolSearchParameters.vtToolDirection = EdgeToMachine.vtN - ToolSearchParameters.bAllowTopHead = true - -- TODO bisognerà implementare anche la lama da sotto - ToolSearchParameters.bAllowBottomHead = false - ToolSearchParameters.bForceLongcutBlade = false - ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) - nToolIndex = ToolInfo.nToolIndex - local vCuts = DiceCut.GetDice( Part, Face1, Face2, OptionalParameters) + -- scelta lama da sopra o da sotto + if not nToolIndex then + nToolIndex = GetBestBladeForDicing( Proc, Part, Face1, OptionalParameters) + end + + + local OptionalParametersDiceCut = {} + local vCuts = DiceCut.GetDice( Part, Face1, Face2, OptionalParametersDiceCut) diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index f5085a5..bbaef35 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -127,7 +127,15 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.ptEdge1, _, Cutting.ptEdge2 = EgtSurfTmFacetOppositeSide( Proc.id, FaceToMachine.id, -Cutting.vtToolDirection, GDB_ID.ROOT) local b3BoxEdge = BBox3d( Cutting.ptEdge1, Cutting.ptEdge2) Cutting.dLengthOnX = b3BoxEdge:getDimX() - -- + + -- TODO gestire lama da sotto e lama downUp + -- TODO qui il check andrebbe migliorato e sostituito con una funzione più generale (così è ottimizzato solo per tasche non inclinate) + if bAllowToolInvert and FaceToMachine.vtN:getZ() < - 10 * GEO.EPS_SMALL then + Cutting.bToolInvert = true + Cutting.bInvert = not Cutting.bInvert + else + Cutting.bToolInvert = false + end -- ricerca utensile if nToolIndex then @@ -135,7 +143,11 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar else local ToolSearchParameters = {} ToolSearchParameters.dElevation = dDepthToMachine - ToolSearchParameters.vtToolDirection = Cutting.vtToolDirection + if Cutting.bToolInvert then + ToolSearchParameters.vtN = -FaceToMachine.vtN + else + ToolSearchParameters.vtN = FaceToMachine.vtN + end ToolSearchParameters.bAllowTopHead = true -- TODO bisognerà implementare anche la lama da sotto ToolSearchParameters.bAllowBottomHead = false @@ -144,7 +156,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar Cutting.nToolIndex = ToolInfo.nToolIndex end Cutting.nType = MCH_OY.MILLING - if not TOOLS[Cutting.nToolIndex].sName then + if not TOOLS[Cutting.nToolIndex] or not TOOLS[Cutting.nToolIndex].sName then Cutting.sMessage = 'Blade not found' Cutting.bIsApplicable = false EgtOutLog( Cutting.sMessage) @@ -175,7 +187,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar -- inizio e fine aperti o chiusi Cutting.bIsStartClosed = not EdgeToMachine.bIsStartOpen Cutting.bIsEndClosed = not EdgeToMachine.bIsEndOpen - -- lato di lavoro e inversioni + -- lato di lavoro e inversione if TOOLS[Cutting.nToolIndex].bIsCCW then Cutting.nWorkside = MCH_MILL_WS.RIGHT Cutting.bInvert = true @@ -186,13 +198,8 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar if bOppositeToolDirection then Cutting.bInvert = not Cutting.bInvert end - -- TODO gestire lama da sotto e lama downUp - -- TODO qui il check della vtN dovrebbe essere sulla dMaxNegativeAngle in SetupInfo dell'utensile? - if bAllowToolInvert and FaceToMachine.vtN:getZ() < - 10 * GEO.EPS_SMALL then - Cutting.bToolInvert = true + if Cutting.bToolInvert then Cutting.bInvert = not Cutting.bInvert - else - Cutting.bToolInvert = false end -- profondità da lavorare e offset radiale if TOOLS[Cutting.nToolIndex].dMaxDepth > dDepthToMachine - 10 * GEO.EPS_SMALL then diff --git a/StrategyLibs/SPLITCUT.lua b/StrategyLibs/SPLITCUT.lua index bc71238..cc5fdd0 100644 --- a/StrategyLibs/SPLITCUT.lua +++ b/StrategyLibs/SPLITCUT.lua @@ -28,7 +28,7 @@ function SPLITCUT.GetStrategy( Proc, Part, OptionalParameters) local Splitting = {} -- imposto parametri di ricerca utensile in base a topologia local ToolSearchParameters = {} - ToolSearchParameters.vtToolDirection = Proc.Faces[1].vtN + ToolSearchParameters.vtN = Proc.Faces[1].vtN -- ===== RICERCA UTENSILE ===== -- cerco lama sopra