diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 7f8a97e..4d7179b 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -97,8 +97,8 @@ function BeamExec.GetToolsFromDB() -- verifico se utensile disponibile in attrezzaggio attuale e che abbia un tipo ben definito local bToolLoadedOnSetup, sToolTCPos = EgtFindToolInCurrSetup( Tool.sName) - local dToolTypeID = EgtTdbGetCurrToolParam( MCH_TP.TYPE) - local sToolType, sToolFamily = GetToolTypeNameFromToolTypeID( dToolTypeID) + local nToolTypeId = EgtTdbGetCurrToolParam( MCH_TP.TYPE) + local sToolType, sToolFamily = GetToolTypeNameFromToolTypeID( nToolTypeId) -- se verifica condizioni minime, recupero tutti gli altri dati if bToolLoadedOnSetup and sToolType then @@ -108,7 +108,7 @@ function BeamExec.GetToolsFromDB() Tool.sTcPos = sToolTCPos Tool.sFamily = sToolFamily Tool.sType = sToolType - Tool.dTypeID = dToolTypeID + Tool.nTypeId = nToolTypeId Tool.dMaxMaterial = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) Tool.dDiameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM) Tool.dLength = EgtTdbGetCurrToolParam( MCH_TP.LEN) @@ -586,7 +586,7 @@ local function AreDrillingsMirrored( Proc, ProcMirror, Part) -- centri allineati, equidistanti dalla mezzeria trave, non troppo vicini local vtDisplacement = ptBC - ptBCMirror - local ptCenRaw = Part.b3RawBox:getCenter() + local ptCenRaw = Part.b3Raw:getCenter() if nDouble == 2 then local dYMinDistance = max( Proc.b3Box:getMin():getY(), ProcMirror.b3Box:getMin():getY()) - min( Proc.b3Box:getMax():getY(), ProcMirror.b3Box:getMax():getY()) if not ( abs( vtDisplacement:getX()) < 100 * GEO.EPS_SMALL and abs( vtDisplacement:getZ()) < 100 * GEO.EPS_SMALL and @@ -873,10 +873,10 @@ function BeamExec.ProcessFeatures() while Part.idRaw do -- verifico che il grezzo contenga pezzi oppure sia abbastanza lungo da essere scaricato coi carrelli Part.idPart = EgtGetFirstPartInRawPart( Part.idRaw) - Part.b3RawBox = EgtGetRawPartBBox( Part.idRaw) + Part.b3Raw = EgtGetRawPartBBox( Part.idRaw) Part.b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( Part.idPart, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) - if not Part.idPart and Part.b3RawBox:getDimX() < BeamData.dMinRaw then break end + if not Part.idPart and Part.b3Raw:getDimX() < BeamData.dMinRaw then break end -- per ogni rotazione, calcolo come lavorare le feature per decidere posizionamento iniziale e in che rotazione verranno lavorate le singole feature local vProcRot = {} @@ -905,7 +905,7 @@ end -- ruoto il grezzo per calcolare la fattibilità delle lavorazioni nella prossima rotazione -- vettore movimento grezzi per rotazione di 90deg ogni step - local dDeltaYZ = Part.b3RawBox:getDimY() - Part.b3RawBox:getDimZ() + local dDeltaYZ = Part.b3Raw:getDimY() - Part.b3Raw:getDimZ() local vtMove = Vector3d( 0, dDeltaYZ / 2 * EgtIf( BeamData.RIGHT_LOAD, -1, 1), dDeltaYZ / 2) local bPreMove = ( dDeltaYZ < 0) -- ruoto le travi della fase corrente @@ -917,7 +917,7 @@ end EgtMoveRawPart( Part.idRaw, vtMove) end -- aggiorno info pezzo - Part.b3RawBox = EgtGetRawPartBBox( Part.idRaw) + Part.b3Raw = EgtGetRawPartBBox( Part.idRaw) Part.b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( Part.idPart, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) end diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 82e8c20..2657bfd 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -8,6 +8,7 @@ local BeamLib = {} -- Include require( 'EgtBase') +local BeamData = require( 'BeamData') EgtOutLog( ' BeamLib started', 1) @@ -262,14 +263,14 @@ function BeamLib.GetFaceHvRefDim( nSurfId, idFace, Part) local dDimH = b3HV:getDimX() local dDimV = b3HV:getDimY() -- se definito grezzo (o solido), applico eventuali limiti - if Part.b3RawBox then + if Part.b3Raw then local dCoeffY = abs( frHV:getVersX():getY()) if dCoeffY > GEO.EPS_SMALL then - dDimH = min( dDimH, Part.b3RawBox:getDimY() / dCoeffY) + dDimH = min( dDimH, Part.b3Raw:getDimY() / dCoeffY) end local dCoeffZ = abs( frHV:getVersY():getZ()) if dCoeffZ > GEO.EPS_SMALL then - dDimV = min( dDimV, Part.b3RawBox:getDimZ() / dCoeffZ) + dDimV = min( dDimV, Part.b3Raw:getDimZ() / dCoeffZ) end end @@ -312,5 +313,44 @@ function BeamLib.LoadCustomParametersInStrategy( CustomParameters) return Parameters end +--------------------------------------------------------------------- +function BeamLib.GetChainSawInitAngs( vtN, vtO, nInd) + if BeamData.GetChainSawInitAngs then + return BeamData.GetChainSawInitAngs( vtN, vtO, nInd) + else + if BeamData.C_SIMM then + return EgtIf( vtN:getY() > 0, 'C=180', 'C=-180') + else + if nInd == 1 then + return '' + else + return EgtIf( vtN:getY() > 0, 'C=180', 'C=-180') + end + end + end +end + +--------------------------------------------------------------------- +function BeamLib.GetBlockedAxis( nToolIndex, sBlockedAxis, b3Raw, vtTool, vtOut) + -- se presente funzione specifica nella macchina, la richiamo + if BeamData.GetBlockedAxis then + return BeamData.GetBlockedAxis( TOOLS[nToolIndex].sHead, TOOLS[nToolIndex].nTypeId, sBlockedAxis, b3Raw, vtTool, vtOut) or '' + -- sezione mantenuta per retrocompatibilità con GetChainSawBlockedAxis + elseif TOOLS[nToolIndex].nTypeId == MCH_TY.MORTISE_STD then + local nInd = EgtIf( sBlockedAxis == 'parallel', 0, 1) + if BeamData.GetChainSawBlockedAxis then + return BeamData.GetChainSawBlockedAxis( nInd) + else + if nInd == 1 then + return EgtIf( BeamData.C_SIMM, 'A=90', 'A=90') + else + return EgtIf( BeamData.C_SIMM, 'A=0', 'A=0') + end + end + end + + return '' +end + ------------------------------------------------------------------------------------------------------------- return BeamLib diff --git a/LuaLibs/FeatureData.lua b/LuaLibs/FeatureData.lua index ea2f3b4..7060ecb 100644 --- a/LuaLibs/FeatureData.lua +++ b/LuaLibs/FeatureData.lua @@ -111,14 +111,14 @@ end ------------------------------------------------------------------------------------------------------------- -- restituisce vero se la feature con box b3Proc taglia l'intera sezione della barra, rappresentata dalle sue dimensioni W e H local function IsFeatureCuttingEntireSection( b3Proc, Part) - return ( b3Proc:getDimY() > ( Part.b3RawBox:getDimY() - 500 * GEO.EPS_SMALL) and b3Proc:getDimZ() > ( Part.b3RawBox:getDimZ() - 500 * GEO.EPS_SMALL)) + return ( b3Proc:getDimY() > ( Part.b3Raw:getDimY() - 500 * GEO.EPS_SMALL) and b3Proc:getDimZ() > ( Part.b3Raw:getDimZ() - 500 * GEO.EPS_SMALL)) end ------------------------------------------------------------------------------------------------------------- -- restituisce vero se la feature con box b3Proc taglia l'intera lunghezza della barra, rappresentata dalle sue dimensioni W e L oppure H e L local function IsFeatureCuttingEntireLength( b3Proc, Part) - return ( ( b3Proc:getDimY() > ( Part.b3RawBox:getDimY() - 500 * GEO.EPS_SMALL) and b3Proc:getDimX() > ( Part.b3RawBox:getDimX() - 500 * GEO.EPS_SMALL)) or - ( b3Proc:getDimZ() > ( Part.b3RawBox:getDimZ() - 500 * GEO.EPS_SMALL) and b3Proc:getDimX() > ( Part.b3RawBox:getDimX() - 500 * GEO.EPS_SMALL))) + return ( ( b3Proc:getDimY() > ( Part.b3Raw:getDimY() - 500 * GEO.EPS_SMALL) and b3Proc:getDimX() > ( Part.b3Raw:getDimX() - 500 * GEO.EPS_SMALL)) or + ( b3Proc:getDimZ() > ( Part.b3Raw:getDimZ() - 500 * GEO.EPS_SMALL) and b3Proc:getDimX() > ( Part.b3Raw:getDimX() - 500 * GEO.EPS_SMALL))) end --------------------------------------------------------------------- diff --git a/Strategies/STR0003/STR0003.lua b/Strategies/STR0003/STR0003.lua index 7ca01d7..56fd3ab 100644 --- a/Strategies/STR0003/STR0003.lua +++ b/Strategies/STR0003/STR0003.lua @@ -119,13 +119,14 @@ local function CalculateLeadInOut( Machining, EdgeToMachine) end -local function AddNewMachining( Machining, b3Raw) +local function AddNewMachining( Machining, Part) local sErr = '' local nOperationId = EgtCreateMachining( Machining.sOperationName, Machining.nType, TOOLS[Machining.nToolIndex].sName) -- impostazione parametri lavorazione local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) EgtSetMachiningGeometry( Machining.Geometry) + EgtSetMachiningParam( MCH_MP.DEPTH, Machining.Depth or 0) EgtSetMachiningParam( MCH_MP.FACEUSE, Machining.nFaceuse) EgtSetMachiningParam( MCH_MP.SCC, Machining.nSCC) EgtSetMachiningParam( MCH_MP.INVERT, Machining.bInvert) @@ -155,7 +156,7 @@ local function AddNewMachining( Machining, b3Raw) EgtSetMachiningParam( MCH_MP.STEP, Machining.Steps.dStepLength) end end - EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BeamLib.GetBlockedAxis( Machining.sName, Machining.BlockedAxis.sOrientation, b3Raw, Machining.BlockedAxis.vtN, Machining.BlockedAxis.vtOut)) + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BeamLib.GetBlockedAxis( Machining.nToolIndex, Machining.BlockedAxis.sOrientation, Part.b3Raw, Machining.BlockedAxis.vtN, Machining.BlockedAxis.vtOut)) if Machining.nType == MCH_OY.MORTISING then EgtSetMachiningParam( MCH_MP.INITANGS, BeamLib.GetChainSawInitAngs( Machining.SuggestedAngles.vtN, Machining.SuggestedAngles.vtOrtho, Machining.SuggestedAngles.nIndex)) end @@ -178,7 +179,7 @@ local function AddNewMachining( Machining, b3Raw) else Machining.BlockedAxis.sOrientation = 'perpendicular' end - EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BeamLib.GetBlockedAxis( Machining.sName, Machining.BlockedAxis.sOrientation, b3Raw, Machining.BlockedAxis.vtN, Machining.BlockedAxis.vtOut)) + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BeamLib.GetBlockedAxis( Machining.nToolIndex, Machining.BlockedAxis.sOrientation, Part.b3Raw, Machining.BlockedAxis.vtN, Machining.BlockedAxis.vtOut)) if Machining.SuggestedAngles.nIndex == 1 then Machining.SuggestedAngles.nIndex = 2 else @@ -223,6 +224,7 @@ end function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) local Cutting = {} Cutting.bCanApply = true + Cutting.dDepthToMachine = 0 Cutting.sMessage = '' Cutting.idProc = Proc.id local dResidualDepth = 0 @@ -375,7 +377,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) end -function Blade.AddMachiningAllSteps( Cutting, b3Raw) +function Blade.AddMachiningAllSteps( Cutting, Part) local bIsCuttingOk = false local sCuttingApplyMessage = '' @@ -388,7 +390,7 @@ function Blade.AddMachiningAllSteps( Cutting, b3Raw) Cutting.LeadIn.dPerpDistance = dOriginalLeadInPerpDistance - Cutting.dRadialOffset Cutting.LeadOut.dPerpDistance = dOriginalLeadOutPerpDistance - Cutting.dRadialOffset -- applicazione lavorazione - bIsCuttingOk, sCuttingApplyMessage = AddNewMachining( Cutting, b3Raw) + bIsCuttingOk, sCuttingApplyMessage = AddNewMachining( Cutting, Part) -- update messaggi if sCuttingApplyMessage and #sCuttingApplyMessage > 0 then sCuttingApplyMessage = sCuttingApplyMessage .. 'Apply : ' .. sCuttingApplyMessage .. '\n' @@ -570,7 +572,7 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi end -function Chainsaw.AddMachiningAllSteps( Mortising, b3Raw) +function Chainsaw.AddMachiningAllSteps( Mortising, Part) local bIsMortisingOk = false local sMortisingApplyMessage = '' @@ -578,7 +580,7 @@ function Chainsaw.AddMachiningAllSteps( Mortising, b3Raw) for i = Mortising.VerticalSteps.nCount, 1, -1 do Mortising.dRadialOffset = dOriginalRadialOffsetMortising + Mortising.VerticalSteps.dStepLength * ( i - 1) -- applicazione lavorazione - bIsMortisingOk, sMortisingApplyMessage = AddNewMachining( Mortising, b3Raw) + bIsMortisingOk, sMortisingApplyMessage = AddNewMachining( Mortising, Part.b3Raw) -- update messaggi if sMortisingApplyMessage and #sMortisingApplyMessage > 0 then Mortising.sMessage = Mortising.sMessage .. '\n' .. 'Apply : ' .. sMortisingApplyMessage @@ -602,7 +604,6 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) Blade.Result = {} Chainsaw.Result = {} - local b3Raw = EgtGetRawPartBBox( Part.idRaw) local dResidualDepth = 0 if not IsTopologyOk( Proc) then @@ -634,7 +635,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) Blade.Result[#Blade.Result].sMessage = Cutting.sMessage Blade.Result[#Blade.Result].dDepthMachined = Cutting.dDepthToMachine if bAddMachining and Cutting.bCanApply then - Blade.Result[#Blade.Result].bIsApplyOk, Blade.Result[#Blade.Result].sApplyMessage = Blade.AddMachiningAllSteps( Cutting, b3Raw) + Blade.Result[#Blade.Result].bIsApplyOk, Blade.Result[#Blade.Result].sApplyMessage = Blade.AddMachiningAllSteps( Cutting, Part) end local dBottomDepthToMachine = dResidualDepth -- lato opposto del tunnel @@ -646,7 +647,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) Blade.Result[#Blade.Result].sMessage = Cutting.sMessage Blade.Result[#Blade.Result].dDepthMachined = Cutting.dDepthToMachine if bAddMachining and Cutting.bCanApply then - Blade.Result[#Blade.Result].bIsApplyOk, Blade.Result[#Blade.Result].sApplyMessage = Blade.AddMachiningAllSteps( Cutting, b3Raw) + Blade.Result[#Blade.Result].bIsApplyOk, Blade.Result[#Blade.Result].sApplyMessage = Blade.AddMachiningAllSteps( Cutting, Part) end else -- se la lama non è arrivata sul fondo e c'è almeno un lato aperto va lavorato @@ -660,7 +661,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) Blade.Result[#Blade.Result].sMessage = Cutting.sMessage Blade.Result[#Blade.Result].dDepthMachined = Cutting.dDepthToMachine if bAddMachining and Cutting.bCanApply then - Blade.Result[#Blade.Result].bIsApplyOk, Blade.Result[#Blade.Result].sApplyMessage = Blade.AddMachiningAllSteps( Cutting, b3Raw) + Blade.Result[#Blade.Result].bIsApplyOk, Blade.Result[#Blade.Result].sApplyMessage = Blade.AddMachiningAllSteps( Cutting, Part) end end -- eventuale lavorazione di lama - lato della tasca in cui finisce la lavorazione @@ -672,7 +673,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) Blade.Result[#Blade.Result].sMessage = Cutting.sMessage Blade.Result[#Blade.Result].dDepthMachined = Cutting.dDepthToMachine if bAddMachining and Cutting.bCanApply then - Blade.Result[#Blade.Result].bIsApplyOk, Blade.Result[#Blade.Result].sApplyMessage = Blade.AddMachiningAllSteps( Cutting, b3Raw) + Blade.Result[#Blade.Result].bIsApplyOk, Blade.Result[#Blade.Result].sApplyMessage = Blade.AddMachiningAllSteps( Cutting, Part) end end -- la lama è arrivata sul fondo e tasca passante, non servono ulteriori lavorazioni @@ -684,6 +685,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if Strategy.Parameters.bApplyOnlyBlade then local bAreAllApplyOk local nApplyOkCount = 0 + local dCompletionPercentage = 0 for i = 1, #Blade.Result do Strategy.Result.sInfo = Strategy.Result.sInfo .. '\n' .. Blade.Result[i].sMessage .. '\n' .. ( Blade.Result[i].sApplyMessage or '') if Blade.Result[i].bIsApplyOk then @@ -696,16 +698,16 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if not Strategy.Parameters.bContinueOnFailedApply and ( bAreAllApplyOk == false) then Strategy.Result.sStatus = 'Not-Applicable' else - Strategy.Result.dCompletionPercentage = GetCompletionPercentage( Proc, Blade.Result) - if Strategy.Result.dCompletionPercentage > 99 + 10 * GEO.EPS_SMALL then + dCompletionPercentage = GetCompletionPercentage( Proc, Blade.Result) + if dCompletionPercentage > 99 + 10 * GEO.EPS_SMALL then Strategy.Result.sStatus = 'Completed' else Strategy.Result.sStatus = 'Not-Completed' end end - Strategy.Result.nCompletionIndex = FeatureData.GetFeatureCompletionIndex( Strategy.Result.dCompletionPercentage) + Strategy.Result.nCompletionIndex = FeatureData.GetFeatureCompletionIndex( dCompletionPercentage) Strategy.Result.nQuality = FeatureData.GetFeatureQuality( 'Blade') - Strategy.Result.dMRR = FeatureData.GetFeatureMRR( TOOLS[Cutting.nToolIndex].dThickness, TOOLS[Cutting.nToolIndex].dSideStep, TOOLS[Cutting.nToolIndex].Feeds.dFeed) + Strategy.Result.dMRR = MachiningLib.GetToolMRR( TOOLS[Cutting.nToolIndex].dThickness, TOOLS[Cutting.nToolIndex].dSideStep, TOOLS[Cutting.nToolIndex].Feeds.dFeed) return bAreAllApplyOk, Strategy.Result end @@ -722,14 +724,14 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) end local bIsMortisingOk = false if bAddMachining and Mortising.bCanApply then - bIsMortisingOk, Mortising.Message = Chainsaw.AddMachiningAllSteps( Mortising, b3Raw) + bIsMortisingOk, Mortising.Message = Chainsaw.AddMachiningAllSteps( Mortising, Part) end -- lato opposto del tunnel if Proc.Topology == 'Tunnel' and ( dResidualDepth > 10 * GEO.EPS_SMALL) then Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2]) bIsMortisingOk = false if bAddMachining and Mortising.bCanApply then - bIsMortisingOk, Mortising.Message = Chainsaw.AddMachiningAllSteps( Mortising, b3Raw) + bIsMortisingOk, Mortising.Message = Chainsaw.AddMachiningAllSteps( Mortising, Part) end if not bIsMortisingOk then return bIsMortisingOk, Mortising.Message @@ -742,7 +744,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1]) bIsMortisingOk = false if bAddMachining and Mortising.bCanApply then - bIsMortisingOk, Mortising.Message = Chainsaw.AddMachiningAllSteps( Mortising, b3Raw) + bIsMortisingOk, Mortising.Message = Chainsaw.AddMachiningAllSteps( Mortising, Part) end if not bIsMortisingOk then return bIsMortisingOk, Mortising.Message @@ -753,7 +755,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].Edges.SideEdges[2]) bIsMortisingOk = false if bAddMachining and Mortising.bCanApply then - bIsMortisingOk, Mortising.Message = Chainsaw.AddMachiningAllSteps( Mortising, b3Raw) + bIsMortisingOk, Mortising.Message = Chainsaw.AddMachiningAllSteps( Mortising, Part) end if not bIsMortisingOk then return bIsMortisingOk, Mortising.Message