From cb81dc1d1516c0975d3f0c6e2b6dadf1485e439d Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Fri, 12 Sep 2025 11:33:32 +0200 Subject: [PATCH] - Lettura parametri Q - Nuovi parametri configurabili --- LuaLibs/BasicCustomerStrategies.lua | 12 + LuaLibs/FeatureLib.lua | 1 + Strategies/Standard/STR0015/STR0015.lua | 306 ++++++++++++++++++------ 3 files changed, 240 insertions(+), 79 deletions(-) diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index be4bff1..8ed811d 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -476,6 +476,18 @@ 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 : 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'}) end return Parameters diff --git a/LuaLibs/FeatureLib.lua b/LuaLibs/FeatureLib.lua index 084faa0..ba5725a 100644 --- a/LuaLibs/FeatureLib.lua +++ b/LuaLibs/FeatureLib.lua @@ -573,6 +573,7 @@ function FeatureLib.GetFeatureCompletionIndex( dCompletionPercentage) end ------------------------------------------------------------------------------------------------------------- +-- TODO funzione da rivedere. Se è fatto di fresa con antischeggia deve avere qualità massima, o comunque più alta di fresa normale -- funzione che restituisce qualità della lavorazione in base agli utensili utilizzati function FeatureLib.GetFeatureQuality( sTypeTools) local nQuality = 5 diff --git a/Strategies/Standard/STR0015/STR0015.lua b/Strategies/Standard/STR0015/STR0015.lua index cd6b301..f668559 100644 --- a/Strategies/Standard/STR0015/STR0015.lua +++ b/Strategies/Standard/STR0015/STR0015.lua @@ -1,7 +1,7 @@ --- Strategia: STR0009 +-- Strategia: STR0015 -- Descrizione -- Fresatura di contorno --- Feature tipo Arco +-- Feature tipo Profilo arcuato, Convesso, Concavo, Arco -- carico librerie @@ -9,32 +9,113 @@ local BeamLib = require( 'BeamLib') local BeamData = require( 'BeamData') local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') +local ID = require( 'Identity') + -- strategie di base local BladeToWaste = require('BLADETOWASTE') -- Tabella per definizione modulo -local STR0009 = {} +local STR0015 = {} local Strategy = {} +--------------------------------------------------------------------- +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 + 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) + end + dRot = dRot / 2 + end + -- restituisco i dati del piano + return ptStart, vtNP +end + +------------------------------------------------------------------------------------------------------------- +local function GetRoughStrategy( Proc, Part, bSaveAddedGeometries) + local Machining = {} + local Result = {} + + -- ====== Taglio di sgrossatura generale su tutto il profilo ====== + local vtNF = EgtSurfTmFacetNormVersor( Proc.id, Proc.nFct-1, GDB_ID.ROOT) + local nAddGroupId = BeamLib.GetAddGroup( Part.id) + -- aggiungo piano di sgrossatura e lo lavoro + local ptStart, vtNP = GetSawCutData( Proc.idAddAuxGeom, vtNF) + local AddId = EgtSurfTmPlaneInBBox( nAddGroupId, ptStart, vtNP, Part.b3Part, GDB_RT.GLOB) + 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) + + -- se non ci sono lavorazioni, provo con fresa + if not Machining then + -- TODO + end + + return Machining, Result +end + + +------------------------------------------------------------------------------------------------------------- +local function GetEdgeWithCornerStrategy( Proc, Part) + + if Strategy.Parameters.sConcaveFaceStrategy == 'AUTO' or Strategy.Parameters.sConcaveFaceStrategy == 'BLADE_FORCED' then + end + +end + +------------------------------------------------------------------------------------------------------------- +local function GetChamferStrategy( Proc, Part) + local Machining = {} + local Result = {} + + 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 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 dDepth = abs( EgtCurveThickness( Proc.idAddAuxGeom)) + local vtExtr = EgtCurveExtrusion( Proc.idAddAuxGeom, 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 @@ -153,93 +234,160 @@ local function GetArcStrategy( Proc, Part) 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 = '' + Result.sStatus = 'Completed' + Result.nCompletionIndex = 5 + Result.dMRR = MachiningLib.GetToolMRR( Machining[1].ToolInfo or Machining[2].ToolInfo) + Result.nQuality = FeatureLib.GetFeatureQuality( 'Mill') + Result.sInfo = '' - return Machining + return Machining, Result end ------------------------------------------------------------------------------------------------------------- -function STR0009.Make( bAddMachining, Proc, Part, CustomParameters) +local function GetFeatureResult() + local Result = {} + + Result.sStatus = 'Completed' + Result.nCompletionIndex = 5 + Result.dMRR = 1 + Result.nQuality = FeatureLib.GetFeatureQuality( 'Mill') + Result.sInfo = '' + + return Result +end + +------------------------------------------------------------------------------------------------------------- +function STR0015.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.Chamfer = {} + Strategy.Chamfer.Machinings = {} + Strategy.Chamfer.Result = {} + Strategy.Profile = {} + Strategy.Profile.Machinings = {} + Strategy.Profile.Result = {} Strategy.Result = {} local bAreAllMachiningsAdded = true - local Milling = {} - Strategy.Machinings = GetArcStrategy( Proc, Part) + -- 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 + + -- lavorazione smussi + Strategy.Chamfer.Machinings, Strategy.Chamfer.Result = GetChamferStrategy( Proc, Part) + + -- se non bisogna fare solo gli smussi, si calcolano le altre lavorazioni + 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 = {} + 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 + + -- lavorazione profilo (a meno che non si facciano solo smussi) + if not Strategy.Parameters.bOnlyChamfer then + Strategy.Profile.Machinings, Strategy.Profile.Result = GetArcStrategy( Proc, Part) + end + end + + Strategy.Result = GetFeatureResult() 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 + -- lavorazione degli smussi + if Strategy.Chamfer.Machinings then + end - 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) + -- lavorazione di sgrezzatura di lama + if Strategy.RoughCut.Machinings then + end - -- 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 + -- lavorazione degli angoli interni + if Strategy.EdgeWithCorner.Machinings then + end - 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 + -- lavorazione del profilo + if Strategy.Profile.Machinings then + for i = 1, #Strategy.Profile.Machinings do - -- 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 + 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) - -- 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() + -- 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 + Strategy.Profile.Machinings[i].LeadIn.dPerpDistance = 0 + Strategy.Profile.Machinings[i].LeadIn.dStartAddLength = 0 + Strategy.Profile.Machinings[i].LeadOut.dTangentDistance = TOOLS[Strategy.Profile.Machinings[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC + Strategy.Profile.Machinings[i].LeadOut.dPerpDistance = 0 + Strategy.Profile.Machinings[i].LeadOut.dEndAddLength = 0 - 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]) + 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 + + -- preparo attacco/uscita in caso di spezzatura arco + Strategy.Profile.Machinings[i].LeadInForSplit = BeamLib.TableCopyDeep( Strategy.Profile.Machinings[i].LeadIn) + Strategy.Profile.Machinings[i].LeadOutForSplit = BeamLib.TableCopyDeep( Strategy.Profile.Machinings[i].LeadOut) + Strategy.Profile.Machinings[i].LeadInForSplit.nType = MCH_MILL_LI.LINEAR + Strategy.Profile.Machinings[i].LeadOutForSplit.nType = MCH_MILL_LI.LINEAR + Strategy.Profile.Machinings[i].LeadInForSplit.dTangentDistance = 0 + Strategy.Profile.Machinings[i].LeadInForSplit.dPerpDistance = TOOLS[Strategy.Profile.Machinings[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC + Strategy.Profile.Machinings[i].LeadOutForSplit.dTangentDistance = 0 + Strategy.Profile.Machinings[i].LeadOutForSplit.dPerpDistance = TOOLS[Strategy.Profile.Machinings[i].ToolInfo.nToolIndex].dDiameter / 2 + BeamData.COLL_SIC + + -- sistemo il lato e la direzione di lavoro + if i == 1 then + Strategy.Profile.Machinings[i].bInvert = EgtIf( TOOLS[Strategy.Profile.Machinings[i].ToolInfo.nToolIndex].bIsCCW, false, true) + Strategy.Profile.Machinings[i].nWorkside = EgtIf( TOOLS[Strategy.Profile.Machinings[i].ToolInfo.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + else + Strategy.Profile.Machinings[i].bToolInvert = true + Strategy.Profile.Machinings[i].bInvert = EgtIf( TOOLS[Strategy.Profile.Machinings[i].ToolInfo.nToolIndex].bIsCCW, true, false) + Strategy.Profile.Machinings[i].nWorkside = EgtIf( TOOLS[Strategy.Profile.Machinings[i].ToolInfo.nToolIndex].bIsCCW, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT) + end + Strategy.Profile.Machinings[i].ptEdge1 = EgtSP( Proc.idAddAuxGeom, GDB_ID.ROOT) + Strategy.Profile.Machinings[i].ptEdge2 = EgtEP( Proc.idAddAuxGeom, GDB_ID.ROOT) + Strategy.Profile.Machinings[i].dEdgeLength = EgtCurveLength( Proc.idAddAuxGeom) + Strategy.Profile.Machinings[i].vtEdgeDirection = EgtSV( Proc.idAddAuxGeom, GDB_ID.ROOT) + EgtMV( Proc.idAddAuxGeom, GDB_ID.ROOT) + EgtEV( Proc.idAddAuxGeom, GDB_ID.ROOT) + Strategy.Profile.Machinings[i].dLengthOnX = Proc.b3Box:getDimX() + + local MachiningToSplit = {} + table.insert( MachiningToSplit, Strategy.Profile.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 @@ -252,4 +400,4 @@ end ------------------------------------------------------------------------------------------------------------- - return STR0009 \ No newline at end of file + return STR0015 \ No newline at end of file