diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 9e7100e..71d0bd0 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,4 +1,4 @@ --- BeamExec.lua by Egaltech s.r.l. 2020/06/04 +-- BeamExec.lua by Egaltech s.r.l. 2020/07/25 -- Libreria esecuzione lavorazioni per Travi -- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- 2019/09/04 Corretto controllo feature di testa e coda con sovramateriale di testa elevato. @@ -14,6 +14,7 @@ -- 2020/05/21 Correzione rotazione di 90deg (caso DY > DZ). -- 2020/05/25 Correzione rotazione di 90deg dopo scarico su carico. -- 2020/06/02 Per dati foro si chiama funzione GetData di ProcessDrill (per gestire variazioni di diametro da UserParams). +-- 2020/07/25 Ricalcolati flag head e tail della prima parte del foro dopo lo split. -- Tabella per definizione modulo local BeamExec = {} @@ -344,8 +345,8 @@ local function CollectFeatures( PartId, b3Raw, dCurrOvmH) Proc.TaskId = nTaskId Proc.Box = EgtGetBBoxGlob( ProcId, GDB_BB.STANDARD) if Proc.Box and not Proc.Box:isEmpty() then - Proc.Head = Proc.Box and IsHeadFeature( Proc, b3Raw, dCurrOvmH) - Proc.Tail = Proc.Box and IsTailFeature( Proc, b3Raw, dCurrOvmH) + Proc.Head = IsHeadFeature( Proc, b3Raw, dCurrOvmH) + Proc.Tail = IsTailFeature( Proc, b3Raw, dCurrOvmH) table.insert( vProc, Proc) -- se foro if Drill.Identify( Proc) then @@ -353,8 +354,10 @@ local function CollectFeatures( PartId, b3Raw, dCurrOvmH) Proc.Diam, Proc.Fcs, Proc.Fce = Drill.GetData( Proc, b3Raw) -- verifico se necessaria seconda lavorazione da parte opposta per foro più lungo della punta if Drill.Split( Proc, b3Raw) then - -- aggiorno flag prima parte foro (dati tabelle sempre per riferimento) + -- aggiorno flags prima parte foro (dati tabelle sempre per riferimento) Proc.Flg = 2 + Proc.Head = IsHeadFeature( Proc, b3Raw, dCurrOvmH) + Proc.Tail = IsTailFeature( Proc, b3Raw, dCurrOvmH) -- definisco dati seconda parte local Proc2 = {} Proc2.Id = ProcId diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 36ee5d0..ab47c40 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -827,7 +827,7 @@ function BeamLib.MakeOneFaceBySaw( nSurfId, nFacet, sCutting, dSawDiam, Par5, dV EgtSetOperationMode( nMchFId, false) return false, sErr end - return true, sName + return true, sName, nMchFId end ------------------------------------------------------------------------------------------------------------- diff --git a/LuaLibs/DiceCut.lua b/LuaLibs/DiceCut.lua index 0924542..52ffec7 100644 --- a/LuaLibs/DiceCut.lua +++ b/LuaLibs/DiceCut.lua @@ -370,13 +370,15 @@ end -- ptCBond*: il punto centrale della superfice limitante (se non esistono altre superfici può essere omesso) -- vtNBond*: il versore normale della superfice limitante (se non esistono altre superfici può essere omesso) -- dOrthoMaxDim : massima profondità taglio se faccia singola perpendicolare facce laterali trave +-- dCustMaxDimDice: dimensione massima customizzata, sostituisce il parametro BD.MAX_DIM_DICE ---------------------------------------------------------------------------------------------------------------------------------------------------- -function DiceCut.GetDice( nParent, BBoxRawPart, ptCPlanes, vtNPlanes, bGetOrtoPlanes, ptCBond, vtNBond, dOrthoMaxDim) +function DiceCut.GetDice( nParent, BBoxRawPart, ptCPlanes, vtNPlanes, bGetOrtoPlanes, ptCBond, vtNBond, dOrthoMaxDim, dCustMaxDimDice) + local dMaxDimDice = ( dCustMaxDimDice and dCustMaxDimDice < BD.MAX_DIM_DICE) or BD.MAX_DIM_DICE local dTolerance = 0 -- distanza di sicurezza per i tagli ortogonali - local OffsetP = BD.MAX_DIM_DICE -- distanza tra i piani paralleli + local OffsetP = dMaxDimDice -- distanza tra i piani paralleli local StepP = 20 -- numero massimo di piani paralleli da generare - local OffsetO = BD.MAX_DIM_DICE -- distanza tra i piani ortogonali + local OffsetO = dMaxDimDice -- distanza tra i piani ortogonali local StepO = 20 -- numero massimo di piani ortogonali da generare --Ricavo le altezze dei BoundingBox contenente feature e estremi del grezzo diff --git a/LuaLibs/ProcessCut.lua b/LuaLibs/ProcessCut.lua index 60ce5e5..e273152 100644 --- a/LuaLibs/ProcessCut.lua +++ b/LuaLibs/ProcessCut.lua @@ -1,4 +1,4 @@ --- ProcessCut.lua by Egaltech s.r.l. 2020/06/20 +-- ProcessCut.lua by Egaltech s.r.l. 2020/07/25 -- Gestione calcolo singoli tagli di lama per Travi -- Tabella per definizione modulo @@ -183,9 +183,11 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom) return true end end - -- inserimento smussi - local bOkc, sErrC = MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead) - if not bOkc then return bOkc, sErrC end + -- se vero taglio, eventuale inserimento smussi + if Proc.Prc == 10 then + local bOkc, sErrC = MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead) + if not bOkc then return bOkc, sErrC end + end -- recupero la lavorazione local sCutting = ML.FindCutting( EgtIf( Proc.Head, 'HeadSide', 'TailSide')) if not sCutting then @@ -251,6 +253,8 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom) local vtO if #vCuts[i-1] > 0 then vtO = EgtSurfTmFacetNormVersor( vCuts[i-1][1], 0, GDB_ID.ROOT) + elseif vCuts[i+1] and #vCuts[i+1] > 0 then + vtO = EgtSurfTmFacetNormVersor( vCuts[i+1][1], 0, GDB_ID.ROOT) else bNoPerpCuts = true end diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index e35663e..08758c6 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -1,4 +1,4 @@ --- ProcessDrill.lua by Egaltech s.r.l. 2020/06/18 +-- ProcessDrill.lua by Egaltech s.r.l. 2020/07/25 -- Gestione calcolo forature per Travi -- Tabella per definizione modulo @@ -49,7 +49,7 @@ end -- Verifica se feature di coda function ProcessDrill.IsTailFeature( Proc, b3Raw) -- verifico se è in coda - if Proc.Box:getMin():getX() > b3Raw:getMin():getX() + BD.MAX_DIST_HTFEA then + if Proc.Box:getMin():getX() > b3Raw:getMin():getX() + BD.OVM_MID + BD.MAX_DIST_HTFEA then return false end -- recupero e verifico l'entità foro @@ -60,7 +60,7 @@ function ProcessDrill.IsTailFeature( Proc, b3Raw) end local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) -- se entrata principale - if Proc.Flg > 0 then + if Proc.Flg == 2 or ( Proc.Flg == 1 and vtExtr:getZ() >= BD.DRILL_VZ_MIN) then local nFcs = EgtGetInfo( Proc.Id, 'FCS', 'i') or 0 return ( ( nFcs == 5 or nFcs == 6) and vtExtr:getX() < -0.5) -- altrimenti entrata opposta diff --git a/LuaLibs/ProcessDtMortise.lua b/LuaLibs/ProcessDtMortise.lua index 0ac97ee..3f4d922 100644 --- a/LuaLibs/ProcessDtMortise.lua +++ b/LuaLibs/ProcessDtMortise.lua @@ -1,4 +1,4 @@ --- ProcessDtMortise.lua by Egaltech s.r.l. 2020/06/20 +-- ProcessDtMortise.lua by Egaltech s.r.l. 2020/07/27 -- Gestione calcolo mortase a coda di rondice per Travi -- Tabella per definizione modulo @@ -30,7 +30,7 @@ end function ProcessDtMortise.IsTailFeature( Proc, b3Raw) -- la mortasa di fronte è già stata classificata nel chiamante -- controllo la mortasa standard - if Proc.Box:getMin():getX() > b3Raw:getMin():getX() + BD.MAX_DIST_HTFEA then + if Proc.Box:getMin():getX() < b3Raw:getMin():getX() + BD.MAX_DIST_HTFEA then -- recupero la curva di profilo local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') if not AuxId then return false end diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 45d4e0b..3e38d8d 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2020/06/19 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/07/23 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. @@ -295,14 +295,14 @@ local function GetTunnelDimension( Proc, nPartId) EgtOutLog( sErr) return false, sErr end - -- mi assicuro che la Z del punto utilizzato per creare la superfic sia alla Z media del bounding box locale + -- mi assicuro che la Z del punto utilizzato per creare la superficie sia alla Z media del bounding box locale local ptN2 = Point3d(ptN1) ptN2:toLoc(frFc) ptN2 = Point3d( ptN2:getX(), ptN2:getY(), ( bBoxLoc:getMin():getZ() + bBoxLoc:getMax():getZ())/2) ptN2:toGlob(frFc) - -- creeo superfice intermedia + -- creo superficie intermedia local nSurfInt = EgtSurfTmPlaneInBBox( nAddGrpId, ptN2, vtOrtho, b3Solid, GDB_ID.ROOT) - -- ritaglio la superfici con le facce della fessura + -- ritaglio la superficie con le facce della fessura for i = 1, nFacCnt do local ptN, vtN = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT) EgtCutSurfTmPlane( nSurfInt, ptN, -vtN, false, GDB_ID.ROOT) @@ -1722,14 +1722,17 @@ local function MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw) end -- recupero i dati dell'utensile local dSawDiam = 400 + local dSawThick = 0 if EgtMdbSetCurrMachining( sCutting) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam + dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThick end end -- eseguo il taglio - return BL.MakeOneFaceBySaw( Proc.Id, nFacet, sCutting, dSawDiam, vtN, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + local bMadeASbyBld, sWarn, nIdMach = BL.MakeOneFaceBySaw( Proc.Id, nFacet, sCutting, dSawDiam, vtN, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + return bMadeASbyBld, sWarn, nIdMach, dSawThick end --------------------------------------------------------------------- @@ -2420,6 +2423,113 @@ local function CheckDiamToolByFaces( Proc, nFacInd, dH, dV, bIsU, bIsL, dElev) end end +--------------------------------------------------------------------- +local function MakeChamfer( Proc, b3FacesUsed, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) + + -- recupero la lavorazione + local sMilling = ML.FindMilling( 'Mark') + if not sMilling then + local sErr = 'Error : chamfer not found in library' + EgtOutLog( sErr) + return -1, sErr + end + -- ottengo le curve di contorno libero + local nAuxId1, nAuxId2, nNumIdAux + if b3FacesUsed then +-- nAuxId1, _ = EgtExtractSurfTmLoops( nSurfInt, nAddGrpId) +-- EgtModifyCurveExtrusion( nAuxId1, vtOrtho, GDB_RT.GLOB) +-- SetOpenSide( nAuxId1, vtOrtho, b3Solid, nAddGrpId, true) +-- nNumIdAux = 2 + + -- estraggo i percorsi + nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId) + -- se percorso creato estraggo solo i percorsi delle facce interessate, non di testa + if nAuxId1 then + nAuxId1, nNumIdAux, nAuxId2 = ExtractExternalPaths( nAuxId1, nNumIdAux, vtOrtho, b3Solid, nAddGrpId) + end + else + nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId) + if not nNumIdAux then nNumIdAux = 0 end + end + + local dExtra = 2 + for i = 1, nNumIdAux do + local AuxId + local vtExtr + if b3FacesUsed then + if i == 1 then + AuxId = nAuxId1 + else + -- faccio la copia del percorso +-- AuxId = EgtCopyGlob( nAuxId1, nAddGrpId) + AuxId = nAuxId2 + end + if AuxId then + vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) + end + else + AuxId = nAuxId1 + i - 1 + vtExtr, _, _ = EgtCurveArea( AuxId) + end + if vtExtr then + if not b3FacesUsed then + local fFrCurve = EgtGetGlobFrame( AuxId) + vtExtr:toGlob( fFrCurve) + end +-- if b3FacesUsed and i == nNumIdAux then +-- vtExtr = -vtExtr +-- end + -- Se normale entro certi limiti +-- if vtExtr:getZ() > -0.707 and ( abs(vtOrtho:getX()) > 0.99 or abs(vtOrtho:getY()) > 0.99 or abs(vtOrtho:getZ()) > 0.99) then + if vtExtr:getZ() > -0.707 and ( abs(vtExtr:getX()) > 0.99 or abs(vtExtr:getY()) > 0.99 or abs(vtExtr:getZ()) > 0.99) then + -- inserisco la lavorazione + local sNameCh = 'Cham_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i) + local nMchId = EgtAddMachining( sNameCh, sMilling) + if not nMchId then + local sErr = 'Error adding machining ' .. sNameCh .. '-' .. sMilling + EgtOutLog( sErr) + return -1, sErr + end + -- modifico estrusione percorso + EgtModifyCurveExtrusion( AuxId, vtExtr, GDB_RT.GLOB) + -- aggiungo geometria + EgtSetMachiningGeometry( {{ AuxId, -1}}) + -- imposto posizione braccio porta testa + if vtExtr:getY() < GEO.EPS_SMALL then + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM) + else + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP) + end + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + -- assegno affondamento e offset radiale +-- EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra - EgtIf( b3FacesUsed, (dDepth / 2), 0)) + EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra) + EgtSetMachiningParam( MCH_MP.OFFSR, dExtra) + -- se opero su 3 facce e sono al secondo e ultimo percorso inverto la lavorazione +-- if b3FacesUsed and i == nNumIdAux then +-- EgtSetMachiningParam( MCH_MP.INVERT, true) +-- end + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return -1, sErr + end + -- se non perpendicolare emetto un warning + -- else + -- sWarn = 'Warning : chamfer skipped because not perpendicular to face or from bottom' + -- EgtOutLog( sWarn) + end + --emetto un warning + -- else + -- sWarn = 'Warning : chamfer skipped because not perpendicular to face' + -- EgtOutLog( sWarn) + end + end + + return 0 +end + --------------------------------------------------------------------- local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMchFindMaster, b3FacesUsed, b3Solid, bOrthoFacesMaster) @@ -2453,105 +2563,8 @@ local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCha -- verifico la direzione -- se devo inserire il chamfer if nChamfer > 0 then - -- recupero la lavorazione - local sMilling = ML.FindMilling( 'Mark') - if not sMilling then - local sErr = 'Error : chamfer not found in library' - EgtOutLog( sErr) - return -1, sErr - end - -- ottengo le curve di contorno libero - local nAuxId1, nAuxId2, nNumIdAux - if b3FacesUsed then --- nAuxId1, _ = EgtExtractSurfTmLoops( nSurfInt, nAddGrpId) --- EgtModifyCurveExtrusion( nAuxId1, vtOrtho, GDB_RT.GLOB) --- SetOpenSide( nAuxId1, vtOrtho, b3Solid, nAddGrpId, true) --- nNumIdAux = 2 - - -- estraggo i percorsi - nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId) - -- se percorso creato estraggo solo i percorsi delle facce interessate, non di testa - if nAuxId1 then - nAuxId1, nNumIdAux, nAuxId2 = ExtractExternalPaths( nAuxId1, nNumIdAux, vtOrtho, b3Solid, nAddGrpId) - end - else - nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId) - if not nNumIdAux then nNumIdAux = 0 end - end - local dExtra = 2 - for i = 1, nNumIdAux do - local AuxId - local vtExtr - if b3FacesUsed then - if i == 1 then - AuxId = nAuxId1 - else - -- faccio la copia del percorso --- AuxId = EgtCopyGlob( nAuxId1, nAddGrpId) - AuxId = nAuxId2 - end - if AuxId then - vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) - end - else - AuxId = nAuxId1 + i - 1 - vtExtr, _, _ = EgtCurveArea( AuxId) - end - if vtExtr then - if not b3FacesUsed then - local fFrCurve = EgtGetGlobFrame( AuxId) - vtExtr:toGlob( fFrCurve) - end --- if b3FacesUsed and i == nNumIdAux then --- vtExtr = -vtExtr --- end - -- Se normale entro certi limiti --- if vtExtr:getZ() > -0.707 and ( abs(vtOrtho:getX()) > 0.99 or abs(vtOrtho:getY()) > 0.99 or abs(vtOrtho:getZ()) > 0.99) then - if vtExtr:getZ() > -0.707 and ( abs(vtExtr:getX()) > 0.99 or abs(vtExtr:getY()) > 0.99 or abs(vtExtr:getZ()) > 0.99) then - -- inserisco la lavorazione - local sNameCh = 'Cham_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i) - local nMchId = EgtAddMachining( sNameCh, sMilling) - if not nMchId then - local sErr = 'Error adding machining ' .. sNameCh .. '-' .. sMilling - EgtOutLog( sErr) - return -1, sErr - end - -- modifico estrusione percorso - EgtModifyCurveExtrusion( AuxId, vtExtr, GDB_RT.GLOB) - -- aggiungo geometria - EgtSetMachiningGeometry( {{ AuxId, -1}}) - -- imposto posizione braccio porta testa - if vtExtr:getY() < GEO.EPS_SMALL then - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM) - else - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP) - end - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - -- assegno affondamento e offset radiale --- EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra - EgtIf( b3FacesUsed, (dDepth / 2), 0)) - EgtSetMachiningParam( MCH_MP.DEPTH, dDepthCham + dExtra) - EgtSetMachiningParam( MCH_MP.OFFSR, dExtra) - -- se opero su 3 facce e sono al secondo e ultimo percorso inverto la lavorazione --- if b3FacesUsed and i == nNumIdAux then --- EgtSetMachiningParam( MCH_MP.INVERT, true) --- end - -- eseguo - if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) - return -1, sErr - end - -- se non perpendicolare emetto un warning - -- else - -- sWarn = 'Warning : chamfer skipped because not perpendicular to face or from bottom' - -- EgtOutLog( sWarn) - end - --emetto un warning - -- else - -- sWarn = 'Warning : chamfer skipped because not perpendicular to face' - -- EgtOutLog( sWarn) - end - end + local nOk, sErr = MakeChamfer( Proc, b3FacesUsed, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) + if nOk < 0 then return -1, sErr end end -- se smusso non è esclusivo if nChamfer < 2 then @@ -3120,6 +3133,14 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSinglePart) return bOk, sWarn end end + else + -- se devo inserire il chamfer + if ( ( Proc.Fct == 3 and bIsU) or (Proc.Fct == 2 and bIsL)) and nChamfer > 0 then + -- ottengo le dimensioni dello pseudotunnel + local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc, nPartId) + local nOk, sErr = MakeChamfer( Proc, true, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) + if nOk < 0 then return -1, sErr end + end end -- se richiesti antischeggia con lama su U trasversale e smusso non esclusivo -- rimane da gestire: se da eseguire con fresa o se richiesto lama ma impossibile utilizzarla, si utilizza fresa @@ -3127,11 +3148,63 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSinglePart) if nChamfer < 2 and EgtGetInfo( Proc.Id, sAntisplintMode, 'i') == 1 and ( bIsU or bIsL) and ( Proc.Box:getDimY() > b3Raw:getDimY() - 1 or Proc.Box:getDimZ() > b3Raw:getDimZ() - 1) then local nNumFac = EgtIf( bIsU, 2, 1) + local nPrefSide = 1 -- di preferenza il motore è meglio tenerlo sinistra + -- se a U cerco di ottimizzare il lato di lavoro della lama + if bIsU then + if abs(vtN:getZ()) > 0.7 or abs(vtN:getY()) > 0.7 then + -- se X è negativa allora devo tenere il motore a destra + if vtN:getX() < -(10 * GEO.EPS_SMALL) then + nPrefSide = 2 + end + end + end + -- va eseguito sulle facce diverse dalla principale for nFacet = 0, nNumFac do if nFacet ~= nFacInd then - bMadeASbyBld, sWarn = MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw) + local bInvertMach + if bIsU then + if abs(vtN:getZ()) > 0.7 or abs(vtN:getY()) > 0.7 then + -- prendo il vettore normale alla faccia + local _, vtNFc = EgtSurfTmFacetCenter( Proc.Id, nFacet, GDB_ID.ROOT) + -- valuto l'angolo tra le due facce + local bAdj, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, nFacet, GDB_ID.ROOT) + -- se posizione ancora da definire perchè la superficie principale è parallela al piano XY o XZ + if vtNFc:getX() > 0 and nPrefSide == 1 then + -- se angolo interno e <= 90 + if dAng < -90 + 20 * GEO.EPS_ANG_SMALL then + bInvertMach = true + end + elseif vtNFc:getX() < 0 and nPrefSide == 2 then + -- se angolo interno e <= 90 + if dAng < -90 + 20 * GEO.EPS_ANG_SMALL then + bInvertMach = true + end + end + end + end +-- debug +-- bInvertMach = false + local dSawThick = 0 + bMadeASbyBld, sWarn, nIdMach, dSawThick = MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw) if not bMadeASbyBld then return false, sWarn end + if bInvertMach then + local bInvert = EgtGetMachiningParam( MCH_MP.INVERT) +-- local nWorkSide = EgtGetMachiningParam( MCH_MP.WORKSIDE) + local bToolInvert = EgtGetMachiningParam( MCH_MP.TOOLINVERT) + -- inverto i parametri + EgtSetMachiningParam( MCH_MP.INVERT, not bInvert) +-- EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( nWorkSide == MCH_MILL_WS.RIGHT, MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT)) + EgtSetMachiningParam( MCH_MP.TOOLINVERT, not bToolInvert) + -- setto l'offset pari allo spessore lama + EgtSetMachiningParam( MCH_MP.OFFSL, -dSawThick) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nIdMach, false) + return false, sErr + end + end end end end @@ -3255,7 +3328,7 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) -- in base al tipo di feature attribuisco il significato dei parametri Q AssignQValues( Proc) -- verifico forzatura lama - local bForcedBlade = EgtGetInfo( Proc.Id, sUseRoughTool, 'i') ~= 1 + local bForcedBlade = EgtGetInfo( Proc.Id, sUseRoughTool, 'i') ~= 1 and EgtGetInfo( Proc.Id, sUseMill, 'i') ~= 1 -- se lunghezza richiede spezzatura if Proc.Box:getDimX() > BD.LONGCUT_MAXLEN then -- una faccia @@ -3311,6 +3384,31 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- altrimenti, con lama else + -- verifico se devo fare prima gli amussi + -- 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 + -- recupero l'ingombro della trave + local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + if not b3Solid then + local sErr = 'Error : part box not found' + EgtOutLog( sErr) + return false, sErr + end + -- verifico se due facce o L con una o due facce di terminazione + local bIsL = ( Proc.Fct == 2 or TestElleShape3( Proc) or TestElleShape4( Proc) == 2) + -- verifico se sono presenti i parametri Q per la profondità smusso e + -- per eseguire in esclusiva solo lo smusso + local nChamfer, dDepthCham, sErrCham = EvaluateQParam( Proc, false, sDepthChamferMill, sPreemptiveChamfer, sForceUseBlade) + if (Proc.Fct == 2 and bIsL) and nChamfer > 0 then + local _, _, _, vtOrtho, _, nSurfInt = GetTunnelDimension( Proc, nPartId) + local nOk, sErr = MakeChamfer( Proc, true, nAddGrpId, vtOrtho, b3Solid, nSurfInt, dDepthCham) + if nOk < 0 then return false, sErr end + end return Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, 'HeadSide') end -- tre o più facce diff --git a/LuaLibs/ProcessScarfJoint.lua b/LuaLibs/ProcessScarfJoint.lua index 17c494e..0b9a297 100644 --- a/LuaLibs/ProcessScarfJoint.lua +++ b/LuaLibs/ProcessScarfJoint.lua @@ -1,4 +1,4 @@ --- ProcessScarfJoint.lua by Egaltech s.r.l. 2020/06/04 +-- ProcessScarfJoint.lua by Egaltech s.r.l. 2020/07/21 -- Gestione calcolo giunto Gerber per Travi -- Tabella per definizione modulo @@ -121,6 +121,77 @@ local function MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead) return true end +--------------------------------------------------------------------- +local function ApplyDiceCut( vFaceOrd, nGoodFace1, nGoodFace4, nAddGrpId, b3Solid, ptC, vtN, Proc, vtRef, bHead, sCutting, dSawDiam, b3Raw, dNewDiceDim) + + local vCuts = {} + local bOk = true + local sErr = '' + + if nGoodFace1 and nGoodFace4 and nGoodFace1 > 0 and nGoodFace4 > 0 then + -- lavoro solo la faccia inclinata perché la faccia tappo completa la lavoro successivamente + -- questo evita di lavorare due volte la faccia tappo + vCuts = DC.GetDice( nAddGrpId, b3Solid, ptC[vFaceOrd[4]], vtN[vFaceOrd[4]], false, ptC[vFaceOrd[1]], vtN[vFaceOrd[1]], nil, dNewDiceDim) + elseif nGoodFace4 and nGoodFace4 > 0 then + vCuts = DC.GetDice( nAddGrpId, b3Solid, ptC[vFaceOrd[4]], vtN[vFaceOrd[4]], true, nil, nil, nil, dNewDiceDim) + end + + if #vCuts > 0 then + -- sistemo posizione nel DB e nome + for i = 1, #vCuts do + for j = 1, #vCuts[i] do + EgtSetName( vCuts[i][j], 'AddCut_' .. tostring( Proc.Id)) + EgtSetInfo( vCuts[i][j], 'TASKID', Proc.TaskId) + end + end + -- calcolo secondo riferimento per testa o coda + local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) + -- eseguo + for i = 1, #vCuts do + local vtOrthoO + if i % 2 == 1 then + vtOrthoO = Vector3d( vtRef) + else + if #vCuts[i-1] > 0 then + vtOrthoO = Vector3d( EgtIf( vtRef2, vtRef2, vtRef)) + else + local vtO + for j = 1, #vCuts[i-1] do + _, vtO = EgtSurfTmFacetCenter( vCuts[i-1][j], 0, GDB_ID.ROOT) + break + end + if vtO then + vtOrthoO = Vector3d( vtO) + else + vtOrthoO = Y_AX() + end + end + end + -- lavoro la faccia + for j = 1, #vCuts[i] do + bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then return bOk, sErr end + end + end + -- lavoro la faccia interna in ogni caso + if vFaceOrd[1] ~= 0 then + -- inserisco la lavorazione + local vtOrthoO = Vector3d( vtRef) + bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then return bOk, sErr end + end + -- lavoro la faccia opposta (definita dal parametro P11) + if vFaceOrd[3] ~= 0 then + -- inserisco la lavorazione + local vtOrthoO = Vector3d( vtRef) + local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOk then return bOk, sErr end + end + end + + return bOk, sErr, vCuts +end + --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessScarfJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) @@ -201,7 +272,7 @@ function ProcessScarfJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) vtRef = Vector3d( 0, vtN[vFaceOrd[2]]:getY(), vtN[vFaceOrd[2]]:getZ()) end end - + -- determino se di testa o di coda local bHead = ( vtN[1]:getX() > 0) @@ -267,100 +338,53 @@ function ProcessScarfJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) nGoodFace1 = EgtSurfTmFacetCount( nFace1) end - local vCuts = {} - if nGoodFace1 and nGoodFace4 and nGoodFace1 > 0 and nGoodFace4 > 0 then - -- lavoro solo la faccia inclinata perché la faccia tappo completa la lavoro successivamente - -- questo evita di lavorare due volte la faccia tappo - vCuts = DC.GetDice( nAddGrpId, b3Solid, ptC[vFaceOrd[4]], vtN[vFaceOrd[4]], false, ptC[vFaceOrd[1]], vtN[vFaceOrd[1]]) - elseif nGoodFace4 and nGoodFace4 > 0 then - vCuts = DC.GetDice( nAddGrpId, b3Solid, ptC[vFaceOrd[4]], vtN[vFaceOrd[4]], true) - end + local bOkd, sErrD, vCuts = ApplyDiceCut( vFaceOrd, nGoodFace1, nGoodFace4, nAddGrpId, b3Solid, ptC, vtN, Proc, vtRef, bHead, sCutting, dSawDiam, b3Raw) + if not bOkd then return bOkd, sErrD end - if #vCuts > 0 then - -- sistemo posizione nel DB e nome - for i = 1, #vCuts do - for j = 1, #vCuts[i] do - EgtSetName( vCuts[i][j], 'AddCut_' .. tostring( Proc.Id)) - EgtSetInfo( vCuts[i][j], 'TASKID', Proc.TaskId) + if #vCuts == 0 then + -- se ho la faccia intermedia, per prima cosa verifico se ho intersezione con la faccia tappo + if nGoodFace4 ~= 0 then + -- taglio sulla faccia interna + if vFaceOrd[1] ~= 0 then + -- inserisco la lavorazione + local vtOrthoO = Vector3d( vtRef) + bOkd, sErrD = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOkd then return bOkd, sErrD end end - end - -- calcolo secondo riferimento per testa o coda - local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) - -- eseguo - for i = 1, #vCuts do --- local nOrthoOpposite - local vtOrthoO - if i % 2 == 1 then - vtOrthoO = Vector3d( vtRef) - else - if #vCuts[i-1] > 0 then - vtOrthoO = Vector3d( EgtIf( vtRef2, vtRef2, vtRef)) - else - local vtO - for j = 1, #vCuts[i-1] do - _, vtO = EgtSurfTmFacetCenter( vCuts[i-1][j], 0, GDB_ID.ROOT) - break - end - if vtO then - vtOrthoO = Vector3d( vtO) - else - vtOrthoO = Y_AX() - end + -- se non ho intersezione con la faccia tappo posso fare il taglio sul fianco + if not nGoodFace1 or nGoodFace1 == 0 then + -- lavoro la faccia opposta (definita dal parametro P11) + if vFaceOrd[3] ~= 0 then + -- inserisco la lavorazione + local vtOrthoO = Vector3d( vtRef) + bOkd, sErrD = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOkd then return bOkd, sErrD end end + -- inserisco la lavorazione + local vtRef2 = EgtIf( abs(vtRef:getZ()) < GEO.EPS_SMALL, Z_AX(), EgtIf( bHead, Y_AX(), -Y_AX())) + bOkd, sErrD = BL.MakeOneFaceBySaw( nFace4, nGoodFace4 - 1, sCutting, dSawDiam, vtRef2, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOkd then return bOkd, sErrD end + else -- altrimenti se ho intersezione forzo il DiceCut ad essere eseguito con distanze più piccole + -- definisco la nuova dimensione massima del dice cut + local dNewDiceDim = EgtIf( abs(vtRef:getZ()) < GEO.EPS_SMALL, b3Raw:getDimZ(), b3Raw:getDimY()) + bOkd, sErrD = ApplyDiceCut( vFaceOrd, nGoodFace1, nGoodFace4, nAddGrpId, b3Solid, ptC, vtN, Proc, vtRef, bHead, sCutting, dSawDiam, b3Raw, dNewDiceDim) + if not bOkd then return bOkd, sErrD end end - -- lavoro la faccia - for j = 1, #vCuts[i] do - local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) - if not bOk then - return bOk, sErr - end + else + -- taglio sulla faccia interna + if vFaceOrd[1] ~= 0 then + -- inserisco la lavorazione + local vtOrthoO = Vector3d( vtRef) + bOkd, sErrD = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOkd then return bOkd, sErrD end end - end - -- lavoro la faccia interna in ogni caso - if vFaceOrd[1] ~= 0 then - -- inserisco la lavorazione - local vtOrthoO = Vector3d( vtRef) - local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) - if not bOk then return bOk, sNameOrErr end - end - -- lavoro la faccia opposta (definita dal parametro P11) - if vFaceOrd[3] ~= 0 then - -- inserisco la lavorazione - local vtOrthoO = Vector3d( vtRef) - local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) - if not bOk then return bOk, sNameOrErr end - end - else - -- taglio sulla faccia interna - local bIntCut = false - if vFaceOrd[1] ~= 0 then - -- inserisco la lavorazione - local vtOrthoO = Vector3d( vtRef) - local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) - if not bOk then return bOk, sNameOrErr end - if #sNameOrErr > 0 then bIntCut = true end - end - -- taglio sulla faccia intermedia (inclinata) - if vFaceOrd[4] ~= 0 then - -- calcolo secondo testa o coda - local vtRef2 = EgtIf( bHead, X_AX(), -X_AX()) - -- se non ho il taglio sulla faccia interna - if not bIntCut then - local frHV, DimH, DimV = BL.GetFaceHvRefDim( Proc.Id, vFaceOrd[4] - 1) - if DimV > DimH then - vtRef2 = Vector3d( frHV:getVersX()) - end + -- lavoro la faccia opposta (definita dal parametro P11) + if vFaceOrd[3] ~= 0 then + -- inserisco la lavorazione + local vtOrthoO = Vector3d( vtRef) + bOkd, sErrD = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) + if not bOkd then return bOkd, sErrD end end - -- inserisco la lavorazione - local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[4] - 1, sCutting, dSawDiam, vtRef2, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) - if not bOk then return bOk, sErr end - end - -- lavoro la faccia opposta (definita dal parametro P11) - if vFaceOrd[3] ~= 0 then - -- inserisco la lavorazione - local vtOrthoO = Vector3d( vtRef) - local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, vtOrthoO, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw) - if not bOk then return bOk, sNameOrErr end end end diff --git a/LuaLibs/ProcessTenon.lua b/LuaLibs/ProcessTenon.lua index 47975c0..e180e8f 100644 --- a/LuaLibs/ProcessTenon.lua +++ b/LuaLibs/ProcessTenon.lua @@ -1,4 +1,4 @@ --- ProcessTenon.lua by Egaltech s.r.l. 2020/04/27 +-- ProcessTenon.lua by Egaltech s.r.l. 2020/07/25 -- Gestione calcolo tenone per Travi -- Tabella per definizione modulo @@ -160,7 +160,8 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) end -- altrimenti applico taglio di lama else - local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg, + local b3Cut = EgtGetBBoxGlob( AddId or GDB_ID.NULL, GDB_BB.STANDARD) + local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = b3Cut, Fct = 1, Flg = Proc.Flg, Head = Proc.Head, Tail = Proc.Tail, CutId = Proc.CutId, TaskId = Proc.TaskId} local bFromBottom = ( b3Solid:getDimX() < BD.LEN_SHORT_PART and vtExtr:getZ() > 0.25) local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0, bFromBottom)