diff --git a/BatchProcess.lua b/BatchProcess.lua index bd38cc6..f77fdff 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -1,4 +1,4 @@ --- BatchProcess.lua by Egaltech s.r.l. 2021/10/27 +-- BatchProcess.lua by Egaltech s.r.l. 2022/02/24 -- Gestione calcolo batch disposizione e lavorazioni per Pareti -- 2020/07/24 Nuvola di punti riferita allo Zero Tavola. -- 2020/10/28 Corretto spostamento pezzi per rotazioni (0 o 180) e inversioni( 0, 90, 180, o 270). @@ -9,6 +9,8 @@ -- 2021/04/09 Corretto spostamento pezzi per rotazioni e inversioni. -- 2021/07/28 Aggiunta scelta direzione di vista per modifica e simulazione. -- 2021/10/27 Nel controllo spessore si deve considerare anche PosY. +-- 2022/02/24 Se ricalcolo si aggiorna il setup. In ogni caso si verifica prima di simulazione. + -- Intestazioni require( 'EgtBase') @@ -488,6 +490,7 @@ else -- Se necessario eseguo aggiornamento con ricalcolo delle lavorazioni if bToRecalc then EgtOutLog( ' +++ Recalculating all dispositions and machinings >>>') + EgtImportSetup() EgtApplyAllMachinings() -- copia del file btl originale (per dichiarare progetto ricalcolato) EgtCopyFile( WALL.FILE, sDir..sTitle..'.ori'..sExt) @@ -499,6 +502,20 @@ end -- *** Eseguo simulazione con verifica collisione in cieco *** if ( WALL.FLAG == 0 and ( bToProcess or bToRecalc)) or WALL.FLAG == 3 or WALL.FLAG == 4 then EgtOutLog( ' +++ Simulating with collision check >>>') + -- verifico setup + local bSetUpOk, SetUpErrors = EgtVerifyCurrSetup() + if not bSetUpOk then + local sToolsList = "" + for ToolIndex = 1, #SetUpErrors do + sToolsList = sToolsList .. SetUpErrors[ToolIndex] + if ToolIndex ~= #SetUpErrors then + sToolsList = sToolsList .. ", " + end + end + WriteErrToLogFile( 19, 'Error in setup: tool/s ' .. sToolsList .. ' not found', 0, 0, 0) + return + end + -- lancio simulazione local bSimOk, nErr, sErr = EgtSimulate() if not bSimOk then if nErr == MCH_SHE.INIT then diff --git a/LuaLibs/WProcessDrill.lua b/LuaLibs/WProcessDrill.lua index 8814b84..550664d 100644 --- a/LuaLibs/WProcessDrill.lua +++ b/LuaLibs/WProcessDrill.lua @@ -266,11 +266,36 @@ function WPD.Make( Proc, nRawId, b3Raw) end if sDrilling then sHead = '' end end + local bAngledContourDrill = false + local nAngledContourDrillId = GDB_ID.NULL + local dReduceDepth = 0 -- se trovata svuotatura, verifico se richiesta invece contornatura if nType == 'Pocket' then -- recupero eventuale flag per fare sola contornatura local nContourOnly = ( EgtGetInfo( Proc.Id, sContourOnly, 'i') or 0) if nContourOnly == 1 then + -- imposto riduzione profondita' per evitare distacco pezzo interno + dReduceDepth = 5 + -- se inclinato e passante + if abs( vtExtr:getZ()) >= WD.DRILL_VZ_MIN and abs( vtExtr:getZ()) < 0.999 and Proc.Fcs > 0 and Proc.Fce > 0 then + -- gruppo ausiliario per preforo + local nAddGrpId = WL.GetAddGroup( Proc.PartId) + -- ricavo contorno inferiore della superficie + local nAngledCircleId, nAngledCircleCnt = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId) + local dMinZ = 10000 + local nMinCircleId = GDB_ID.NULL + for Circleindex = 1, nAngledCircleCnt do + local b3Circle = EgtGetBBoxGlob( nAngledCircleId + Circleindex -1, GDB_BB.EXACT) + if b3Circle:getMin():getZ() < dMinZ then + nMinCircleId = nAngledCircleId + Circleindex -1 + end + end + -- estrudo + EgtModifyCurveExtrusion( nMinCircleId, vtExtr, GDB_RT.GLOB) + EgtModifyCurveThickness( nMinCircleId, dLen) + bAngledContourDrill = true + nAngledContourDrillId = nMinCircleId + end sDrilling = WM.FindMilling( 'FreeContour', dLen, nil, nil, nil, nil, true) if sDrilling then nType = 'Mill' @@ -295,6 +320,7 @@ function WPD.Make( Proc, nRawId, b3Raw) local dMaxDepth = 20 local dFreeLen = 20 local dDiamTh = 35 + local dDiamT = 35 if EgtMdbSetCurrMachining( sDrilling) then local bIsDrilling = ( EgtMdbGetCurrMachiningParam( MCH_MP.TYPE) == MCH_MY.DRILLING) local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) @@ -307,8 +333,14 @@ function WPD.Make( Proc, nRawId, b3Raw) dMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxDepth, dFreeLen) end dDiamTh = EgtTdbGetCurrToolThDiam() + dDiamT = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dDiamT end end + -- calcolo riduzione lunghezza aggiuntiva per inclinazione utensile + if bAngledContourDrill then + local dToolAngleReduce = ( dDiamT / 2) * sqrt( 1 - vtExtr:getZ() * vtExtr:getZ()) / vtExtr:getZ() + dReduceDepth = ( dToolAngleReduce) + ( 5 / vtExtr:getZ()) + end -- aggiusto massimo affondamento per fori lungo Y con teste speciali if sHead == 'H5' then local dMaxY = WD.HOR_DRILL_Y_SPLIT + WD.HOR_DRILL_Y_TABLE / 2 @@ -348,7 +380,11 @@ function WPD.Make( Proc, nRawId, b3Raw) EgtSetInfo( nMchId, 'MOVE_AFTER', 1) end -- aggiungo geometria - EgtSetMachiningGeometry( {{ AuxId, -1}}) + if bAngledContourDrill then + EgtSetMachiningGeometry( nAngledContourDrillId) + else + EgtSetMachiningGeometry( {{ AuxId, -1}}) + end -- eventuale inversione if nType == 'Drill' then EgtSetMachiningParam( MCH_MP.INVERT, bToInvert) @@ -356,7 +392,14 @@ function WPD.Make( Proc, nRawId, b3Raw) EgtSetMachiningParam( MCH_MP.TOOLINVERT, bToInvert) end -- se fresatura gestisco il lato di lavoro - if nType == 'Mill' then + if bAngledContourDrill then + local nWorkSide = EgtGetMachiningParam( MCH_MP.WORKSIDE) + if nWorkSide == MCH_MILL_WS.CENTER then + nWorkSide = MCH_MILL_WS.RIGHT + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + end + EgtSetMachiningParam( MCH_MP.INVERT, nWorkSide == MCH_MILL_WS.LEFT) + elseif nType == 'Mill' then local frRef = EgtGetGlobFrame( AuxId) local vtNa, _, dArea = EgtCurveArea( AuxId) vtNa:toGlob( frRef) @@ -387,7 +430,7 @@ function WPD.Make( Proc, nRawId, b3Raw) EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- aggiusto l'affondamento local sMyWarn - local dDepth = dLen + local dDepth = dLen - dReduceDepth if dDepth > dMaxDepth + 10 * GEO.EPS_SMALL then dDepth = dMaxDepth if abs( Proc.Flg) ~= 2 then diff --git a/LuaLibs/WProcessFreeContour.lua b/LuaLibs/WProcessFreeContour.lua index eb3d859..4a695b9 100644 --- a/LuaLibs/WProcessFreeContour.lua +++ b/LuaLibs/WProcessFreeContour.lua @@ -1,4 +1,4 @@ --- ProcessFreeContour.lua by Egaltech s.r.l. 2022/02/21 +-- ProcessFreeContour.lua by Egaltech s.r.l. 2022/02/25 -- Gestione calcolo profilo libero per Pareti -- 2021/11/15 Penna e chiodature sono sempre riportate sulla faccia sopra anche se nel progetto sono sotto. -- 2021/12/10 In taglio con lama aggiunta gestione SCC per testa Gearbox. @@ -257,6 +257,8 @@ local function ReorderFaces( nIdSurf, nNumFacet) nIdFace = i end end + -- se è presente una faccia isolata non faccio riordino + if nAdjMin == 0 then return nIdSurf end -- se il numero faccia minore con minori adiacenze è <> 1 faccio lo scambio if nIdFace and nIdFace ~= 1 then EgtSurfTmSwapFacets( nIdSurf, nIdFace-1, 0) @@ -365,12 +367,12 @@ local function GetFacesData( Proc, bOpposite, bCalclForBlade, dToolDiam, dToolMa local dLenY = dLen * abs( vFace[i].Norm:getX()) / sqrt( 1 - vFace[i].Norm:getZ() * vFace[i].Norm:getZ()) local nType = 0 if vFace[i].PrevAng < -0.1 or - ( WD.BEAM_MACHINE and not IsPointOnRawLongEdges( vFace[i].Cen, b3Raw) and ( dLen > 0.5 * WD.CUT_MAX_LENGTH or dLenY > 0.9 * b3Raw:getDimY())) then + ( WD.BEAM_MACHINE and not IsPointOnRawLongEdges( vFace[i].Cen, b3Raw) and ( dLen > 0.5 * WD.CUT_MAX_LENGTH or dLenY > 0.4 * b3Raw:getDimY())) then dLen = dLen - EgtIf( bCalclForBlade, dWhisk, 0) nType = nType + 1 end if vFace[EgtIf( i < nNumFacet, i + 1, 1)].PrevAng < -0.1 or - ( WD.BEAM_MACHINE and not IsPointOnRawLongEdges( vFace[i].Cen, b3Raw) and ( dLen > 0.5 * WD.CUT_MAX_LENGTH or dLenY > 0.9 * b3Raw:getDimY())) then + ( WD.BEAM_MACHINE and not IsPointOnRawLongEdges( vFace[i].Cen, b3Raw) and ( dLen > 0.5 * WD.CUT_MAX_LENGTH or dLenY > 0.4 * b3Raw:getDimY())) then dLen = dLen - EgtIf( bCalclForBlade, dWhisk, 0) nType = nType + 2 end @@ -378,9 +380,13 @@ local function GetFacesData( Proc, bOpposite, bCalclForBlade, dToolDiam, dToolMa if dLen < MIN_LEN_CUT then nType = 4 end + -- numero dei lati + local nEdges = #(EgtSurfTmFacetAdjacencies( nNewProc, i - 1)[1]) + -- assegno i nuovi dati vFace[i].Depth = dDepth vFace[i].Whisk = dWhisk vFace[i].Type = nType + vFace[i].Edges = nEdges end -- recupero le regioni degli altri pezzi local vOthers = GetOtherRegions( Proc.PartId) @@ -463,12 +469,14 @@ local function GetFacesData( Proc, bOpposite, bCalclForBlade, dToolDiam, dToolMa vFace[nInd3].Type = 4 end end + -- eventuali stampe for i = 1, #vFace do local Face = vFace[i] local sOut = 'Face '..tostring( Face.Fac)..' C'..tostring( Face.Cen)..' N'..tostring( Face.Norm).. - ' L='..EgtNumToString( Face.Len, 1)..' W='..EgtNumToString( Face.Width, 1)..' Ap='..EgtNumToString( Face.PrevAng, 1)..' App='..EgtNumToString( Face.PlPrevAng, 1).. - ' D='..EgtNumToString( Face.Depth, 1)..' B='..EgtNumToString( Face.Whisk, 1).. ' As='..EgtNumToString( Face.SideAng, 1)..' T='..tostring( Face.Type) + ' L='..EgtNumToString( Face.Len, 1)..' W='..EgtNumToString( Face.Width, 1)..' Ap='..EgtNumToString( Face.PrevAng, 1).. + ' App='..EgtNumToString( Face.PlPrevAng, 1)..' D='..EgtNumToString( Face.Depth, 1)..' B='..EgtNumToString( Face.Whisk, 1).. + ' As='..EgtNumToString( Face.SideAng, 1)..' T='..tostring( Face.Type)..' E='..tostring( Face.Edges) EgtOutLog( sOut) end @@ -1182,8 +1190,8 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd -- ciclo di inserimento delle fresate sulle facce del contorno in esame local i = 1 -- se faccia finale con fine non lavorato, forzo partenza da prima faccia non tutta saltata (tipo 4) - if bClosed and ( vFace[#vFace].Type == 4 or ( vFace[#vFace].Type & 2) ~= 0) then - while i <= #vFace and vFace[i].Type == 4 and abs( vFace[i].SideAng) < 0.1 do + if bClosed and ( ( vFace[#vFace].Type == 4 and vFace[#vFace].Edges > 3) or ( vFace[#vFace].Type & 2) ~= 0) then + while i <= #vFace and vFace[i].Type == 4 and vFace[i].Edges > 3 and abs( vFace[i].SideAng) < 0.1 do i = i + 1 end end @@ -1193,7 +1201,7 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd while i <= #vFace do -- se inizio faccia senza taglio e non è successiva di senza taglio, inserisco una fresatura local j = EgtIf( i > 1, i - 1, EgtIf( bClosed, #vFace, nil)) - if ( vFace[i].Type & 1) ~= 0 and ( not j or ( vFace[j].Type == 0 or vFace[j].Type == 1) or abs( vFace[j].SideAng - vFace[i].SideAng) > 0.1) then + if ( vFace[i].Type & 1) ~= 0 and ( not j or ( vFace[j].Type == 0 or vFace[j].Type == 1) or abs( vFace[i].SideAng) > 0.1) then -- inserisco la lavorazione local sName = 'Free_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) local nMchId = EgtAddMachining( sName, sMilling) @@ -1282,7 +1290,7 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd end end -- se tutta la faccia o la sua fine senza taglio, inserisco una fresatura - if ( vFace[i].Type & 2) ~= 0 or vFace[i].Type == 4 then + if ( vFace[i].Type & 2) ~= 0 or ( vFace[i].Type == 4 and vFace[i].Edges > 3) then -- inserisco la lavorazione local sName = 'Free_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) local nMchId = EgtAddMachining( sName, sMilling) @@ -1323,7 +1331,7 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd local LastJ i = i + 1 local j = EgtIf( i <= #vFace, i, EgtIf( bAllType4 or not bClosed, nil, 1)) - while j and ( ( vFace[j].Type & 1) ~= 0 or vFace[j].Type == 4) and abs( vFace[j].SideAng - vFace[OrigI].SideAng) < 0.1 do + while j and ( ( vFace[j].Type & 1) ~= 0 or ( vFace[j].Type == 4 and vFace[j].Edges > 3)) and abs( vFace[j].SideAng) < 0.1 and abs( vFace[OrigI].SideAng) < 0.1 do table.insert( vGeom, { Proc.Id, vFace[j].Fac}) LastJ = j dEal = EgtIf( ( vFace[j].Type & 1) ~= 0, vFace[j].Whisk - vFace[j].Len, 0) @@ -1334,13 +1342,13 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd j = EgtIf( j + 1 <= #vFace, j + 1, EgtIf( bAllType4 or not bClosed, nil, 1)) end -- se faccia singola è da fare tutta senza oltrepassare estremi - if #vFace == 1 and vFace[OrigI].Type == 4 then + if #vFace == 1 and vFace[OrigI].Type == 4 and vFace[OrigI].Edges > 3 then dSal = -dMillDiam / 2 dEal = -dMillDiam / 2 -- altrimenti va verificato else -- se lavorazione completa su faccia iniziale - if vFace[OrigI].Type == 4 then + if vFace[OrigI].Type == 4 and vFace[OrigI].Edges > 3 then -- se angolo interno prima if vFace[OrigI].PrevAng < -30 then local dSinA = -sin( vFace[OrigI].PlPrevAng + 90) @@ -1361,7 +1369,7 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd -- se lavorazione completa o finale su faccia finale local LastFace = ( LastJ or OrigI) local OrigK = EgtIf( LastFace < #vFace, LastFace + 1, EgtIf( bClosed, 1, nil)) - if vFace[LastFace].Type == 4 or ( vFace[LastFace].Type & 2) ~= 0 then + if ( vFace[LastFace].Type == 4 and vFace[LastFace].Edges > 3) or ( LastFace == OrigI and ( vFace[LastFace].Type & 2) ~= 0) then -- se angolo interno dopo if OrigK and vFace[OrigK].PrevAng < -30 then local dSinA = -sin( vFace[OrigK].PlPrevAng + 90) @@ -1380,7 +1388,7 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd end end -- per sola lavorazione finale - if ( vFace[LastFace].Type & 2) ~= 0 then + if LastFace == OrigI and ( vFace[LastFace].Type & 2) ~= 0 then -- se angolo interno dopo e faccia successiva inclinata verso l'alto oltre 16.1 deg if OrigK and vFace[OrigK].PrevAng < -30 and vFace[OrigK].Norm:getZ() < 0.96078 and vFace[OrigK].Norm:getZ() > 0 then dSal = dSal + vFace[OrigK].Width * vFace[OrigK].Norm:getZ() @@ -1622,7 +1630,7 @@ local function AddSawings( sSawing, vFace, Proc, nRawId, b3Raw) end end -- se fine faccia non tagliato completamente o faccia non tagliata completamente e abbastanza lunga, inserisco un ripasso con sega a catena - if ( vFace[i].Type & 2) ~= 0 or ( vFace[i].Type == 4 and vFace[i].Len > dSawDiam + 1) then + if ( vFace[i].Type & 2) ~= 0 or ( vFace[i].Type == 4 and vFace[i].Edges > 3 and vFace[i].Len > dSawDiam + 1) then -- inserisco la lavorazione local sName = 'Free_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) local nMchId = EgtAddMachining( sName, sSawing) diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 935394e..19ccf6e 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -1576,95 +1576,71 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d bThroughRaw = true end - -- se passante - if bThroughRaw then - -- calcolo larghezza e lunghezza canale - local dGorgeWidth = dMillDiam - -- verifico se elevazione minore per fare meno tagli - if dElev + 2 * WD.COLL_SIC < dGorgeWidth then - dGorgeWidth = max( dElev + 2 * WD.COLL_SIC, 0) + -- recupero la lavorazione di taglio + local sCuttingGorge = WM.FindCutting( 'Standard') + if not sCuttingGorge then + local sErr = 'Error : Sawblade not found in library' + EgtOutLog( sErr) + return false, sErr + end + + -- acquisisco dati utensile lama + local dSawThickness = 0 + local dSawDiam = 0 + if EgtMdbSetCurrMachining( sCuttingGorge) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dSawThickness = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThickness + dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam + end + end + + -- dati utensile fresa piccola + local dMillDiamFirst = 0 + local dMaxMatFirst = 0 + local bMillInvert = false + local bSawInvertSE = false + + -- se non passante, aggiungo fresatura area della fresa + if not bThroughRaw then + local SquareId -- Id della composita da fresare + local dSawShortening = sqrt( b3Raw:getDimZ() * ( dSawDiam - b3Raw:getDimZ())) -- da calcolare in base a raggio lama e spessore grezzo + -- gruppo ausiliario + local nAddGrpId = WL.GetAddGroup( Proc.PartId) + -- disegno quadrato di fresatura + local p3Start + -- se orientato lungo la Y (direzione) + if abs( vtN:getX()) > 0.9 then + local dStartX = EgtIf( vtN:getX() > 0.9, Proc.Box:getMax():getX(), Proc.Box:getMin():getX()) + local dStartY = EgtIf( bStartPos, Proc.Box:getMin():getY(), Proc.Box:getMax():getY()) + p3Start = Point3d( dStartX, dStartY, Proc.Box:getMin():getZ()) + local vtNPerp = Vector3d( vtN) + vtNPerp:rotate(-Z_AX(), 90 * EgtIf( bStartPos, 1, -1) * EgtIf( vtN:getX() > 0.9, 1, -1)) + local FirstLineId = EgtLinePVL( nAddGrpId, p3Start, vtNPerp, dMillDiam / 2 , GDB_RT.GLOB) -- Y_AX() + local SecondLineId = EgtLinePVL( nAddGrpId, EgtEP( FirstLineId, GDB_RT.GLOB), vtN, dMillDiam - dSideElev, GDB_RT.GLOB) -- -X_AX() + local dThirdLineLen = min( (dMillDiam / 2) + ( Proc.Box:getMax():getY() - Proc.Box:getMin():getY()), dSawShortening + 10) + local ThirdLineId = EgtLinePVL( nAddGrpId, EgtEP( SecondLineId, GDB_RT.GLOB), -vtNPerp, dThirdLineLen, GDB_RT.GLOB) -- -Y_AX() + local FourthLineId = EgtLinePVL( nAddGrpId, EgtEP( ThirdLineId, GDB_RT.GLOB), -vtN, dMillDiam -dSideElev , GDB_RT.GLOB) -- X_AX() + SquareId = EgtCurveCompo( nAddGrpId, { FirstLineId, SecondLineId, ThirdLineId, FourthLineId}) + bMillInvert = EgtIf( vtN:getX() > 0.9, not (bStartPos or false), bStartPos or false) + bSawInvertSE = EgtIf( vtN:getX() > 0.9, bStartPos or false, not (bStartPos or false)) + -- altrimenti orientato lungo la X + elseif abs( vtN:getY()) > 0.9 then + local dStartX = EgtIf( bStartPos, Proc.Box:getMin():getX(), Proc.Box:getMax():getX()) + local dStartY = EgtIf( vtN:getY() > 0.9, Proc.Box:getMax():getY(), Proc.Box:getMin():getY()) + p3Start = Point3d( dStartX, dStartY, Proc.Box:getMin():getZ()) + local vtNPerp = Vector3d( vtN) + vtNPerp:rotate(-Z_AX(), 90 * EgtIf( bStartPos, -1, 1) * EgtIf( vtN:getY() > 0.9, 1, -1)) + local FirstLineId = EgtLinePVL( nAddGrpId, p3Start, vtNPerp, dMillDiam / 2 , GDB_RT.GLOB) -- Y_AX() + local SecondLineId = EgtLinePVL( nAddGrpId, EgtEP( FirstLineId, GDB_RT.GLOB), vtN, dMillDiam -dSideElev, GDB_RT.GLOB) -- -X_AX() + local dThirdLineLen = min( (dMillDiam / 2) + ( Proc.Box:getMax():getX() - Proc.Box:getMin():getX()), dSawShortening + 10) + local ThirdLineId = EgtLinePVL( nAddGrpId, EgtEP( SecondLineId, GDB_RT.GLOB), -vtNPerp, dThirdLineLen, GDB_RT.GLOB) -- -Y_AX() + local FourthLineId = EgtLinePVL( nAddGrpId, EgtEP( ThirdLineId, GDB_RT.GLOB), -vtN, dMillDiam -dSideElev , GDB_RT.GLOB) -- X_AX() + SquareId = EgtCurveCompo( nAddGrpId, { FirstLineId, SecondLineId, ThirdLineId, FourthLineId}) + bMillInvert = EgtIf( vtN:getY() > 0.9, bStartPos or false, not (bStartPos or false)) + bSawInvertSE = EgtIf( vtN:getY() > 0.9, not (bStartPos or false), bStartPos or false) end - local dGorgeExtraLength = ( dMillDiamTh + WD.COLL_SIC) / 2 - - -- recupero la lavorazione - local sCuttingGorge = WM.FindCutting( 'Standard') - if not sCuttingGorge then - local sErr = 'Error : Sawblade not found in library' - EgtOutLog( sErr) - return false, sErr - end - - -- acquisisco dati utensile - local dSawThickness = 0 - if EgtMdbSetCurrMachining( sCuttingGorge) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dSawThickness = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dSawThickness - end - end - - -- sottraggo lato esterno lapjoint per ottenere larghezza netta del gorge - dGorgeWidth = dGorgeWidth - dSideElev - - -- calcolo quanti passi devo fare in larghezza per scaricare l'area di impegno utensile - local nNumStep = ceil( ( dGorgeWidth) / WD.SAWGORGE_INTERAX) - local dC = 0 - if ( nNumStep - 1) > 0 then - dC = ( dGorgeWidth) / ( nNumStep) - else - nNumStep = 1 - end - -- inserisco la lavorazione - local nNm = 0 - -- passi di allargamento - for i = 1, nNumStep - 1 do - nNm = nNm + 1 - -- inserisco la lavorazione di taglio sfrido gorge - local sNameGorge = 'GorgeCut_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. tostring( nFacet) .. '_' .. tostring( nNm) - local nMchFId = EgtAddMachining( sNameGorge, sCuttingGorge) - if not nMchFId then - local sErr = 'Error adding machining ' .. sNameGorge .. '-' .. sCuttingGorge - EgtOutLog( sErr) - return false, sErr - end - -- aggiungo geometria - EgtSetMachiningGeometry( {{ Proc.Id, nFacet}}) - - EgtSetInfo( nMchFId, 'Part', Proc.PartId) - -- percorso da non invertire - EgtSetMachiningParam( MCH_MP.INVERT, false) - -- assegno affondamento - EgtSetMachiningParam( MCH_MP.DEPTH, 0) - -- assegno il lato di lavoro - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - -- assegno l'attacco e l'uscita - EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT) - EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT) - -- aggiungo l'offset laterale - EgtSetMachiningParam( MCH_MP.OFFSL, ( dSideElev - dSawThickness + ( dC * ( i)))) - -- nessun criterio per il braccio è necessario - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE) - - -- eseguo - if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr - end - end - -- se non passante - else - -- calcolo quanto deve essere largo e lungo il canale di fresatura - local dDistGorge = ( dMillDiam - dMillDiamTh) / 2 - WD.COLL_SIC - local dDimGorge = dMillDiamTh + 2 * WD.COLL_SIC - -- se il materiale extra è inferiore della gola completa, ricalcolo la dimensione della gola - -- per fare meno fresature inutili - if dElev + 2 * WD.COLL_SIC < dDistGorge + dDimGorge then - dDimGorge = max( dElev - dDistGorge + 2 * WD.COLL_SIC, 0) - end - -- calcolo extra allungamenti - local dExtraLongGorge = ( dMillDiamTh + WD.COLL_SIC) / 2 -- recupero la lavorazione local sMillingGorge = WM.FindMilling( 'Gorge', nil, nil, nil, 80) if not sMillingGorge then @@ -1673,8 +1649,6 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d return false, sErr end -- acquisisco dati utensile - local dMillDiamFirst = 0 - local dMaxMatFirst = 0 if EgtMdbSetCurrMachining( sMillingGorge) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then @@ -1682,60 +1656,122 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d dMaxMatFirst = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMatFirst end end - -- calcolo quanti passi devo fare in larghezza per scaricare l'area di impegno utensile - local nNumStep = ceil( ( dDimGorge - dMillDiamFirst) / ( dMillDiamFirst * 0.9)) + 1 - local dC = 0 - if ( nNumStep - 1) > 0 then - dC = ( dDimGorge - dMillDiamFirst) / ( nNumStep - 1) - else - nNumStep = 1 + -- inserisco la lavorazione di fresatura + local sNameGorge = 'Gorge_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. tostring( nFacet) .. '_' .. tostring( nNm) + local nMchFId = EgtAddMachining( sNameGorge, sMillingGorge) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameGorge .. '-' .. sMillingGorge + EgtOutLog( sErr) + return false, sErr end - -- inserisco la lavorazione - local nNm = 0 - -- passi di allargamento - for i = 1, nNumStep do - nNm = nNm + 1 - -- inserisco la lavorazione di fresatura - local sNameGorge = 'Gorge_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. tostring( nFacet) .. '_' .. tostring( nNm) - local nMchFId = EgtAddMachining( sNameGorge, sMillingGorge) - if not nMchFId then - local sErr = 'Error adding machining ' .. sNameGorge .. '-' .. sMillingGorge - EgtOutLog( sErr) - return false, sErr + -- aggiungo geometria + EgtSetMachiningGeometry( SquareId) + -- imposto posizione braccio porta testa + local nSCC = MCH_SCC.ADIR_ZP + if abs( vtN:getZ()) < GEO.EPS_SMALL then + nSCC = EgtIf( Proc.Box:getDimX() >= Proc.Box:getDimY(), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_XP) + end + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- imposto modo di lavorare la faccia + local nFaceUse = WL.GetNearestParalOpposite( Z_AX(), vtN) + EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) + -- imposto elevazione e step + local dStep = EgtGetMachiningParam( MCH_MP.STEP) + if dStep < GEO.EPS_SMALL then dStep = dMaxMat end + ---- se sto lavorando la gola centrale setto l'elevazione e l'affondamento + --if nSinglePass and nSinglePass == 0 then + -- local dZElev = b3Raw:getDimZ() + -- local dDepth = Proc.Box:getMax():getZ() - b3Raw:getMin():getZ() + -- EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dZElev, 3) .. ';') + -- EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + --end + EgtSetMachiningParam( MCH_MP.STEP, dStep) + -- imposto invert in base al lato fresa + local bWorkSide = EgtGetMachiningParam( MCH_MP.WORKSIDE) + if bWorkSide == MCH_MILL_WS.RIGHT then + bMillInvert = not bMillInvert + end + EgtSetMachiningParam( MCH_MP.INVERT, bMillInvert) + -- aggiungo allungamenti iniziali e finali + EgtSetMachiningParam( EgtIf( bMillInvert, MCH_MP.STARTADDLEN, MCH_MP.ENDADDLEN), -dMillDiamFirst / 2 - dSawThickness / 2) + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + end + + -- calcolo larghezza canale + local dGorgeWidth = dMillDiam + -- verifico se elevazione minore per fare meno tagli + if dElev + 2 * WD.COLL_SIC < dGorgeWidth then + dGorgeWidth = max( dElev + 2 * WD.COLL_SIC, 0) + end + + -- sottraggo lato esterno lapjoint per ottenere larghezza netta del gorge + dGorgeWidth = dGorgeWidth - dSideElev + + -- calcolo quanti passi devo fare in larghezza per scaricare l'area di impegno utensile + local nNumStep = ceil( ( dGorgeWidth) / WD.SAWGORGE_INTERAX) + local dC = 0 + if ( nNumStep - 1) > 0 then + dC = ( dGorgeWidth) / ( nNumStep) + else + nNumStep = 1 + end + -- inserisco la lavorazione + local nNm = 0 + -- passi di allargamento + for i = 1, nNumStep - 1 do + nNm = nNm + 1 + -- inserisco la lavorazione di taglio sfrido gorge + local sNameGorge = 'GorgeCut_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. tostring( nFacet) .. '_' .. tostring( nNm) + local nMchFId = EgtAddMachining( sNameGorge, sCuttingGorge) + if not nMchFId then + local sErr = 'Error adding machining ' .. sNameGorge .. '-' .. sCuttingGorge + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ Proc.Id, nFacet}}) + + EgtSetInfo( nMchFId, 'Part', Proc.PartId) + -- assegno invert + EgtSetMachiningParam( MCH_MP.INVERT, false) + -- assegno affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, 0) + -- assegno il lato di lavoro + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) -- EgtIf( bMillInvert, MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT)) + -- assegno l'attacco e l'uscita + if not bThroughRaw and bSawInvertSE then + EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_SAW_LI.STRICT) + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT) + -- aggiungo allungamento finale + if not bThroughRaw then + EgtSetMachiningParam( MCH_MP.STARTADDLEN, ( dMillDiam / 2) - ( dMillDiamFirst / 2)) end - -- aggiungo geometria - EgtSetMachiningGeometry( {{ Proc.Id, nFacet}}) - -- imposto posizione braccio porta testa - local nSCC = MCH_SCC.ADIR_ZP - if abs( vtN:getZ()) < GEO.EPS_SMALL then - nSCC = EgtIf( Proc.Box:getDimX() >= Proc.Box:getDimY(), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_XP) - end - EgtSetMachiningParam( MCH_MP.SCC, nSCC) - -- imposto modo di lavorare la faccia - local nFaceUse = WL.GetNearestParalOpposite( Z_AX(), vtN) - EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) - -- imposto elevazione e step - local dStep = EgtGetMachiningParam( MCH_MP.STEP) - if dStep < GEO.EPS_SMALL then dStep = dMaxMat end - -- se sto lavorando la gola centrale setto l'elevazione e l'affondamento - if nSinglePass and nSinglePass == 0 then - local dZElev = b3Raw:getDimZ() - local dDepth = Proc.Box:getMax():getZ() - b3Raw:getMin():getZ() - EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dZElev, 3) .. ';') - EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) - end - EgtSetMachiningParam( MCH_MP.STEP, dStep) - -- aggiungo l'offset laterale - EgtSetMachiningParam( MCH_MP.OFFSR, ( dDistGorge + dC * ( i - 1))) - -- aggiungo allungamenti iniziali e finali - EgtSetMachiningParam( MCH_MP.STARTADDLEN, dExtraLongIni + dExtraLongGorge) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, dExtraLongEnd + dExtraLongGorge) - -- eseguo - if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) - return false, sErr + elseif not bThroughRaw and not bSawInvertSE then + EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_SAW_LO.CENT) + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_SAW_LI.STRICT) + -- aggiungo allungamento finale + if not bThroughRaw then + EgtSetMachiningParam( MCH_MP.ENDADDLEN, ( dMillDiam / 2) - ( dMillDiamFirst / 2)) end + else + EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_SAW_LO.CENT) + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_SAW_LI.CENT) + end + -- aggiungo l'offset laterale + EgtSetMachiningParam( MCH_MP.OFFSL, ( dSideElev - dSawThickness + ( dC * ( i)))) + -- nessun criterio per il braccio è necessario + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE) + + -- eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr end end end @@ -1749,7 +1785,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d end EgtSetInfo( nMchFId, 'Part', Proc.PartId) -- se ho abilitato la lavorazione di lama per garantire passaggio utensile, setto la nota per spostare la fresatura dopo i tagli di lama - if bEnablePreMill and bThroughRaw then + if bEnablePreMill then EgtSetInfo( nMchFId, 'MOVE_AFTER', 1) end -- aggiungo geometria diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index b6cba11..b5f0150 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -110,6 +110,7 @@ function WallLib.GetFaceWithMostAdj( nSurfId, nPartId, bCompare3Fc, dCosSideAng) local vAdj = {} local vUcut = {} local vOrtho = {} + local vBlind = {} for i = 1, nFacCnt do -- recupero le adiacenze del loop esterno local vFacAdj = EgtSurfTmFacetAdjacencies( nSurfId, i - 1)[1] @@ -137,8 +138,19 @@ function WallLib.GetFaceWithMostAdj( nSurfId, nPartId, bCompare3Fc, dCosSideAng) end end end + -- verifico se schermata da altra faccia + local bBlind = false + for j = 1, nFacCnt do + if i ~= j then + if vvtN[i] * vvtN[j] < -0.5 then + bBlind = true + end + end + end + -- assegno i risultati vUcut[i] = bUcut vOrtho[i] = bOrtho + vBlind[i] = bBlind end -- se 4 facce tutte con adiacenza 2, allora è un tunnel if nFacCnt == 4 then @@ -177,12 +189,11 @@ function WallLib.GetFaceWithMostAdj( nSurfId, nPartId, bCompare3Fc, dCosSideAng) local nMaxAdj = -1 local nSupAdj = -1 for i = 1, nFacCnt do - if not vUcut[i] then - if vAdj[i] > nMaxAdj then - nFacInd = {} - nFacInd[1] = i - 1 + if not vUcut[i] and not vBlind[i] then + if vAdj[i] >= nMaxAdj and vAdj[i] > 0 then + table.insert( nFacInd, i - 1) nMaxAdj = vAdj[i] - elseif vAdj[i] == nMaxAdj and nMaxAdj > 0 then + elseif vAdj[i] > 0 then table.insert( nFacInd, i - 1) end end @@ -196,18 +207,22 @@ function WallLib.GetFaceWithMostAdj( nSurfId, nPartId, bCompare3Fc, dCosSideAng) end -- premio la faccia con minore elevazione local nFacOpt, nFacOpt2 + local nOptAdj, nOptAdj2 local dMinElev, dMinElev2 = GEO.INFINITO, GEO.INFINITO for i = 1, #nFacInd do local dElev = WallLib.GetFaceElevation( nSurfId, nFacInd[i], nPartId) - if dElev < dMinElev then + if dElev < dMinElev and ( not nOptAdj or vAdj[nFacInd[i]+1] >= nOptAdj) then if dMinElev < dMinElev2 then nFacOpt2 = nFacOpt + nOptAdj2 = nOptAdj dMinElev2 = dMinElev end nFacOpt = nFacInd[i] + nOptAdj = vAdj[nFacInd[i]+1] dMinElev = dElev - elseif dElev < dMinElev2 then + elseif dElev < dMinElev2 and ( not nOptAdj2 or vAdj[nFacInd[i]+1] >= nOptAdj2) then nFacOpt2 = nFacInd[i] + nOptAdj2 = vAdj[nFacInd[i]+1] dMinElev2 = dElev end end diff --git a/NestProcess.lua b/NestProcess.lua index 8df8e51..865ab6d 100644 --- a/NestProcess.lua +++ b/NestProcess.lua @@ -16,6 +16,7 @@ EgtEnableDebug( false) NEST.LAP_JOINT_U_MACH_AREA = 1 -- 0 NEST.MACH_AREA_USE_OTHER_DIAM = 1 -- 0 NEST.MACH_AREA_OTHER_DIAM = 200 +NEST.MACH_AREA_IGNORE_3rdFACE = 1 -- 0 local sLog = 'NestProcess : ' .. NEST.FILE .. ', ' .. NEST.MACHINE .. ', ' .. LEN["1"] .. ', ' .. WIDTH["1"] @@ -208,8 +209,9 @@ local function IdentifyLJFromBottom( Proc, bCompute, nOutlineGrp) local bAdj2, ptP3, ptP4 = EgtSurfTmFacetsContact( Proc.Id, nFace, nOtherFace, GDB_ID.ROOT) if AreSamePointApprox( ptP2, ptP3) or AreSamePointApprox( ptP2, ptP4) then ptP1, ptP2 = ptP2, ptP1 - end - nRectId = CreateToolRectangle( ptP1, 0, ptP2, WD.SIDEMILL_DIAM_DOWN / 2, vtFace[1], WD.SIDEMILL_DIAM_DOWN, nOutlineGrp) + end + local dVal = EgtIf( NEST.MACH_AREA_IGNORE_3rdFACE == 1, WD.SIDEMILL_DIAM_DOWN / 2, 0) + nRectId = CreateToolRectangle( ptP1, dVal, ptP2, WD.SIDEMILL_DIAM_DOWN / 2, vtFace[1], WD.SIDEMILL_DIAM_DOWN, nOutlineGrp) end end end