diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index 34c4b64..be4bff1 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -377,6 +377,7 @@ local function GetStrategies_Essetre( Proc) --------------------------------------------------------------------- -- Feature : Head Cambered Profile (0-103) elseif ID.IsHeadCamberedProfile( Proc) then + Strategies = { { sStrategyId = 'STR0015'}} --------------------------------------------------------------------- -- Feature : Round Arch (0-104) elseif ID.IsRoundArch( Proc) then diff --git a/Strategies/AvailableStrategyList.json b/Strategies/AvailableStrategyList.json index c524082..de5af80 100644 --- a/Strategies/AvailableStrategyList.json +++ b/Strategies/AvailableStrategyList.json @@ -602,7 +602,7 @@ "nGrp": 0, "TopologyList" : [ { "sName": "Feature", - "StrategyList" : [ ] + "StrategyList" : [ { "sStrategyId": "STR0015" } ] } ] }, diff --git a/Strategies/Standard/STR0015/STR0015.json b/Strategies/Standard/STR0015/STR0015.json new file mode 100644 index 0000000..19f554b --- /dev/null +++ b/Strategies/Standard/STR0015/STR0015.json @@ -0,0 +1,57 @@ +{ + "sStrategyId": "STR0009", + "sStrategyName": "Mill Heading", + "ParameterList" : [ + { + "sName": "dDepthChamfer", + "sNameNge": "DEPTH_CHAMFER", + "sValue": "0", + "sDescriptionShort": "Depth Chamfer", + "sDescriptionLong": "Depth of the V-Mill to execute chamfers on cut-edges", + "sType": "d", + "sMessageId": " ", + "sMinUserLevel": "1" + }, + { + "sName": "dOverMaterial", + "sNameNge": "OVERMAT", + "sValue": "0", + "sDescriptionShort": "Overmaterial", + "sDescriptionLong": "", + "sType": "d", + "sMessageId": " ", + "sMinUserLevel": "1" + }, + { + "sName": "bForceStrip", + "sNameNge": "FORCE_STRIP", + "sValue": "false", + "sDescriptionShort": "Force strip", + "sDescriptionLong": "Enable the parameter to force the software to leave a strip to sustain the piece", + "sType": "b", + "sMessageId": " ", + "sMinUserLevel": "1" + }, + { + "sName": "dStripWidth", + "sNameNge": "STRIP_WIDTH", + "sValue": "0", + "sDescriptionShort": "Strip width", + "sDescriptionLong": "Width of the strip in case if foreseen from the machining", + "sType": "d", + "sMessageId": " ", + "sMinUserLevel": "1" + }, + { + "sName": "sMillingList", + "sNameNge": "PROFILE_TOOL_LIST", + "sValue": "", + "sDescriptionShort": "Available mill to machine the profile", + "sDescriptionLong": "", + "sType": "tool", + "sSubType": "Mill", + "sMessageId": " ", + "sMinUserLevel": "1" + } + ] +} \ No newline at end of file diff --git a/Strategies/Standard/STR0015/STR0015.lua b/Strategies/Standard/STR0015/STR0015.lua new file mode 100644 index 0000000..cd6b301 --- /dev/null +++ b/Strategies/Standard/STR0015/STR0015.lua @@ -0,0 +1,255 @@ +-- Strategia: STR0009 +-- Descrizione +-- Fresatura di contorno +-- Feature tipo Arco + + +-- carico librerie +local BeamLib = require( 'BeamLib') +local BeamData = require( 'BeamData') +local MachiningLib = require( 'MachiningLib') +local FeatureLib = require( 'FeatureLib') +-- strategie di base +local BladeToWaste = require('BLADETOWASTE') + +-- Tabella per definizione modulo +local STR0009 = {} +local Strategy = {} + +------------------------------------------------------------------------------------------------------------- +-- TODO gestire il caso in cui non si trova l'utensile +local function GetArcStrategy( Proc, Part) + local Machining = {} + local ToolSearchParameters = {} + + -- recupero e verifico l'entità curva + local idAux = EgtGetInfo( Proc.id, 'AUXID', 'i') + if idAux then idAux = idAux + Proc.id end + if not idAux or ( EgtGetType( idAux) & GDB_FY.GEO_CURVE) == 0 then + local sErr = 'Error on process ' .. tostring( Proc.id) .. ' missing profile geometry' + EgtOutLog( sErr) + return false, sErr + end + Proc.idAddAuxGeom = idAux + + -- recupero i dati della curva e del profilo + local dDepth = abs( EgtCurveThickness( idAux)) + local vtExtr = EgtCurveExtrusion( idAux, GDB_RT.GLOB) + local bToolInvert = ( vtExtr:getZ() < -0.1) + local bIsHorizontal = abs( vtExtr:getZ()) < 10 * GEO.EPS_SMALL + local bIsFeatureDown = Proc.AffectedFaces.bBottom and not Proc.AffectedFaces.bTop + 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 bExecStrip = false + -- se la lavorazione si trova nella parte inferiore o in battuta dietro, il codolo va sempre lasciato + if bIsFeatureDown or bIsFeatureBack or bForceStrip then + if bIsFeatureDown or bIsFeatureBack then + dDimStrip = dDimStrip or max( BeamData.DIM_STRIP or 5, 5) + else + dDimStrip = dDimStrip or max( BeamData.DIM_STRIP_SMALL or 5, 1) + end + bExecStrip = true + end + if not bExecStrip then + dDimStrip = 0 + end + + -- se lavorazione orizzontale + 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) + ToolSearchParameters.vtToolDirection = EgtIf( bToolInvert, -vtExtr, vtExtr) + ToolSearchParameters.AvailableToolList = MachiningLib.GetAvailableToolList( Proc, Strategy.Parameters.sMillingList, 'Milling') + Milling.ToolInfo = {} + 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) + end + Milling.bToolInvert = bToolInvert + Milling.vtToolDirection = vtExtr + + if bDouble or bExecStrip then + if bDouble then + Milling.sDepth = ( dDepth + BeamData.MILL_OVERLAP) / 2 + else + Milling.sDepth = ( dDepth - dDimStrip) / 2 + end + table.insert( Machining, Milling) + local Milling2 = BeamLib.TableCopyDeep( Milling) + 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, 'Milling') + Milling.ToolInfo = {} + Milling.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) + -- si cerca utensile 2 + local Milling2 = {} + Milling2.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, 'Milling') + Milling2.ToolInfo = {} + Milling2.ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) + + -- se serve codolo + if bExecStrip then + -- se a disposizione entrambi gli utensili + if Milling.ToolInfo.nToolIndex and Milling2.ToolInfo.nToolIndex then + table.insert( Machining, Milling) + table.insert( Machining, Milling2) + -- se disponibile solo primo utensile + elseif Milling.ToolInfo.nToolIndex then + table.insert( Machining, Milling) + -- se disponibile solo secondo utensile + elseif Milling2.ToolInfo.nToolIndex then + table.insert( Machining, Milling2) + -- nessun utensile disponibile + else + -- non si fa nulla + end + -- altrimenti senza codolo + else + -- se utensile 1 esegue completamente + if Milling.ToolInfo.nToolIndex and Milling.ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then + table.insert( Machining, Milling) + -- se utensile 2 esegue completamente + elseif Milling2.ToolInfo.nToolIndex and Milling2.ToolInfo.dResidualDepth < 10 * GEO.EPS_SMALL then + table.insert( Machining, Milling2) + -- se possono lavorare entrambi + elseif Milling.ToolInfo.nToolIndex and Milling2.ToolInfo.nToolIndex then + table.insert( Machining, Milling) + table.insert( Machining, Milling2) + -- se utensile 1 non completo + elseif Milling.ToolInfo.nToolIndex then + table.insert( Machining, Milling) + -- se utensile 2 non completo + elseif Milling2.ToolInfo.nToolIndex then + table.insert( Machining, Milling2) + end + end + end + + -- TODO VOTO DA FARE!!!! + Strategy.Result.sStatus = 'Completed' + Strategy.Result.nCompletionIndex = 5 + Strategy.Result.dMRR = MachiningLib.GetToolMRR( Machining[1].ToolInfo or Machining[2].ToolInfo) + Strategy.Result.nQuality = FeatureLib.GetFeatureQuality( 'Mill') + Strategy.Result.sInfo = '' + + return Machining +end + +------------------------------------------------------------------------------------------------------------- +function STR0009.Make( bAddMachining, Proc, Part, CustomParameters) + -- carico parametri de default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) + local StrategyLib = {} + StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] + Strategy.sName = StrategyLib.Config.sStrategyId + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Machinings = {} + Strategy.Result = {} + + local bAreAllMachiningsAdded = true + local Milling = {} + + Strategy.Machinings = GetArcStrategy( Proc, Part) + + if bAddMachining and Strategy.Result.sStatus ~= 'Not-Applicable' then + -- eventuali punti di spezzatura + local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) + + for i = 1, #Strategy.Machinings do + + Strategy.Machinings[i].Geometry = {{ Proc.idAddAuxGeom, -1}} + Strategy.Machinings[i].nToolIndex = Strategy.Machinings[i].ToolInfo.nToolIndex + Strategy.Machinings[i].nType = MCH_MY.MILLING + Strategy.Machinings[i].dStartSafetyLength = 0 + Strategy.Machinings[i].Steps = {} + Strategy.Machinings[i].Steps.dStep = TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].dStep + Strategy.Machinings[i].Steps = MachiningLib.GetMachiningSteps( tonumber( Strategy.Machinings[i].sDepth), TOOLS[Strategy.Machinings[i].nToolIndex].dStep) + + -- LeadIn / LeadOut + Strategy.Machinings[i].LeadIn = {} + Strategy.Machinings[i].LeadOut = {} + Strategy.Machinings[i].LeadIn.nType = MCH_MILL_LI.TANGENT + Strategy.Machinings[i].LeadOut.nType = MCH_MILL_LI.TANGENT + Strategy.Machinings[i].LeadIn.dTangentDistance = TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC + Strategy.Machinings[i].LeadIn.dPerpDistance = 0 + Strategy.Machinings[i].LeadIn.dStartAddLength = 0 + Strategy.Machinings[i].LeadOut.dTangentDistance = TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC + Strategy.Machinings[i].LeadOut.dPerpDistance = 0 + Strategy.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.Machinings[i].sStage = 'AfterTail' + end + + -- preparo attacco/uscita in caso di spezzatura arco + Strategy.Machinings[i].LeadInForSplit = BeamLib.TableCopyDeep( Strategy.Machinings[i].LeadIn) + Strategy.Machinings[i].LeadOutForSplit = BeamLib.TableCopyDeep( Strategy.Machinings[i].LeadOut) + Strategy.Machinings[i].LeadInForSplit.nType = MCH_MILL_LI.LINEAR + Strategy.Machinings[i].LeadOutForSplit.nType = MCH_MILL_LI.LINEAR + Strategy.Machinings[i].LeadInForSplit.dTangentDistance = 0 + Strategy.Machinings[i].LeadInForSplit.dPerpDistance = TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC + Strategy.Machinings[i].LeadOutForSplit.dTangentDistance = 0 + Strategy.Machinings[i].LeadOutForSplit.dPerpDistance = TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC + + -- sistemo il lato e la direzione di lavoro + if i == 1 then + Strategy.Machinings[i].bInvert = EgtIf( TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].bIsCCW, false, true) + Strategy.Machinings[i].nWorkside = EgtIf( TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + else + Strategy.Machinings[i].bToolInvert = true + Strategy.Machinings[i].bInvert = EgtIf( TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].bIsCCW, true, false) + Strategy.Machinings[i].nWorkside = EgtIf( TOOLS[Strategy.Machinings[i].ToolInfo.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + end + Strategy.Machinings[i].ptEdge1 = EgtSP( Proc.idAddAuxGeom, GDB_ID.ROOT) + Strategy.Machinings[i].ptEdge2 = EgtEP( Proc.idAddAuxGeom, GDB_ID.ROOT) + Strategy.Machinings[i].dEdgeLength = EgtCurveLength( Proc.idAddAuxGeom) + Strategy.Machinings[i].vtEdgeDirection = EgtSV( Proc.idAddAuxGeom, GDB_ID.ROOT) + EgtMV( Proc.idAddAuxGeom, GDB_ID.ROOT) + EgtEV( Proc.idAddAuxGeom, GDB_ID.ROOT) + Strategy.Machinings[i].dLengthOnX = Proc.b3Box:getDimX() + + local MachiningToSplit = {} + table.insert( MachiningToSplit, Strategy.Machinings[i]) + local MachiningResult = MachiningLib.GetSplitMachinings( MachiningToSplit, FeatureSplittingPoints, Part) + -- aggiunge lavorazione + for j = 1, #MachiningResult do + bAreAllMachiningsAdded = MachiningLib.AddMachinings( Proc, MachiningResult[j]) + end + end + + else + bAreAllMachiningsAdded = false + end + + return bAreAllMachiningsAdded, Strategy.Result +end + +------------------------------------------------------------------------------------------------------------- + + return STR0009 \ No newline at end of file diff --git a/Strategies/Strategies.ini b/Strategies/Strategies.ini index f553995..3f772d6 100644 --- a/Strategies/Strategies.ini +++ b/Strategies/Strategies.ini @@ -14,6 +14,7 @@ STR0011 = Foratura STR0012 = RidgeLap STR0013 = Foratura con fresa (svuotatura) STR0014 = Incisione con fresa/penna (Mark/text) +STR0015 = Profilo arcuato (Head Cambered Profile) [Strategies] ; Processing , Gruppo , Topologia , Strategie