diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index de3381c..cfe4039 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -41,6 +41,8 @@ _G.package.loaded.ProcessLongCut = nil local LongCut = require( 'ProcessLongCut') _G.package.loaded.ProcessLongDoubleCut = nil local Long2Cut = require( 'ProcessLongDoubleCut') +_G.package.loaded.ProcessSawCut = nil +local SawCut = require( 'ProcessSawCut') _G.package.loaded.ProcessRidgeLap = nil local RidgeLap = require( 'ProcessRidgeLap') _G.package.loaded.ProcessLapJoint = nil @@ -502,6 +504,9 @@ local function ClassifyFeatures( vProc, b3Raw, Stats) -- se doppio taglio longitudinale elseif Long2Cut.Identify( Proc) then bOk, bDown = Long2Cut.Classify( Proc) + -- se taglio con lama + elseif SawCut.Identify( Proc) then + bOk, bDown = SawCut.Classify( Proc) -- se mezzo-legno di testa elseif RidgeLap.Identify( Proc) then bOk, bDown = RidgeLap.Classify( Proc) @@ -642,6 +647,10 @@ local function AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3 else bOk, sErr = LongCut.Make( Proc, nPhase, nRawId, nPartId) end + -- se taglio con lama ( 0/3/4-013-X) + elseif SawCut.Identify( Proc) then + -- esecuzione taglio + bOk, sErr = SawCut.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- se mezzo-legno di testa ( 1/2-030-X) elseif RidgeLap.Identify( Proc) then -- esecuzione mezzo-legno di testa diff --git a/LuaLibs/ProcessDtMortise.lua b/LuaLibs/ProcessDtMortise.lua index f2947a1..1be8d29 100644 --- a/LuaLibs/ProcessDtMortise.lua +++ b/LuaLibs/ProcessDtMortise.lua @@ -49,7 +49,7 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId) -- recupero e verifico l'entità curva local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') if AuxId then AuxId = AuxId + Proc.Id end - if not AuxId or ( EgtGetType( AuxId) & 256) == 0 then + if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry' EgtOutLog( sErr) return false, sErr diff --git a/LuaLibs/ProcessDtTenon.lua b/LuaLibs/ProcessDtTenon.lua index db2298d..80178fa 100644 --- a/LuaLibs/ProcessDtTenon.lua +++ b/LuaLibs/ProcessDtTenon.lua @@ -86,7 +86,7 @@ function ProcessDtTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- recupero e verifico l'entità curva local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') if AuxId then AuxId = AuxId + Proc.Id end - if not AuxId or ( EgtGetType( AuxId) & 256) == 0 then + if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry' EgtOutLog( sErr) return false, sErr diff --git a/LuaLibs/ProcessFreeContour.lua b/LuaLibs/ProcessFreeContour.lua index 34b4c0c..d14925b 100644 --- a/LuaLibs/ProcessFreeContour.lua +++ b/LuaLibs/ProcessFreeContour.lua @@ -123,7 +123,7 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead) -- recupero e verifico l'entità curva local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 if AuxId then AuxId = AuxId + Proc.Id end - if not AuxId or ( EgtGetType( AuxId) & 256) == 0 then + if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry' EgtOutLog( sErr) return false, sErr @@ -268,7 +268,7 @@ local function MakeByPocket( Proc, nPhase, nRawId, nPartId, dOvmHead) -- recupero e verifico l'entità curva local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 if AuxId then AuxId = AuxId + Proc.Id end - if not AuxId or ( EgtGetType( AuxId) & 256) == 0 then + if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry' EgtOutLog( sErr) return false, sErr diff --git a/LuaLibs/ProcessMortise.lua b/LuaLibs/ProcessMortise.lua index 38d9bc6..e409975 100644 --- a/LuaLibs/ProcessMortise.lua +++ b/LuaLibs/ProcessMortise.lua @@ -64,7 +64,7 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId) if AuxId then AuxId = AuxId + Proc.Id end - if not AuxId or ( EgtGetType( AuxId) & 256) == 0 then + if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry' EgtOutLog( sErr) return false, sErr diff --git a/LuaLibs/ProcessRoundArch.lua b/LuaLibs/ProcessRoundArch.lua index d109dd7..3b4441c 100644 --- a/LuaLibs/ProcessRoundArch.lua +++ b/LuaLibs/ProcessRoundArch.lua @@ -93,7 +93,7 @@ function ProcessRoundArch.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- recupero e verifico l'entità curva local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') if AuxId then AuxId = AuxId + Proc.Id end - if not AuxId or ( EgtGetType( AuxId) & 256) == 0 then + if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry' EgtOutLog( sErr) return false, sErr diff --git a/LuaLibs/ProcessSawCut.lua b/LuaLibs/ProcessSawCut.lua new file mode 100644 index 0000000..b69ef3e --- /dev/null +++ b/LuaLibs/ProcessSawCut.lua @@ -0,0 +1,100 @@ +-- ProcessSawCut.lua by Egaltech s.r.l. 2020/01/29 +-- Gestione calcolo taglio di lama per Travi + +-- Tabella per definizione modulo +local ProcessSawCut = {} + +-- Include +require( 'EgtBase') +local BL = require( 'BeamLib') +local DC = require( 'DiceCut') + +EgtOutLog( ' ProcessSawCut started', 1) + +-- Dati +local BD = require( 'BeamData') +local ML = require( 'MachiningLib') + +--------------------------------------------------------------------- +-- Riconoscimento della feature +function ProcessSawCut.Identify( Proc) + return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 13) +end + +--------------------------------------------------------------------- +-- Classificazione della feature +function ProcessSawCut.Classify( Proc, b3Raw) + -- recupero i dati del versore direzione di accesso della lavorazione + local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') + if not AuxId then return false end + AuxId = AuxId + Proc.Id + local vtDir = EgtSV( AuxId, GDB_ID.ROOT) + return true, ( vtDir:getZ() <= - 0.088) +end + +--------------------------------------------------------------------- +-- Applicazione della lavorazione +function ProcessSawCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) + -- ingombro del grezzo + local b3Raw = EgtGetRawPartBBox( nRawId) + -- ingombro del pezzo + local Ls = EgtGetFirstNameInGroup( nPartId, 'Box') + local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD) + if not b3Solid then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' part box not found' + EgtOutLog( sErr) + return false, sErr + end + + -- dati geometrici del taglio + local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT) + -- recupero e verifico l'entità vettore + local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') + if AuxId then AuxId = AuxId + Proc.Id end + if not AuxId or EgtGetType( AuxId) ~= GDB_TY.GEO_VECTOR then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing access direction' + EgtOutLog( sErr) + return false, sErr + end + local vtDir = EgtSV( AuxId, GDB_ID.ROOT) + + -- se taglio di testa + if Proc.Head then + -- se coincide con il taglio di separazione precedente, non va fatto + if AreSameVectorApprox( vtN, X_AX()) and abs( ptC:getX() - b3Raw:getMax():getX() + dOvmHead) < 10 * GEO.EPS_SMALL then + return true + end + -- altrimenti taglio di coda + else + -- se coincide con taglio di separazione, non va fatto + if AreSameVectorApprox( vtN, - X_AX()) and abs( ptC:getX() - b3Raw:getMin():getX()) < BD.OVM_MID + 10 * GEO.EPS_SMALL then + return true + end + end + -- recupero la lavorazione + local sCutting = ML.FindCutting( EgtIf( Proc.Head, 'HeadSide', 'TailSide')) + if not sCutting then + local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library' + EgtOutLog( sErr) + return false, sErr + end + -- recupero i dati dell'utensile + local dSawDiam = 400 + local dMaxDepth = 0 + if EgtMdbSetCurrMachining( sCutting) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam + dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + end + end + -- lavoro la faccia + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, vtDir, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then + return bOk, sErr + end + return true +end + +--------------------------------------------------------------------- +return ProcessSawCut diff --git a/LuaLibs/ProcessStepJointNotch.lua b/LuaLibs/ProcessStepJointNotch.lua index ab75dd6..cf5f914 100644 --- a/LuaLibs/ProcessStepJointNotch.lua +++ b/LuaLibs/ProcessStepJointNotch.lua @@ -192,7 +192,7 @@ local function MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead) -- recupero e verifico l'entità curva associata local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 if AuxId then AuxId = AuxId + Proc.Id end - if not AuxId or ( EgtGetType( AuxId) & 256) == 0 then + if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry' EgtOutLog( sErr) return false, sErr diff --git a/LuaLibs/ProcessTenon.lua b/LuaLibs/ProcessTenon.lua index 8ab2925..1c710c3 100644 --- a/LuaLibs/ProcessTenon.lua +++ b/LuaLibs/ProcessTenon.lua @@ -87,7 +87,7 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- recupero e verifico l'entità curva local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') if AuxId then AuxId = AuxId + Proc.Id end - if not AuxId or ( EgtGetType( AuxId) & 256) == 0 then + if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry' EgtOutLog( sErr) return false, sErr @@ -209,7 +209,7 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- aggiungo geometria EgtSetMachiningGeometry( {{ AuxId, -1}}) -- sistemo i parametri - EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dTenH, 1) .. ';') + EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dTenH - 100 * GEO.EPS_SMALL, 1) .. ';') EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) local dOffset = ( i - 1) * dStep EgtSetMachiningParam( MCH_MP.OFFSR, dOffset) diff --git a/ShowSolid.lua b/ShowSolid.lua index bf29d6d..d8278d0 100644 --- a/ShowSolid.lua +++ b/ShowSolid.lua @@ -105,7 +105,7 @@ local dStep = 1.23 * min( max( b3Solid:getDimY(), b3Solid:getDimZ()), 2 * min( b local ProcLy = EgtGetFirstNameInGroup( PartId, 'Processings') local ProcId = EgtGetFirstInGroup( ProcLy) while ProcId do - if EgtGetInfo( ProcId, 'DO', 'i') ~= 0 and EgtGetType( ProcId) == GDB_TY.SRF_MESH then + if EgtGetInfo( ProcId, 'DO', 'i') ~= 0 and EgtGetInfo( ProcId, 'TRIM', 'i') ~= 0 and EgtGetType( ProcId) == GDB_TY.SRF_MESH then local NewSurfId = RegularizeTriMesh( ProcId, SolidLy, dStep) EgtSurfTmIntersect( SolidId, NewSurfId) if NewSurfId ~= ProcId then