diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index 8ed811d..2fb3a67 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -367,13 +367,15 @@ local function GetStrategies_Essetre( Proc) --------------------------------------------------------------------- -- Feature : Front Profile (0-100) elseif ID.IsFrontProfile( Proc) then + Strategies = { { sStrategyId = 'STR0015'}} --------------------------------------------------------------------- -- Feature : Head Concave Profile (0-101) elseif ID.IsHeadConcaveProfile( Proc) then + Strategies = { { sStrategyId = 'STR0015'}} --------------------------------------------------------------------- -- Feature : Head Convex Profile (0-102) elseif ID.IsHeadConvexProfile( Proc) then - Strategies = { { sStrategyId = 'STR0009'}} + Strategies = { { sStrategyId = 'STR0015'}} --------------------------------------------------------------------- -- Feature : Head Cambered Profile (0-103) elseif ID.IsHeadCamberedProfile( Proc) then @@ -381,10 +383,11 @@ local function GetStrategies_Essetre( Proc) --------------------------------------------------------------------- -- Feature : Round Arch (0-104) elseif ID.IsRoundArch( Proc) then - Strategies = { { sStrategyId = 'STR0009'}} + Strategies = { { sStrategyId = 'STR0015'}} --------------------------------------------------------------------- -- Feature : Head Profile (0-106) elseif ID.IsHeadProfile( Proc) then + Strategies = { { sStrategyId = 'STR0015'}} --------------------------------------------------------------------- -- Feature : Sphere (0-107) elseif ID.IsSphere( Proc) then @@ -430,7 +433,7 @@ end -- funzione che recupera i parametri custom della strategia. Per cliente Essetre, vengono salvati dei valori 'Q' sul processing del file NGE per modificare il comportamento delle macro local function GetParameters_Essetre( Proc, sStrategyIdToGet) local Parameters = {} - + --###---###---###---###---###---###---###---###---###---###---###---###---###-- -- Feature : HeadCut (1-340) if ID.IsHeadCut( Proc) then -- Per Essetre non esiste il taglio di testa, quindi si leggono le variabili Q sul processing che coincide con il taglio di testa @@ -447,6 +450,7 @@ local function GetParameters_Essetre( Proc, sStrategyIdToGet) table.insert( Parameters, { sName = 'bFinishWithMill', sValue = bFinishWithMill, sType = 'b'}) end end + --###---###---###---###---###---###---###---###---###---###---###---###---###-- -- Feature : Cut (1-10) elseif ID.IsCut( Proc) then local dDepthChamfer = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q06', 'd') or 0 @@ -464,6 +468,7 @@ local function GetParameters_Essetre( Proc, sStrategyIdToGet) table.insert( Parameters, { sName = 'sCuttingStrategy', sValue = sCuttingStrategy, sType = 's'}) end end + --###---###---###---###---###---###---###---###---###---###---###---###---###-- -- Feature : Drill (1-40) elseif ID.IsDrill( Proc) then if sStrategyIdToGet == 'STR0011' then @@ -476,20 +481,66 @@ local function GetParameters_Essetre( Proc, sStrategyIdToGet) local bDrillFromOneSide = ( EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q02', 'd') or 0) == 1 local sDrillingMode = EgtIf( bDrillFromOneSide, 'PREFER_ONE', 'AUTO') table.insert( Parameters, { sName = 'sDrillingMode', sValue = sDrillingMode, sType = 's'}) + --###---###---###---###---###---###---###---###---###---###---###---###---###-- + -- Feature : Front Profile (0-100) + elseif ID.IsFrontProfile( Proc) then + local dDepthChamfer = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q01', 'd') or 0 + local dOverMaterial = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q02', 'd') or 0 + local bOnlyChamfer = ( EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q03', 'd') or 0) == 1 + table.insert( Parameters, { sName = 'dDepthChamfer' , sValue = dDepthChamfer, sType = 'd'}) + table.insert( Parameters, { sName = 'bOnlyChamfer' , sValue = bOnlyChamfer, sType = 'b'}) + table.insert( Parameters, { sName = 'dOverMaterial' , sValue = dOverMaterial, sType = 'd'}) + --###---###---###---###---###---###---###---###---###---###---###---###---###-- + -- Feature : Head Concave Profile (0-101) + elseif ID.IsHeadConcaveProfile( Proc) then + local dDepthChamfer = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q01', 'd') or 0 + local dOverMaterial = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q02', 'd') or 0 + local bOnlyChamfer = ( EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q04', 'd') or 0) == 1 + table.insert( Parameters, { sName = 'dDepthChamfer' , sValue = dDepthChamfer, sType = 'd'}) + table.insert( Parameters, { sName = 'bOnlyChamfer' , sValue = bOnlyChamfer, sType = 'b'}) + table.insert( Parameters, { sName = 'dOverMaterial' , sValue = dOverMaterial, sType = 'd'}) + --###---###---###---###---###---###---###---###---###---###---###---###---###-- + -- Feature : Head Convex Profile (0-102) + elseif ID.IsHeadConvexProfile( Proc) then + local dDepthChamfer = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q02', 'd') or 0 + local dOverMaterial = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q04', 'd') or 0 + local bOnlyChamfer = ( EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q01', 'd') or 0) == 1 + table.insert( Parameters, { sName = 'dDepthChamfer' , sValue = dDepthChamfer, sType = 'd'}) + table.insert( Parameters, { sName = 'bOnlyChamfer' , sValue = bOnlyChamfer, sType = 'b'}) + table.insert( Parameters, { sName = 'dOverMaterial' , sValue = dOverMaterial, sType = 'd'}) + --###---###---###---###---###---###---###---###---###---###---###---###---###-- -- Feature : Head Cambered Profile (0-103) elseif ID.IsHeadCamberedProfile( Proc) then local sUpperFaceStrategy = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q01', 's') or '' -- Q01 = forza fresa sUpperFaceStrategy = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q02', 's') or sUpperFaceStrategy or 'AUTO' -- Q02 = forza lama (se entrambi attivi comanda la lama) table.insert( Parameters, { sName = 'sUpperFaceStrategy' , sValue = sUpperFaceStrategy, sType = 's'}) - local dDepthChamfer = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q03', 'd') or 0 local dOverMaterial = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q04', 'd') or 0 local bOnlyChamfer = ( EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q05', 'd') or 0) == 1 table.insert( Parameters, { sName = 'dDepthChamfer' , sValue = dDepthChamfer, sType = 'd'}) table.insert( Parameters, { sName = 'bOnlyChamfer' , sValue = bOnlyChamfer, sType = 'b'}) table.insert( Parameters, { sName = 'dOverMaterial' , sValue = dOverMaterial, sType = 'd'}) + --###---###---###---###---###---###---###---###---###---###---###---###---###-- + -- Feature : Round Arch (0-104) + elseif ID.IsRoundArch( Proc) then + local dDepthChamfer = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q03', 'd') or 0 + local dOverMaterial = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q01', 'd') or 0 + local dStripWidth = ( EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q02', 'd') or 0) + table.insert( Parameters, { sName = 'dDepthChamfer' , sValue = dDepthChamfer, sType = 'd'}) + table.insert( Parameters, { sName = 'dStripWidth' , sValue = dStripWidth, sType = 'b'}) + table.insert( Parameters, { sName = 'dOverMaterial' , sValue = dOverMaterial, sType = 'd'}) + --###---###---###---###---###---###---###---###---###---###---###---###---###-- + -- Feature : Head Profile (0-106) + elseif ID.IsHeadProfile( Proc) then + local dDepthChamfer = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q01', 'd') or 0 + local dOverMaterial = EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q02', 'd') or 0 + local bOnlyChamfer = ( EgtGetInfo( Proc.id or GDB_ID.NULL, 'Q03', 'd') or 0) == 1 + table.insert( Parameters, { sName = 'dDepthChamfer' , sValue = dDepthChamfer, sType = 'd'}) + table.insert( Parameters, { sName = 'bOnlyChamfer' , sValue = bOnlyChamfer, sType = 'b'}) + table.insert( Parameters, { sName = 'dOverMaterial' , sValue = dOverMaterial, sType = 'd'}) end + ------------------------------------------------------------------------------- return Parameters end @@ -509,17 +560,18 @@ end local function GetToolsFromMachDataFile( MachiningDataList, TagListToGet) local ToolList = {} - if MachiningDataList and #MachiningDataList > 0 then + if MachiningDataList and #MachiningDataList > 0 and #TagListToGet > 0 then for nIndex = 1, #MachiningDataList do -- se utensile attivo e compatibile con TAG if MachiningDataList[nIndex].On and Contains( TagListToGet, MachiningDataList[nIndex].Type) then -- se è nuova versione, prendo il tool if MachiningDataList[nIndex].Tool then - table.insert( ToolList, MachiningDataList[nIndex].Tool) + table.insert( ToolList, { sName = MachiningDataList[nIndex].Tool}) -- altrimenti dalla lavorazione si ricava il tool - else - EgtMdbSetCurrMachining( MachiningDataList[nIndex].Name) - table.insert( ToolList, { sName = EgtMdbGetCurrMachiningParam( MCH_MP.TOOL)}) + elseif MachiningDataList[nIndex].Name then + if EgtMdbSetCurrMachining( MachiningDataList[nIndex].Name) then + table.insert( ToolList, { sName = EgtMdbGetCurrMachiningParam( MCH_MP.TOOL)}) + end end end end @@ -558,11 +610,14 @@ local function GetTools_Essetre( Proc, sMachiningCategory) end ToolList = GetToolsFromMachDataFile( DrillData, TagList) end - elseif sMachiningCategory == 'Milling' or sMachiningCategory == 'MillingFinish' or sMachiningCategory == 'MillingAntiSplint' or sMachiningCategory == 'MillingChamfer' then + elseif sMachiningCategory == 'Milling' or sMachiningCategory == 'MillingFinish' or sMachiningCategory == 'MillingAntiSplint' or sMachiningCategory == 'MillingChamfer' or + sMachiningCategory == 'MillingSmooth' then if EgtExistsFile( sMachDir .. '\\Beam\\MillingData.lua') then local MillingData = dofile( sMachDir .. '\\Beam\\MillingData.lua') -- si cercano TAG esclusivi - if sMachiningCategory == 'MillingAntiSplint' then + if sMachiningCategory == 'MillingSmooth' then + TagList = { 'Mark', 'Text', 'Decor01', 'CleanCorner'} + elseif sMachiningCategory == 'MillingAntiSplint' then TagList = { 'AntiSplintMillCut'} elseif ID.IsTenon( Proc) then TagList = { 'Tenon'} @@ -575,7 +630,8 @@ local function GetTools_Essetre( Proc, sMachiningCategory) end elseif ID.IsDovetailMortise( Proc) then TagList = { 'DtMortise'} - elseif ID.IsHeadConcaveProfile( Proc) or ID.IsHeadConvexProfile( Proc) or ID.IsHeadCamberedProfile( Proc) or ID.IsRoundArch( Proc) or ID.IsHeadProfile( Proc) then + elseif ID.IsFrontProfile( Proc) or ID.IsHeadConcaveProfile( Proc) or ID.IsHeadConvexProfile( Proc) or + ID.IsHeadCamberedProfile( Proc) or ID.IsRoundArch( Proc) or ID.IsHeadProfile( Proc) then if sMachiningCategory == 'MillingFinish' then TagList = { 'Prof_end'} end @@ -587,7 +643,7 @@ local function GetTools_Essetre( Proc, sMachiningCategory) elseif ID.IsMarking( Proc) then TagList = { 'Mark'} elseif sMachiningCategory == 'MillingChamfer' then - TagList = { 'Chamfer', 'Mark'} + TagList = { 'Chamfer'} elseif ID.IsText( Proc) then TagList = { 'Text'} elseif ID.IsTyroleanDovetail( Proc) or ID.IsDovetail( Proc) then diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index 305837f..f2a3861 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -146,10 +146,21 @@ function FaceData.GetEdgesInfo( ProcOrId, idFace ) end ------------------------------------------------------------------------------------------------------------- -function FaceData.GetFacesInfo( Proc, Part) +function FaceData.GetFacesInfo( Proc, Part, FacesToGet) EgtOutLog( '---Faces START---') local Faces = {} + local function FaceIsToGet( nIndex) + if not FacesToGet then return false end + for i = 1, #FacesToGet do + -- correggo indice perche' id delle facce è 0-based + if FacesToGet[i] == nIndex - 1 then + return true + end + end + return false + end + local vAdj if Proc.AdjacencyMatrix then vAdj = Proc.AdjacencyMatrix @@ -165,7 +176,7 @@ function FaceData.GetFacesInfo( Proc, Part) Faces[i] = {} Faces[i].id = i - 1 Faces[i].ptCenter, Faces[i].vtN = EgtSurfTmFacetCenter( Proc.id, i - 1, GDB_ID.ROOT) - if Proc.nFct < 6 then + if Proc.nFct < 6 or FaceIsToGet( i) then -- frame OCS faccia Faces[i].vtFrameHV = Frame3d( Faces[i].ptCenter, Faces[i].vtN) -- elevazione calcolata rispetto al box della parte diff --git a/LuaLibs/FeatureLib.lua b/LuaLibs/FeatureLib.lua index 3768975..440f8d1 100644 --- a/LuaLibs/FeatureLib.lua +++ b/LuaLibs/FeatureLib.lua @@ -564,6 +564,9 @@ function FeatureLib.GetFeatureCompletionIndex( dCompletionPercentage) -- Medium elseif dCompletionPercentage < 80 then nCompletionIndex = 2 + -- High + elseif dCompletionPercentage < 95 then + nCompletionIndex = 4 -- High / Complete else nCompletionIndex = 5 diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index dec5c30..19afd15 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -231,7 +231,7 @@ function MachiningLib.GetSplitMachinings( Machinings, SplittingPoints, Part) end ------------------------------------------------------------------------------------------------------------- --- funzione che ritorna la posizione nella quale si tyrova l'utensile cercato. Serve in caso l'utente voglia rispettare l'ordine degli utensili settato +-- funzione che ritorna la posizione nella quale si trova l'utensile cercato. Serve in caso l'utente voglia rispettare l'ordine degli utensili settato local function GetIndexToolInAvailableToolList( AvailableToolList, sToolName) for nIndex = 1, #AvailableToolList do if sToolName == AvailableToolList[nIndex].sName then @@ -280,6 +280,8 @@ function MachiningLib.FindMill( Proc, ToolSearchParameters) bIsToolCompatible = false elseif ToolSearchParameters.dMinToolDiameter and TOOLS[i].dDiameter < ToolSearchParameters.dMinToolDiameter then bIsToolCompatible = false + elseif ( ToolSearchParameters.bCCW and not TOOLS[i].bIsCCW) or ( ToolSearchParameters.bCW and TOOLS[i].bIsCCW) then + bIsToolCompatible = false elseif TOOLS[i].SetupInfo.HeadType.bTop and ToolSearchParameters.vtToolDirection:getZ() < TOOLS[i].SetupInfo.GetMinNz( ToolSearchParameters.vtToolDirection, TOOLS[i]) - GEO.EPS_ZERO then bIsToolCompatible = false elseif TOOLS[i].SetupInfo.HeadType.bBottom and ToolSearchParameters.vtToolDirection:getZ() > TOOLS[i].SetupInfo.GetMaxNz( ToolSearchParameters.vtToolDirection, TOOLS[i]) + GEO.EPS_ZERO then diff --git a/Strategies/AvailableStrategyList.json b/Strategies/AvailableStrategyList.json index 56f50b6..885806c 100644 --- a/Strategies/AvailableStrategyList.json +++ b/Strategies/AvailableStrategyList.json @@ -572,7 +572,7 @@ "nGrp": 0, "TopologyList" : [ { "sName": "Feature", - "StrategyList" : [ ] + "StrategyList" : [ { "sStrategyId": "STR0015" } ] } ] }, @@ -582,7 +582,7 @@ "nGrp": 0, "TopologyList" : [ { "sName": "Feature", - "StrategyList" : [ ] + "StrategyList" : [ { "sStrategyId": "STR0015" } ] } ] }, @@ -592,7 +592,7 @@ "nGrp": 0, "TopologyList" : [ { "sName": "Feature", - "StrategyList" : [ { "sStrategyId": "STR0009" } ] + "StrategyList" : [ { "sStrategyId": "STR0015" } ] } ] }, @@ -612,7 +612,7 @@ "nGrp": 0, "TopologyList" : [ { "sName": "Feature", - "StrategyList" : [ { "sStrategyId": "STR0009" } ] + "StrategyList" : [ { "sStrategyId": "STR0015" } ] } ] }, @@ -622,7 +622,7 @@ "nGrp": 0, "TopologyList" : [ { "sName": "Feature", - "StrategyList" : [ ] + "StrategyList" : [ { "sStrategyId": "STR0015" } ] } ] }, diff --git a/Strategies/Standard/STR0015/STR0015.json b/Strategies/Standard/STR0015/STR0015.json index 4bc47a0..3e833fd 100644 --- a/Strategies/Standard/STR0015/STR0015.json +++ b/Strategies/Standard/STR0015/STR0015.json @@ -45,7 +45,7 @@ { "sName": "bExecRough", "sNameNge": "EXEC_ROUGH", - "sValue": "0", + "sValue": "true", "sDescriptionShort": "Execute cut to remove material", "sDescriptionLong": "", "sType": "b", @@ -87,6 +87,12 @@ "sDescriptionLong": "", "sMessageId": "" }, + { + "sValue": "NONE", + "sDescriptionShort": "No machining", + "sDescriptionLong": "", + "sMessageId": "" + }, { "sValue": "BLADE_FORCED", "sDescriptionShort": "Blade forced", diff --git a/Strategies/Standard/STR0015/STR0015.lua b/Strategies/Standard/STR0015/STR0015.lua index 3447196..8bebfad 100644 --- a/Strategies/Standard/STR0015/STR0015.lua +++ b/Strategies/Standard/STR0015/STR0015.lua @@ -9,51 +9,90 @@ local BeamLib = require( 'BeamLib') local BeamData = require( 'BeamData') local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') +local FaceData = require( 'FaceData') local ID = require( 'Identity') -- strategie di base local BladeToWaste = require('BLADETOWASTE') +local FaceByBlade = require('FACEBYBLADE') +local FaceByMill = require('FACEBYMILL') -- Tabella per definizione modulo local STR0015 = {} local Strategy = {} +------------------------------------------------------------------------------------------------------------- +local function GetEdgeToMachine( Proc, idFace, vtEdge) + local Edge + local dBestEdgeAngle = 999 + for i = 1, #Proc.Faces[idFace].Edges do + local dAngle = abs( GetAngle( Proc.Faces[idFace].Edges[i].vtN, vtEdge)) + if dAngle < dBestEdgeAngle then + dBestEdgeAngle = dAngle + Edge = Proc.Faces[idFace].Edges[i] + end + end + return Edge +end + + +-- TODO funzione recuperata da beam vecchio, verificare se possibile migliorare --------------------------------------------------------------------- -local function GetSawCutData( AuxId, vtNF) - -- comincio con la normale a 45deg - local vtNP = Vector3d( vtNF) - for i = 1, 3 do - if vtNP[i] > GEO.EPS_SMALL then - vtNP[i] = 1 - elseif vtNP[i] < -GEO.EPS_SMALL then - vtNP[i] = -1 +local function GetSawCutData( Proc, AuxId, vtNF, vtN) + local ptStart, vtNP + + if ID.IsHeadConcaveProfile( Proc) or ID.IsHeadConvexProfile( Proc) or ID.IsHeadProfile( Proc) or ID.IsFrontProfile( Proc) then + vtNP = Vector3d( vtN) + -- comincio con la normale a 45deg + for i = 1, 3 do + if vtNP[i] > GEO.EPS_SMALL then + vtNP[i] = 1 + elseif vtNP[i] < -GEO.EPS_SMALL then + vtNP[i] = -1 + end end - end - vtNP:normalize() - -- assegno un punto di passaggio - local ptStart = EgtSP( AuxId, GDB_ID.ROOT) + vtNP * 5.0 - -- determino asse di rotazione - local vtRot = - Y_AX() - if vtNF:getX() < 0 then vtRot = - vtRot end - if vtNF:getZ() < -0.1 then - vtRot = - vtRot - elseif vtNF:getY() < -0.1 then - vtRot:rotate( X_AX(), 90) - elseif vtNF:getY() > 0.1 then - vtRot:rotate( X_AX(), -90) - end - -- miglioro l'inclinazione (ripartendo da faccia perpendicolare asse trave) - vtNP[2] = 0 vtNP[3] = 0 - local dRot = 45 - for i = 1, 4 do - local vtNP2 = Vector3d( vtNP) - vtNP2:rotate( vtRot, dRot) - local frRef = Frame3d( ptStart, vtNP2) - local b3Box = EgtGetBBoxRef( AuxId, GDB_BB.STANDARD, frRef) - if b3Box:getMax():getZ() < -3 then - vtNP = Vector3d( vtNP2) + vtNP:normalize() + -- assegno un punto di passaggio + ptStart = EgtMP( AuxId, GDB_ID.ROOT) + local frOCS = Frame3d( ptStart, vtNP) ; + local b3Box = EgtGetBBoxRef( AuxId, GDB_BB.STANDARD, frOCS) + ptStart = ptStart + vtNP * ( b3Box:getMax():getZ() + 10.0) + elseif ID.IsHeadCamberedProfile( Proc) then + vtNP = Vector3d( vtNF) + -- comincio con la normale a 45deg + for i = 1, 3 do + if vtNP[i] > GEO.EPS_SMALL then + vtNP[i] = 1 + elseif vtNP[i] < -GEO.EPS_SMALL then + vtNP[i] = -1 + end + end + vtNP:normalize() + -- assegno un punto di passaggio + ptStart = EgtSP( AuxId, GDB_ID.ROOT) + vtNP * 5.0 + -- determino asse di rotazione + local vtRot = - Y_AX() + if vtNF:getX() < 0 then vtRot = - vtRot end + if vtNF:getZ() < -0.1 then + vtRot = - vtRot + elseif vtNF:getY() < -0.1 then + vtRot:rotate( X_AX(), 90) + elseif vtNF:getY() > 0.1 then + vtRot:rotate( X_AX(), -90) + end + -- miglioro l'inclinazione (ripartendo da faccia perpendicolare asse trave) + vtNP[2] = 0 vtNP[3] = 0 + local dRot = 45 + for i = 1, 4 do + local vtNP2 = Vector3d( vtNP) + vtNP2:rotate( vtRot, dRot) + local frRef = Frame3d( ptStart, vtNP2) + local b3Box = EgtGetBBoxRef( AuxId, GDB_BB.STANDARD, frRef) + if b3Box:getMax():getZ() < -3 then + vtNP = Vector3d( vtNP2) + end + dRot = dRot / 2 end - dRot = dRot / 2 end -- restituisco i dati del piano return ptStart, vtNP @@ -66,24 +105,68 @@ local function GetRoughStrategy( Proc, Part, bSaveAddedGeometries) -- ====== Taglio di sgrossatura generale su tutto il profilo ====== local vtNF = EgtSurfTmFacetNormVersor( Proc.id, Proc.nFct-1, GDB_ID.ROOT) + local nMidFacet = Proc.nFct // 2 -- faccia a metà circa + local vtN = EgtSurfTmFacetNormVersor( Proc.id, nMidFacet, GDB_ID.ROOT) + local nAddGroupId = BeamLib.GetAddGroup( Part.id) -- aggiungo piano di sgrossatura e lo lavoro - local ptStart, vtNP = GetSawCutData( Proc.idAddAuxGeom, vtNF) + local ptStart, vtNP = GetSawCutData( Proc, Proc.idAddAuxGeom, vtNF, vtN) local AddId = EgtSurfTmPlaneInBBox( nAddGroupId, ptStart, vtNP, Part.b3Part, GDB_RT.GLOB) - if not bSaveAddedGeometries then - EgtSetLevel( AddId, GDB_LV.TEMP) - end + -- se la faccia è stata creata + if AddId then + if not bSaveAddedGeometries then + EgtSetLevel( AddId, GDB_LV.TEMP) + end - -- creo piano di taglio sulla testa del tenone - local OptionalParameters = { dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume, - dMaxWasteLength = Strategy.Parameters.dMaxWasteLength, - bReduceBladePath = Strategy.Parameters.bReduceBladePath - } - Machining, Result = BladeToWaste.Make( AddId, Part, OptionalParameters) + -- creo piano di taglio sulla testa del tenone + local OptionalParameters = { dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume, + dMaxWasteLength = Strategy.Parameters.dMaxWasteLength, + bReduceBladePath = Strategy.Parameters.bReduceBladePath + } + Machining, Result = BladeToWaste.Make( AddId, Part, OptionalParameters) - -- se non ci sono lavorazioni, provo con fresa - if not Machining then - -- TODO + -- se non ci sono lavorazioni, provo con fresa + if not Machining or #Machining == 0 then + Machining.bCuttingWithMill = true + -- === ricerca utensile per svuotare taglio iniziale, se taglio non possibile === + if not( Proc.AffectedFaces.bLeft) or Strategy.bCanMoveAfterSplit then + ToolSearchParameters = {} + + -- TODO SISTEMARE!!! qui la svuotatura non deve limitare l'elevazione se aperta da tutti i lati. In futuro si deve passare 0 come elevazione + ToolSearchParameters.dElevation = EgtSurfTmFacetElevationInBBox( AddId, 0, Part.b3Part, true, GDB_ID.ROOT) + + ToolSearchParameters.vtToolDirection = vtNP + ToolSearchParameters.AvailableToolList = MachiningLib.GetAvailableToolList( Proc, Strategy.Parameters.sPocketingList, 'Pocketing') + Machining.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) + + -- TODO anche il test sul ResidualDepth va tolto + if Machining.ToolInfo.nToolIndex and ( Machining.ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL) then + Machining.bIsApplicable = true + local ParametersMRR = {} + ParametersMRR.nToolIndex = Machining.ToolInfo.nToolIndex + Result.dMRR = MachiningLib.GetToolMRR( ParametersMRR) + Result.sStatus = 'Completed' + Machining.Steps = {} + Machining.LeadIn = {} + Machining.nType = MCH_MY.POCKETING + Machining.nSubType = MCH_POCK_SUB.SPIRALIN + Machining.LeadIn.nType = MCH_POCK_LI.ZIGZAG + Machining.Steps.dStep = TOOLS[Machining.ToolInfo.nToolIndex].dStep + Machining.Steps.dSideStep = TOOLS[Machining.ToolInfo.nToolIndex].dSideStep + Machining.nToolIndex = Machining.ToolInfo.nToolIndex + Machining.LeadIn.dTangentDistance = TOOLS[Machining.ToolInfo.nToolIndex].dDiameter/2 + Machining.LeadIn.dElevation = TOOLS[Machining.ToolInfo.nToolIndex].dDiameter/2 + Machining.sDepth = 0 + Machining.Geometry = {{ AddId, 0}} + Machining.vtToolDirection = vtNF + if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then + Machining.sStage = 'AfterTail' + end + -- tempo di svuotatura + Result.dTimeToMachine = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Machining, Part) + end + end + end end return Machining, Result @@ -93,9 +176,136 @@ end ------------------------------------------------------------------------------------------------------------- local function GetEdgeWithCornerStrategy( Proc, Part) local Machining = {} - local Result = {} + local Result = { dCompletionPercentage = 100} + local nFirstFacet = 0 -- faccia iniziale + local nLastFacet = Proc.nFct - 1 -- faccia finale + -- verifico se necessari ripassi agli estremi negli angoli + local _, _, _, dFirstAng = EgtSurfTmFacetsContact( Proc.id, nFirstFacet, nFirstFacet + 1, GDB_ID.ROOT) + local bFirstTrim = ( dFirstAng and dFirstAng < -30) + local _, _, _, dLastAng = EgtSurfTmFacetsContact( Proc.id, nLastFacet, nLastFacet - 1, GDB_ID.ROOT) + local bLastTrim = ( dLastAng and dLastAng < -30) + local nMidFacet = ( nLastFacet + 1) // 2 -- faccia a metà circa + local vtN = EgtSurfTmFacetNormVersor( Proc.id, nMidFacet, GDB_ID.ROOT) + + + -- se non ci sono angoli da pulire si esce subito + if Strategy.Parameters.sConcaveFaceStrategy == 'NONE' or ( not bFirstTrim and not bLastTrim) then + return nil, nil + end + + local FacesToGet = {} + if bFirstTrim then + table.insert( FacesToGet, nFirstFacet) + table.insert( FacesToGet, nFirstFacet+1) + end + if bLastTrim then + table.insert( FacesToGet, nLastFacet - 1) + table.insert( FacesToGet, nLastFacet) + end + -- ricavo info facce da lavorare + Proc.Faces = FaceData.GetFacesInfo( Proc, Part, FacesToGet) + + -- direzioni di lavorazione + local vtCutDir1 + -- se è diretta verso alto o basso + if vtN:getZ() > vtN:getY() then + if vtN:getZ() > 0 then + vtCutDir1 = Z_AX() + else + vtCutDir1 = -Z_AX() + end + -- altrimenti è di fianco + else + if vtN:getY() > 0 then + vtCutDir1 = Y_AX() + else + vtCutDir1 = -Y_AX() + end + end + + local vtCutDir2 + if vtN:getX() > 0 then + vtCutDir2 = X_AX() + else + vtCutDir2 = -X_AX() + end + + -- AUTO = preferisce lama. Se non è possibile prende fresa + -- BLADE_FORCED = solo lama, altriemnti non applica nulla (potrebbe essere necessario un ribaltamento) + -- MILL_FORCED = solo fresa, altriemnti non applica nulla (potrebbe essere necessario un ribaltamento) if Strategy.Parameters.sConcaveFaceStrategy == 'AUTO' or Strategy.Parameters.sConcaveFaceStrategy == 'BLADE_FORCED' then + -- TODO c'è una funzione che ritorni l'edge di connessione tra una faccia e un'altra? + -- lavorazione faccia 1 spigolo finale + if bLastTrim then + local EdgeToMachine = GetEdgeToMachine( Proc, nLastFacet+1, vtCutDir1) + local Cutting = FaceByBlade.Make( Proc, Part, Proc.Faces[nLastFacet+1], EdgeToMachine) + if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then + Cutting.sStage = 'AfterTail' + end + if Cutting then + table.insert( Machining, Cutting) + end + end + + -- lavorazione faccia 1 spigolo iniziale + if bFirstTrim then + local EdgeToMachine = GetEdgeToMachine( Proc, nFirstFacet+2, vtCutDir1) + local Cutting = FaceByBlade.Make( Proc, Part, Proc.Faces[nFirstFacet+2], EdgeToMachine) + if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then + Cutting.sStage = 'AfterTail' + end + if Cutting then + table.insert( Machining, Cutting) + end + end + + -- lavorazione faccia 2 spigolo finale + if bLastTrim then + EdgeToMachine = GetEdgeToMachine( Proc, nLastFacet, vtCutDir2) + Cutting = FaceByBlade.Make( Proc, Part, Proc.Faces[nLastFacet], EdgeToMachine) + if Cutting then + table.insert( Machining, Cutting) + end + end + + -- lavorazione faccia 2 spigolo iniziale + if bFirstTrim then + local EdgeToMachine = GetEdgeToMachine( Proc, nFirstFacet+1, vtCutDir2) + local Cutting = FaceByBlade.Make( Proc, Part, Proc.Faces[nFirstFacet+1], EdgeToMachine) + if Cutting then + table.insert( Machining, Cutting) + end + end + end + + -- se non ci sono lavorazioni provo a pulire spigoli con fresa, a patto che non sia stato forzato con lama + if #Machining == 0 and Strategy.Parameters.sConcaveFaceStrategy ~= 'BLADE_FORCED' then + -- TODO c'è una funzione che ritorni l'edge di connessione tra una faccia e un'altra? + -- lavorazione faccia 1 spigolo iniziale + if bFirstTrim then + local EdgeToMachine = GetEdgeToMachine( Proc, nFirstFacet+2, vtCutDir1) + local Milling = FaceByMill.Make( Proc, Part, Proc.Faces[nFirstFacet+2], EdgeToMachine) + if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then + Milling.sStage = 'AfterTail' + end + if Milling then + table.insert( Machining, Milling) + end + end + + -- lavorazione faccia 2 spigolo finale + if bLastTrim then + EdgeToMachine = GetEdgeToMachine( Proc, nLastFacet, vtCutDir2) + local Milling = FaceByMill.Make( Proc, Part, Proc.Faces[nLastFacet], EdgeToMachine) + if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then + Milling.sStage = 'AfterTail' + end + if Milling then + table.insert( Machining, Milling) + end + end + end return Machining, Result @@ -105,18 +315,115 @@ end local function GetChamferStrategy( Proc, Part) local Machining = {} local Result = {} + local ToolSearchParameters = {} + local dExtraDepth = 2 + local vtExtr = EgtCurveExtrusion( Proc.idAddAuxGeom, GDB_RT.GLOB) + local bIsHorizontal = abs( vtExtr:getZ()) < 10 * GEO.EPS_SMALL + local bToolInvert = ( vtExtr:getZ() < -0.1) if Strategy.Parameters.dDepthChamfer > 100 * GEO.EPS_SMALL then + -- controllo conformità affondamento smussi + Strategy.Parameters.dDepthChamfer = EgtClamp( Strategy.Parameters.dDepthChamfer, 0.1, 5) + + -- si prapara tabella con parametri di base comuni a tutte le lavorazioni + local BasicMach = MachiningLib.InitMachiningParameters( MCH_MY.MILLING) + BasicMach.Geometry = {{ Proc.idAddAuxGeom, -1}} + BasicMach.nType = MCH_MY.MILLING + BasicMach.sDepth = Strategy.Parameters.dDepthChamfer + dExtraDepth + -- LeadIn / LeadOut + BasicMach.LeadIn.nType = MCH_MILL_LI.NONE + BasicMach.LeadOut.nType = MCH_MILL_LI.NONE + BasicMach.LeadIn.dStartAddLength = 5 + BasicMach.LeadOut.dEndAddLength = 5 + if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then + BasicMach.sStage = 'AfterTail' + end + BasicMach.ptEdge1 = EgtSP( Proc.idAddAuxGeom, GDB_ID.ROOT) + BasicMach.ptEdge2 = EgtEP( Proc.idAddAuxGeom, GDB_ID.ROOT) + BasicMach.dEdgeLength = EgtCurveLength( Proc.idAddAuxGeom) + BasicMach.vtEdgeDirection = EgtSV( Proc.idAddAuxGeom, GDB_ID.ROOT) + EgtMV( Proc.idAddAuxGeom, GDB_ID.ROOT) + EgtEV( Proc.idAddAuxGeom, GDB_ID.ROOT) + BasicMach.dLengthOnX = Proc.b3Box:getDimX() + -- parametri di ricerca utensile comuni a tutte le lavorazioni + ToolSearchParameters.sMillShape = 'VMILL' + ToolSearchParameters.dElevation = Strategy.Parameters.dDepthChamfer + ToolSearchParameters.AvailableToolList = MachiningLib.GetAvailableToolList( Proc, Strategy.Parameters.sMillingList, 'MillingSmooth') + + -- se lavorazione orizzontale + if bIsHorizontal then + local Milling = {} + ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) + Milling.ToolInfo = {} + Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) + -- se trovato utensile adatto + if Milling.ToolInfo.nToolIndex then + Milling.vtToolDirection = ToolSearchParameters.vtToolDirection + + Milling.nToolIndex = Milling.ToolInfo.nToolIndex + Milling.dRadialOffset = dExtraDepth * cos( TOOLS[Milling.nToolIndex].dSideAngle) + + Milling.bInvert = EgtIf( TOOLS[Milling.nToolIndex].bIsCCW, false, true) + Milling.nWorkside = EgtIf( TOOLS[Milling.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + Milling = BeamLib.MergeTables( BasicMach, Milling) + table.insert( Machining, Milling) + + local Milling2 = BeamLib.TableCopyDeep( Milling) + Milling2.bToolInvert = true + Milling2.bInvert = EgtIf( TOOLS[Milling2.nToolIndex].bIsCCW, true, false) + Milling2.nWorkside = EgtIf( TOOLS[Milling2.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + + table.insert( Machining, Milling2) + end + -- se lavorazione verticale + else + -- si cerca utensile 1 + local Milling = {} + ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) + Milling.ToolInfo = {} + Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) + Milling.vtToolDirection = ToolSearchParameters.vtToolDirection + + -- si cerca utensile 2 + local Milling2 = {} + ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, vtExtr, -vtExtr) + Milling2.ToolInfo = {} + Milling2.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) + Milling2.vtToolDirection = ToolSearchParameters.vtToolDirection + Milling2.bToolInvert = true + + -- se trovato utensile 1 adatto + if Milling.ToolInfo.nToolIndex then + + Milling.nToolIndex = Milling.ToolInfo.nToolIndex + Milling.dRadialOffset = dExtraDepth * cos( TOOLS[Milling.nToolIndex].dSideAngle) + + Milling.bInvert = EgtIf( TOOLS[Milling.nToolIndex].bIsCCW, false, true) + Milling.nWorkside = EgtIf( TOOLS[Milling.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + Milling = BeamLib.MergeTables( BasicMach, Milling) + table.insert( Machining, Milling) + end + + -- se trovato utensile 2 adatto + if Milling2.ToolInfo.nToolIndex then + + Milling2.nToolIndex = Milling2.ToolInfo.nToolIndex + Milling2.dRadialOffset = dExtraDepth * cos( TOOLS[Milling2.nToolIndex].dSideAngle) + + Milling2.bToolInvert = true + Milling2.bInvert = EgtIf( TOOLS[Milling2.nToolIndex].bIsCCW, true, false) + Milling2.nWorkside = EgtIf( TOOLS[Milling2.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + Milling2 = BeamLib.MergeTables( BasicMach, Milling2) + table.insert( Machining, Milling2) + end + end end return Machining, Result end ------------------------------------------------------------------------------------------------------------- --- TODO gestire il caso in cui non si trova l'utensile local function GetArcStrategy( Proc, Part) local Machining = {} - local Result = {} + local Result = { dCompletionPercentage = 100} local ToolSearchParameters = {} -- recupero i dati della curva e del profilo @@ -128,6 +435,7 @@ local function GetArcStrategy( Proc, Part) local bIsFeatureBack = Proc.AffectedFaces.bBack and not Proc.AffectedFaces.bFront local bForceStrip = Strategy.Parameters.bForceStrip local dDimStrip = EgtIf( Strategy.Parameters.dStripWidth < 100 * GEO.EPS_SMALL, nil, Strategy.Parameters.dStripWidth) + local sMaxDepth = dDepth * 2 local bExecStrip = false -- se la lavorazione si trova nella parte inferiore o in battuta dietro, il codolo va sempre lasciato @@ -158,7 +466,6 @@ local function GetArcStrategy( Proc, Part) if bIsHorizontal then local bDouble local Milling = MachiningLib.InitMachiningParameters( MCH_MY.MILLING) - Milling.bIsApplicable = false ToolSearchParameters = {} ToolSearchParameters.sMillShape = 'STANDARD' ToolSearchParameters.dElevation = EgtIf( bExecStrip, ( dDepth - dDimStrip) / 2, dDepth + BeamData.MILL_OVERLAP) @@ -169,126 +476,210 @@ local function GetArcStrategy( Proc, Part) Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) -- se posso lavorare in una passata, ma utensile trovato non completa la lavorazione, -- allora provo a cercare utensile con massimo materiale sufficiente per fare le due passate, magari trova un utensile più prestante - if Milling.ToolInfo.dResidualDepth > 10 * GEO.EPS_SMALL and not bExecStrip then - bDouble = true - ToolSearchParameters.dElevation = ( dDepth + BeamData.MILL_OVERLAP) / 2 - ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) - Milling.ToolInfo = {} - Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) - end - Milling.vtToolDirection = ToolSearchParameters.vtToolDirection - - if nCycle == 2 then - Milling.dRadialOffset = Strategy.Parameters.dOverMaterial - end - - if bDouble or bExecStrip then - if bDouble then - Milling.sDepth = ( dDepth + BeamData.MILL_OVERLAP) / 2 - else - Milling.sDepth = ( dDepth - dDimStrip) / 2 + if Milling.ToolInfo.nToolIndex then + if Milling.ToolInfo.dResidualDepth > 10 * GEO.EPS_SMALL and not bExecStrip then + bDouble = true + ToolSearchParameters.dElevation = ( dDepth + BeamData.MILL_OVERLAP) / 2 + Milling.ToolInfo = {} + Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) + end + Milling.vtToolDirection = ToolSearchParameters.vtToolDirection + + if nCycle == 2 then + Milling.dRadialOffset = Strategy.Parameters.dOverMaterial + end + + -- se non completo + if Milling.ToolInfo.dResidualDepth > 10 * GEO.EPS_SMALL then + sMaxDepth = ToolSearchParameters.dElevation - Milling.ToolInfo.dResidualDepth + -- si salva percentuala lavorata + Result.dCompletionPercentage = 100 - ceil( ( Milling.ToolInfo.dResidualDepth / ToolSearchParameters.dElevation) * 100) + end + if bDouble or bExecStrip then + if bDouble then + Milling.sDepth = min( sMaxDepth, ( dDepth + BeamData.MILL_OVERLAP) / 2) + else + Milling.sDepth = min( sMaxDepth, ( dDepth - dDimStrip) / 2) + end + table.insert( Machining, Milling) + local Milling2 = BeamLib.TableCopyDeep( Milling) + Milling2.bOtherDirection = true + table.insert( Machining, Milling2) + else + Milling.sDepth = min( sMaxDepth, dDepth + BeamData.MILL_OVERLAP) + table.insert( Machining, Milling) end - table.insert( Machining, Milling) - local Milling2 = BeamLib.TableCopyDeep( Milling) - Milling2.bOtherDirection = true - table.insert( Machining, Milling2) - else - Milling.sDepth = dDepth + BeamData.MILL_OVERLAP - table.insert( Machining, Milling) end -- se lavorazione verticale else - -- si cerca utensile 1 - local Milling = {} - Milling.bIsApplicable = false ToolSearchParameters = {} ToolSearchParameters.sMillShape = 'STANDARD' ToolSearchParameters.dElevation = dDepth + BeamData.MILL_OVERLAP - ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) ToolSearchParameters.AvailableToolList = MachiningLib.GetAvailableToolList( Proc, Strategy.Parameters.sMillingList, sTypeTool) ToolSearchParameters.dMaxToolDiameter = nMaxDiamMill + + -- si cerca utensile 1 + local Milling = MachiningLib.InitMachiningParameters( MCH_MY.MILLING) + ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) Milling.ToolInfo = {} Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) if nCycle == 2 then Milling.dRadialOffset = Strategy.Parameters.dOverMaterial end Milling.vtToolDirection = ToolSearchParameters.vtToolDirection + Milling.bOtherDirection = bToolInvert + -- si cerca utensile 2 - local Milling2 = {} - Milling2.bIsApplicable = false - ToolSearchParameters = {} - ToolSearchParameters.sMillShape = 'STANDARD' - ToolSearchParameters.dElevation = dDepth + BeamData.MILL_OVERLAP + local Milling2 = MachiningLib.InitMachiningParameters( MCH_MY.MILLING) ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, vtExtr, -vtExtr) - ToolSearchParameters.AvailableToolList = MachiningLib.GetAvailableToolList( Proc, Strategy.Parameters.sMillingList, sTypeTool) - ToolSearchParameters.dMaxToolDiameter = nMaxDiamMill Milling2.ToolInfo = {} Milling2.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) - Milling2.bOtherDirection = true if nCycle == 2 then Milling2.dRadialOffset = Strategy.Parameters.dOverMaterial end Milling2.vtToolDirection = ToolSearchParameters.vtToolDirection + Milling2.bOtherDirection = bToolInvert -- se serve codolo if bExecStrip then + local sDepthMachined = 0 -- se a disposizione entrambi gli utensili if Milling.ToolInfo.nToolIndex and Milling2.ToolInfo.nToolIndex then + local dExtraDepth = ( dDepth - dDimStrip - ( Milling.ToolInfo.dResidualDepth + Milling2.ToolInfo.dResidualDepth)) / 2 + Milling.sDepth = dDepth - Milling.ToolInfo.dResidualDepth - dExtraDepth + Milling2.sDepth = dDepth - Milling2.ToolInfo.dResidualDepth - dExtraDepth + sDepthMachined = Milling.sDepth + Milling2.sDepth table.insert( Machining, Milling) table.insert( Machining, Milling2) -- se disponibile solo primo utensile elseif Milling.ToolInfo.nToolIndex then + sMaxDepth = ToolSearchParameters.dElevation - Milling.ToolInfo.dResidualDepth + Milling.sDepth = min( sMaxDepth, dDepth - dDimStrip) table.insert( Machining, Milling) + sDepthMachined = Milling.sDepth -- se disponibile solo secondo utensile elseif Milling2.ToolInfo.nToolIndex then + sMaxDepth = ToolSearchParameters.dElevation - Milling2.ToolInfo.dResidualDepth + Milling2.sDepth = min( sMaxDepth, dDepth - dDimStrip) table.insert( Machining, Milling2) + sDepthMachined = Milling2.sDepth -- nessun utensile disponibile else -- non si fa nulla end + Result.dCompletionPercentage = min( ( sDepthMachined * 100) / ( dDepth - dDimStrip), 100) -- altrimenti senza codolo else - -- se utensile 1 esegue completamente - if Milling.ToolInfo.nToolIndex and Milling.ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then + local sDepthMachined = 0 + local dExtraDepth = ( dDepth - BeamData.MILL_OVERLAP - ( Milling.ToolInfo.dResidualDepth + Milling2.ToolInfo.dResidualDepth)) / 2 + -- se utensile 1 esegue completamente (con almeno 1mm extra) + if Milling.ToolInfo.nToolIndex and Milling.ToolInfo.dResidualDepth < 1000 * GEO.EPS_SMALL then + sMaxDepth = ToolSearchParameters.dElevation - Milling.ToolInfo.dResidualDepth + Milling.sDepth = min( sMaxDepth, dDepth + BeamData.MILL_OVERLAP) table.insert( Machining, Milling) - -- se utensile 2 esegue completamente - elseif Milling2.ToolInfo.nToolIndex and Milling2.ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then + sDepthMachined = Milling.sDepth + -- se utensile 2 esegue completamente (con almeno 1mm extra) + elseif Milling2.ToolInfo.nToolIndex and Milling2.ToolInfo.dResidualDepth < 1000 * GEO.EPS_SMALL then + sMaxDepth = ToolSearchParameters.dElevation - Milling2.ToolInfo.dResidualDepth + Milling2.sDepth = min( sMaxDepth, dDepth + BeamData.MILL_OVERLAP) table.insert( Machining, Milling2) + sDepthMachined = Milling2.sDepth -- se possono lavorare entrambi elseif Milling.ToolInfo.nToolIndex and Milling2.ToolInfo.nToolIndex then + Milling.sDepth = dDepth - Milling.ToolInfo.dResidualDepth - dExtraDepth + Milling2.sDepth = dDepth - Milling2.ToolInfo.dResidualDepth - dExtraDepth table.insert( Machining, Milling) table.insert( Machining, Milling2) + sDepthMachined = Milling.sDepth + Milling2.sDepth -- se utensile 1 non completo elseif Milling.ToolInfo.nToolIndex then + Milling.sDepth = ToolSearchParameters.dElevation - Milling.ToolInfo.dResidualDepth table.insert( Machining, Milling) + sDepthMachined = Milling.sDepth -- se utensile 2 non completo elseif Milling2.ToolInfo.nToolIndex then + Milling2.sDepth = ToolSearchParameters.dElevation - Milling2.ToolInfo.dResidualDepth table.insert( Machining, Milling2) + sDepthMachined = Milling2.sDepth end + Result.dCompletionPercentage = min( ( sDepthMachined * 100) / ( dDepth - dDimStrip), 100) end end end - -- TODO VOTO DA FARE!!!! - Result.sStatus = 'Completed' - Result.nCompletionIndex = 5 - Result.dMRR = 1 - Result.nQuality = FeatureLib.GetStrategyQuality( 'MILL') - Result.sInfo = '' + Machining.bIsApplicable = #Machining > 0 return Machining, Result end ------------------------------------------------------------------------------------------------------------- -local function GetFeatureResult() - local Result = {} +local function GetFeatureResult( Proc) + local Result = { sStatus = 'Completed', dCompletionPercentage = 100, sInfo = ''} + local dPercentageChamfer = 10 + local dPercentageEdgeCorner = 10 + local dPercentageProfile = 80 - Result.sStatus = 'Completed' - Result.nCompletionIndex = 5 + -- se non ci sono lavorazioni di smusso + if not Strategy.Chamfer.Machinings or #Strategy.Chamfer.Machinings < 2 then + -- se esclusivo, non applicabile + if Strategy.Parameters.bOnlyChamfer then + Result = FeatureLib.GetStrategyResultNotApplicable( 'Not possible to machine chamfer only, tool not found!') + Result.dCompletionPercentage = 0 + -- se non esclusivo, non completo + elseif Strategy.Parameters.dDepthChamfer > 100 * GEO.EPS_SMALL then + Result.dCompletionPercentage = Result.dCompletionPercentage - dPercentageChamfer -- gli smussi incidono per il 10% + dPercentageChamfer = 0 + Result.sInfo = '- Chamfer not executed, tool not found!\n' + end + end + + -- se richieste anche le altre lavorazioni + if not Strategy.Parameters.bOnlyChamfer then + -- per tutti tranne che per feature RoundArc + if not ID.IsRoundArch( Proc) then + -- se sgrossatura da eseguire + if Strategy.Parameters.bExecRough then + if not Strategy.RoughCut.Machinings or #Strategy.RoughCut.Machinings == 0 then + Result.dCompletionPercentage = Result.dCompletionPercentage -- non incide sulla percentuale lavorata, solo messaggio che manca + Result.sInfo = Result.sInfo .. '- Roughing not executed\n' + end + end + -- se lavorazioni corner + if Strategy.EdgeWithCorner.Machinings and #Strategy.EdgeWithCorner.Machinings == 0 then + Result.dCompletionPercentage = Result.dCompletionPercentage - dPercentageEdgeCorner -- la pulizia dei corner incide per il 10% + dPercentageEdgeCorner = 0 + Result.sInfo = Result.sInfo .. '- Corner not executed, material left\n' + end + end + + -- lavorazione del profilo + if not Strategy.Profile.Machinings or #Strategy.Profile.Machinings == 0 then + Result.sInfo = Result.sInfo .. '- Profile not executed, tool not found!\n' + else + local dTotalPercentage = dPercentageProfile + dPercentageEdgeCorner + dPercentageChamfer + Result.dCompletionPercentage = Result.dCompletionPercentage - ( ( ( 100 - Strategy.Profile.Result.dCompletionPercentage) * dTotalPercentage) / 100) + end + end + + -- si setta lo stato in base alla percentuale di completamento + if Result.dCompletionPercentage == 100 then + Result.sStatus = "Completed" + elseif Result.dCompletionPercentage == 0 then + Result.sStatus = "Not-Applicable" + else + Result.sStatus = "Not-Completed" + local dPercentageLeft = ceil( 100 - Result.dCompletionPercentage) + Result.sInfo = Result.sInfo .. '- Not Complete : left ' .. tostring( dPercentageLeft) .. '%\n' + end + Result.nCompletionIndex = FeatureLib.GetFeatureCompletionIndex( Result.dCompletionPercentage) Result.dMRR = 1 - Result.nQuality = FeatureLib.GetStrategyQuality( 'MILL') - Result.sInfo = '' + -- se tutte le lavorazioni sono state eseguite, è la massima qualità che si possa ottenere, altrimenti qualità più bassa + if Result.sInfo == '' then + Result.nQuality = FeatureLib.GetStrategyQuality( 'BEST') + else + Result.nQuality = FeatureLib.GetStrategyQuality( 'MILL') + end return Result end @@ -328,15 +719,17 @@ function STR0015.Make( bAddMachining, Proc, Part, CustomParameters) if not Strategy.Parameters.bOnlyChamfer then -- per tutti tranne che per feature RoundArc if not ID.IsRoundArch( Proc) then - Strategy.RoughCut = {} - Strategy.RoughCut.Machinings = {} - Strategy.RoughCut.Result = {} + -- lavorazione taglio per sgrossare + if Strategy.Parameters.bExecRough then + Strategy.RoughCut = {} + Strategy.RoughCut.Machinings = {} + Strategy.RoughCut.Result = {} + Strategy.RoughCut.Machinings, Strategy.RoughCut.Result = GetRoughStrategy( Proc, Part, bAddMachining) + end + -- lavorazione degli estremi con angoli interni Strategy.EdgeWithCorner = {} Strategy.EdgeWithCorner.Machinings = {} Strategy.EdgeWithCorner.Result = {} - -- lavorazione taglio per sgrossare - Strategy.RoughCut.Machinings, Strategy.RoughCut.Result = GetRoughStrategy( Proc, Part, bAddMachining) - -- lavorazione degli estremi con angoli interni Strategy.EdgeWithCorner.Machinings, Strategy.EdgeWithCorner.Result = GetEdgeWithCornerStrategy( Proc, Part) end @@ -347,7 +740,7 @@ function STR0015.Make( bAddMachining, Proc, Part, CustomParameters) Strategy.Profile.Machinings, Strategy.Profile.Result = GetArcStrategy( Proc, Part) end - Strategy.Result = GetFeatureResult() + Strategy.Result = GetFeatureResult( Proc) if bAddMachining and Strategy.Result.sStatus ~= 'Not-Applicable' then -- eventuali punti di spezzatura @@ -355,31 +748,48 @@ function STR0015.Make( bAddMachining, Proc, Part, CustomParameters) -- lavorazione degli smussi if Strategy.Chamfer.Machinings then + for i = 1, #Strategy.Chamfer.Machinings do + local MachiningToSplit = {} + table.insert( MachiningToSplit, Strategy.Chamfer.Machinings[i]) + local MachiningResult = MachiningLib.GetSplitMachinings( MachiningToSplit, FeatureSplittingPoints, Part) + -- aggiunge lavorazione + for j = 1, #MachiningResult do + bAreAllMachiningsAdded = MachiningLib.AddMachinings( Proc, MachiningResult[j]) + end + end end - -- lavorazione di sgrezzatura di lama - if Strategy.RoughCut.Machinings then - -- se cutting da fare come svuotatura - if Strategy.RoughCut.Machinings.bCuttingWithMill then - -- TODO - -- taglio di lama - else - for i = 1, #Strategy.RoughCut.Machinings do - if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then - Strategy.RoughCut.Machinings[i].sStage = 'AfterTail' + -- per tutti tranne che per feature RoundArc + if not ID.IsRoundArch( Proc) then + -- lavorazione di sgrezzatura di lama + if Strategy.Parameters.bExecRough and Strategy.RoughCut.Machinings then + -- se cutting da fare come svuotatura + if Strategy.RoughCut.Machinings.bCuttingWithMill then + bAreAllMachiningsAdded = MachiningLib.AddMachinings( Proc, Strategy.RoughCut.Machinings) + -- taglio di lama + else + for i = 1, #Strategy.RoughCut.Machinings do + if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then + Strategy.RoughCut.Machinings[i].sStage = 'AfterTail' + end + local bIsMachiningAdded = MachiningLib.AddMachinings( Proc, Strategy.RoughCut.Machinings[i]) + if not bIsMachiningAdded then + bAreAllMachiningsAdded = false + end end - local bIsMachiningAdded = MachiningLib.AddMachinings( Proc, Strategy.RoughCut.Machinings[i]) + end + end + + -- lavorazione degli angoli interni + if Strategy.EdgeWithCorner.Machinings then + for i = 1, #Strategy.EdgeWithCorner.Machinings do + local bIsMachiningAdded = MachiningLib.AddMachinings( Proc, Strategy.EdgeWithCorner.Machinings[i]) if not bIsMachiningAdded then bAreAllMachiningsAdded = false end end end end - - -- lavorazione degli angoli interni - if Strategy.EdgeWithCorner.Machinings then - end - -- lavorazione del profilo if Strategy.Profile.Machinings then for i = 1, #Strategy.Profile.Machinings do @@ -387,14 +797,13 @@ function STR0015.Make( bAddMachining, Proc, Part, CustomParameters) Strategy.Profile.Machinings[i].Geometry = {{ Proc.idAddAuxGeom, -1}} Strategy.Profile.Machinings[i].nToolIndex = Strategy.Profile.Machinings[i].ToolInfo.nToolIndex Strategy.Profile.Machinings[i].nType = MCH_MY.MILLING - Strategy.Profile.Machinings[i].dStartSafetyLength = 0 Strategy.Profile.Machinings[i].Steps = {} + Strategy.Profile.Machinings[i].Steps.dStep = TOOLS[Strategy.Profile.Machinings[i].ToolInfo.nToolIndex].dStep Strategy.Profile.Machinings[i].Steps = MachiningLib.GetMachiningSteps( tonumber( Strategy.Profile.Machinings[i].sDepth), TOOLS[Strategy.Profile.Machinings[i].nToolIndex].dStep) + Strategy.Profile.Machinings[i].Steps.nStepType = MCH_MILL_ST.ONEWAY -- LeadIn / LeadOut - Strategy.Profile.Machinings[i].LeadIn = {} - Strategy.Profile.Machinings[i].LeadOut = {} Strategy.Profile.Machinings[i].LeadIn.nType = MCH_MILL_LI.TANGENT Strategy.Profile.Machinings[i].LeadOut.nType = MCH_MILL_LI.TANGENT Strategy.Profile.Machinings[i].LeadIn.dTangentDistance = TOOLS[Strategy.Profile.Machinings[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC @@ -404,8 +813,6 @@ function STR0015.Make( bAddMachining, Proc, Part, CustomParameters) Strategy.Profile.Machinings[i].LeadOut.dPerpDistance = 0 Strategy.Profile.Machinings[i].LeadOut.dEndAddLength = 0 - local dLengthOnX = Proc.b3Box:getDimX() - Strategy.bCanMoveAfterSplit = MachiningLib.CanMoveAfterSplitcut( dLengthOnX, Part) if Proc.AffectedFaces.bLeft and Strategy.bCanMoveAfterSplit then Strategy.Profile.Machinings[i].sStage = 'AfterTail' end diff --git a/Strategies/Strategies.ini b/Strategies/Strategies.ini index 3f772d6..4c6baa0 100644 --- a/Strategies/Strategies.ini +++ b/Strategies/Strategies.ini @@ -8,7 +8,7 @@ STR0005 = 1, 2 o 3 facce. Lama con taglio singolo o cubetti. Se richiesto o nece STR0006 = Tenone. Lama + fresa STR0007 = Mortasa a coda di rondine e mortasa frontale a coda di rondine STR0008 = Svuotatura tasca -STR0009 = Fresatura di fianco (tipo arco) +STR0009 = !!DEPRECATA!! Sostituita da STR0015. RIUTILIZZABILE! STR0010 = Fresatura perpendicolare (tipo cut, longcut) STR0011 = Foratura STR0012 = RidgeLap