diff --git a/Compile.bat b/Compile.bat index 9e11c86..4091878 100644 --- a/Compile.bat +++ b/Compile.bat @@ -45,6 +45,7 @@ REM Compilazione 32 e 64 bit \EgtProg\Dll32\luac54 -o bin\LuaLibs\ProcessText.lua -s LuaLibs\ProcessText.lua \EgtProg\Dll32\luac54 -o bin\LuaLibs\ProcessTyroleanDovetail.lua -s LuaLibs\ProcessTyroleanDovetail.lua \EgtProg\Dll32\luac54 -o bin\LuaLibs\ProcessVariant.lua -s LuaLibs\ProcessVariant.lua +\EgtProg\Dll32\luac54 -o bin\LuaLibs\ProcessProbing.lua -s LuaLibs\ProcessProbing.lua \EgtProg\Dll32\luac54 -o bin\BatchProcess.lua -s BatchProcess.lua \EgtProg\Dll32\luac54 -o bin\BatchProcessNew.lua -s BatchProcessNew.lua \EgtProg\Dll32\luac54 -o bin\GetBeamData.lua -s GetBeamData.lua diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 60afcc9..8efc44b 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -108,6 +108,7 @@ _G.package.loaded.ProcessScarfJoint = nil _G.package.loaded.ProcessSimpleScarf = nil _G.package.loaded.ProcessStepJoint = nil _G.package.loaded.ProcessStepJointNotch = nil +_G.package.loaded.ProcessProbing = nil _G.package.loaded.ProcessProfFront = nil _G.package.loaded.ProcessProfConcave = nil _G.package.loaded.ProcessProfConvex = nil diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 1d66881..72188fb 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -899,6 +899,27 @@ function BeamLib.FindFaceBestOrientedAsAxis( Proc, vtAx, fctExclude) return nFaceIndMax, ptC, vtN end +--------------------------------------------------------------------- +function BeamLib.GetEdgeToMachineFromVector( nSurfId, nFacet, vtOrtho) + local _, EdgesEgt = EgtSurfTmGetFacetOutlineInfo( nSurfId, nFacet, GDB_ID.ROOT) + + local nEdgeIndMax = 0 + local dMaxComp = - GEO.INFINITO + for i = 1, #EdgesEgt do + local vtN = EdgesEgt[i].Norm + if EdgesEgt[i].Open then + vtN = -vtN + end + local dComp = vtN * vtOrtho + if dComp > dMaxComp then + nEdgeIndMax = i -1 + dMaxComp = dComp + end + end + + return nEdgeIndMax +end + --------------------------------------------------------------------- function BeamLib.GetTunnelDimension( Proc, nPartId) -- sono necessarie almeno due facce diff --git a/LuaLibs/DiceCut.lua b/LuaLibs/DiceCut.lua index a91a07f..183fa66 100644 --- a/LuaLibs/DiceCut.lua +++ b/LuaLibs/DiceCut.lua @@ -566,7 +566,7 @@ function DiceCut.GetDice( nParent, BBoxRawPart, ptCPlanes, vtNPlanes, bGetOrtoPl end end - return UltimateTable + return UltimateTable, OffsetP, OffsetO end ---------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/LuaLibs/FacesBySaw.lua b/LuaLibs/FacesBySaw.lua index c7da7aa..3c8e4b2 100644 --- a/LuaLibs/FacesBySaw.lua +++ b/LuaLibs/FacesBySaw.lua @@ -46,7 +46,7 @@ local BD = require( 'BeamData') local ML = require( 'MachiningLib') --------------------------------------------------------------------- -function MakeParallelOne( nSurfId, nFacet, sCutting, dSawDiam, nFaceUse, dVzLimDwnUp, dCutExtra, dCutSic, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw, bForceInvert, bForceTangentLeadInOut) +function MakeParallelOne( nSurfId, nFacet, sCutting, dSawDiam, nFaceUse, dVzLimDwnUp, dCutExtra, dCutSic, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw, bForceInvert, sLeadInOutType, dActualElevation) EgtOutLog( 'FacesBySaw.MakeParallelOne', 3) -- dati della faccia local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, nFacet, GDB_ID.ROOT) @@ -68,16 +68,28 @@ function MakeParallelOne( nSurfId, nFacet, sCutting, dSawDiam, nFaceUse, dVzLimD local dLiPerp = dDistX + dCutExtra + dCutSic local dLoTang = dLiTang local dLoPerp = dLiPerp + local dLiCompLength = 0 + local dLoCompLength = 0 -- lunghezza attacco/uscita tangenti local dLi2Tang = dSawDiam / 2 + dCutSic local dLi2Perp = 0 local dLo2Tang = dLi2Tang local dLo2Perp = dLi2Perp + local dLi2CompLength = 0 + local dLo2CompLength = 0 -- scelgo l'attacco più conveniente local bLioTang local Ktp = 1.1 if BD.KIOTP then Ktp = BD.KIOTP end - if bForceTangentLeadInOut or ( Ktp * dLi2Tang < dLiPerp) then + if ( sLeadInOutType == 'PerpendicularOutraw') then + bLioTang = false + dLiCompLength = dActualElevation + EgtMdbGetGeneralParam( MCH_GP.SAFEZ) + dCutExtra + dLoCompLength = dActualElevation + EgtMdbGetGeneralParam( MCH_GP.SAFEZ) + dCutExtra + dLiTang = 1 + dLoTang = 1 + dLiPerp = 0 + dLoPerp = 0 + elseif ( sLeadInOutType ~= 'Perpendicular') and ( ( sLeadInOutType == 'Tangent') or ( Ktp * dLi2Tang < dLiPerp)) then bLioTang = true dLiTang, dLiPerp, dLoTang, dLoPerp = dLi2Tang, dLi2Perp, dLo2Tang, dLo2Perp if BD.TURN then @@ -136,9 +148,11 @@ function MakeParallelOne( nSurfId, nFacet, sCutting, dSawDiam, nFaceUse, dVzLimD -- imposto attacco/uscita EgtSetMachiningParam( MCH_MP.LITANG, dLiTang) EgtSetMachiningParam( MCH_MP.LIPERP, dLiPerp) + EgtSetMachiningParam( MCH_MP.LICOMPLEN, dLiCompLength) if BD.TURN and bLioTang then EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.PERP_TG) end EgtSetMachiningParam( MCH_MP.LOTANG, dLoTang) EgtSetMachiningParam( MCH_MP.LOPERP, dLoPerp) + EgtSetMachiningParam( MCH_MP.LOCOMPLEN, dLoCompLength) -- imposto allungamenti iniziale e finale EgtSetMachiningParam( MCH_MP.STARTADDLEN, -dAccStart) EgtSetMachiningParam( MCH_MP.ENDADDLEN, -dAccEnd) @@ -157,6 +171,9 @@ function MakeParallelOne( nSurfId, nFacet, sCutting, dSawDiam, nFaceUse, dVzLimD local vtOut = EgtIf( vtN:getX() > 0, X_AX(), -X_AX()) EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetBlockedAxis( sCutting, 'perpendicular', b3Raw, vtTool, vtOut)) -- eventuali note + if ( sLeadInOutType == 'PerpendicularOutraw') then + sNotes = EgtSetValInNotes( sNotes, 'OutRaw', 3) + end if sNotes and #sNotes > 0 then EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) end -- eseguo if not ML.ApplyMachining( true, false) then @@ -214,7 +231,7 @@ local function GetEdgeToMachineFromVector( nSurfId, nFacet, vtOrthO) end --------------------------------------------------------------------- -function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDwnUp, dCutExtra, dCutSic, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw, bForceInvert, bMaximizeVerticalDepth, bSpecialTangentLeadInOut, bForceTangentLeadInOut, Par5Alternative) +function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDwnUp, dCutExtra, dCutSic, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw, bForceInvert, bMaximizeVerticalDepth, bSpecialTangentLeadInOut, sLeadInOutType, Par5Alternative, dActualElevation) -- se lama con asse parallelo alla faccia, passo alla apposita funzione if ( Par5 == MCH_MILL_FU.PARAL_DOWN or Par5 == MCH_MILL_FU.PARAL_TOP or @@ -222,7 +239,7 @@ function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDw Par5 == MCH_MILL_FU.PARAL_BACK or Par5 == MCH_MILL_FU.PARAL_LEFT or Par5 == MCH_MILL_FU.PARAL_RIGHT) then - return MakeParallelOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDwnUp, dCutExtra, dCutSic, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw, bForceInvert, bForceTangentLeadInOut) + return MakeParallelOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDwnUp, dCutExtra, dCutSic, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw, bForceInvert, sLeadInOutType, dActualElevation) end -- la lama ha asse perpendicolare alla faccia EgtOutLog( 'FacesBySaw.MakeOne', 3) @@ -457,7 +474,17 @@ function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDw local bLioTang local Ktp = 1.1 if BD.KIOTP then Ktp = BD.KIOTP end - if ( bForceTangentLeadInOut or ( not bDownUp or abs( vtTg:getY()) > 0.5) and + if ( sLeadInOutType == 'PerpendicularOutraw') then + bLioTang = false + dLiCompLength = dActualElevation + EgtMdbGetGeneralParam( MCH_GP.SAFEZ) + dCutExtra + dLoCompLength = dActualElevation + EgtMdbGetGeneralParam( MCH_GP.SAFEZ) + dCutExtra + dLiTang = 1 + dLoTang = 1 + dLiPerp = 0 + dLoPerp = 0 + dLenLi = sqrt( dLiTang * dLiTang + dLiPerp * dLiPerp) + dLenLo = sqrt( dLoTang * dLoTang + dLoPerp * dLoPerp) + elseif ( sLeadInOutType ~= 'Perpendicular') and ( ( sLeadInOutType == 'Tangent') or ( not bDownUp or abs( vtTg:getY()) > 0.5) and ( not bDownHead or abs( vtTg:getZ()) < 0.51) and abs( vtTg:getX()) < 0.9848 and ( ( abs( vtTg:getZ()) < 0.17 and ( vtV1:getZ() < -0.5 or vtV2:getZ() < -0.5) and not bDownHead) or @@ -603,6 +630,9 @@ function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDw local sBlockedAxis = EgtIf( bMaximizeVerticalDepth, 'parallel', 'perpendicular') EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BL.GetBlockedAxis( sCutting, sBlockedAxis, b3Raw, vtN, vtOrthO)) -- eventuali note + if ( sLeadInOutType == 'PerpendicularOutraw') then + sNotes = EgtSetValInNotes( sNotes, 'OutRaw', 3) + end if sNotes and #sNotes > 0 then EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) end -- eseguo if not ML.ApplyMachining( true, false) then diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index b8970c3..167e9cb 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -25,11 +25,14 @@ EgtOutLog( ' MachiningLib started', 1) -- Dati local BD = require( 'BeamData') -local Cuttings = require( 'CutData') -local Millings = require( 'MillingData') -local Pocketings = require( 'PocketingData') -local Sawings = require( 'SawingData') -local Drillings = require( 'DrillData') +-- librerie lavorazioni caricate con pcall perchè potrebbero non esserci +local Cuttings, Millings, Pocketings, Sawings, Drillings, Probing +if pcall( require, 'CutData') then Cuttings = require( 'CutData') end +if pcall( require, 'MillingData') then Millings = require( 'MillingData') end +if pcall( require, 'PocketingData') then Pocketings = require( 'PocketingData') end +if pcall( require, 'SawingData') then Sawings = require( 'SawingData') end +if pcall( require, 'DrillData') then Drillings = require( 'DrillData') end +if pcall( require, 'ProbingData') then Probing = require( 'ProbingData') end -- tipo di teste macchina local ONE_HEAD = 1 -- una testa (Fast, One, Turn1T) @@ -184,18 +187,32 @@ end --------------------------------------------------------------------- function GetMachinings( MachiningType, sType) - local Machinings + local Machinings = {} -- leggo le lavorazioni disponibili if MachiningType == MCH_MY.DRILLING then - Machinings = Drillings + if Drillings and type( Drillings) == "table" then + Machinings = Drillings + end elseif MachiningType == MCH_MY.SAWING then - Machinings = Cuttings + if Cuttings and type( Cuttings) == "table" then + Machinings = Cuttings + end elseif MachiningType == MCH_MY.MILLING then - Machinings = Millings + if Millings and type( Millings) == "table" then + Machinings = Millings + end elseif MachiningType == MCH_MY.POCKETING then - Machinings = Pocketings + if Pocketings and type( Pocketings) == "table" then + Machinings = Pocketings + end elseif MachiningType == MCH_MY.MORTISING then - Machinings = Sawings + if Sawings and type( Sawings) == "table" then + Machinings = Sawings + end + elseif MachiningType == MCH_MY.PROBING then + if Probing and type( Probing) == "table" then + Machinings = Probing + end end -- scrivo i parametri utensile nella lavorazione local validMachinings = {} @@ -208,27 +225,30 @@ function GetMachinings( MachiningType, sType) if Machining.Tool.Name then if EgtTdbSetCurrTool( Machining.Tool.Name) then table.insert( validMachinings, Machining) - if ( MachiningType == MCH_MY.MILLING) or ( MachiningType == MCH_MY.POCKETING) or ( MachiningType == MCH_MY.DRILLING and EgtStartsWith( sType, 'Pocket')) then - Machining.Tool.MaxMat = EgtTdbGetCurrToolMaxDepth() - else - Machining.Tool.MaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) - end - if MachiningType == MCH_MY.DRILLING then - if EgtStartsWith( Machining.Type, 'Drill') then - Machining.SubType = 'Drill' - elseif EgtStartsWith( Machining.Type, 'AngleDrill') then - Machining.SubType = 'AngleDrill' - elseif EgtStartsWith( Machining.Type, 'Pocket') then - Machining.SubType = 'DrillPocket' - elseif EgtStartsWith( Machining.Type, 'Predrill') then - Machining.SubType = 'Predrill' + -- se non è tastatura, recupero dati utensile + if MachiningType ~= MCH_MY.PROBING then + if ( MachiningType == MCH_MY.MILLING) or ( MachiningType == MCH_MY.POCKETING) or ( MachiningType == MCH_MY.DRILLING and EgtStartsWith( sType, 'Pocket')) then + Machining.Tool.MaxMat = EgtTdbGetCurrToolMaxDepth() + else + Machining.Tool.MaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) end + if MachiningType == MCH_MY.DRILLING then + if EgtStartsWith( Machining.Type, 'Drill') then + Machining.SubType = 'Drill' + elseif EgtStartsWith( Machining.Type, 'AngleDrill') then + Machining.SubType = 'AngleDrill' + elseif EgtStartsWith( Machining.Type, 'Pocket') then + Machining.SubType = 'DrillPocket' + elseif EgtStartsWith( Machining.Type, 'Predrill') then + Machining.SubType = 'Predrill' + end + end + Machining.Tool.Diameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + Machining.Tool.Length = EgtTdbGetCurrToolParam( MCH_TP.LEN) + Machining.Tool.TotalLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) + Machining.Tool.ToolHolderDiameter = EgtTdbGetCurrToolThDiam() + Machining.Tool.ToolHolderLength = EgtTdbGetCurrToolThLength() or 72 end - Machining.Tool.Diameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - Machining.Tool.Length = EgtTdbGetCurrToolParam( MCH_TP.LEN) - Machining.Tool.TotalLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) - Machining.Tool.ToolHolderDiameter = EgtTdbGetCurrToolThDiam() - Machining.Tool.ToolHolderLength = EgtTdbGetCurrToolThLength() or 72 end end end @@ -311,6 +331,7 @@ end --------------------------------------------------------------------- local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, bExcludeH2, bExcludeH3, sSortingCriterion) + local bOptimizeHeads = BEAM and BEAM.BW and ( not sSortingCriterion or sSortingCriterion == '') if bTopHead == nil and bDownHead == nil then bTopHead = true bDownHead = false @@ -348,15 +369,15 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, ForEnd = 1 ForStep = -1 end - if ( BEAM and BEAM.BW) or MachineHeadType == ONE_HEAD or MachineHeadType == TWO_EQUAL_HEADS or ( MachineHeadType == TWO_UP_DOWN_HEADS and not bDownHead) then + if bOptimizeHeads or MachineHeadType == ONE_HEAD or MachineHeadType == TWO_EQUAL_HEADS or ( MachineHeadType == TWO_UP_DOWN_HEADS and not bDownHead) then _, sType = EgtEndsWith( sType, '_H2') - elseif not ( BEAM and BEAM.BW) and MachineHeadType == TWO_UP_DOWN_HEADS and not bTopHead and bDownHead then + elseif not bOptimizeHeads and MachineHeadType == TWO_UP_DOWN_HEADS and not bTopHead and bDownHead then if not EgtEndsWith( sType, '_H2') then sType = sType .. '_H2' end end local MachineHeadUse = MachineHeadType - if not ( BEAM and BEAM.BW) and MachineHeadUse == TWO_EQUAL_HEADS then + if not bOptimizeHeads and MachineHeadUse == TWO_EQUAL_HEADS then MachineHeadUse = ONE_HEAD end if MachineHeadUse == TWO_UP_DOWN_HEADS and bTopHead and bDownHead then @@ -368,7 +389,7 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, for i = ForStart, ForEnd, ForStep do local Machining = Machinings[i] local sMachiningType = Machining.Type - if ( BEAM and BEAM.BW) or MachineHeadUse == TWO_EQUAL_HEADS then + if bOptimizeHeads or MachineHeadUse == TWO_EQUAL_HEADS then _, sMachiningType = EgtEndsWith( Machining.Type, '_H2') end -- recupero dati utensile @@ -444,7 +465,7 @@ local function FindMachining( MachiningType, sType, Params, bTopHead, bDownHead, end end local bH2, sOrigType = EgtEndsWith( sType, '_H2') - if ( not BEAM or not BEAM.BW) and MachineHeadType == TWO_UP_DOWN_HEADS and bH2 and bTopHead then + if not bOptimizeHeads and MachineHeadType == TWO_UP_DOWN_HEADS and bH2 and bTopHead then return FindMachining( MachiningType, sOrigType, Params, true, false) end end @@ -481,8 +502,8 @@ function MachiningLib.FindAngleDrilling( dDiam, dDepth, bTopHead, bDownHead) end --------------------------------------------------------------------- -function MachiningLib.FindMilling( sType, dDepth, sTuuidMstr, dMaxDiam, dMaxTotLen, bTopHead, bDownHead, bExcludeH2, bExcludeH3) - return FindMachining( MCH_MY.MILLING, sType, { Depth = dDepth, TuuidMstr = sTuuidMstr, MaxDiam = dMaxDiam, MaxTotLen = dMaxTotLen}, bTopHead, bDownHead, bExcludeH2, bExcludeH3) +function MachiningLib.FindMilling( sType, dDepth, sTuuidMstr, dMaxDiam, dMaxTotLen, bTopHead, bDownHead, bExcludeH2, bExcludeH3, sSortingCriterion) + return FindMachining( MCH_MY.MILLING, sType, { Depth = dDepth, TuuidMstr = sTuuidMstr, MaxDiam = dMaxDiam, MaxTotLen = dMaxTotLen}, bTopHead, bDownHead, bExcludeH2, bExcludeH3, sSortingCriterion) end --------------------------------------------------------------------- diff --git a/LuaLibs/ProcessCut.lua b/LuaLibs/ProcessCut.lua index 947bdde..62fff86 100644 --- a/LuaLibs/ProcessCut.lua +++ b/LuaLibs/ProcessCut.lua @@ -261,7 +261,7 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione con testa da sopra -local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, bCustDiceCut, bForced, b3Raw, sNotes, nLimitingSurf, bForceTangentLeadInOut) +local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, bCustDiceCut, bForced, b3Raw, sNotes, nLimitingSurf, sLeadInOutType) local sWarn -- ingombro del grezzo b3Raw = b3Raw or EgtGetRawPartBBox( nRawId) @@ -377,6 +377,8 @@ local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, b -- se lungo, una faccia e rivolto sul retro verso l'alto si forzano i cubetti per evitare di rovinare il pezzo successivo local bForceDicing = ( Proc.Fct == 1 and Proc.AffectedFaces.Left and bLongCut and vtN:getZ() > 10 * GEO.EPS_SMALL and vtN:getY() < 10 * GEO.EPS_SMALL) local vCuts = {} + local dDicingOffsetP + local dDicingOffsetO if ( ( not Proc.AdvTail) or bForceDicing) and ( dCutH > dMaxDepth - BD.CUT_EXTRA - 3 * BD.COLL_SIC or dCutV > dMaxVertDepth - BD.CUT_EXTRA - 3 * BD.COLL_SIC) then local ptExtra, vtExtra local bAutoCalcSurf = true @@ -424,10 +426,10 @@ local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, b end -- se il taglio è più spesso della lama abilito il dicing, altrimenti no if ( dMaxElev > dSawThick) or bForceDicing then - vCuts = DC.GetDice( nAddGrpId, EgtIf( bForced, b3Raw, b3Solid), ptC, vtN, bAutoCalcSurf, ptExtra, vtExtra, dMaxVertDepth - BD.CUT_EXTRA, dNewDiceDim) + vCuts, dDicingOffsetP = DC.GetDice( nAddGrpId, EgtIf( bForced, b3Raw, b3Solid), ptC, vtN, bAutoCalcSurf, ptExtra, vtExtra, dMaxVertDepth - BD.CUT_EXTRA, dNewDiceDim) -- se taglio sborda in coda e non è stato inserito nessun taglio a cubetti, lo rilancio con le dimensioni customizzate if ( bFillTail or bCustDiceCut) and #vCuts == 0 then - vCuts = DC.GetDice( nAddGrpId, b3Solid, ptC, vtN, bAutoCalcSurf, ptExtra, vtExtra, dMaxVertDepth - BD.CUT_EXTRA, Proc.Box:getDimY()) + vCuts, dDicingOffsetP = DC.GetDice( nAddGrpId, b3Solid, ptC, vtN, bAutoCalcSurf, ptExtra, vtExtra, dMaxVertDepth - BD.CUT_EXTRA, Proc.Box:getDimY()) end end end @@ -596,8 +598,17 @@ local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, b if ( i % 2 == 0) and ( Proc.Fct == 1) and bNoPerpCuts then vtOrthoOAlternative = - vtOrthoO end - bForceTangentLeadInOut = bForceTangentLeadInOut and ( ( i % 2) ~= 0) - local bOk, sErr = Fbs.MakeOne( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, dVzLimDwnUp, dExtraCut, BD.CUT_SIC, 0, 0, 0, sNotes, b3Raw, nil, nil, bSpecialTangentLeadInOut, bForceTangentLeadInOut, vtOrthoOAlternative) + local sLeadInOutTypeFbs = 'Calculated' + if ( ( i % 2) ~= 0) then + if ( sLeadInOutType == 'Tangent') then + sLeadInOutTypeFbs = 'Tangent' + elseif ( sLeadInOutType == 'Perpendicular') then + sLeadInOutTypeFbs = 'Perpendicular' + elseif ( sLeadInOutType == 'PerpendicularOutraw') then + sLeadInOutTypeFbs = 'PerpendicularOutraw' + end + end + local bOk, sErr = Fbs.MakeOne( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, dVzLimDwnUp, dExtraCut, BD.CUT_SIC, 0, 0, 0, sNotes, b3Raw, nil, nil, bSpecialTangentLeadInOut, sLeadInOutTypeFbs, vtOrthoOAlternative, dDicingOffsetP) if not bOk then return bOk, sErr end end end @@ -838,7 +849,7 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione -function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, bCustDiceCut, bForced, b3Raw, sNotes, dOvmTail, bUpdateIng, nLimitingSurf, bForceTangentLeadInOut) +function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, bCustDiceCut, bForced, b3Raw, sNotes, dOvmTail, bUpdateIng, nLimitingSurf, sLeadInOutType) -- sovramateriale di coda dOvmTail = dOvmTail or BD.OVM_MID -- ingombro del grezzo @@ -878,7 +889,7 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, local sWarn -- se taglio con testa da sopra if not bDownHead and not bDownTurn then - local bOk, sErr, bNoDicing2 = MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, bCustDiceCut, bForced, b3Raw, sNotes, nLimitingSurf, bForceTangentLeadInOut) + local bOk, sErr, bNoDicing2 = MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, bCustDiceCut, bForced, b3Raw, sNotes, nLimitingSurf, sLeadInOutType) bNoDicing = bNoDicing2 if not bOk then return false, sErr diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index d29dd7c..7856b25 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -546,7 +546,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) if bIntersectionOk then local dHoleToCutDistance = vDistance[1] -- se il taglio accorcia realmente il foro - if dHoleToCutDistance > 10 * GEO.EPS_SMALL and dHoleToCutDistance < dLen then + if ( dHoleToCutDistance > 10 * GEO.EPS_SMALL or Proc.AffectedFaces.Right) and dHoleToCutDistance < dLen then dMaxDepth = dMaxDepthOri dMaxElev = dLen - dHoleToCutDistance bTryDrill = true diff --git a/LuaLibs/ProcessDtMortise.lua b/LuaLibs/ProcessDtMortise.lua index ad4e66a..2d44d8a 100644 --- a/LuaLibs/ProcessDtMortise.lua +++ b/LuaLibs/ProcessDtMortise.lua @@ -20,6 +20,7 @@ local ProcessDtMortise = {} require( 'EgtBase') local BL = require( 'BeamLib') local Cut = require( 'ProcessCut') +local Probe = require( 'ProcessProbing') EgtOutLog( ' ProcessDtMortise started', 1) @@ -103,7 +104,7 @@ function ProcessDtMortise.GetCutPlane( Proc) end --------------------------------------------------------------------- -local function CalcTopPath( nProcId, AuxId, nAddGrpId, dAltMort, dSideAng, b3Solid) +local function CalcPathAtHeight( nProcId, AuxId, nAddGrpId, dHeight, dSideAng, b3Solid) -- copio la curva di base local NewAuxId = EgtCopyGlob( AuxId, nAddGrpId) if not NewAuxId then return end @@ -111,7 +112,7 @@ local function CalcTopPath( nProcId, AuxId, nAddGrpId, dAltMort, dSideAng, b3Sol EgtAddCurveCompoLineTg( NewAuxId, 100, false) EgtAddCurveCompoLineTg( NewAuxId, 100, true) EgtMergeCurvesInCurveCompo( NewAuxId) - local dOffset = dAltMort * tan( dSideAng) + local dOffset = dHeight * tan( dSideAng) if not EgtOffsetCurve( NewAuxId, dOffset) then return end -- la limito entro la trave local refBox = Frame3d( b3Solid:getMin()) @@ -119,7 +120,7 @@ local function CalcTopPath( nProcId, AuxId, nAddGrpId, dAltMort, dSideAng, b3Sol local nCount NewAuxId, nCount = EgtTrimFlatCurveWithBox( NewAuxId, refBox, vtBoxDiag, true, true, GDB_RT.GLOB) -- eseguo traslazione e offset per portarla sul top - local vtMove = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) * ( dAltMort - 10 * GEO.EPS_SMALL) + local vtMove = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) * ( dHeight - 10 * GEO.EPS_SMALL) EgtMove( NewAuxId, vtMove, GDB_RT.GLOB) -- se divisa in più parti, le unisco congiungendole con segmenti if nCount > 1 then @@ -136,6 +137,23 @@ local function CalcTopPath( nProcId, AuxId, nAddGrpId, dAltMort, dSideAng, b3Sol return NewAuxId end +--------------------------------------------------------------------- +local function GetVerticalSteps( dMachiningDepth, dStep ) + local MachiningSteps = {} + MachiningSteps.StepLength = 0 + + if dMachiningDepth <= 0 then + MachiningSteps.Count = 0 + return MachiningSteps + end + + MachiningSteps.Count = ceil( (dMachiningDepth - 10 * GEO.EPS_SMALL) / dStep ) + + MachiningSteps.StepLength = dMachiningDepth / MachiningSteps.Count + + return MachiningSteps +end + --------------------------------------------------------------------- -- verifica che il box includa il punto in XY function EnclosesPoint( b3Box, ptP) @@ -154,6 +172,7 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) + bMakeAntiSplitPath = true -- ingombro del pezzo local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) if not b3Solid then @@ -273,6 +292,7 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) local dToolDiam = 100 local dMaxMat = 30 local dSideAng = 0 + local sHeadTool = 'H1' local bCW = true local bMillOnAggregate = sMchExt == '_AT' if EgtMdbSetCurrMachining( sMilling) then @@ -282,16 +302,66 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) dToolDiam = max( dToolDiam, 10) dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat dSideAng = EgtTdbGetCurrToolParam( MCH_TP.SIDEANG) or dSideAng + sHeadTool = EgtTdbGetCurrToolParam( MCH_TP.HEAD) local dSpeed = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) or 0 bCW = ( dSpeed >= 0) end end - -- verifico che la profondità non superi il massimo materiale dell'utensile + local bMultipleZPasses = false + -- se necessario, cerco un utensile più lungo if dAltMort > dMaxMat + 10 * GEO.EPS_SMALL then - local sErr = 'Error : DtMortise Depth bigger than Tool Cutting edge' - EgtOutLog( sErr) - return false, sErr + -- recupero la lavorazione : prima ricerca per sola tipologia + sMilling = ML.FindMilling( sMillType..sMchExt, nil, nil, nil, nil, bMillUp, bMillDown, bExcludeH2, nil, 'Longest') + if not sMilling and bMillUp then + sMilling = ML.FindMilling( sMillType, nil, nil, nil, nil, bMillUp, bMillDown, bExcludeH2, nil, 'Longest') + end + if not sMilling then + local sErr = 'Milling not found in library : Error on DtMortise ' .. tostring( Proc.Id) + EgtOutLog( sErr) + return false, sErr + end + -- recupero la lavorazione : seconda ricerca con tipologia e diametro massimo + sMilling = ML.FindMilling( sMillType..sMchExt, nil, nil, 2 * dMinRad, nil, bMillUp, bMillDown, bExcludeH2, nil, 'Longest') + if not sMilling and bMillUp then + sMilling = ML.FindMilling( sMillType, nil, nil, 2 * dMinRad, nil, bMillUp, bMillDown, bExcludeH2, nil, 'Longest') + sMchExt = '' + end + if not sMilling then + local sErr = 'Radius too small : Error on DtMortise ' .. tostring( Proc.Id) + EgtOutLog( sErr) + return false, sErr + end + if not sMilling then + local sErr = 'Error : DtMortise Depth bigger than Tool Cutting edge' + EgtOutLog( sErr) + return false, sErr + end + -- riassegno dati utensile + dToolDiam = 100 + dMaxMat = 30 + dSideAng = 0 + bCW = true + bMillOnAggregate = sMchExt == '_AT' + if EgtMdbSetCurrMachining( sMilling) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam + dToolDiam = max( dToolDiam, 10) + dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat + dSideAng = EgtTdbGetCurrToolParam( MCH_TP.SIDEANG) or dSideAng + local dSpeed = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) or 0 + bCW = ( dSpeed >= 0) + end + end + + bMultipleZPasses = true end + + + -- tastatura se richiesta + local Info = { vtProbe = vtExtr, ptProbe = ptBC, sType = 'DTMortise', sHead = sHeadTool} + local bProbeExecuted, sErr = Probe.Make( Proc, nPartId, Info) + -- se con tasca, la lavoro (mai in doppio) if bPocket then -- recupero il contorno della tasca (seconda curva ausiliaria) @@ -374,7 +444,7 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) return false, sErr end -- calcolo il percorso top mortise - local nAuxId1 = CalcTopPath( Proc.Id, AuxId, nAddGrpId, dAltMort, dSideAng, b3Solid) + local nAuxId1 = CalcPathAtHeight( Proc.Id, AuxId, nAddGrpId, dAltMort, dSideAng, b3Solid) -- se esiste il percorso if nAuxId1 then -- creo percorso sulla parte alta della mortasa @@ -433,6 +503,10 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.DEPTH, dAltMort) -- setto offset radiale con aggiunto un ulteriore allargamento di 1mm EgtSetMachiningParam( MCH_MP.OFFSR, dToolRadDelta - 1) + -- antischeggia sempre con una passata + if bMultipleZPasses then + EgtSetMachiningParam( MCH_MP.STEP, 0) + end -- sistemo il lato e la direzione di lavoro EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( bCW, MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT)) EgtSetMachiningParam( MCH_MP.INVERT, EgtIf( bCW, false, true)) @@ -476,6 +550,23 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) local nPass = ceil( dDist / ( 1.9 * dToolDiam)) local dStep = 0 if nPass > 1 then dStep = max( ( dDist - 2 * dToolDiam) / ( 2 * nPass - 2), 0.25 * dToolDiam) end + + local dVerticalStep = 0 + if bMultipleZPasses then + local dToolVerticalStep = 0 + if EgtMdbSetCurrMachining( sMilling) then + dToolVerticalStep = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) or 0 + end + if dToolVerticalStep < 10 * GEO.EPS_SMALL then + dToolVerticalStep = dMaxMat / 3 + else + dToolVerticalStep = min( dToolVerticalStep, dMaxMat / 3) + end + local VerticalSteps = GetVerticalSteps( dAltMort, dToolVerticalStep) + dVerticalStep = VerticalSteps.StepLength + nPass = VerticalSteps.Count + end + for i = nPass, 1, -1 do -- inserisco la lavorazione di contornatura local sNameF = 'DtMt_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nPass) @@ -486,10 +577,39 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) return false, sErr end -- aggiungo geometria - EgtSetMachiningGeometry( {{ AuxId, -1}}) + local GeomId = AuxId + if ( i > 1) and bMultipleZPasses then + local dCurrentHeight = dAltMort - ( ( nPass - i + 1) * dVerticalStep) + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error : missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end + local b3MortiseNoPocket = EgtGetBBoxGlob( AuxId, GDB_BB.STANDARD) + GeomId = CalcPathAtHeight( Proc.Id, AuxId, nAddGrpId, dCurrentHeight, dSideAng, b3MortiseNoPocket) + if not GeomId then + local sErr = 'Wrong geometry : Error on DtMortise ' .. tostring( Proc.Id) + EgtOutLog( sErr) + return false, sErr + end + end + EgtSetMachiningGeometry( {{ GeomId, -1}}) -- imposto offset local dOffs = ( i - 1) * dStep + if bMultipleZPasses then + if i > 1 then + dOffs = 1 + else + dOffs = 0 + end + end EgtSetMachiningParam( MCH_MP.OFFSR, dOffs) + -- in caso di passate in Z già calcolate lo step deve essere nullo per garantire passate singole + if bMultipleZPasses then + EgtSetMachiningParam( MCH_MP.STEP, 0) + end -- sistemo il lato e la direzione di lavoro EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( bCW, MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT)) EgtSetMachiningParam( MCH_MP.INVERT, EgtIf( bCW, false, true)) @@ -522,11 +642,15 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end -- se necessario, imposto SCC - if nSCC then + if nSCC then EgtSetMachiningParam( MCH_MP.SCC, nSCC) end -- dichiaro massima elevazione e assenza sfridi per VMill - local sUserNotes = EgtSetVal( 'MaxElev', EgtNumToString( dMaxMat - 0.1, 1)) .. ';' .. EgtSetVal( 'VMRS', 0) .. ';' + local dMaxElev = dMaxMat + if bMultipleZPasses then + dMaxElev = dVerticalStep + end + local sUserNotes = EgtSetVal( 'MaxElev', EgtNumToString( dMaxElev - 0.1, 1)) .. ';' .. EgtSetVal( 'VMRS', 0) .. ';' -- in presenza di pocket dichiaro che non sto entrando e uscendo nel grezzo if bPocket then sUserNotes = EgtSetValInNotes( sUserNotes, 'OutRaw', 3) @@ -539,6 +663,10 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) sUserNotes = EgtSetValInNotes( sUserNotes, 'StartZmax', 2) end end + -- se c'è stata tastatura, si disattiva sull'ultima lavorazione + if bProbeExecuted and i == 1 then + sUserNotes = EgtSetValInNotes( sUserNotes, 'END-PROBE', true) + end EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- eseguo if not ML.ApplyMachining( true, false) then diff --git a/LuaLibs/ProcessDtTenon.lua b/LuaLibs/ProcessDtTenon.lua index ce528d3..fe14138 100644 --- a/LuaLibs/ProcessDtTenon.lua +++ b/LuaLibs/ProcessDtTenon.lua @@ -236,11 +236,32 @@ function ProcessDtTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) bCW = ( dSpeed >= 0) end end - -- verifico che l'altezza non superi il massimo materiale dell'utensile + -- se necessario, cerco un utensile più lungo if dDtTenH > dMaxMat + 10 * GEO.EPS_SMALL then - local sErr = 'Error : DtTenon Height bigger than Tool Cutting edge' - EgtOutLog( sErr) - return false, sErr + sMilling = ML.FindMilling( sMillType .. EgtIf( bMillDown and not bMillUp, '_H2', ''), nil, nil, nil, nil, bMillUp, bMillDown, nil, nil, 'Longest') + if not sMilling then + local sErr = 'Error : milling not found in library' + EgtOutLog( sErr) + return false, sErr + end + if not sMilling then + local sErr = 'Error : DtTenon Height bigger than Tool Cutting edge' + EgtOutLog( sErr) + return false, sErr + end + -- riassegno dati utensile + dTDiam = 50 + dMaxMat = 30 + bCW = true + if EgtMdbSetCurrMachining( sMilling) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam + dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat + local dSpeed = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) or 0 + bCW = ( dSpeed >= 0) + end + end end -- calcolo distanza massima della curva dal punto più lontano della base tenone Dt (facet 0) local dMaxDist diff --git a/LuaLibs/ProcessHeadCut.lua b/LuaLibs/ProcessHeadCut.lua index be5a112..85ac1f5 100644 --- a/LuaLibs/ProcessHeadCut.lua +++ b/LuaLibs/ProcessHeadCut.lua @@ -161,7 +161,7 @@ end --------------------------------------------------------------------- -- tagli verticali aggiuntivi -local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw) +local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw, dOffsetBetweenCuts) local nVerticalCuts = ceil( Proc.Face[1].WidthTrimmed / ( BD.MAX_LEN_DICE)) - 1 local dVerticalSliceHeight = Proc.Face[1].WidthTrimmed / ( nVerticalCuts + 1) -- recupero il diametro dell'utensile @@ -177,8 +177,8 @@ local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw) for j = nVerticalCuts, 1, -1 do local nFaceUse = MCH_MILL_FU.PARAL_FRONT local dVerticalCutOffset = dVerticalSliceHeight * -j - local bForceTangentLeadInOut = BD.PRESS_ROLLER and not BD.DOWN_HEAD - bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nFaceUse, nil, -0.1 -dCutXOffset, BD.CUT_SIC, dVerticalCutOffset, 0, 0, '', b3Raw, nil, nil, nil, bForceTangentLeadInOut) + local sLeadInOutType = 'PerpendicularOutraw' + bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nFaceUse, nil, -0.1 -dCutXOffset, BD.CUT_SIC, dVerticalCutOffset, 0, 0, '', b3Raw, nil, nil, nil, sLeadInOutType, nil, dOffsetBetweenCuts) if not bOk then return bOk, sErr end end @@ -240,8 +240,8 @@ local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, HeadCut for j = nHorizontalCuts, 1, -1 do local nFaceUse = MCH_MILL_FU.PARAL_DOWN local dHorizontalCutOffset = dHorizontalSliceHeight * -j - local bForceTangentLeadInOut = BD.PRESS_ROLLER - local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, Cutting1Data.sCutting, Cutting1Data.dSawDiam, nFaceUse, nil, -0.1 -dCutXOffset, BD.CUT_SIC, dHorizontalCutOffset, 0, 0, '', b3Raw, nil, nil, nil, bForceTangentLeadInOut) + local sLeadInOutType = 'PerpendicularOutraw' + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, Cutting1Data.sCutting, Cutting1Data.dSawDiam, nFaceUse, nil, -0.1 -dCutXOffset, BD.CUT_SIC, dHorizontalCutOffset, 0, 0, '', b3Raw, nil, nil, nil, sLeadInOutType, nil, dOffsetBetweenCuts) if not bOk then return bOk, sErr end end -- se necessario taglio verticale doppio, eseguo l'opposto @@ -284,7 +284,7 @@ local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, HeadCut local dCutOffset = ( i - 1) * dOffsetBetweenCuts -- se trave larga effettuo tagli verticali aggiuntivi if HeadCutType.bNeedVerticalAddedCuts then - local bOk, sErr = AddVerticalPreCuts( Proc, Cutting1Data.sCutting, dCutOffset, b3Raw) + local bOk, sErr = AddVerticalPreCuts( Proc, Cutting1Data.sCutting, dCutOffset, b3Raw, dOffsetBetweenCuts) if not bOk then return bOk, sErr end end if i == 1 and HeadCutType.sType =='Precut' then @@ -340,7 +340,7 @@ local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, HeadCut end -- se trave larga effettuo tagli verticali aggiuntivi if HeadCutType.bNeedVerticalAddedCuts then - local bOk, sErr = AddVerticalPreCuts( Proc, Cutting1Data.sCutting, dCutOffset, b3Raw) + local bOk, sErr = AddVerticalPreCuts( Proc, Cutting1Data.sCutting, dCutOffset, b3Raw, dOffsetBetweenCuts) if not bOk then return bOk, sErr end end local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, Cutting1Data.sCutting, Cutting1Data.dSawDiam, MCH_MILL_FU.ORTHO_DOWN, dVzLimDwnUp, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, 0, '', b3Raw) @@ -498,18 +498,16 @@ function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bNeedHCut if AreSameVectorApprox( X_AX(), vtNLimitingSurf) then EgtInvertSurf( nLimitingSurf) end end -- tagli verticali - bOk, sErr = AddVerticalPreCuts( AddProc, sCutting, 0, b3Raw) + bOk, sErr = AddVerticalPreCuts( AddProc, sCutting, 0, b3Raw, dOffsL) if not bOk then return bOk, sErr end -- tagli a cubetti con eventuale superficie limitante - bOk, sErr = Cut.Make( AddProc, nPhase, nRawId, nPartId, dOvmHead, nil, false, true, nil, nil, nil, nil, nLimitingSurf) + local sLeadInOutType = 'PerpendicularOutraw' + bOk, sErr = Cut.Make( AddProc, nPhase, nRawId, nPartId, dOvmHead, nil, false, true, nil, nil, nil, nil, nLimitingSurf, sLeadInOutType) end -- tagli aggiuntivi non necessari else - local bForceTangentLeadInOut = false - if BD.PRESS_ROLLER then - bForceTangentLeadInOut = true - end - bOk, sErr = Cut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, nil, false, true, nil, nil, nil, nil, nil, bForceTangentLeadInOut) + local sLeadInOutType = 'PerpendicularOutraw' + bOk, sErr = Cut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, nil, false, true, nil, nil, nil, nil, nil, sLeadInOutType) end return bOk, sErr end diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 0b63fe5..298cde5 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -192,6 +192,8 @@ local function AssignQIdent( Proc) Q_STAIRCASE = '' Q_SAW_PLUS_CHAIN = 'Q11' Q_FORCE_CHAINSAW = 'Q12' + -- TODO da riportare a Q13 quando è sistemata la gestione del movimento in macchina nell'attacco laterale + Q_CHAINSAW_FROM_SIDE = 'Q999' if ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 16 then Q_FORCE_BLADE = 'Q01' -- i @@ -965,6 +967,12 @@ function ProcessLapJoint.Classify( Proc, b3Raw) bDown = ( vtN2:getZ() < BD.NZ_MINB) end end + + local bNoRotation = ( EgtGetInfo( Proc.Id, Q_CHAINSAW_FROM_SIDE, 'i') or 0) == 1 + if bDown and bNoRotation then + bDown = false + end + return true, bDown end end @@ -3087,10 +3095,20 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, return false, sErr end local bGoFromHead = true - -- se la lunghezza utensile non riesce ad arrivare sul fondo assegno la possibilità di lavorare di fianco (se possibile) - if dElev > dMaxDepth + 10 * GEO.EPS_SMALL then + local bAttackFromSide = ( ( EgtGetInfo( Proc.Id, Q_CHAINSAW_FROM_SIDE, 'i') or 0) == 1) + and ( Proc.Fct == 4) and ( Proc.Topology == 'Groove') + -- se normale lungo Z è da sopra: si tenta attacco laterale se richiesto + if AreSameOrOppositeVectorApprox( Proc.Face[ nFacInd + 1].VtN, Z_AX()) then + if bAttackFromSide then + bGoFromHead = false + end + elseif dElev > dMaxDepth + 10 * GEO.EPS_SMALL then + if bAttackFromSide then + bGoFromHead = false -- continuo di testa se fessura con tre facce o non è tunnel - bGoFromHead = (( bIs3Faces and dMaxElev) or not bOrthoFaces) + else + bGoFromHead = (( bIs3Faces and dMaxElev) or not bOrthoFaces) + end end -- se continuo a lavorare di testa if bGoFromHead then @@ -3187,16 +3205,36 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, return false, sWarn end end - -- altrimenti sega a catena di fianco + -- altrimenti sega a catena di fianco + -- si arriva qui anche per groove 4 lati con rotazione esclusa else - -- verifico se posso farlo con la sega-catena + local vtRef = Vector3d( vtOrtho) + if vtRef and ( vtRef:getY() > 0.5 or vtRef:getZ() < -0.1) then + vtRef = -vtRef + end + if not ( Proc.Topology == 'Tunnel') then + dDimMin = min( Proc.Face[ nFacInd + 1].Width, Proc.Face[ nFacInd + 1].Height) + dDimMax = min( Proc.Face[ nFacAdj + 1].Width, Proc.Face[ nFacAdj + 1].Height) + nLundIdFace = nFacAdj + local nFaceZ + if not vtRef then + if Proc.AffectedFaces.Top then + vtRef = Z_AX() + nFaceZ = BL.FindFaceBestOrientedAsAxis( Proc, Z_AX()) + else + vtRef = -Z_AX() + nFaceZ = BL.FindFaceBestOrientedAsAxis( Proc, -Z_AX()) + end + else + nFaceZ = nFacInd + end + dDepth = Proc.Face[ nFaceZ + 1].Elevation + end local bMakeChainSaw, sSawing2, dMaxMat2, dSawCornerRad2, dSawThick2 = VerifyChainSaw( Proc, dDimMin, dDimMax, dDepth) if bMakeChainSaw then -- Calcolo normale faccia da lavorare local vtNL = EgtSurfTmFacetNormVersor( Proc.Id, nLundIdFace, GDB_ID.ROOT) -- Calcolo uso faccia - local vtRef = Vector3d( vtOrtho) - if vtRef:getY() > 0.5 or vtRef:getZ() < -0.1 then vtRef = -vtRef end local nFaceUse = BL.GetNearestParalOpposite( vtRef, vtNL) -- Verifico se necessarie più passate local nStep = ceil( ( dDimMin - 100 * GEO.EPS_SMALL) / dSawThick2) @@ -3223,21 +3261,76 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, -- imposto offset radiale local dOffs = ( i - 1) * dStep EgtSetMachiningParam( MCH_MP.OFFSR, dOffs) - -- se possibile aumento l'affondamento pari al raggio corner + 1 - if dMaxMat2 > ( dDepth + dSawCornerRad2 + 1) then - EgtSetMachiningParam( MCH_MP.DEPTH, (dDepth + dSawCornerRad2 + 1)) - -- se massimo affondamento supera altezza fessura, uso massimo affondamento - elseif dMaxMat2 > (dDepth + 1) then - EgtSetMachiningParam( MCH_MP.DEPTH, (dMaxMat2 - 1)) - -- se massimo affondamento utensile inferiore fessura, setto affondamento ed emetto warning - elseif dMaxMat2 < dDepth then - EgtSetMachiningParam( MCH_MP.DEPTH, dMaxMat2) - sWarn = 'Warning : elevation bigger than max tool depth' - EgtOutLog( sWarn) + local dMachiningDepth = dDepth + if Proc.Topology == 'Tunnel' then + -- se possibile aumento l'affondamento pari al raggio corner + 1 + if dMaxMat2 > ( dDepth + dSawCornerRad2 + 1) then + dMachiningDepth = ( dDepth + dSawCornerRad2 + 1) + -- se massimo affondamento supera altezza fessura, uso massimo affondamento + elseif dMaxMat2 > ( dDepth + 1) then + dMachiningDepth = (dMaxMat2 - 1) + -- se massimo affondamento utensile inferiore fessura, setto affondamento ed emetto warning + elseif dMaxMat2 < dDepth then + dMachiningDepth = dMaxMat2 + sWarn = 'Warning : elevation bigger than max tool depth' + EgtOutLog( sWarn) + end + EgtSetMachiningParam( MCH_MP.DEPTH, dMachiningDepth) + else + -- se possibile si lavora tutta la profondità + if dMaxMat2 > (dDepth - 100 * GEO.EPS_SMALL) then + dMachiningDepth = dDepth + -- in alternativa si arriva al massimo materiale + else + dMachiningDepth = dMaxMat2 + sWarn = 'Warning : elevation bigger than max tool depth' + EgtOutLog( sWarn) + end + EgtSetMachiningParam( MCH_MP.DEPTH, dMachiningDepth) + -- si decidono lato di lavoro, inversione e estensione in base al lato aperto + local nEdgeIndex = BL.GetEdgeToMachineFromVector( Proc.Id, nFacAdj, vtRef) + local EdgesEgt = BL.GetEdgesInfo( Proc, Proc.Face[nFacAdj+1]) + local CurrentEdge = EdgesEgt[nEdgeIndex+1] + local dStartAddLen = 0 + local dEndAddLen = 0 + if CurrentEdge.IsStartOpen then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MORTISE_WS.RIGHT) + EgtSetMachiningParam( MCH_MP.INVERT, false) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MORTISE_WS.LEFT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + end + dStartAddLen = dSawWidth / 2 + EgtMdbGetGeneralParam( MCH_GP.SAFEZ) + EgtMdbGetGeneralParam( MCH_GP.SAFEAGGRBOTTZ) + dEndAddLen = - dSawWidth / 2 + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dStartAddLen) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEndAddLen) + end + -- in caso di attacco esterno si setta in modo da fare un primo step adeguato per evitare finecorsa + -- si riduce la feed opportunamente + if not ( Proc.Topology == 'Tunnel') then + local dMachiningStep = EgtGetMachiningParam( MCH_MP.STEP) or 0 + -- TODO qui sostituire con valore preciso da GetSetupInfo + if BD.C_SIMM then + dMachiningStep = 175 + if vtRef:getZ() < - 10 * GEO.EPS_SMALL then + dMachiningStep = 260 + end + end + local dActualStep = ( dMachiningDepth - dMachiningStep) / ( 2 + 1) + dElev = dMachiningDepth - dMachiningStep + dActualStep - 0.1 + if dActualStep < 0 then + dActualStep = 1 + dElev = 2 + end + EgtSetMachiningParam( MCH_MP.STEP, dActualStep) + + local dFeed = EgtGetMachiningParam( MCH_MP.FEED) / 2 + EgtSetMachiningParam( MCH_MP.FEED, dFeed) end - -- considero estremi inizio/fine chiusi - -- imposto massima elevazione local sNotes = 'MaxElev=' .. EgtNumToString( dElev, 1) .. ';' + if not ( Proc.Topology == 'Tunnel') then + sNotes = EgtSetValInNotes( sNotes, 'Plunge', 10) + end EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) -- eseguo if not ML.ApplyMachining( true, false) then @@ -7515,6 +7608,22 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) return MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, true) -- se ortogonali e non forzata lama, con fresa elseif not bUseBlade then + -- verifico se devo fare prima gli smussi + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + if not nAddGrpId then + local sErr = 'Error : missing AddGroup' + EgtOutLog( sErr) + return false, sErr + end + -- verifiche per smusso + local nChamfer, dDepthCham, sErrCham = EvaluateQParam( Proc) + -- se smusso da fare + if nChamfer > 0 then + local _, _, _, vtOrtho, _, nSurfInt = BL.GetTunnelDimension( Proc, nPartId) + local nOk, sErr = MakeChamfer( Proc, true, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) + if nOk < 0 then return false, sErr end + end -- se piccole if Proc.Box:getDimX() < MAX_MILL_LIN and ( Proc.Box:getDimZ() < MAX_MILL_LIN or Proc.Box:getDimY() < MAX_MILL_LIN) and bAdj and abs( dAng + 90) < 1 then return MakeTwoFacesByMill( Proc, nPhase, nRawId, nPartId, bDownHeadMill) diff --git a/LuaLibs/ProcessLongDoubleCut.lua b/LuaLibs/ProcessLongDoubleCut.lua index 85d44a2..5238263 100644 --- a/LuaLibs/ProcessLongDoubleCut.lua +++ b/LuaLibs/ProcessLongDoubleCut.lua @@ -286,9 +286,11 @@ local function CalcBladeUse( bUseBlade, bDown_Head, nSide, vtN1, vtN2, bConvex, end end else - if ( vtN1 and vtN1:getZ() >= EgtIf( dCustomAngle, dCustomAngle, -0.5)) and ( not vtN2 or vtN2:getZ() >= -0.5) then - bCanUseBlade = true - end + --if ( vtN1 and vtN1:getZ() >= EgtIf( dCustomAngle, dCustomAngle, -0.5)) and ( not vtN2 or vtN2:getZ() >= -0.5) then + -- bCanUseBlade = true + --end + -- viene abilitata sempre lama da sotto + bCanUseBlade = true end end end @@ -423,12 +425,22 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster -- analisi del taglio local vOrd = {} local vFaceUse = {} + local bIsMachDownUp = false if nSide == 1 or ( nSide == -1 and ( BD.DOWN_HEAD or BD.TURN)) then vOrd = EgtIf( ptC[1]:getY() < ptRef:getY(), { 1, 2}, { 2, 1}) vFaceUse = { BL.GetNearestOrthoOpposite( ptC[1] - ptM), BL.GetNearestOrthoOpposite( ptC[2] - ptM)} elseif nSide == -1 then vOrd = EgtIf( ptC[1]:getY() < ptRef:getY(), { 1, 2}, { 2, 1}) - vFaceUse = { BL.GetNearestParalOpposite( ptC[1] - ptM), BL.GetNearestParalOpposite( ptC[2] - ptM)} + local vtFaceUse1, vtFaceUse2 + if bCanUseBlade and not BD.DOWN_HEAD then + bIsMachDownUp = true + vtFaceUse1 = BL.GetOrtupOpposite( BL.GetNearestOrthoOpposite( ptC[1] - ptM)) + vtFaceUse2 = BL.GetOrtupOpposite( BL.GetNearestOrthoOpposite( ptC[2] - ptM)) + else + vtFaceUse1 = BL.GetNearestParalOpposite( ptC[1] - ptM) + vtFaceUse2 = BL.GetNearestParalOpposite( ptC[2] - ptM) + end + vFaceUse = { vtFaceUse1, vtFaceUse2} else local bFront = ( ( vtN[1]:getY() + vtN[2]:getY()) < 0) if bFront then @@ -851,7 +863,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster -- imposto la direzione di lavoro per avere scarico del truciolo ottimale local nWorkSide, bInvert if ( not bIsTopBladeCurrent and abs( nSide) ~= 0) or ( bCanUseBlade and bCanUseUnderBlade and nSide == -1) then - if bIsCurrentBladeCCW then + if bIsCurrentBladeCCW and not bIsMachDownUp then nWorkSide = MCH_MILL_WS.LEFT bInvert = true dSal, dEal = dEal, dSal @@ -860,7 +872,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster bInvert = false end else - if bIsCurrentBladeCCW then + if bIsCurrentBladeCCW and not bIsMachDownUp then nWorkSide = MCH_MILL_WS.LEFT bInvert = false else @@ -1067,6 +1079,11 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster if nSide == -1 and BD.DOWN_HEAD then EgtSetMachiningParam( MCH_MP.STARTADDLEN, dEal) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dSal) + elseif nSide == -1 and not BD.DOWN_HEAD and bIsMachDownUp then + EgtSetMachiningParam( MCH_MP.INVERT, EgtIf( EgtGetMachiningParam( MCH_MP.INVERT), false, true)) + dOffset = 5 + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dEal) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dSal) else EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) @@ -1289,6 +1306,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster end -- ciclo sulle parti local nM = 0 + local bInverted = false for j = 1, nC do -- su entrambe le facce for i = nIni, nFin do @@ -1332,8 +1350,19 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster -- controllo se lavorazione completa local dMachDepth = vElevation[vOrd[i]] if dMachDepth > dMaxDepth - 10 * GEO.EPS_ANG_SMALL then - sWarn = 'Warning : elevation bigger than max tool depth' - EgtOutLog( sWarn) + -- verifico se posso lavorare la faccia 2 + local nOtherFace = EgtIf( i == 1, 2, 1) + if j == 1 and vtN[vOrd[nOtherFace]]:getZ() > dLimitAngle and vWidth[vOrd[i]] < dMaxDepth then + vOrd[1], vOrd[2] = vOrd[2], vOrd[1] + dLargh = vWidth[vOrd[i]] + dSal, dEal = dEal, dSal + bInverted = true + else + sWarn = 'Warning : elevation bigger than max tool depth' + EgtOutLog( sWarn) + end + elseif bInverted then + dSal, dEal = dEal, dSal end if not bSide and dLargh > 0.8 * dToolDiam then nO = ceil( dLargh / ( 0.6 * dToolDiam)) @@ -1368,7 +1397,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster --EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( bSide, BL.GetParallelOpposite( vFaceUse[vOrd[i]]), vFaceUse[vOrd[i]])) EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( bSide, MCH_MILL_FU.PARAL_DOWN, vFaceUse[vOrd[i]])) -- imposto lato di lavoro e inversione - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( bIsMachDownUp, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT)) EgtSetMachiningParam( MCH_MP.INVERT, EgtIf( bSide, true, false)) -- imposto offset radiale (nullo se concavo o di lato) local dOffsR = EgtIf( k < nO, ( nO - k) * dStep, EgtIf( bConvex, - BD.CUT_EXTRA, 0)) @@ -1804,7 +1833,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster end end -- imposto lato di lavoro e inversione - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( bIsMachDownUp, MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT)) EgtSetMachiningParam( MCH_MP.INVERT, true) -- calcolo la componente dNz non in base alla classificazione della feature (sopra, sotto, fianchi) ma alla componente maggiore -- local dNz = EgtIf( nSide == 0, vtN[vOrd[i]]:getY(), vtN[vOrd[i]]:getZ()) diff --git a/LuaLibs/ProcessProbing.lua b/LuaLibs/ProcessProbing.lua new file mode 100644 index 0000000..b90cfcd --- /dev/null +++ b/LuaLibs/ProcessProbing.lua @@ -0,0 +1,103 @@ +-- ProcessSplit.lua by Egaltech s.r.l. 2025/06/20 +-- Gestione tastatura + +-- Tabella per definizione modulo +local ProcessProbing = {} + +-- Include +require( 'EgtBase') +local BL = require( 'BeamLib') + +-- Dati +local ML = require( 'MachiningLib') + +--------------------------------------------------------------------- +local function GetProbingMachining( Machinings, sHead) + local sProbeMachining, sHeadTool + + -- TODO questa associazione "testa utensile"-"testa tastatore" dovrebbe essere spostata nella macchina. + -- Non è detto che se testa utensile inizia con "H2" allora bisogna prendere lavorazione con "_H2" + + -- se la testa utilizzata dalla lavorazione inizia con H2, dovrebbe essere la seconda testa + if EgtStartsWith( sHead, 'H2') then + sHeadTool = '_H2' + else + sHeadTool = '_H1' + end + + for i = 1, #Machinings do + if EgtEndsWith( Machinings[i].Name, sHeadTool) then + sProbeMachining = Machinings[i] + return sProbeMachining + end + end + sProbeMachining = Machinings[1] + return sProbeMachining +end + +--------------------------------------------------------------------- +local function MoveProbePointToRawFaces( ptProbe, vtProbe, nPartId) + local b3BoxPart = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + -- si porta linea di tastatura su grezzo + if AreSameVectorApprox( vtProbe, Z_AX()) then + ptProbe[3] = b3BoxPart:getMax():getZ() + elseif AreSameVectorApprox( vtProbe, -Z_AX()) then + ptProbe[3] = b3BoxPart:getMin():getZ() + elseif AreSameVectorApprox( vtProbe, Y_AX()) then + ptProbe[2] = b3BoxPart:getMax():getY() + elseif AreSameVectorApprox( vtProbe, -Y_AX()) then + ptProbe[2] = b3BoxPart:getMin():getY() + end + return ptProbe +end + +--------------------------------------------------------------------- +-- Applicazione della lavorazione +function ProcessProbing.Make( Proc, nPartId, Info) + local bOk, sErr + + -- per eseguire tastatura servono tutti i dati, altriemnti impossibile + if Info.vtProbe and Info.ptProbe and Info.sType then + Info.ptProbe = MoveProbePointToRawFaces( Info.ptProbe, Info.vtProbe, nPartId) + -- recupero gruppo per geometria addizionale + local nAddGrpId = BL.GetAddGroup( nPartId) + local nIdLine = EgtLinePVL( nAddGrpId, Info.ptProbe, Info.vtProbe, 10, GDB_RT.GLOB) -- TODO lunghezza da portare fuori come parametro + local Machinings = GetMachinings( MCH_MY.PROBING, Info.sType) + -- se c'è almeno una lavorazione, allora devo fare tastatura + if Machinings and #Machinings > 0 then + local sProbing = GetProbingMachining( Machinings, Info.sHead) + -- se c'è la linea e la lavorazione, applico + if sProbing and nIdLine then + local sName = 'DtMtProbe_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchFId = EgtAddMachining( sName, sProbing.Name) + -- si inverte la direzione della linea, deve essere entrante, oppostaa vettore estrusione + EgtInvertCurve( nIdLine) + -- aggiungo geometria + EgtSetMachiningGeometry( {{ nIdLine, -1}}) + + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + else + bOk = true + end + else + bOk = false + sErr = 'Error on probing' + end + -- altrimenti tastatura non richiesta, esco + else + return true + end + else + bOk = false + sErr = 'Error on probing' + end + + return bOk, sErr +end + +--------------------------------------------------------------------- +return ProcessProbing diff --git a/LuaLibs/ProcessProfCamb.lua b/LuaLibs/ProcessProfCamb.lua index b2f8a72..1778090 100644 --- a/LuaLibs/ProcessProfCamb.lua +++ b/LuaLibs/ProcessProfCamb.lua @@ -33,6 +33,7 @@ local sEnableExtraBladeUpperFace = 'Q02' -- i local sDepthChamferMill = 'Q03' -- d local sOverMaterialForFinish = 'Q04' -- d local sPreemptiveChamfer = 'Q05' -- i +local bUseSmallMill = 'Q06' -- i -- abilitazioni extra local dMakeAntiSplintOnHead = 1 -- valore impronta antischeggia, per disattivare settare = nil o = 0 @@ -206,6 +207,41 @@ local function VerifyCham( Proc, AuxId, nRawId, bMakeVertCham, sDephtCham, sOnly return nChamfer, dDepth, sMilling, sMilling2 end +--------------------------------------------------------------------- +function VerifySmallMillCanFinish( dDiamCurrentTool, dDepthProfile, nSide) + local dToolMaxDepthSmall, dToolDiamSmall + -- abilitazione lavorazione da sotto + local sMillType = 'Prof' + local sMillingSmall, _, _, bH2Small = ML.FindMilling( sMillType, nil, nil, nil, nil, true, nil, nil, nil, 'Smallest') + if not sMillingSmall then + return false + end + -- Recupero i dati dell'utensile + if EgtMdbSetCurrMachining( sMillingSmall) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid)) then + dToolMaxDepthSmall = EgtTdbGetCurrToolMaxDepth() + dToolDiamSmall = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + -- se non ci sono almeno 5mm di differenza si fa con utensile standard + if dDiamCurrentTool - 5 < dToolDiamSmall then + return false + end + end + else + return false + end + local bDouble = ( dDepthProfile + BD.CUT_EXTRA > dToolMaxDepthSmall) + -- se lavorazione in doppio richiesta, si verifica se richiesta testa sotto + if bDouble and nSide == 0 then + return false -- TODO macchine con BD.DOWN_HEAD potrebbero lavorare in doppio in questo caso! + end + + if not bDouble or ( dDepthProfile + BD.MILL_OVERLAP < dToolMaxDepthSmall * 2) then + return true, sMillingSmall, bDouble + end + return false +end + --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) @@ -244,7 +280,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) if vtN:getZ() > 0.1 then nSide = 1 elseif vtN:getZ() < -0.1 then - nSide = -1 + nSide = -1 end -- abilitazione lavorazione da sotto local bMillDown = ( BD.DOWN_HEAD and nSide == -1) @@ -468,6 +504,15 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end end + + + local bUseSmallMillOnFinish = EgtGetInfo( Proc.Id, bUseSmallMill, 'i') == 1 + local sMillingSmall, bDoubleSmall + -- se serve fresa più piccola per finitura + if bUseSmallMillOnFinish then + bUseSmallMillOnFinish, sMillingSmall, bDoubleSmall = VerifySmallMillCanFinish( dMillDiam, dProfDepth, nSide) + end + -- se il chamfer non è esclusivo continuo con le altre lavorazioni if nChamfer < 2 then -- verifico se necessario lavorare in doppio @@ -477,7 +522,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) local sMillingDown if bDouble then if nSide == 0 then - if BD.DOWN_HEAD then + if BD.DOWN_HEAD then -- recupero la lavorazione sMillingDown = ML.FindMilling( 'Prof_H2', nil, nil, nil, nil, false, true) if not sMillingDown then @@ -537,10 +582,6 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) bFinish = true end - -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale precedente - if dOffsetPar > 0 then - EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) - end -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -567,7 +608,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) nMchId = nMch2Id end -- se abilitata, aggiungo lavorazione di finitura - if bFinish then + if bFinish and not bUseSmallMillOnFinish then -- inserisco la lavorazione local sNewName = 'ProfB_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) @@ -682,7 +723,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) nMchId = nMch2Id end -- se abilitata, aggiungo lavorazione di finitura - if bFinish then + if bFinish and not bUseSmallMillOnFinish then -- inserisco la lavorazione local sNewName = 'Prof_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) @@ -738,6 +779,44 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) return false, sErr end end + -- se finitura con fresa piccola + if bFinish and bUseSmallMillOnFinish then + local sDepthSmall = EgtIf( bDoubleSmall, ( dProfDepth+ BD.MILL_OVERLAP ) / 2, dProfDepth + BD.CUT_EXTRA) + local sMachName = 'Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + nMchId = EgtAddMachining( sMachName, sMillingSmall) + if not nMchId then + local sErr = 'Error adding machining ' .. sMachName .. '-' .. sMillingSmall + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ AuxId, -1}}) + + -- imposto l'affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, sDepthSmall) + -- posizione braccio porta testa + EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + + if bDoubleSmall then + local sNewName = 'FinB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) + + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end + end + end end -- aggiorno ingombro testa o coda per presa if nSide ~= 1 then -- se feature di fianco o da sotto diff --git a/LuaLibs/ProcessRidgeLap.lua b/LuaLibs/ProcessRidgeLap.lua index df34b2b..dbfc145 100644 --- a/LuaLibs/ProcessRidgeLap.lua +++ b/LuaLibs/ProcessRidgeLap.lua @@ -173,7 +173,7 @@ function ProcessRidgeLap.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- calcolo riferimenti per facce inclinate local vtRef = Vector3d( vtN[vFaceOrd[3]]) - local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) + local vtRef2 = Vector3d( vtN[vFaceOrd[2]]) -- eseguo for i = 1, #vCuts do local nOrthoOpposite diff --git a/LuaLibs/ProcessSplit.lua b/LuaLibs/ProcessSplit.lua index f2d888d..d50cbca 100644 --- a/LuaLibs/ProcessSplit.lua +++ b/LuaLibs/ProcessSplit.lua @@ -336,7 +336,7 @@ end --------------------------------------------------------------------- -- tagli verticali aggiuntivi -local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw, sNotes) +local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw, sNotes, dOffsetBetweenCuts) local nVerticalCuts = ceil( Proc.Face[1].WidthTrimmed / ( BD.MAX_LEN_DICE)) - 1 local dVerticalSliceHeight = Proc.Face[1].WidthTrimmed / ( nVerticalCuts + 1) -- recupero il diametro dell'utensile @@ -352,8 +352,8 @@ local function AddVerticalPreCuts( Proc, sCutting, dCutXOffset, b3Raw, sNotes) for j = nVerticalCuts, 1, -1 do local nFaceUse = MCH_MILL_FU.PARAL_FRONT local dVerticalCutOffset = dVerticalSliceHeight * -j - local bForceTangentLeadInOut = BD.PRESS_ROLLER and not BD.DOWN_HEAD - bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nFaceUse, nil, -0.1 -dCutXOffset, BD.CUT_SIC, dVerticalCutOffset, 0, 0, sNotes, b3Raw, nil, nil, nil, bForceTangentLeadInOut) + local sLeadInOutType = 'PerpendicularOutraw' + bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nFaceUse, nil, -0.1 -dCutXOffset, BD.CUT_SIC, dVerticalCutOffset, 0, 0, sNotes, b3Raw, nil, nil, nil, sLeadInOutType, nil, dOffsetBetweenCuts) if not bOk then return bOk, sErr end end @@ -422,8 +422,8 @@ local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, TailCut for j = nHorizontalCuts, 1, -1 do local nFaceUse = MCH_MILL_FU.PARAL_DOWN local dHorizontalCutOffset = dHorizontalSliceHeight * -j - local bForceTangentLeadInOut = BD.PRESS_ROLLER - local bOk, sErr = Fbs.MakeOne( Proc.Id, 0 , Cutting1Data.sCutting, Cutting1Data.dSawDiam, nFaceUse, nil, -0.1 - dCutXOffset, BD.CUT_SIC, dHorizontalCutOffset, 0, 0, 'Precut;', b3Raw, nil, nil, nil, bForceTangentLeadInOut) + local sLeadInOutType = 'PerpendicularOutraw' + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0 , Cutting1Data.sCutting, Cutting1Data.dSawDiam, nFaceUse, nil, -0.1 - dCutXOffset, BD.CUT_SIC, dHorizontalCutOffset, 0, 0, 'Precut;', b3Raw, nil, nil, nil, sLeadInOutType, nil, dOffsetBetweenCuts) if not bOk then return false, sErr end end -- se necessario taglio verticale doppio, eseguo l'opposto @@ -472,7 +472,7 @@ local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, TailCut -- se trave larga effettuo tagli verticali aggiuntivi if TailCutType.bNeedVerticalAddedCuts then local sSpecNotes = EgtIf( TailCutType.bSplit, 'Presplit;', 'Precut;') - local bOk, sErr = AddVerticalPreCuts( Proc, Cutting1Data.sCutting, dCutOffset, b3Raw, sSpecNotes) + local bOk, sErr = AddVerticalPreCuts( Proc, Cutting1Data.sCutting, dCutOffset, b3Raw, sSpecNotes, dOffsetBetweenCuts) if not bOk then return bOk, sErr end end if i == 1 and TailCutType.sType =='Precut' then @@ -541,7 +541,7 @@ local function MakeStandardCuts( Proc, b3Raw, nCuts, dOffsetBetweenCuts, TailCut -- se trave larga effettuo tagli verticali aggiuntivi if TailCutType.bNeedVerticalAddedCuts then local sSpecNotes = EgtIf( TailCutType.bSplit, 'Presplit;', 'Precut;') - local bOk, sErr = AddVerticalPreCuts( Proc, Cutting1Data.sCutting, dCutOffset, b3Raw, sSpecNotes) + local bOk, sErr = AddVerticalPreCuts( Proc, Cutting1Data.sCutting, dCutOffset, b3Raw, sSpecNotes, dOffsetBetweenCuts) if not bOk then return bOk, sErr end end local sNotes @@ -771,18 +771,16 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt if AreOppositeVectorApprox( X_AX(), vtNLimitingSurf) then EgtInvertSurf( nLimitingSurf) end end -- tagli verticali - bOk, sErr = AddVerticalPreCuts( AddProc, sCutting, 0, b3Raw, sNotes) + bOk, sErr = AddVerticalPreCuts( AddProc, sCutting, 0, b3Raw, sNotes, dOffsL) if not bOk then return bOk, sErr end -- tagli a cubetti con eventuale superficie limitante - bOk, sErr = Cut.Make( AddProc, nNewPhase, nRawId, nPartId, dMaxElev, nil, false, true, b3Raw, sNotes, dCurrOvmT, nil, nLimitingSurf) + local sLeadInOutType = 'PerpendicularOutraw' + bOk, sErr = Cut.Make( AddProc, nNewPhase, nRawId, nPartId, dMaxElev, nil, false, true, b3Raw, sNotes, dCurrOvmT, nil, nLimitingSurf, sLeadInOutType) end -- tagli aggiuntivi non necessari else - local bForceTangentLeadInOut = false - if BD.PRESS_ROLLER then - bForceTangentLeadInOut = true - end - bOk, sErr = Cut.Make( Proc, nNewPhase, nRawId, nPartId, dMaxElev, nil, false, true, b3Raw, sNotes, dCurrOvmT, nil, nil, bForceTangentLeadInOut) + local sLeadInOutType = 'PerpendicularOutraw' + bOk, sErr = Cut.Make( Proc, nNewPhase, nRawId, nPartId, dMaxElev, nil, false, true, b3Raw, sNotes, dCurrOvmT, nil, nil, sLeadInOutType) end if sNotesFinal then EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesFinal) diff --git a/UpdateLog.txt b/UpdateLog.txt index 27179d6..c65cc68 100644 --- a/UpdateLog.txt +++ b/UpdateLog.txt @@ -1,7 +1,16 @@ ==== Beam Update Log ==== +Versione 2.7g1 (08/07/2025) +- Added : in LapJoint, aggiunti smussi anche se lavorazione con truciolatore +- Added : per profilo caudato aggiunta finitura con fresa piccola +- Added : gestione tastatura +- Modif : nei tagli di testa e coda, compresi quelli di spezzatura, la lama evita di arretrare se non necessario +- Modif : in LongDoubleCut migliorie varie +- Modif : in RidgeLap migliorie varie +- Modif : nelle forature che attraversano un taglio ora si considera la profondità già lavorata + Versione 2.7f3 (19/06/2025) -- Modifx : in StepJointNotch corretta distanza attacco in/out +- Modif : in StepJointNotch corretta distanza attacco in/out Versione 2.7f2 (18/06/2025) - Modif : in LongDoubleCut aggiunto messaggio feature non completa se utensile non arriva sul fondo @@ -20,10 +29,10 @@ Versione 2.7e2 (23/05/2025) - Fixed : in Scarf Joint correzione alla scelta faccia da lavorare Versione 2.7e1 (05/05/2025) +- Modif : in LapJoint se tunnel verticale lavorato solo da sopra e l'utensile non arriva, si restituisce warning - Fixed : in taglio di separazione si riduce percorso di taglio solo se il pezzo è effettivamente alto - Fixed : in foratura corretto caso in cui non si sceglieva l'utensile più lungo disponibile - Fixed : In BatchProcess (Ts7) corretta generazione in caso di progetto senza ricalcolo -- Modif : in LapJoint se tunnel verticale lavorato solo da sopra e l'utensile non arriva, si restituisce warning Versione 2.7d3 (22/04/2025) - Fixed : in LapJoint corretta gestione errata Q04 diff --git a/Version.lua b/Version.lua index a3359a8..72baa7a 100644 --- a/Version.lua +++ b/Version.lua @@ -2,5 +2,5 @@ -- Gestione della versione di Beam NAME = 'Beam' -VERSION = '2.7f3' -MIN_EXE = '2.6e5' +VERSION = '2.7g1' +MIN_EXE = '2.7f2'