diff --git a/.gitignore b/.gitignore index aece050..8e23b4e 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,8 @@ /bin/*.ini /bin/LuaLibs/*.lua /bin/Images/*.png +.vscode/settings.json +bin/Images/.placeholder +bin/LuaLibs/.placeholder +bin/Images/.placeholder +bin/LuaLibs/.placeholder diff --git a/BatchProcess.lua b/BatchProcess.lua index 1dd8a29..f666518 100644 --- a/BatchProcess.lua +++ b/BatchProcess.lua @@ -1,4 +1,4 @@ --- BatchProcess.lua by Egaltech s.r.l. 2022/04/28 +-- BatchProcess.lua by Egaltech s.r.l. 2022/05/10 -- Gestione calcolo batch disposizione e lavorazioni per Travi -- 2019/07/11 Aggiunta gestione stato rotazione di feature per TS3. -- 2019/07/16 Aggiunta gestione modalità oltre 10 per impostazione macchina e uscita. @@ -23,6 +23,8 @@ -- 2021/06/16 Se disponibile si aggiunge la versione dell'eseguibile alle info del programma CN. -- 2021/08/04 Direzione vista simulazione da BD.SIMUL_VIEW_DIR se esiste. -- 2022/04/28 In info generazione aggiunta indicazione se 64bit. +-- 2023/05/03 Tolleranza su sezione portata a 0.1 mm (100 * GEO.EPS_SMALL). +-- 2022/05/10 Dopo aver fatto rotazioni e inversioni dei pezzi cambio chiave Info relative. -- Intestazioni require( 'EgtBase') @@ -266,22 +268,26 @@ if bToProcess then vBeam[i].PosX = PosX end - -- Eseguo eventuali rotazioni e inversioni testa-coda + -- Se non già eseguite, applico eventuali rotazioni e inversioni testa-coda for i = 1, #vBeam do local b3Solid = vBeam[i].Box -- rotazione - local dRotAng = EgtGetInfo( vBeam[i].Id, 'ROTATED', 'd') - if dRotAng and abs( dRotAng) > GEO.EPS_ANG_SMALL then + local dRotAng = EgtGetInfo( vBeam[i].Id, 'ROTATED', 'd') or 0 + if abs( dRotAng) > GEO.EPS_ANG_SMALL then local ptRotCen = b3Solid:getCenter() EgtRotate( vBeam[i].Id, ptRotCen, X_AX(), dRotAng, GDB_RT.GLOB) b3Solid:rotate( ptRotCen, X_AX(), dRotAng) end + EgtRemoveInfo( vBeam[i].Id, 'ROTATED') + EgtSetInfo( vBeam[i].Id, 'ROTATED_OK', dRotAng) -- inversione local dInvAng = 180 - ( EgtGetInfo( vBeam[i].Id, 'INVERTED', 'd') or 0) if abs( dInvAng) > GEO.EPS_ANG_SMALL then local ptInvCen = b3Solid:getCenter() EgtRotate( vBeam[i].Id, ptInvCen, Z_AX(), dInvAng, GDB_RT.GLOB) end + EgtRemoveInfo( vBeam[i].Id, 'INVERTED') + EgtSetInfo( vBeam[i].Id, 'INVERTED_OK', 180 - dInvAng) end -- Ne verifico le dimensioni @@ -291,8 +297,8 @@ if bToProcess then for i = 2, #vBeam do local dDimW = vBeam[i].Box:getDimY() local dDimH = vBeam[i].Box:getDimZ() - if ( abs( dDimW - dRawW) > 10 * GEO.EPS_SMALL or abs( dDimH - dRawH) > 10 * GEO.EPS_SMALL) and - ( abs( dDimH - dRawW) > 10 * GEO.EPS_SMALL or abs( dDimW - dRawH) > 10 * GEO.EPS_SMALL) then + if ( abs( dDimW - dRawW) > 100 * GEO.EPS_SMALL or abs( dDimH - dRawH) > 100 * GEO.EPS_SMALL) and + ( abs( dDimH - dRawW) > 100 * GEO.EPS_SMALL or abs( dDimW - dRawH) > 100 * GEO.EPS_SMALL) then table.insert( vBeamErr, i) end end diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 8131b40..68b8251 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -1,4 +1,4 @@ --- BeamExec.lua by Egaltech s.r.l. 2022/12/28 +-- BeamExec.lua by Egaltech s.r.l. 2023/03/31 -- 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. @@ -44,6 +44,7 @@ -- 2023/02/17 Ora le forature che intersecano le mortase sono sempre fatte prima della mortasa stessa. -- 2023/02/17 Nelle tasche in doppio, la distanza minima ammessa tra le feature è stata portata a 50. -- 2023/02/20 Ora le mortase a coda di rondine laterali sono sempre fatte prima dei tagli longitudinali. +-- 2023/03/31 Corretto ordinamento per fori di coda da lasciare in coda. -- Tabella per definizione modulo local BeamExec = {} @@ -696,41 +697,6 @@ local function OrderFeatures( vProc, b3Raw) if B1.Head ~= B2.Head then return B1.Head end - -- se primo è foro e secondo è un ribasso, il foro va sempre prima - if Drill.Identify(B1) and ( LapJoint.Identify(B2) or Mortise.Identify(B2)) and - B1.Box:getCenter():getX() > B2.Box:getMin():getX() and B1.Box:getCenter():getX() < B2.Box:getMax():getX() then - return true - end - -- se primo è un ribasso e secondo è un foro, il ribasso va sempre dopo - if (LapJoint.Identify(B1) or Mortise.Identify(B1)) and Drill.Identify(B2) and - B2.Box:getCenter():getX() > B1.Box:getMin():getX() and B2.Box:getCenter():getX() < B1.Box:getMax():getX() then - return false - end - -- se prima è mortasa coda di rondine sul fianco e secondo taglio longitudinale, la coda di rondine va sempre prima - if DtMortise.SideIdentify(B1) and ( LongCut.Identify(B2) or Long2Cut.Identify(B2)) and - OverlapsX( B1.Box, B2.Box) then - return true - end - -- se primo è taglio longitudinale e seconda è mortasa coda di rondine sul fianco, il taglio longitudinale va sempre dopo - if ( LongCut.Identify(B1) or Long2Cut.Identify(B1)) and DtMortise.SideIdentify(B2) and - OverlapsX( B1.Box, B2.Box) then - return false - end - -- se entrambi tenoni e si intersecano, metto prima tenone vero e poi base tenone - if ( Tenon.Identify( B1) or DtTenon.Identify( B1)) and ( Tenon.Identify( B2) or DtTenon.Identify( B2)) and - B1.Box:getMin():getX() < B2.Box:getMax():getX() + 100 * GEO.EPS_SMALL and B2.Box:getMin():getX() < B1.Box:getMax():getX() + 100 * GEO.EPS_SMALL then - return ( ( B1.Prc == 50 or B1.Prc == 55) and B2.Prc == 52) - end - -- se primo house mortise, secondo mortise e si intersecano, metto prima house mortise - if Mortise.Identify( B1) and B1.Prc == 53 and ( Mortise.Identify( B2) or DtMortise.Identify( B2)) and B2.Prc ~= 53 and - B1.Box:getMin():getX() < B2.Box:getMax():getX() + 100 * GEO.EPS_SMALL and B2.Box:getMin():getX() < B1.Box:getMax():getX() + 100 * GEO.EPS_SMALL then - return true - end - -- se primo mortise, secondo house mortise e si intersecano, metto prima house mortise - if ( Mortise.Identify( B1) or DtMortise.Identify( B1)) and B1.Prc ~= 53 and Mortise.Identify( B2) and B2.Prc == 53 and - B1.Box:getMin():getX() < B2.Box:getMax():getX() + 100 * GEO.EPS_SMALL and B2.Box:getMin():getX() < B1.Box:getMax():getX() + 100 * GEO.EPS_SMALL then - return false - end -- se entrambi di testa e primo è scasso o mortasa e secondo no va messo dopo if B1.Head and B2.Head and ( LapJoint.Identify( B1) or Mortise.Identify( B1) or DtMortise.Identify( B1)) and not ( LapJoint.Identify( B2) or Mortise.Identify( B2) or DtMortise.Identify( B2)) then @@ -741,14 +707,6 @@ local function OrderFeatures( vProc, b3Raw) not ( LapJoint.Identify( B1) or Mortise.Identify( B1) or DtMortise.Identify( B1)) then return true end - -- se primo è feature di coda e l'altro è separazione o non è feature di coda - if B1.Tail and ( Split.Identify( B2) or not B2.Tail) then - return false - end - -- se secondo è feature di coda e l'altro è separazione o non è feature di coda - if B2.Tail and ( Split.Identify( B1) or not B1.Tail) then - return true - end -- se primo è feature di coda anticipata e l'altro non è feature di coda if B1.AdvTail and ( not Split.Identify( B2) or not B2.Tail) then return false @@ -757,6 +715,14 @@ local function OrderFeatures( vProc, b3Raw) if B2.AdvTail and ( not Split.Identify( B1) or not B1.Tail) then return true end + -- se primo è feature di coda e l'altro è separazione o non è feature di coda + if B1.Tail and ( Split.Identify( B2) or not B2.Tail) then + return false + end + -- se secondo è feature di coda e l'altro è separazione o non è feature di coda + if B2.Tail and ( Split.Identify( B1) or not B1.Tail) then + return true + end -- se primo è scasso o mortasa di coda e secondo no, sempre dopo if B1.Tail and ( LapJoint.Identify( B1) or Mortise.Identify( B1) or DtMortise.Identify( B1)) and not ( B2.Tail and ( LapJoint.Identify( B2) or Mortise.Identify( B2) or DtMortise.Identify( B2))) then @@ -784,6 +750,16 @@ local function OrderFeatures( vProc, b3Raw) if abs( B2.Box:getDimX() - b3Raw:getDimX()) < 0.2 * b3Raw:getDimX() then return not ( B1.Tail or B2.Box:getMin():getX() + 20 > B1.Box:getCenter():getX()) end + -- se primo è foro e secondo è un ribasso, il foro va sempre prima + if Drill.Identify(B1) and ( LapJoint.Identify(B2) or Mortise.Identify(B2)) and + B1.Box:getCenter():getX() > B2.Box:getMin():getX() and B1.Box:getCenter():getX() < B2.Box:getMax():getX() then + return true + end + -- se primo è un ribasso e secondo è un foro, il ribasso va sempre dopo + if (LapJoint.Identify(B1) or Mortise.Identify(B1)) and Drill.Identify(B2) and + B2.Box:getCenter():getX() > B1.Box:getMin():getX() and B2.Box:getCenter():getX() < B1.Box:getMax():getX() then + return false + end -- se primo è foro e l'altro no, lo penalizzo if B1.Prc == 40 and B2.Prc ~= 40 then return ( B1.Box:getCenter():getX() > B2.Box:getMax():getX() + dDrillPenalty) @@ -792,6 +768,31 @@ local function OrderFeatures( vProc, b3Raw) if B1.Prc ~= 40 and B2.Prc == 40 then return ( B1.Box:getMax():getX() + dDrillPenalty > B2.Box:getCenter():getX()) end + -- se prima è mortasa coda di rondine sul fianco e secondo taglio longitudinale, la coda di rondine va sempre prima + if DtMortise.SideIdentify(B1) and ( LongCut.Identify(B2) or Long2Cut.Identify(B2)) and + OverlapsX( B1.Box, B2.Box) then + return true + end + -- se primo è taglio longitudinale e seconda è mortasa coda di rondine sul fianco, il taglio longitudinale va sempre dopo + if ( LongCut.Identify(B1) or Long2Cut.Identify(B1)) and DtMortise.SideIdentify(B2) and + OverlapsX( B1.Box, B2.Box) then + return false + end + -- se entrambi tenoni e si intersecano, metto prima tenone vero e poi base tenone + if ( Tenon.Identify( B1) or DtTenon.Identify( B1)) and ( Tenon.Identify( B2) or DtTenon.Identify( B2)) and + B1.Box:getMin():getX() < B2.Box:getMax():getX() + 100 * GEO.EPS_SMALL and B2.Box:getMin():getX() < B1.Box:getMax():getX() + 100 * GEO.EPS_SMALL then + return ( ( B1.Prc == 50 or B1.Prc == 55) and B2.Prc == 52) + end + -- se primo house mortise, secondo mortise e si intersecano, metto prima house mortise + if Mortise.Identify( B1) and B1.Prc == 53 and ( Mortise.Identify( B2) or DtMortise.Identify( B2)) and B2.Prc ~= 53 and + B1.Box:getMin():getX() < B2.Box:getMax():getX() + 100 * GEO.EPS_SMALL and B2.Box:getMin():getX() < B1.Box:getMax():getX() + 100 * GEO.EPS_SMALL then + return true + end + -- se primo mortise, secondo house mortise e si intersecano, metto prima house mortise + if ( Mortise.Identify( B1) or DtMortise.Identify( B1)) and B1.Prc ~= 53 and Mortise.Identify( B2) and B2.Prc == 53 and + B1.Box:getMin():getX() < B2.Box:getMax():getX() + 100 * GEO.EPS_SMALL and B2.Box:getMin():getX() < B1.Box:getMax():getX() + 100 * GEO.EPS_SMALL then + return false + end -- se entrambi fori con posizione praticamente uguale ordino secondo diametro e faccia di inizio (Fcs) if B1.Prc == 40 and B2.Prc == 40 and abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) < dSmallDrillRange then if abs( B1.Diam - B2.Diam) < 1.0 then @@ -1394,16 +1395,14 @@ end ------------------------------------------------------------------------------------------------------------- -- Controlla se la feature ProcMirror è la specchiata di Proc, per feature di tipo tasca o simile local function CheckMirrorPocket( Proc, ProcMirror, b3Raw, AuxId) - + -- recupero i dati geometrici della curva Proc local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) local ptBC = EgtGP( AuxId, GDB_RT.GLOB) local rfDtMrt = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 0, GDB_RT.GLOB) local b3DtMrt = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, rfDtMrt) local b3Proc = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) - -- determino l'asse della curva Proc - local vtAx = EgtEV( AuxId, GDB_RT.GLOB) - EgtSV( AuxId, GDB_RT.GLOB) - + -- recupero e verifico l'entità curva ProcMirror local AuxIdMirror = EgtGetInfo( ProcMirror.Id, 'AUXID', 'i') if AuxIdMirror then AuxIdMirror = AuxIdMirror + ProcMirror.Id end @@ -1419,35 +1418,49 @@ local function CheckMirrorPocket( Proc, ProcMirror, b3Raw, AuxId) local ptBCMirror = EgtGP( AuxIdMirror, GDB_RT.GLOB) local b3DtMrtMirror = EgtGetBBoxRef( ProcMirror.Id, GDB_BB.STANDARD, rfDtMrt) local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD) - -- determino l'asse della curva ProcMirror - local vtAxMirror = EgtEV( AuxIdMirror, GDB_RT.GLOB) - EgtSV( AuxIdMirror, GDB_RT.GLOB) - - -- verifico se le mortase sono specchiate - local bIsMirror = true + + -- verifico se le mortase sono specchiate : + -- devono avere estrusioni opposte + if not AreOppositeVectorApprox( vtExtr, vtExtrMirror) then + return false + end + -- se di tipo Dt, devono avere l'asse allineato + if DtMortise.SideIdentify( Proc) or DtMortise.SideIdentify( ProcMirror) then + local vtAx = EgtEV( AuxId, GDB_RT.GLOB) - EgtSV( AuxId, GDB_RT.GLOB) + local vtAxMirror = EgtEV( AuxIdMirror, GDB_RT.GLOB) - EgtSV( AuxIdMirror, GDB_RT.GLOB) + if not AreSameVectorApprox( vtAx, vtAxMirror) then + return false + end + end + -- devono avere il centro allineato, essere equidistanti dalla mezzaria trave e non essere troppo vicine local vtDisplacement = ptBC - ptBCMirror local ptCenRaw = b3Raw:getCenter() - local dYMinDistance = EgtIf( ptBC:getY() > ptBCMirror:getY(), abs( b3ProcMirror:getMax():getY() - b3Proc:getMin():getY()), abs( b3Proc:getMax():getY() - b3ProcMirror:getMin():getY())) - local dZMinDistance = EgtIf( ptBC:getZ() > ptBCMirror:getZ(), abs( b3ProcMirror:getMax():getZ() - b3Proc:getMin():getZ()), abs( b3Proc:getMax():getZ() - b3ProcMirror:getMin():getZ())) local dMinimumDistanceMirroredFeatures = 50 - -- controllo che il centro delle due mortase sia allineato, che queste siano equidistanti dalla mezzeria della trave - -- e che queste non siano troppo vicine if AreSameOrOppositeVectorApprox( vtExtr, Y_AX()) then - bIsMirror = abs( vtDisplacement:getX()) < 500 * GEO.EPS_SMALL and abs( vtDisplacement:getZ()) < 500 * GEO.EPS_SMALL and - ( abs( ptBC:getY() - ptCenRaw:getY()) - abs( ptBCMirror:getY() - ptCenRaw:getY())) < 500 * GEO.EPS_SMALL and - dYMinDistance - dMinimumDistanceMirroredFeatures > 10 * GEO.EPS_SMALL + local dYMinDistance = max( b3Proc:getMin():getY(), b3ProcMirror:getMin():getY()) - min( b3Proc:getMax():getY(), b3ProcMirror:getMax():getY()) + if not ( abs( vtDisplacement:getX()) < 500 * GEO.EPS_SMALL and abs( vtDisplacement:getZ()) < 500 * GEO.EPS_SMALL and + ( abs( ptBC:getY() - ptCenRaw:getY()) - abs( ptBCMirror:getY() - ptCenRaw:getY())) < 500 * GEO.EPS_SMALL and + dYMinDistance > dMinimumDistanceMirroredFeatures + 10 * GEO.EPS_SMALL) then + return false + end elseif AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then - bIsMirror = abs( vtDisplacement:getX()) < 500 * GEO.EPS_SMALL and abs( vtDisplacement:getY()) < 500 * GEO.EPS_SMALL and - ( abs( ptBC:getZ() - ptCenRaw:getZ()) - abs( ptBCMirror:getZ() - ptCenRaw:getZ())) < 500 * GEO.EPS_SMALL and - dZMinDistance - dMinimumDistanceMirroredFeatures > 10 * GEO.EPS_SMALL + local dZMinDistance = max( b3Proc:getMin():getZ(), b3ProcMirror:getMin():getZ()) - min( b3Proc:getMax():getZ(), b3ProcMirror:getMax():getZ()) + if not ( abs( vtDisplacement:getX()) < 500 * GEO.EPS_SMALL and abs( vtDisplacement:getY()) < 500 * GEO.EPS_SMALL and + ( abs( ptBC:getZ() - ptCenRaw:getZ()) - abs( ptBCMirror:getZ() - ptCenRaw:getZ())) < 500 * GEO.EPS_SMALL and + dZMinDistance > dMinimumDistanceMirroredFeatures + 10 * GEO.EPS_SMALL) then + return false + end + else + return false + end + -- devono avere box con le stesse dimensioni + if not ( abs( b3DtMrt:getDimX() - b3DtMrtMirror:getDimX()) < 500 * GEO.EPS_SMALL and + abs( b3DtMrt:getDimY() - b3DtMrtMirror:getDimY()) < 500 * GEO.EPS_SMALL and + abs( b3DtMrt:getDimZ() - b3DtMrtMirror:getDimZ()) < 500 * GEO.EPS_SMALL) then + return false end - -- controllo che le dimensioni dei due box siano le stesse - bIsMirror = bIsMirror and abs( b3DtMrt:getDimX() - b3DtMrtMirror:getDimX()) < 500 * GEO.EPS_SMALL and - abs( b3DtMrt:getDimY() - b3DtMrtMirror:getDimY()) < 500 * GEO.EPS_SMALL and - abs( b3DtMrt:getDimZ() - b3DtMrtMirror:getDimZ()) < 500 * GEO.EPS_SMALL - -- controllo che l'asse delle due mortase sia allineato - bIsMirror = bIsMirror and AreSameVectorApprox( vtAx, vtAxMirror) - return bIsMirror + return true end ------------------------------------------------------------------------------------------------------------- @@ -1832,11 +1845,15 @@ function BeamExec.ProcessFeatures() nRId = EgtGetNextRawPart( nRId) end EgtSetInfo( nDispId, 'ROT', -2) + -- flag feature precedente in doppio + local nPrevDouble = 0 -- inserisco le lavorazioni da lavorare ribaltate for i = 1, #vProc do -- creo la lavorazione local Proc = vProc[i] if Proc.Flg ~= 0 and Proc.Down then + Proc.PrevDouble = nPrevDouble + nPrevDouble = Proc.Double local bOk, sMsg, nNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, bNeedHCut, b3Raw, nOrd, sDownOrSideOrStd, nil, nil, dCurrOvmT) if not bOk then nTotErr = nTotErr + 1 @@ -1904,12 +1921,16 @@ function BeamExec.ProcessFeatures() nRId = EgtGetNextRawPart( nRId) end EgtSetInfo( nDispId, 'ROT', -1) + -- flag feature precedente in doppio + local nPrevDouble = 0 -- inserisco le lavorazioni da lavorare ruotate local nSideMchOk = 0 for i = 1, #vProc do -- creo la lavorazione local Proc = vProc[i] if Proc.Flg ~= 0 and Proc.Side then + Proc.PrevDouble = nPrevDouble + nPrevDouble = Proc.Double local bOk, sMsg, nNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, false, b3Raw, nOrd, sDownOrSideOrStd, bPreMove, vtMove, dCurrOvmT) if not bOk then nTotErr = nTotErr + 1 @@ -1966,11 +1987,15 @@ function BeamExec.ProcessFeatures() EgtSetInfo( nDispId, 'ORD', nOrd) end sDownOrSideOrStd = 'STD' + -- flag feature precedente in doppio + local nPrevDouble = 0 -- inserisco le lavorazioni non ribaltate della trave for i = 1, #vProc do -- creo la lavorazione local Proc = vProc[i] if Proc.Flg ~= 0 and ( not ( Proc.Down or Proc.Side) or BD.DOWN_HEAD or BD.TURN) then + Proc.PrevDouble = nPrevDouble + nPrevDouble = Proc.Double local bOk, sMsg, nNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, false, b3Raw, nOrd, sDownOrSideOrStd, nil, nil, dCurrOvmT) if not bOk then nTotErr = nTotErr + 1 diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index f96b9f6..68f9ed9 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -21,6 +21,7 @@ -- 2023/01/20 Modificata PutStartNearestToEdge per gestire lato preferito come Y+, Y-, z*, Z-. Aggiunta funzione GetDistanceToNextPart. -- 2023/01/31 Aggiunta funzione ConvertToClosedCurve, precedentemente parte di ProcessMortise.Make -- 2023/02/22 Modifiche a SetOpenSide, aggiunte ChangeOrOpenStart e CurveWithOnlyStraightLines. +-- 2023/06/12 In ChangeOrOpenStart corretta ricerca segmento più lungo. -- Tabella per definizione modulo local BeamLib = {} @@ -966,8 +967,8 @@ function BeamLib.ChangeOrOpenStart( nPathInt, nStartPoint) end -- recupero l'indice del segmento aperto più lungo local nMaxOpen, dMaxLen - local vOpen = EgtGetInfo( nPathInt or GDB_ID.NULL, 'OPEN') - for i = 0, #( vOpen or {}) do + local vOpen = EgtGetInfo( nPathInt or GDB_ID.NULL, 'OPEN', 'vi') + for i = 1, #( vOpen or {}) do -- se primo o più lungo, lo salvo local dLen = EgtCurveCompoLength( nPathInt, vOpen[i]) if not dMaxLen or dLen > dMaxLen then diff --git a/LuaLibs/FaceByPocket.lua b/LuaLibs/FaceByPocket.lua index 4d8bdcb..f4f389a 100644 --- a/LuaLibs/FaceByPocket.lua +++ b/LuaLibs/FaceByPocket.lua @@ -1,4 +1,4 @@ --- FaceByPocket.lua by Egaltech s.r.l. 2022/05/82 +-- FaceByPocket.lua by Egaltech s.r.l. 2023/04/04 -- Gestione svuotatura di feature con una faccia -- Tabella per definizione modulo @@ -15,7 +15,7 @@ local BD = require( 'BeamData') local ML = require( 'MachiningLib') --------------------------------------------------------------------- -local function ApplyPocket( Proc, nSurfId, nFacet, sPocketing, nInd, dMaxElev, vtN) +local function ApplyPocket( Proc, nSurfId, nFacet, sPocketing, nInd, dMaxElev, vtN, dOpenMinSafe) -- inserisco la lavorazione di svuotatura local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. nInd @@ -28,11 +28,17 @@ local function ApplyPocket( Proc, nSurfId, nFacet, sPocketing, nInd, dMaxElev, v EgtSetMachiningGeometry( {{ nSurfId, nFacet}}) -- imposto uso faccia EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_CONT) + -- imposto note utente + local sNotes = '' + -- eventuale massima elevazione if dMaxElev > 0.1 then - -- imposto elevazione - local sNotes = 'MaxElev=' .. EgtNumToString( dMaxElev, 2) .. ';' - EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) + sNotes = EgtSetValInNotes( sNotes, 'MaxElev', EgtNumToString( dMaxElev, 2)) end + -- eventuale minima distanza di sicurezza di attacco su lati aperti + if dOpenMinSafe then + sNotes = EgtSetValInNotes( sNotes, 'OpenMinSafe', dOpenMinSafe) + end + EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) -- imposto posizione braccio porta testa local nSCC = MCH_SCC.NONE if not BD.C_SIMM and not BD.TURN then @@ -50,7 +56,7 @@ local function ApplyPocket( Proc, nSurfId, nFacet, sPocketing, nInd, dMaxElev, v end --------------------------------------------------------------------- -function FaceByPocket.Make( Proc, nSurfId, nFacet, sPocketing, nPartId, b3Solid) +function FaceByPocket.Make( Proc, nSurfId, nFacet, sPocketing, nPartId, b3Solid, dOpenMinSafe) local bOk = true local sErr -- recupero gruppo per geometria addizionale @@ -84,14 +90,14 @@ function FaceByPocket.Make( Proc, nSurfId, nFacet, sPocketing, nPartId, b3Solid) EgtSetName( nAddIdTmp, 'AddCut_' .. tostring( Proc.Id)) EgtSetInfo( nAddIdTmp, 'TASKID', Proc.TaskId) -- aggiungo lavorazione - bOk, sErr = ApplyPocket( Proc, nAddIdTmp, 0, sPocketing, i, dSurfStep, vtN) + bOk, sErr = ApplyPocket( Proc, nAddIdTmp, 0, sPocketing, i, dSurfStep, vtN, dOpenMinSafe) if not bOk then return false, sErr end end end -- faccio ultima superfice - bOk, sErr = ApplyPocket( Proc, nSurfId, nFacet, sPocketing, 1, EgtIf( nSurfStep > 1, dSurfStep, 0), vtN) + bOk, sErr = ApplyPocket( Proc, nSurfId, nFacet, sPocketing, 1, EgtIf( nSurfStep > 1, dSurfStep, 0), vtN, dOpenMinSafe) if not bOk then return false, sErr end diff --git a/LuaLibs/FacesBySaw.lua b/LuaLibs/FacesBySaw.lua index 6d04a30..4a66190 100644 --- a/LuaLibs/FacesBySaw.lua +++ b/LuaLibs/FacesBySaw.lua @@ -1,4 +1,4 @@ --- FacesBySaw.lua by Egaltech s.r.l. 2022/09/24 +-- FacesBySaw.lua by Egaltech s.r.l. 2023/06/14 -- Gestione taglio con lama di feature con una o due facce -- 2021/01/06 Cambiato limite per attacco Tg con lama e CalcLeadInOutGeom rinominata in CalcLeadInOutPerpGeom. -- 2021/02/03 In taglio lama si accettano anche due lati con deviazione minore di 20deg. @@ -14,6 +14,9 @@ -- 2022/06/29 DS In MakeTwo modificato controllo facce dirette verso il basso. -- 2022/09/08 In MakeOne aggiunto argomento bForceInvert per poter forzare l'inversione del percorso. -- 2023/02/13 Migliorata la direzione di lavoro della lama in modo da essere tendenzialmente opposta all'avanzamento. +-- 2023/04/20 Alcune modifiche per gestire tagli con faceuse parallelo. +-- 2023/05/18 Imposto in ogni caso dVzLimDwnUp prima anche di bDownHead. +-- 2023/06/14 Aggiunta MakeParallelOne e tolti parametri nForceWorkSide, nForceSCC da MakeOne. -- Tabella per definizione modulo local FacesBySaw = {} @@ -29,8 +32,125 @@ EgtOutLog( ' FacesBySaw started', 1) local BD = require( 'BeamData') local ML = require( 'MachiningLib') +--------------------------------------------------------------------- +function MakeParallelOne( nSurfId, nFacet, sCutting, dSawDiam, nFaceUse, dVzLimDwnUp, dCutExtra, dCutSic, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw, bForceInvert) + -- dati della faccia + local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, nFacet, GDB_ID.ROOT) + -- accetto solo facce perpendicolari all'asse X della trave + if not AreSameOrOppositeVectorApprox( vtN, X_AX()) then + EgtOutLog( 'Error : MakeParallelOne only for faces perpendicular to XAxis') + return false + end + -- l'uso della faccia deve consentire una scelta robusta del percorso + if nFaceUse == MCH_MILL_FU.PARAL_LEFT or + nFaceUse == MCH_MILL_FU.PARAL_RIGHT then + EgtOutLog( 'Error : MakeParallelOne impossible with PARAL_LEFT or PARAL_RIGHT FaceUse') + return false + end + -- distanza della faccia dall'estremo trave verso cui è rivolta + local dDistX = EgtIf( vtN:getX() > 0, b3Raw:getMax():getX() - ptC:getX(), ptC:getX() - b3Raw:getMin():getX()) + -- lunghezza attacco/uscita perpendicolari + local dLiTang = 0 + local dLiPerp = dDistX + dCutExtra + dCutSic + local dLoTang = dLiTang + local dLoPerp = dLiPerp + -- lunghezza attacco/uscita tangenti + local dLi2Tang = dSawDiam / 2 + dCutSic + local dLi2Perp = 0 + local dLo2Tang = dLi2Tang + local dLo2Perp = dLi2Perp + -- scelgo l'attacco più conveniente + local bLioTang + local Ktp = 1.1 + if BD.KIOTP then Ktp = BD.KIOTP end + if Ktp * dLi2Tang < dLiPerp then + bLioTang = true + dLiTang, dLiPerp, dLoTang, dLoPerp = dLi2Tang, dLi2Perp, dLo2Tang, dLo2Perp + if BD.TURN then + local dMove = EgtIf( nFaceUse == MCH_MILL_FU.PARAL_DOWN or nFaceUse == MCH_MILL_FU.PARAL_TOP, b3Raw:getDimY(), b3Raw:getDimZ()) + dLoTang = -( dLiTang - dAccStart - dAccEnd + dMove) + dLoPerp = BD.COLL_SIC + end + end + -- verifico se la lama ruota in senso antiorario + if not EgtMdbSetCurrMachining( sCutting) then + return false + end + local bIsSawCCW = ( EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) < 0) + local bInvert = bForceInvert + -- se la lama ruota in senso antiorario inverto la direzione di lavorazione, per avere rotazione lama opposta a avanzamento + if bInvert == nil then + bInvert = ( not bIsSawCCW) + if not BD.TURN then + if bIsSawCCW then + bInvert = (( nFaceUse == MCH_MILL_FU.PARAL_FRONT and vtN:getX() > 0) or ( nFaceUse == MCH_MILL_FU.PARAL_BACK and vtN:getX() < 0)) + else + bInvert = (( nFaceUse == MCH_MILL_FU.PARAL_FRONT and vtN:getX() < 0) or ( nFaceUse == MCH_MILL_FU.PARAL_BACK and vtN:getX() > 0)) + end + end + end + local nWorkSide = EgtIf( bInvert, MCH_MILL_WS.LEFT, MCH_MILL_WS.RIGHT) + -- posizione braccio + local nSCC = MCH_SCC.NONE + if BD.TURN then + nSCC = EgtIf( nFaceUse == MCH_MILL_FU.PARAL_DOWN or nFaceUse == MCH_MILL_FU.PARAL_TOP, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_ZP) + else + nSCC = EgtIf( vtN:getX() > 0, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) + end + -- inserisco la lavorazione di taglio + local sName = 'Cut_' .. ( EgtGetName( nSurfId) or tostring( nSurfId)) .. '_' .. tostring( nFacet + 1) + local nMchFId = EgtAddMachining( sName, sCutting) + if not nMchFId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sCutting + EgtOutLog( sErr) + return false, sErr + end + sName = EgtGetOperationName( nMchFId) + -- aggiungo geometria + EgtSetMachiningGeometry( {{ nSurfId, nFacet}}) + -- imposto uso faccia + EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) + -- imposto posizione braccio porta testa + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- imposto inversione e lato correzione + EgtSetMachiningParam( MCH_MP.INVERT, bInvert) + EgtSetMachiningParam( MCH_MP.WORKSIDE, nWorkSide) + -- affondamento aggiuntivo + EgtSetMachiningParam( MCH_MP.OFFSR, -dCutExtra) + -- offset longitudinale + EgtSetMachiningParam( MCH_MP.OFFSL, EgtIf( bDownUp, -dCutOffset, dCutOffset)) + -- imposto attacco/uscita + EgtSetMachiningParam( MCH_MP.LITANG, dLiTang) + EgtSetMachiningParam( MCH_MP.LIPERP, dLiPerp) + 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) + -- imposto allungamenti iniziale e finale + EgtSetMachiningParam( MCH_MP.STARTADDLEN, -dAccStart) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, -dAccEnd) + -- eventuali note + if sNotes and #sNotes > 0 then EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) end + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + return true, sName, nMchFId +end + --------------------------------------------------------------------- function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDwnUp, dCutExtra, dCutSic, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw, bForceInvert) + -- 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 + Par5 == MCH_MILL_FU.PARAL_FRONT or + 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) + end + -- la lama ha asse perpendicolare alla faccia -- dati della faccia local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, nFacet, GDB_ID.ROOT) -- risolvo parametro ambiguo @@ -43,8 +163,10 @@ function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDw nOrthoOpposite = Par5 vtOrthO = BL.GetVersRef( Par5) end - -- verifico se testa da sotto + -- verifico se testa da sotto oppure se lavorazione sotto con testa da sopra + if not dVzLimDwnUp then dVzLimDwnUp = BL.GetNzLimDownUp( b3Raw, vtN, vtOrthO) end local bDownHead = ( dVzLimDwnUp and dVzLimDwnUp < - 1.5) + local bDownUp = ( vtN:getZ() < dVzLimDwnUp) -- linea o bilinea di lavorazione (qui uso nOrthoOpposite per ripetere esattamente il calcolo del Mach) local ptP1, ptPm, ptP2, vtV1, vtV2, dLen, dWidth = EgtSurfTmFacetOppositeSide( nSurfId, nFacet, BL.GetVersRef( nOrthoOpposite), GDB_ID.ROOT) if not dLen or dLen < 1.1 or not dWidth or dWidth < 1.1 then @@ -53,24 +175,24 @@ function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDw return true, '' end vtV1 = - vtV1 - -- verifico se lavorazione con lama sotto e testa sopra - if not dVzLimDwnUp then dVzLimDwnUp = BL.GetNzLimDownUp( b3Raw, vtN, vtOrthO) end - local bDownUp = ( vtN:getZ() < dVzLimDwnUp) - -- verifico se la lama ruota in senso orario + -- verifico se la lama ruota in senso antiorario if not EgtMdbSetCurrMachining( sCutting) then return false end - local bIsSawCW = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) < 0 + local bIsSawCCW = ( EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) < 0) local bInvert = bForceInvert - -- se la lama ruota in senso orario inverto la direzione di lavorazione, per avere rotazione lama opposta a avanzamento - if bInvert == nil and bIsSawCW and not bDownUp then - if ( ptP2:getZ() > ptP1:getZ() + 100 * GEO.EPS_SMALL) then - bInvert = false + -- se la lama ruota in senso antiorario inverto la direzione di lavorazione, per avere rotazione lama opposta a avanzamento + if bInvert == nil then + if not BD.TURN then + if bIsSawCCW and not bDownUp then + bInvert = ( ptP2:getZ() < ptP1:getZ() + 100 * GEO.EPS_SMALL) + else + bInvert = ( ptP2:getZ() < ptP1:getZ() - 100 * GEO.EPS_SMALL) + end else - bInvert = true + local vtTmp = ptP2 - ptP1 ; vtTmp:normalize() + bInvert = ( ( vtOrthO:getX() > 0.1 and vtTmp:getX() < -0.1) or ( vtOrthO:getX() < -0.1 and vtTmp:getX() > 0.1)) end - elseif bInvert == nil then - bInvert = ( ptP2:getZ() < ptP1:getZ() - 100 * GEO.EPS_SMALL) end if bInvert then ptP1, ptP2 = ptP2, ptP1 @@ -136,18 +258,16 @@ function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDw -- parametri di attacco/uscita local b3Box = BBox3d( b3Raw) b3Box:expand( dCutSic) - local ptP1act = ptP1 + vtN * dCutOffset - local ptP2act = ptP2 + vtN * dCutOffset -- attacco perpendicolare - local dLiTang, dLiPerp, dLoTang, dLoPerp, vtLio = FacesBySaw.CalcLeadInOutPerpGeom( ptP1act, ptP2act, vtV1, vtV2, vtN, dSawDiam/2, vtRef, dCutExtra, b3Box) + local dLiTang, dLiPerp, dLoTang, dLoPerp, vtLio = FacesBySaw.CalcLeadInOutPerpGeom( ptP1, ptP2, vtV1, vtV2, vtN, dSawDiam/2, vtRef, dCutExtra, b3Box) local dLenLi = sqrt( dLiTang * dLiTang + dLiPerp * dLiPerp) local dLenLo = sqrt( dLoTang * dLoTang + dLoPerp * dLoPerp) -- attacco tangente - local dLi2Tang, dLi2Perp, dLo2Tang, dLo2Perp = FacesBySaw.CalcLeadInOutTangGeom( ptP1act, ptP2act, vtN, dSawDiam/2, vtRef, dCutExtra, b3Box) + local dLi2Tang, dLi2Perp, dLo2Tang, dLo2Perp = FacesBySaw.CalcLeadInOutTangGeom( ptP1, ptP2, vtN, dSawDiam/2, vtRef, dCutExtra, b3Box) local dLenLi2 = abs( dLi2Tang) local dLenLo2 = abs( dLo2Tang) -- scelgo l'attacco più conveniente (se non taglio praticamente longitudinale) - local bTurnTang + local bLioTang local Ktp = 1.1 if BD.KIOTP then Ktp = BD.KIOTP end if ( not bDownUp or abs( vtTg:getY()) > 0.5) and @@ -156,10 +276,11 @@ function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDw ( ( abs( vtTg:getZ()) < 0.17 and ( vtV1:getZ() < -0.5 or vtV2:getZ() < -0.5) and not bDownHead) or ( abs( vtTg:getZ()) < 0.51 and b3Box:getDimZ() > 300 and BD.C_SIMM and BD.MAX_HEIGHT > 450 and b3Box:getDimX() > BD.LEN_SHORT_PART) or ( abs( vtTg:getZ()) < 0.51 and ( dLenLi2 + dLenLo2) < ( dLenLi + dLenLo)) or Ktp * ( dLenLi2 + dLenLo2) < ( dLenLi + dLenLo)) then + bLioTang = true dLiTang, dLiPerp, dLoTang, dLoPerp = dLi2Tang, dLi2Perp, dLo2Tang, dLo2Perp if BD.TURN then - bTurnTang = true - dLoTang = -( dLiTang + dAllStart - dAccStart + dAllEnd - dAccEnd + dLen) + local dMove = dist( ptP1, ptP2) + dLoTang = -( dLiTang + dAllStart - dAccStart + dAllEnd - dAccEnd + dMove) dLoPerp = BD.COLL_SIC end end @@ -173,8 +294,9 @@ function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDw nSCC = EgtIf( ( vtAux:getY() > -GEO.EPS_SMALL), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) end else - if bTurnTang then - local vtTest = EgtIf( bInvert, vtTg, -vtTg) + if bLioTang then + --local vtTest = EgtIf( bInvert, vtTg, -vtTg) + local vtTest = -vtTg if abs( vtTest:getY()) > abs( vtTest:getZ()) then nSCC = EgtIf( vtTest:getY() > 0, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) else @@ -220,7 +342,7 @@ function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDw -- imposto attacco/uscita EgtSetMachiningParam( MCH_MP.LITANG, dLiTang) EgtSetMachiningParam( MCH_MP.LIPERP, dLiPerp) - if bTurnTang then EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.PERP_TG) end + 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) -- imposto allungamenti iniziale e finale @@ -270,7 +392,7 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutType, return false, sErr end local ptM = ( ptT1 + ptT2) / 2 - local vtTg = ptT2 - ptT1 ; + local vtTg = ptT2 - ptT1 ; vtTg:normalize() local bConvex = ( dAngT > 0) -- verifico non siano orientate troppo verso il basso e molto sbandate (oltre 10 deg) local bFaceOk = {} @@ -286,14 +408,14 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutType, vtRef[1] = vtN[1] ^ vtTg if vtRef[1] * vtN[2] < 0 then vtRef[1] = - vtRef[1] end vtRef[1]:normalize() - if abs( vtRef[1]:getZ()) < 0.577 and abs( abs( vtRef[1]:getX()) - abs( vtRef[1]:getY())) < 0.1 then + if abs( vtTg:getZ()) < 0.708 and abs( vtRef[1]:getZ()) < 0.577 and abs( abs( vtRef[1]:getX()) - abs( vtRef[1]:getY())) < 0.1 then vtRef[1] = ptC[1] - ptM vtRef[1]:normalize() end vtRef[2] = vtN[2] ^ vtTg if vtRef[2] * vtN[1] < 0 then vtRef[2] = - vtRef[2] end vtRef[2]:normalize() - if abs( vtRef[2]:getZ()) < 0.577 and abs( abs( vtRef[2]:getX()) - abs( vtRef[2]:getY())) < 0.1 then + if abs( vtTg:getZ()) < 0.708 and abs( vtRef[2]:getZ()) < 0.577 and abs( abs( vtRef[2]:getX()) - abs( vtRef[2]:getY())) < 0.1 then vtRef[2] = ptC[2] - ptM vtRef[2]:normalize() end @@ -306,7 +428,7 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, dOvmHead, sCutType, local nOtInd = 3 - nUpInd -- metto in relazione la scelta facce con il confronto del versore Z con la scelta in base alla grandezza faccia -- se la faccia più grande è messa secondaria e il suo versore Z non è troppo negativo - if nOtInd == nBigInd and vtN[nBigInd]:getZ() > -0.5 and vtN[nSmaInd]:getZ() < 0.966 then + if nOtInd == nBigInd and (( vtN[nBigInd]:getZ() > -0.5 and vtN[nSmaInd]:getZ() < 0.966) or bDownHead) then nUpInd = nBigInd nOtInd = nSmaInd end diff --git a/LuaLibs/ProcessCut.lua b/LuaLibs/ProcessCut.lua index cacc7f2..3c01e54 100644 --- a/LuaLibs/ProcessCut.lua +++ b/LuaLibs/ProcessCut.lua @@ -1,4 +1,4 @@ --- ProcessCut.lua by Egaltech s.r.l. 2022/12/19 +-- ProcessCut.lua by Egaltech s.r.l. 2023/04/05 -- Gestione calcolo singoli tagli di lama per Travi -- 2021/05/18 I due tagli con testa da sotto di un cubetto sono fatti di seguito. -- 2021/06/06 Correzioni per tagli con testa da sotto. @@ -18,6 +18,7 @@ -- 2022/08/30 Modificata la condizione che determina l'utilizzo della testa da sotto. Ora controlla se la trave è più grande del doppio della massima larghezza del cubetto. -- 2022/09/23 Corretta la condizione per cui è richiesto l'aggiornamento del grezzo. -- 2023/01/26 Migliorata la direzione di lavoro della lama in alcuni casi in cui il truciolo veniva scaricato dal lato errato. +-- 2023/06/19 Aggiunti tagli speciali per evitare il rischio che il cubetto rimanga appoggiato al motore. -- Tabella per definizione modulo local ProcessCut = {} @@ -395,6 +396,19 @@ local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, b if bCustDiceCut and #vCuts == 0 then return false, -1 end + + -- per caso speciale in cui c'è il rischio che il cubetto rimanga appoggiato sul motore, faccio solo i tagli perpendicolari seguiti da due tagli verticali laterali + local bDangerousReliefCut = false + local frFace = BL.GetFaceHvRefDim( Proc.Id, 0) + -- verifico che i tagli perpendicolari siano perpendicolari al lato più vicino a Z + local nFirstPerpendicularCut = ( #vCuts ~= 0 and ( vCuts[1][1] or vCuts[3][1])) + if nFirstPerpendicularCut then + local vtTemp = EgtSurfTmFacetNormVersor( nFirstPerpendicularCut, 0, GDB_ID.ROOT) ^ frFace:getVersX() + if #vCuts > 0 and not ( vtTemp:isSmall()) and not ( bDownCut or bFromBottom) and not bLongCut then + bDangerousReliefCut = true + end + end + --DC.PrintOrderCut( vCuts) if #vCuts > 0 then -- sistemo posizione nel DB e nome @@ -453,44 +467,67 @@ local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, b end end end - -- lavoro la faccia - for j = 1, #vCuts[i] do - -- se taglio dal basso - if bDownCut then - -- se strato pari composto da 1 o 2 elementi - if ( i % 2) == 0 and #vCuts[i] <= 2 then - -- il primo elemento prende la direzione prevista, il secondo quella opposta - local vtNewOrthoO = Vector3d( vtOrthoO) - local dVzLimDwnUp = dNzLimDwnUp - if j ~= 1 then - vtNewOrthoO = -vtOrthoO - if not BD.C_SIMM and not BD.TURN and abs( vtN:getY()) > 0.05 then dVzLimDwnUp = -0.708 end + local nCurrentParallelFace = EgtSurfTmBySewing( nAddGrpId, vCuts[i], false) + local _, dDiceFaceH = BL.GetFaceHvRefDim( nCurrentParallelFace or GDB_ID.NULL, 0, b3Raw) + -- caso speciale con rischio cubetto sul motore + if ( i % 2 == 0) and bDangerousReliefCut and ( dMaxDepth * 2 > dDiceFaceH + BD.CUT_EXTRA) then + local bDoubleCut = false + local dCutExtra = BD.CUT_EXTRA + if dMaxDepth < dDiceFaceH + BD.CUT_EXTRA then + bDoubleCut = true + dCutExtra = - 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA + end + local nFaceUseCut1, nFaceUseCut2 = MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT + if Proc.Tail then + nFaceUseCut1, nFaceUseCut2 = nFaceUseCut2, nFaceUseCut1 + end + if bDoubleCut then + local bOk, sErr = Fbs.MakeOne( nCurrentParallelFace, 0, sCutting, dSawDiam, nFaceUseCut1, nil, dCutExtra, BD.CUT_SIC, 0, 0, 0, '', b3Raw, true) + if not bOk then return false, sErr end + end + local bOk2, sErr2 = Fbs.MakeOne( nCurrentParallelFace, 0, sCutting, dSawDiam, nFaceUseCut2, nil, dCutExtra, BD.CUT_SIC, 0, 0, 0, '', b3Raw) + if not bOk2 then return false, sErr2 end + -- caso standard + else + -- lavoro la faccia + for j = 1, #vCuts[i] do + -- se taglio dal basso + if bDownCut then + -- se strato pari composto da 1 o 2 elementi + if ( i % 2) == 0 and #vCuts[i] <= 2 then + -- il primo elemento prende la direzione prevista, il secondo quella opposta + local vtNewOrthoO = Vector3d( vtOrthoO) + local dVzLimDwnUp = dNzLimDwnUp + if j ~= 1 then + vtNewOrthoO = -vtOrthoO + if not BD.C_SIMM and not BD.TURN and abs( vtN:getY()) > 0.05 then dVzLimDwnUp = -0.708 end + end + local bOk, sErr = Fbs.MakeOne( vCuts[i][j], 0, sCutting, dSawDiam, vtNewOrthoO, dVzLimDwnUp, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, 0, nil, b3Raw) + if not bOk then return bOk, sErr end end - local bOk, sErr = Fbs.MakeOne( vCuts[i][j], 0, sCutting, dSawDiam, vtNewOrthoO, dVzLimDwnUp, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, 0, nil, b3Raw) + -- tutti gli altri casi vengono saltati + -- caso generale + else + -- in generale sta sollevato di pochissimo + local dExtraCut = -0.1 + -- se tagli paralleli + if ( i % 2) == 0 then + -- se non ci sono tagli ortogonali devo affondare + if bNoPerpCuts then + dExtraCut = BD.CUT_EXTRA + -- se altrimenti tagli ortogonali invertiti, devo approfondire dello spessore lama + elseif bOrthInv then + dExtraCut = dSawThick + -- se ultimo taglio, devo affondare + elseif j == #vCuts[i] then + dExtraCut = BD.CUT_EXTRA + end + end + local dVzLimDwnUp = dNzLimDwnUp + if not BD.C_SIMM and not BD.TURN and vtN:getZ() > 0.707 then dVzLimDwnUp = -0.708 end + local bOk, sErr = Fbs.MakeOne( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, dVzLimDwnUp, dExtraCut, BD.CUT_SIC, 0, 0, 0, sNotes, b3Raw) if not bOk then return bOk, sErr end end - -- tutti gli altri casi vengono saltati - -- caso generale - else - -- in generale sta sollevato di pochissimo - local dExtraCut = -0.1 - -- se tagli paralleli - if ( i % 2) == 0 then - -- se non ci sono tagli ortogonali devo affondare - if bNoPerpCuts then - dExtraCut = BD.CUT_EXTRA - -- se altrimenti tagli ortogonali invertiti, devo approfondire dello spessore lama - elseif bOrthInv then - dExtraCut = dSawThick - -- se ultimo taglio, devo affondare - elseif j == #vCuts[i] then - dExtraCut = BD.CUT_EXTRA - end - end - local dVzLimDwnUp = dNzLimDwnUp - if not BD.C_SIMM and not BD.TURN and vtN:getZ() > 0.707 then dVzLimDwnUp = -0.708 end - local bOk, sErr = Fbs.MakeOne( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, dVzLimDwnUp, dExtraCut, BD.CUT_SIC, 0, 0, 0, sNotes, b3Raw) - if not bOk then return bOk, sErr end end end end @@ -507,7 +544,7 @@ local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, b local vtOrthoO if bFromBottom and dCutV < dMaxVertDepth - BD.CUT_EXTRA and vtN:getZ() > 0 then vtOrthoO = -Z_AX() - elseif bHorizCut and ( not bVertCutOk or b3Solid:getDimX() > BD.LEN_SHORT_PART or Proc.AdvTail or vtN:getX() > 0 or ( abs( vtN:getY()) < 0.1 and vtN:getZ() <= 0)) then + elseif bHorizCut and ( not bVertCutOk or b3Solid:getDimX() > BD.LEN_SHORT_PART or Proc.AdvTail or ( vtN:getX() > 0 and vtN:getZ() <= 0.708) or ( abs( vtN:getY()) < 0.1 and vtN:getZ() <= 0)) then vtOrthoO = Z_AX() elseif b3Solid:getDimX() < BD.LEN_SHORT_PART and not Proc.AdvTail and abs( vtN:getY()) > 0.259 and vtN:getZ() > -0.174 and abs( vtN:getY()) > abs( vtN:getZ()) and dCutH < dMaxDepth + 10 * GEO.EPS_SMALL then @@ -767,7 +804,9 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom, -- recupero la lavorazione local sCutType = EgtIf( Proc.Head, 'HeadSide', 'TailSide') local sCutting - sCutting, bDownHead = ML.FindCutting( sCutType, bTopHead, bDownHead) + local bH2 + sCutting, bH2 = ML.FindCutting( sCutType, bTopHead, bDownHead) + bDownHead = bH2 and bDownHead if not sCutting then local sErr = 'Error : cutting not found in library' EgtOutLog( sErr) diff --git a/LuaLibs/ProcessDrill.lua b/LuaLibs/ProcessDrill.lua index 22eadcc..61f5964 100644 --- a/LuaLibs/ProcessDrill.lua +++ b/LuaLibs/ProcessDrill.lua @@ -1,4 +1,4 @@ --- ProcessDrill.lua by Egaltech s.r.l. 2022/11/30 +-- ProcessDrill.lua by Egaltech s.r.l. 2023/05/11 -- Gestione calcolo forature per Travi -- 2021/04/14 DS Corretta gestione Invert con testa da sotto. Migliorato calcolo ingombro portautensile. -- 2021/05/03 DS Su macchina con testa da sotto aggiunta possibilità di fare fori verticali metà sopra e l'altra sotto. @@ -16,6 +16,7 @@ -- 2022/10/25 Nella funzione Split aggiunto il controllo che le facce di ingresso e uscita siano differenti (potrebbe succedere per fori molto corti). Modifica importatore in futuro. -- 2022/11/23 Aggiunta la gestione dei fori con angolo < 30 gradi, per i quali si usa la testa della macchina per accorciare l'utile di lavoro. -- 2022/12/28 Implementata gestione forature in doppio +-- 2023/05/11 Se lavorazione in doppio e precedente no oppure di tipo diverso, forzo risalita a Zmax. -- Tabella per definizione modulo local ProcessDrill = {} @@ -155,6 +156,10 @@ function ProcessDrill.Classify( Proc, b3Raw) ptCen = ptCen + vtExtr * dLen end end + -- verifico se foro annegato nel pezzo e quindi non lavorabile + if Proc.Fcs == 0 and Proc.Fce == 0 then + return false, false, false + end -- verifico se troppo inclinato e quindi non lavorabile if not ( Proc.Fcs == 5 or Proc.Fcs == 6 or Proc.Fce == 5 or Proc.Fce == 6) and abs( vtExtr:getX()) > BD.DRILL_VX_MAX then return false, false, false @@ -236,7 +241,7 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) end local bOpen = ( Proc.Fcs ~= 0 and Proc.Fce ~= 0) -- verifico possibilità di foratura da sotto - local bDownDrill = ( BD.DOWN_HEAD and ML.FindDrilling( dDiam, nil, false, true)) + local bDownDrill = ( BD.TURN or ( BD.DOWN_HEAD and ML.FindDrilling( dDiam, nil, false, true))) -- verifico che il foro non sia fattibile solo da sotto local bToInvert = ( vtExtr:getZ() < BD.DRILL_VZ_MIN and not bDownDrill) if bToInvert and ( not bOpen or Proc.Flg ~= 1) then @@ -245,10 +250,10 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) return false, sErr end -- se non già richiesta inversione e invertibile - if not bToInvert and Proc.Flg == 1 and ( -vtExtr:getZ() >= BD.DRILL_VZ_MIN or bDownDrill) then - -- se il foro è cieco o troppo inclinato all'inizio, lo inverto - local _, CosB, _ = GetHoleStartData( ptCen, vtExtr, b3Solid) - if Proc.Fcs == 0 or ( CosB > BD.DRILL_VX_MAX and bOpen) then + if not bToInvert and Proc.Flg == 1 and -vtExtr:getZ() >= BD.DRILL_VZ_MIN then + -- se il foro è cieco o dalla faccia sotto o troppo inclinato all'inizio, lo inverto + local nFac, CosB, _ = GetHoleStartData( ptCen, vtExtr, b3Solid) + if Proc.Fcs == 0 or (( nFac == 2 or CosB > BD.DRILL_VX_MAX) and bOpen) then bToInvert = true end end @@ -494,6 +499,9 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId) -- se lavorazione in doppio if Proc.Double and Proc.Double > 0 then sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', Proc.Double) + if Proc.Double ~= Proc.PrevDouble then + sUserNotes = EgtSetValInNotes( sUserNotes, 'StartZmax', 2) + end end EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- eseguo diff --git a/LuaLibs/ProcessDtMortise.lua b/LuaLibs/ProcessDtMortise.lua index 3094959..870af05 100644 --- a/LuaLibs/ProcessDtMortise.lua +++ b/LuaLibs/ProcessDtMortise.lua @@ -1,4 +1,4 @@ --- ProcessDtMortise.lua by Egaltech s.r.l. 2023/03/06 +-- ProcessDtMortise.lua by Egaltech s.r.l. 2023/05/11 -- Gestione calcolo mortase a coda di rondine per Travi -- 2021/04/08 Aggiunto controllo massimo materiale lavorabile dalla fresa. -- 2021/04/08 Miglioria scelta lavorazione in presenza di testa da sotto. @@ -10,6 +10,8 @@ -- 2022/09/29 Aggiunto riconoscimento della sola feature laterale. -- 2022/12/28 Aggiunta gestione lavorazione in doppio. -- 2023/03/06 Aggiunta forzatura ingresso fuori dal grezzo con pocket. +-- 2023/03/28 Corretto calcolo larghezza mortasa quando più larga che lunga. +-- 2023/05/11 Se lavorazione in doppio e precedente no oppure di tipo diverso, forzo risalita a Zmax. -- Tabella per definizione modulo local ProcessDtMortise = {} @@ -177,13 +179,17 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtOutLog( sErr) return false, sErr end - -- determino l'altezza della mortasa (0=faccia di fondo) - local rfDtMrt, dLenMrt, dWidthMrt = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 0, GDB_RT.GLOB) - local b3DtMrt = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, rfDtMrt) - local dAltMort = b3DtMrt:getDimZ() - -- ne determino l'asse (valido se non pocket) + -- ne determino l'asse local vtAx = EgtEV( AuxId, GDB_RT.GLOB) - EgtSV( AuxId, GDB_RT.GLOB) vtAx:normalize() + -- determino l'altezza della mortasa (0=faccia di fondo) + local rfDtMrt, dLenMrt, dWidthMrt = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 0, GDB_RT.GLOB) + if abs( rfDtMrt:getVersY() * vtAx) > abs( rfDtMrt:getVersX() * vtAx) then + rfDtMrt:rotate( rfDtMrt:getOrigin(), rfDtMrt:getVersZ(), 90) + dLenMrt, dWidthMrt = dWidthMrt, dLenMrt + end + local b3DtMrt = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, rfDtMrt) + local dAltMort = b3DtMrt:getDimZ() -- verifico se di tipo pocket local bPocket = ( EgtGetInfo( Proc.Id, 'P05', 'i') == 1) if bPocket then bMakeAntiSplitPath = false end @@ -284,7 +290,7 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtOutLog( sErr) return false, sErr end - -- se con tasca, la lavoro + -- se con tasca, la lavoro (mai in doppio) if bPocket then -- recupero il contorno della tasca (seconda curva ausiliaria) local sVal = EgtGetInfo( Proc.Id, 'AUXID') @@ -345,6 +351,8 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) nSCC = EgtIf( vtAx:getZ() > 0, MCH_SCC.ADIR_ZP, MCH_SCC.ADIR_ZM) end end + -- flag di mirror precedente aggiornabile localmente + local nMyPrevDouble = Proc.PrevDouble -- se parametro interno abilitato e il percorso non è chiuso, aggiungo percorso e lavorazione antischeggia if bMakeAntiSplitPath and not EgtCurveIsClosed( AuxId) then -- recupero gruppo per geometria addizionale @@ -426,6 +434,10 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- se lavorazione in doppio if Proc.Double and Proc.Double > 0 then sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', Proc.Double) + if Proc.Double ~= nMyPrevDouble then + nMyPrevDouble = Proc.Double + sUserNotes = EgtSetValInNotes( sUserNotes, 'StartZmax', 2) + end end EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- eseguo @@ -511,6 +523,10 @@ function ProcessDtMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- se lavorazione in doppio if Proc.Double and Proc.Double > 0 then sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', Proc.Double) + if Proc.Double ~= nMyPrevDouble then + nMyPrevDouble = Proc.Double + sUserNotes = EgtSetValInNotes( sUserNotes, 'StartZmax', 2) + end end EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- eseguo diff --git a/LuaLibs/ProcessFreeContour.lua b/LuaLibs/ProcessFreeContour.lua index d56a7eb..69d0089 100644 --- a/LuaLibs/ProcessFreeContour.lua +++ b/LuaLibs/ProcessFreeContour.lua @@ -7,6 +7,7 @@ -- 2022/11/24 In MakeByMill aggiunta la lavorazione sopra/sotto nel caso di testa sotto -- In MakeByMill se BeamData forza lettura codolo da Q questo viene sempre fatto indipendentemente dalle dimensioni della feature -- 2023/03/03 Corretta MakeByMark ( non definiti b3Raw e b3Aux ). +-- 2023/06/21 In CalcSpecialAdd modificato l'angolo minimo da 5 a 15 deg. -- Tabella per definizione modulo local ProcessFreeContour = {} @@ -206,8 +207,8 @@ local function CalcSpecialAdd( nCrv, bStartVsEnd, dToolDiam) -- tangenti prima e dopo il punto interno local vtPrev = EgtUV( nCrv, nIn, -1) local vtNext = EgtUV( nCrv, nIn, 1) - -- se c'è perdita di tangenza (delta angolare oltre i 5 gradi) - if vtPrev * vtNext < 0.996 then + -- se c'è perdita di tangenza (delta angolare oltre i 15 gradi) + if vtPrev * vtNext < 0.966 then -- lunghezza del tratto local ptP0 = EgtUP( nCrv, nOut) local ptP1 = EgtUP( nCrv, nIn) diff --git a/LuaLibs/ProcessHeadCut.lua b/LuaLibs/ProcessHeadCut.lua index 51f397b..8a486cb 100644 --- a/LuaLibs/ProcessHeadCut.lua +++ b/LuaLibs/ProcessHeadCut.lua @@ -6,6 +6,7 @@ -- 2022/09/08 Migliorato verso di lavorazione in caso di DoubleCut -- 2022/11/02 Corretti accorciamenti per DoubleCut -- 2022/11/10 Corrette finiture lama per BigSection con trave alta +-- 2023/04/20 Per travi alte aggiunti tagli orizzontali per ridurre le dimensioni degli scarti -- Tabella per definizione modulo local ProcessHeadCut = {} @@ -119,7 +120,7 @@ local function MakeChamfer( nOriId, Proc, nPhase, nRawId, nPartId, dOvmHead) -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) + EgtSetOperationMode( nMch1Id, false) return false, sErr end -- Inserisco la lavorazione del lato opposto @@ -142,7 +143,7 @@ local function MakeChamfer( nOriId, Proc, nPhase, nRawId, nPartId, dOvmHead) -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) + EgtSetOperationMode( nMch1Id, false) return false, sErr end return true, nil @@ -205,9 +206,9 @@ function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bNeedHCut -- se non obbligatorio e coincide con inizio grezzo, non va fatto if not bNeedHCut and AreSameVectorApprox( vtN, X_AX()) and abs( ptC:getX() - b3Raw:getMax():getX()) < 10 * GEO.EPS_SMALL then return true - end + end -- determino se più tagli con offset - local nCuts = max( ceil( dOvmHead / ( BD.MAX_LEN_SCRAP_START or BD.MAX_LEN_SCRAP)), 1) + local nCuts = max( ceil( dOvmHead / (( BD.MAX_LEN_SCRAP_START or BD.MAX_LEN_SCRAP) + 0.5)), 1) local dOffsL = dOvmHead / nCuts -- se taglio per sezioni alte e larghe if bBigSectionCut then @@ -269,6 +270,37 @@ function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bNeedHCut dAccStart = sqrt( dSawRad * dSawRad - dKL * dKL) end end + + -- per travi alte faccio dei tagli orizzontali aggiuntivi + local _, _, dimV = BL.GetFaceHvRefDim( Proc.Id, 0, b3Raw) + local dMinOvmHeadForHorizontalCuts = 10.123 + local bAreHorizontalCutsNeeded = ( dimV > BD.MAX_LEN_DICE) and not bBigSectionCut and ( dOvmHead > dMinOvmHeadForHorizontalCuts - 10 * GEO.EPS_SMALL) + if bAreHorizontalCutsNeeded then + local nHorizontalCuts = ceil( dimV / BD.MAX_DIM_DICE) - 1 + local dHorizontalSliceHeight = dimV / ( nHorizontalCuts + 1) + for i = nCuts, 1, -1 do + local dCutXOffset = ( i - 1) * dOffsL + -- tagli orizzontali + for j = nHorizontalCuts, 1, -1 do + local nFaceUse = MCH_MILL_FU.PARAL_DOWN + local dHorizontalCutOffset = dHorizontalSliceHeight * -j + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nFaceUse, nil, -0.1 -dCutXOffset, BD.CUT_SIC, dHorizontalCutOffset, 0, 0, '', b3Raw) + if not bOk then return bOk, sErr end + end + -- se necessario taglio verticale doppio, eseguo l'opposto + if bDoubleCut then + -- gli accorciamenti vanno invertiti per il taglio opposto + local dAccStartDoubleCut, dAccEndDoubleCut = dAccEnd, dAccStart + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_BACK, nil, dCutExtra, BD.CUT_SIC, dCutXOffset, dAccStartDoubleCut, dAccEndDoubleCut, '', b3Raw, true) + if not bOk then return false, sErr end + end + -- taglio verticale + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutXOffset, dAccStart, dAccEnd, '', b3Raw) + if not bOk then return bOk, sErr end + end + return true, sWarn + end + -- se necessari tagli in doppio, eseguo gli opposti if bDoubleCut then -- gli accorciamenti vanno invertiti per il taglio opposto diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 02dc549..778d72d 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -1,4 +1,4 @@ --- ProcessLapJoint.lua by Egaltech s.r.l. 2022/12/22 +-- ProcessLapJoint.lua by Egaltech s.r.l. 2023/06/06 -- Gestione calcolo mezzo-legno per Travi -- 2019/10/08 Agg. gestione OpenPocket. -- 2021/01/24 Con sega a catena ora sempre impostato asse A. @@ -65,6 +65,9 @@ -- 2023/02/16 Piccola correzione alla scelta utensile di svuotatura. -- 2023/02/21 Piccola correzione alla MakeByPocket. -- 2023/03/13 In MakeByPocket aggiunto Q11=Tool_ID per forzare la scelta utensile in casi con Q03=2/3. +-- 2023/03/31 Correzione al calcolo della distanza di collisione nel caso in cui il gambo sia più piccolo dell'utensile. +-- 2023/06/06 Limiti su svuotature tasche a L 4 facce come per L 3 facce. In svuotatura aggiunto recupero UserNotes da libreria per MaxOptSize. +-- 2023/16/12 Corretto il recupero dati utensile che, in alcune funzioni, puntava all'utensile errato. -- Tabella per definizione modulo local ProcessLapJoint = {} @@ -1360,8 +1363,10 @@ local function MakeRoundCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, local dTMaxDepth = 0 if EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam - dTMaxDepth = EgtTdbGetCurrToolMaxDepth() or dTMaxDepth + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam + dTMaxDepth = EgtTdbGetCurrToolMaxDepth() or dTMaxDepth + end end -- se il diametro trovato non è minore dei 3/4 del diametro utilizzato in precedenza, esco @@ -1540,8 +1545,10 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, local dTMaxDepth = 0 if EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam - dTMaxDepth = EgtTdbGetCurrToolMaxDepth() or dTMaxDepth + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam + dTMaxDepth = EgtTdbGetCurrToolMaxDepth() or dTMaxDepth + end end local sMillingDn = ML.FindMilling( 'SmallToolContour', nil, nil, nil, nil, not( bMillDown and bDoubleSide), bMillDown and bDoubleSide) @@ -1555,8 +1562,10 @@ local function MakeRoundCleanContour( Proc, nPhase, nRawId, nPartId, b3Raw, local dTMaxDepthDn = 0 if EgtMdbSetCurrMachining( sMillingDn) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - dTDiamDn = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiamDn - dTMaxDepthDn = EgtTdbGetCurrToolMaxDepth() or dTMaxDepthDn + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dTDiamDn = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiamDn + dTMaxDepthDn = EgtTdbGetCurrToolMaxDepth() or dTMaxDepthDn + end end -- se il diametro trovato non è minore dei 3/4 del diametro utilizzato in precedenza, esco @@ -1909,7 +1918,9 @@ local function MakeSharpCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacI -- recupero i dati dell'utensile ( temporaneo, per compensare errore nella lavorazione) if EgtMdbSetCurrMachining( sMilling) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - dMaxDepth = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxDepth + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dMaxDepth = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxDepth + end end -- l'altezza di taglio del tagliente corrisponde al raggio del raccordo che si riesce a coprire -- quindi confronto l'elevazione con il raggio utensile utilizzato per la svuotatura @@ -3190,6 +3201,7 @@ local function MakePocket( Proc, nPartId, b3Solid, ptPs, tvtN, nFaceRef, sMchFin if bOpenOutRaw then sNotes = sNotes .. 'OpenOutRaw=1;' end + sNotes = sNotes .. ( EgtGetMachiningParam( MCH_MP.USERNOTES) or '') EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) if not ML.ApplyMachining( true, false) then -- provo ad allargare leggermente la tasca @@ -3285,7 +3297,7 @@ local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, tvtN, nBas EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchFId, false) + EgtSetOperationMode( nMchId, false) return false, sErr end else @@ -4979,11 +4991,11 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa elseif Proc.Fct == 4 then -- se non angoli fittizi, per rifinire gli angoli premio utensile diam 25 o da BD if not bAllWithEndCap then - dDiam = min( dDiam, BD.MAXDIAM_POCK_CORNER) + dDiam = min( EgtIf( bIsL, 2, 1) * dDiam + 10 * GEO.EPS_SMALL, BD.MAXDIAM_POCK_CORNER) end elseif Proc.Fct == 3 and bIsL then -- per rifinire gli angoli premio utensile diam 25 o da BD - dDiam = min( ( 2 * dDiam) + 10 * GEO.EPS_SMALL, BD.MAXDIAM_POCK_CORNER) + dDiam = min( 2 * dDiam + 10 * GEO.EPS_SMALL, BD.MAXDIAM_POCK_CORNER) else dDiam = 2 * dDiam end @@ -5425,8 +5437,34 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, bSinglePa -- eseguo la svuotatura della faccia principale, mi restituisce id utensile, il diametro utensile per il foro opzionale local tvtNx = {} tvtNx[2] = vtN + -- recupero alcuni parametri dell'utensile per decidere la distanza di sicurezza da utilizzare + local dMaxToolCutDepth = 0 + local dMaxToolMaterial = 0 + local dToolThLength = 999 + local dToolTotalLength = 0 + local dToolThDiameter = 999 + local dToolDiameter = 0 + if EgtMdbSetCurrMachining( sPocketing) then + local sTuuidPk = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuidPk) or '') then + dMaxToolCutDepth = EgtTdbGetCurrToolMaxDepth() or dMaxToolCutDepth + dMaxToolMaterial = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxToolMaterial + dToolDiameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiameter + dToolThLength = EgtTdbGetCurrToolThLength() or dToolThLength + dToolThDiameter = EgtTdbGetCurrToolParam( MCH_TP.STEMDIAM) or dToolThDiameter + dToolTotalLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) or dToolTotalLength + end + end + local dMachiningDepth = 0 + -- se il gambo è più largo dell'utensile verifico se la lunghezza del gambo è maggiore della distanza di sicurezza calcolata + local dShankLength = dToolTotalLength - dToolThLength - dMaxToolCutDepth + if ( dMaxToolCutDepth < dMaxToolMaterial + 10 * GEO.EPS_SMALL) and ( dShankLength > dCollSic + 10 * GEO.EPS_SMALL) then + dMachiningDepth = dFacElev + BD.COLL_SIC + else + dMachiningDepth = dFacElev + dCollSic + end local bOk, sWarn2 - bOk, sWarn2, sTuuidPk, dDiamTool = MakePocket( Proc, nPartId, b3Solid, ptC, tvtNx, nFacInd, sMchFind, nUseRoughTool, sPocketing, dFacElev + dCollSic, nil, nil, bAllWithEndCap) + bOk, sWarn2, sTuuidPk, dDiamTool = MakePocket( Proc, nPartId, b3Solid, ptC, tvtNx, nFacInd, sMchFind, nUseRoughTool, sPocketing, dMachiningDepth, nil, nil, bAllWithEndCap) if not bOk then return false, sWarn2 end if sWarn2 then if not sWarn then sWarn = '' end diff --git a/LuaLibs/ProcessLongCut.lua b/LuaLibs/ProcessLongCut.lua index 2837fd1..e6cd8b7 100644 --- a/LuaLibs/ProcessLongCut.lua +++ b/LuaLibs/ProcessLongCut.lua @@ -1,4 +1,4 @@ --- ProcessLongCut.lua by Egaltech s.r.l. 2023/03/06 +-- ProcessLongCut.lua by Egaltech s.r.l. 2023/05/19 -- Gestione calcolo taglio longitudinale per Travi -- 2021/02/03 Corretto FaceUse con fresa orizzontale su taglio orizzontale. -- 2021/05/18 Possibile taglio con lama anche di fianco su macchina con testa da sotto. @@ -25,6 +25,9 @@ -- 2023/03/06 Correzione per i casi con lavorazione limitata. -- 2023/03/15 Modifica alla lavorazione ulteriore con sega a catena per togliere il codolo e lasciare solo dei punti di supporto. -- 2023/03/22 Correzione a SCC lama a seguito di modifiche alle direzioni dei tagli. +-- 2023/04/17 Gestione unificata SCC tramite funzione apposita GetSCC +-- 2023/05/03 Corretto SCC in caso di asse utensile allineato con Z. +-- 2023/05/19 Migliorato calcolo e verifica affondamento per lavorazione con lama con codolo in mezzo. -- Tabella per definizione modulo local ProcessLongCut = {} @@ -62,6 +65,143 @@ function ProcessLongCut.Classify( Proc) return true, false end +--------------------------------------------------------------------- +-- Estrazione dell'UUID utensile di una lavorazione +function GetToolUUID( sMachining) + if EgtMdbSetCurrMachining( sMachining) then + local sToolUUID = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + return sToolUUID + end +end + +--------------------------------------------------------------------- +-- Calcolo dei versori caratteristici della feature +function GetProcessSpecificVectors( Proc, nFacet, nFaceUse, bInvert, sMachining) + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacet, GDB_ID.ROOT) + local vtOrthO = BL.GetVersRef( nFaceUse) + local ptP1, ptPm, ptP2, vtV1, vtV2, dLen, dWidth = EgtSurfTmFacetOppositeSide( Proc.Id, nFacet, vtOrthO, GDB_ID.ROOT) + local vtTg = ptP2 - ptP1 ; vtTg:normalize() + local dAllStart = 0 + local dAllEnd = 0 + -- se bilinea, scarto la parte più allineata con la direzione ortogonale (se deviazione angolare oltre 20 deg o lunghezza minore di dSawDiam/2 * cos( 20/2)) ma maggiore di un minimo + if ( ( ptPm - ptP1) - ( ptPm - ptP1) * vtTg * vtTg):len() > 100 * GEO.EPS_SMALL then + local vtTg1 = ptPm - ptP1 ; vtTg1:normalize() + local vtTg2 = ptP2 - ptPm ; vtTg2:normalize() + local dDist1 = dist( ptP1, ptPm) + local dDist2 = dist( ptP2, ptPm) + local dCosMax = 0.951 -- cos( 18°) + local dLenMin = 30 + local dToolDiam = 400 + if EgtMdbSetCurrMachining( sMachining) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam + end + end + local dLenMax = max( 0.5 * dToolDiam * 0.17365 + 1, 2 * dLenMin) + --if vtTg1 * vtTg2 < dCosMax or ( dDist1 < dLenMax and dDist1 > dLenMin) or ( dDist2 < dLenMax and dDist2 > dLenMin) then + if vtTg1 * vtTg2 < dCosMax then + local dOrtho1 = abs( vtTg1 * vtOrthO) + local dOrtho2 = abs( vtTg2 * vtOrthO) + if dOrtho1 < dOrtho2 or ( abs( dOrtho1 - dOrtho2) < 0.1 and dDist1 > 4 * dDist2) then + if dDist1 > dLenMin or dDist1 > 0.5 * dDist2 then + ptP2 = Point3d( ptPm) + dAllEnd = - dDist2 - 10 * GEO.EPS_SMALL + end + else + if dDist2 > dLenMin or dDist2 > 0.5 * dDist1 then + ptP1 = Point3d( ptPm) + dAllStart = - dDist1 - 10 * GEO.EPS_SMALL + end + end + vtTg = ptP2 - ptP1 ; vtTg:normalize() + end + end + local bWsRight = ( bInvert) + -- Versore di riferimento + local vtRef = Vector3d( vtTg) + vtRef:rotate( vtN, 90) + -- Versore esterno + local vtOut = vtRef - vtRef * vtTg * vtTg ; vtOut:normalize() + -- Versore ausiliario (direzione braccio) + local vtAux = Vector3d( vtN:getX(), vtN:getY(), 0) ; vtAux:normalize() + vtAux:rotate( Z_AX(), EgtIf( bWsRight, 90, -90)) + if vtAux:isSmall() then + vtAux = Vector3d( vtOut:getX(), vtOut:getY(), 0) ; vtAux:normalize() + else + if abs( vtAux * vtOut) < GEO.EPS_SMALL then + if abs( vtTg:getZ()) > 0.5 then + if vtAux * vtRef < 0 then + vtAux = - vtAux + end + elseif vtAux * vtTg > 0 then + vtAux = - vtAux + end + elseif vtAux * vtOut < 0 then + vtAux = - vtAux + end + end + EgtOutLog( 'vtN=' .. tostring( vtN) .. ' vtRef=' .. tostring( vtRef) .. ' vtOut=' .. tostring( vtOut) .. ' vtAux=' .. tostring( vtAux), 3) + return vtAux, vtRef, vtOut, vtTg +end + +--------------------------------------------------------------------- +-- Calcolo posizione braccio +function ProcessLongCut.GetSCC( Proc, nFacet, sMachining, nFaceUse, bInvert, nCuttingStep, nC, bAreCuttingStepsTowardsHead, bIsTopBlade, bCustUseBlade) + local nSCC + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacet, GDB_ID.ROOT) + local sToolUUID = GetToolUUID( sMachining) + local bIsBlade + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sToolUUID) or '') then + bIsBlade = ( ( EgtTdbGetCurrToolParam( MCH_TP.TYPE) & MCH_TF.SAWBLADE) ~= 0) + end + + -- se Turn posiziono la testa per creare il minor ingombro possibile + if BD.TURN then + if nFaceUse == MCH_MILL_FU.ORTHO_DOWN or ( ( nFaceUse == MCH_MILL_FU.PARAL_FRONT or nFaceUse == MCH_MILL_FU.PARAL_BACK) and vtN:getZ() > -GEO.EPS_SMALL) then + nSCC = MCH_SCC.ADIR_ZP + elseif nFaceUse == MCH_MILL_FU.ORTHO_TOP or ( nFaceUse == MCH_MILL_FU.PARAL_FRONT or nFaceUse == MCH_MILL_FU.PARAL_BACK) then + nSCC = MCH_SCC.ADIR_ZM + elseif nFaceUse == MCH_MILL_FU.ORTHO_FRONT or ( ( nFaceUse == MCH_MILL_FU.PARAL_DOWN or nFaceUse == MCH_MILL_FU.PARAL_TOP) and vtN:getY() > -GEO.EPS_SMALL) then + nSCC = MCH_SCC.ADIR_YP + elseif nFaceUse == MCH_MILL_FU.ORTHO_BACK or ( nFaceUse == MCH_MILL_FU.PARAL_DOWN or nFaceUse == MCH_MILL_FU.PARAL_TOP) then + nSCC = MCH_SCC.ADIR_YM + end + -- se Fast e fresa con asse utensile diretto come Z posiziono l'aggregato in Ym per avere il minore ingombro possibile + elseif not BD.C_SIMM and not bIsBlade and AreSameVectorApprox( vtN, Z_AX()) then + nSCC = MCH_SCC.ADIR_YM + -- se Fast ( escluso caso speciale con taglio non passante e inclinato in X e escluso caso con lama esattamente diretta in Z) posiziono l'aggregato in X per ottimizzare il pinzaggio + elseif not BD.C_SIMM and ( not ( bCustUseBlade and abs(vtN:getX()) > 0.001) or not bIsBlade) and not ( bIsBlade and AreSameVectorApprox( vtN, Z_AX())) then + if bAreCuttingStepsTowardsHead then + nSCC = EgtIf( ( not ( nCuttingStep == 1 or nCuttingStep == nC - 1)), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) + else + nSCC = EgtIf( ( not ( nCuttingStep == 1 or nCuttingStep == nC - 1)), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) + end + -- per Fast ( caso speciale con taglio non passante e inclinato in X e caso lama diretta esattamente in Z) + elseif not BD.C_SIMM then + local vtAux = GetProcessSpecificVectors( Proc, nFacet, nFaceUse, bInvert, sMachining) + if bCustUseBlade then + nSCC = EgtIf( ( nFaceUse == MCH_MILL_FU.ORTHO_TOP or nFaceUse == MCH_MILL_FU.ORTHO_FRONT) and vtN:getY() > -GEO.EPS_SMALL, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) + elseif ( abs( vtAux:getX()) > abs( vtAux:getY()) - GEO.EPS_SMALL) then + nSCC = EgtIf( ( vtAux:getX() > -GEO.EPS_SMALL), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) + else + nSCC = EgtIf( ( vtAux:getY() > -GEO.EPS_SMALL), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) + end + -- per PF o simili e lama con aggregato lo posiziono per stare il più lontano possibile dalla trave + elseif ( bIsBlade and bIsTopBlade) then + if abs( vtN:getX()) > 0.001 then + local vtAux = GetProcessSpecificVectors( Proc, nFacet, nFaceUse, bInvert, sMachining) + nSCC = EgtIf( ( vtAux:getY() > -GEO.EPS_SMALL), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) + else + nSCC = MCH_SCC.ADIR_XP + end + -- per PF o simili e lama senza aggregato o fresa non do alcuna preferenza + else + nSCC = MCH_SCC.NONE + end + + return nSCC +end ----------------------------------------------------------------------------------------------- local function MakeSideFace( nId, nFac, nSide, sMilling, dToolDiam, bForcedLim, dDistToMachine, bUnderDir) if ( not BD.DOWN_HEAD or not BD.TURN) and nSide == -1 then @@ -586,11 +726,12 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus local dToolDiam = 0 local dThick = 0 local dMaxDepth = 0 + local dMaxVertDepth = 0 local sCuttingDn local dToolDiamDn = 0 local dThickDn = 0 local dMaxDepthDn = 0 - -- recupero la lavorazione + -- recupero eventuale lavorazione con lama su testa da sotto if bCanUseUnderBlade then sCuttingDn = ML.FindCutting( 'HeadSide_H2', false, true) if not sCuttingDn then @@ -608,6 +749,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus end end end + -- recupero eventuale lavorazione con lama if bCanUseBlade then local sCutType = EgtIf( BD.USE_LONGCUT, 'LongCut', 'HeadSide') sCutting = ML.FindCutting( sCutType) @@ -623,6 +765,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam dThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or dThick dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth + dMaxVertDepth = dMaxDepth - ( BD.DECR_VERT_CUT or 0) end end end @@ -763,7 +906,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus bFinishWithChainSaw = EgtIf ( ( EgtGetInfo( Proc.Id, 'Q05', 'i') or 0) == 1, true, false) end - local nFaceUse + local nFaceUse local nFaceUse2 -- se ho solo lama da sotto if bCanUseUnderBlade and not bCanUseBlade then @@ -777,25 +920,23 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus end -- si percorrono i lati alto e basso della faccia -- calcolo quanto è l'affondamento del taglio - local dOffsetTopBlade = ( dWidth + dDimStrip) / 2 - local dOffsetDownBlade = ( dWidth + dDimStrip) / 2 - if bFinishWithChainSaw then - dOffsetTopBlade = dWidth / 2 - dOffsetDownBlade = dWidth / 2 - end + local dMainMaxDepth = EgtIf( abs( vtN:getY()) < 1e-6, dMaxDepth, dMaxVertDepth) + local dOtherMaxDept = EgtIf( bCanUseUnderBlade, dMaxDepthDn, dMainMaxDepth) + local dCoeff = min( ( dWidth - dDimStrip) / ( dMainMaxDepth + dOtherMaxDept), 1) + local dOffsetTopBlade = dWidth - dCoeff * dMainMaxDepth + local dOffsetDownBlade = dWidth - dCoeff * dOtherMaxDept local nStepDownBlade = 1 - local dStepDownBlade = dWidth - dOffsetDownBlade + local dStepDownBlade = dOtherMaxDept -- se lama da sotto verifico se la componente Y della profondità di taglio supera la capacità della lama - if ( nSide == -1 or abs(nSide) == 2) and bCanUseUnderBlade and (( dWidth - dDimStrip) / 2) > dMaxDepthDn then + if ( nSide == -1 or abs(nSide) == 2) and bCanUseUnderBlade and ( dOffsetTopBlade - dDimStrip) > dOtherMaxDept then if bFinishWithChainSaw then - dOffsetTopBlade = max( dWidth - dMaxDepth + ( BD.DECR_VERT_CUT or 0), dOffsetTopBlade) - dOffsetDownBlade = max( dWidth - dMaxDepthDn, dOffsetDownBlade) local dHCutDownBlade = dWidth - dOffsetDownBlade - local dMaxStepDownBlade = 64 + local dMaxStepDownBlade = 80 nStepDownBlade = ceil( dHCutDownBlade / dMaxStepDownBlade) dStepDownBlade = dHCutDownBlade / nStepDownBlade else - local sErr = 'Error : side depth is bigger than underneath blade cut depth' + local dDelta = dWidth - dDimStrip - ( dMainMaxDepth + dOtherMaxDept) + local sErr = 'Error : side depth is bigger than total cut depth (Diff=' .. EgtNumToString( dDelta)..')' EgtOutLog( sErr) return false, sErr end @@ -835,7 +976,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus end -- eventuale lavorazione della faccia limitante l'inizio if not bStartFixed then - local vtIni = -X_AX() + local vtIni = -X_AX() for j = 1, Proc.Fct - 1 do local _, vtN = EgtSurfTmFacetCenter( Proc.Id, j, GDB_ID.ROOT) if vtIni * vtN > 0 and nCountMilHead < 2 then @@ -851,7 +992,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus -- eventuale lavorazione della faccia limitante la fine if not bEndFixed then - local vtFin = X_AX() + local vtFin = X_AX() for j = 1, Proc.Fct - 1 do local _, vtN = EgtSurfTmFacetCenter( Proc.Id, j, GDB_ID.ROOT) if vtFin * vtN > 0 and nCountMilHead < 2 then @@ -868,8 +1009,6 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus -- inserisco tagli di lama for i = 1, nC do - -- Posizione braccio portatesta - local nSCC = EgtIf( ( BD.C_SIMM or not ( i == 1 or i == nC - 1)), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) -- ciclo sulle passate local dLioTang = 0 for k = 1, 2 do @@ -885,7 +1024,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus bAddOpposite = false end -- faccio in modo di calcolare il valore perpendicolare solo sulla faccia da sotto nel secondo passo o sulla faccia di fianco nel primo passo - if nSide == 1 or ( nSide == -1 and k == 1) or ( abs(nSide) == 2 and k == 2) then + if nSide == 1 or ( nSide == -1 and k == 1) or ( abs(nSide) == 2 and k == 2) then bAddOpposite = false end if bAddOpposite then @@ -977,18 +1116,18 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus end -- recupero alcune informazioni utili dalla lavorazione attuale - local bIsCurrentBladeCW + local bIsCurrentBladeCCW if bIsTopBladeCurrent then EgtMdbSetCurrMachining( sCutting) else EgtMdbSetCurrMachining( sCuttingDn) end - bIsCurrentBladeCW = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) < 0 + bIsCurrentBladeCCW = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) < 0 -- imposto la direzione di lavoro per avere scarico del truciolo ottimale local nWorkSide, bInvert if not bIsTopBladeCurrent and abs( nSide) ~= 2 then - if bIsCurrentBladeCW then + if bIsCurrentBladeCCW then nWorkSide = MCH_MILL_WS.LEFT bInvert = true dSal, dEal = dEal, dSal @@ -997,7 +1136,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus bInvert = false end else - if bIsCurrentBladeCW then + if bIsCurrentBladeCCW then nWorkSide = MCH_MILL_WS.LEFT bInvert = false else @@ -1006,6 +1145,10 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus dSal, dEal = dEal, dSal end end + -- step sempre positivi + local bAreCuttingStepsTowardsHead = true + -- calcolo SCC + local nSCC = ProcessLongCut.GetSCC( Proc, 0, EgtIf( bIsTopBladeCurrent, sCutting, sCuttingDn), nFaceUseCurrent, bInvert, i, nC, bAreCuttingStepsTowardsHead, bIsTopBladeCurrent, bCustUseBlade) -- setto la lavorazione con i valori calcolati EgtSetMachiningParam( MCH_MP.INVERT, bInvert) @@ -1022,12 +1165,7 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus EgtSetMachiningParam( MCH_MP.LIPERP, dLioPerp) EgtSetMachiningParam( MCH_MP.LOTANG, dLioTang) EgtSetMachiningParam( MCH_MP.LOPERP, dLioPerp) - -- se il flag uso lama custom abilitato (indica che questo script è lanciato dal ProcessCut) - -- controllo se componente X versore è maggiore di un valore limite cambio la direzione della forcella - if bCustUseBlade and abs(vtN:getX()) > 0.009 + 5 * GEO.EPS_SMALL then - nSCC = EgtIf( ( not bFront and k == 1) or ( bFront and k == 2), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) - end - -- imposto posizione braccio porta testa per non ingombrare agli estremi + -- imposto posizione braccio porta testa EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- eseguo if not ML.ApplyMachining( true, false) then @@ -1184,17 +1322,6 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus local nM = 0 local nCountMilHead = 0 for i = 1, nC do - -- Posizione braccio portatesta - local nSCC - if not BD.TURN then - if bFront then - nSCC = EgtIf( ( BD.C_SIMM or i == 1 or i == nC - 1), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) - else - nSCC = EgtIf( ( BD.C_SIMM or i == 1 or i == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) - end - else - nSCC = EgtIf( nFaceUse == MCH_MILL_FU.ORTHO_DOWN, MCH_SCC.ADIR_ZP, EgtIf( nFaceUse == MCH_MILL_FU.ORTHO_FRONT, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM)) - end -- ciclo sulle passate local nO = 1 local dStep = 0 @@ -1220,25 +1347,41 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus EgtSetMachiningParam( MCH_MP.LIELEV, 0) EgtSetMachiningParam( MCH_MP.LITANG, 0) EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR) - EgtSetMachiningParam( MCH_MP.LIPERP, dWidth + BD.CUT_EXTRA + BD.CUT_SIC or 20) + EgtSetMachiningParam( MCH_MP.LIPERP, dWidth + BD.CUT_EXTRA + ( BD.CUT_SIC or 20)) end elseif i == nC and not bEndFixed then if nO == 1 or EgtGetMachiningParam( MCH_MP.LOTANG) ~= 0 then EgtSetMachiningParam( MCH_MP.LOELEV, 0) EgtSetMachiningParam( MCH_MP.LOTANG, 0) EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LI.LINEAR) - EgtSetMachiningParam( MCH_MP.LOPERP, dWidth + BD.CUT_EXTRA + BD.CUT_SIC or 20) + EgtSetMachiningParam( MCH_MP.LOPERP, dWidth + BD.CUT_EXTRA + ( BD.CUT_SIC or 20)) end end -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, 0}}) + + -- setto workside e eventuale inversione + local bInvert + if bInvert then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + EgtSetMachiningParam( MCH_MP.INVERT, true) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.INVERT, false) + end -- limito opportunamente la lavorazione local dSal = EgtIf( i == 1, -dStartDist, - dStartAccDist - ( i - 2) * dC) - EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) local dEal = EgtIf( i == nC, -dEndDist, - dEndAccDist - ( nC - i - 1) * dC) + if bInvert then + dSal, dEal = dEal, dSal + end + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) -- imposto offset radiale EgtSetMachiningParam( MCH_MP.OFFSR, ( k - 1) * dStep - BD.CUT_EXTRA) + -- Posizione braccio portatesta + local bAreCuttingStepsTowardsHead = ( nStartSide == 0) + local nSCC = ProcessLongCut.GetSCC( Proc, 0, sMilling, nFaceUse, bInvert, i, nC, bAreCuttingStepsTowardsHead, nil, nil) -- imposto posizione braccio porta testa per non ingombrare agli estremi EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- imposto uso della faccia @@ -1319,8 +1462,8 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus sMilling = ML.FindMilling( sMchType) sPrefix = 'L2CS_' nExtendMach = nUseMillOnSide - if nUseMillOnSide == 2 then - bRemoveToolRadius = true + if nUseMillOnSide == 2 then + bRemoveToolRadius = true end -- se testa da sotto if nSide ~= 1 and BD.DOWN_HEAD then @@ -1605,13 +1748,8 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus local dSal = EgtIf( nPos == 1, -dEndDist, -dEndAccDist - ( nPos - 2) * dC + dOverLapExtend) local dEal = EgtIf( nPos == nC, -dStartDist, -dStartAccDist - ( nC - nPos - 1) * dC + dOverLapExtend) -- Posizione braccio portatesta - local nSCC + --local nSCC for k = 1, nPass do - if bFront then - nSCC = EgtIf( ( BD.C_SIMM or j == 1 or j == nC - 1), MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP) - else - nSCC = EgtIf( ( BD.C_SIMM or j == 1 or j == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) - end -- inserisco le parti di lavorazione nM = nM + 1 local sNameF = EgtIf( vnHead[k] ~= 2, sPrefix, sPrefixDn) .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nM) @@ -1623,22 +1761,22 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus end -- aggiungo geometria EgtSetMachiningGeometry( {{ Proc.Id, 0}}) - -- imposto posizione braccio porta testa per non ingombrare agli estremi - EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- imposto uso faccia - local nUseFace = EgtIf( vnHead[k] ~= 2, MCH_MILL_FU.PARAL_DOWN, MCH_MILL_FU.PARAL_TOP) - if AreSameOrOppositeVectorApprox( vtN, Z_AX()) then nUseFace = MCH_MILL_FU.PARAL_BACK end - EgtSetMachiningParam( MCH_MP.FACEUSE, nUseFace) + local nFaceUse = EgtIf( vnHead[k] ~= 2, MCH_MILL_FU.PARAL_DOWN, MCH_MILL_FU.PARAL_TOP) + if AreSameOrOppositeVectorApprox( vtN, Z_AX()) then nFaceUse = MCH_MILL_FU.PARAL_BACK end + EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) -- imposto lato di lavoro e inversione + local bInvert if k == 1 then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - EgtSetMachiningParam( MCH_MP.INVERT, true) + bInvert = true else EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - EgtSetMachiningParam( MCH_MP.INVERT, false) EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + bInvert = false dSal, dEal = dEal, dSal end + EgtSetMachiningParam( MCH_MP.INVERT, bInvert) -- limito opportunamente la lavorazione EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal) EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal) @@ -1647,6 +1785,12 @@ function ProcessLongCut.Make( Proc, nPhase, nRawId, nPartId, bCustUseBlade, nCus -- assegno attacco perpendicolare EgtSetMachiningParam( MCH_MP.LIPERP, dLioPerp1) EgtSetMachiningParam( MCH_MP.LOPERP, dLioPerp1) + -- step sempre negativi + local bAreCuttingStepsTowardsHead = false + -- calcolo SCC + local nSCC = ProcessLongCut.GetSCC( Proc, 0, EgtIf( vnHead[k] ~= 2, sMilling, sMillingDn), nFaceUse, bInvert, j, nC, bAreCuttingStepsTowardsHead, nil, nil) + -- imposto posizione braccio porta testa + EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- eseguo if not ML.ApplyMachining( true, false) then -- se feature orientata su faccia da sotto provo a cambiare l'attacco diff --git a/LuaLibs/ProcessLongDoubleCut.lua b/LuaLibs/ProcessLongDoubleCut.lua index a1d3bc8..bc89247 100644 --- a/LuaLibs/ProcessLongDoubleCut.lua +++ b/LuaLibs/ProcessLongDoubleCut.lua @@ -1,4 +1,4 @@ --- ProcessLongDoubleCut.lua by Egaltech s.r.l. 2022/11/30 +-- ProcessLongDoubleCut.lua by Egaltech s.r.l. 2023/06/07 -- Gestione calcolo doppio taglio longitudinale per Travi -- 2021/05/18 Possibile taglio con lama anche di fianco su macchina con testa da sotto. -- 2021/06/29 Corretta gestione caso equivalente a due smussi. @@ -17,6 +17,7 @@ -- 2023/02/22 Nuova gestione del verso di avanzamento ottimale che contempla tutti i casi. -- 2023/03/06 Correzione per i casi con lavorazione limitata. -- 2023/03/23 Correzione per caso con doppia lama da sotto. +-- 2023/06/07 Sistemazione SCC per macchina TURN -- Tabella per definizione modulo local ProcessLong2Cut = {} @@ -125,9 +126,9 @@ function ProcessLong2Cut.GetLongFacesCount( Proc) end --------------------------------------------------------------------- -local function MakeSideFace( nId, nFac, nSideLimitingFace, sMilling, dToolDiam, nL2CSide, bIsAnyFaceUpsideDown) - if ( not BD.DOWN_HEAD or not BD.TURN) and bIsAnyFaceUpsideDown then - EgtOutLog( 'Long2Cut : side face finishing skipped , down head required') +local function MakeSideFace( nId, nFac, nSideLimitingFace, nInd, sMilling, dToolDiam, nL2CSide, bIsAnyFaceUpsideDown) + if ( not BD.DOWN_HEAD and not BD.TURN) and bIsAnyFaceUpsideDown then + EgtOutLog( 'Long2Cut : side face finishing skipped, down head required') return true end -- inserisco la lavorazione @@ -141,8 +142,15 @@ local function MakeSideFace( nId, nFac, nSideLimitingFace, sMilling, dToolDiam, -- aggiungo geometria EgtSetMachiningGeometry( {{ nId, nFac}}) -- lato di lavoro e inversione - EgtSetMachiningParam( MCH_MP.INVERT, false) - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + if BD.TURN and + ( ( nSideLimitingFace == 1 and nInd == EgtIf( nL2CSide ~= -1, 2, 1)) or + ( nSideLimitingFace == -1 and nInd == EgtIf( nL2CSide ~= -1, 1, 2))) then + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + else + EgtSetMachiningParam( MCH_MP.INVERT, false) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + end -- uso della faccia local nFaceUse = EgtIf( nSideLimitingFace == 1, MCH_MILL_FU.ORTHO_RIGHT, MCH_MILL_FU.ORTHO_LEFT) EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) @@ -151,8 +159,11 @@ local function MakeSideFace( nId, nFac, nSideLimitingFace, sMilling, dToolDiam, -- attacco e uscita EgtSetMachiningParam( MCH_MP.LIPERP, 0) EgtSetMachiningParam( MCH_MP.LITANG, dToolDiam / 2 + 30) - EgtSetMachiningParam( MCH_MP.LOPERP, 2) + EgtSetMachiningParam( MCH_MP.LOPERP, 5) EgtSetMachiningParam( MCH_MP.LOTANG, 10) + if BD.TURN then + EgtSetMachiningParam( MCH_MP.LOELEV, 10) + end -- se faccia di fianco e testa da sotto, aumento la sicurezza if nL2CSide == 0 and BD.DOWN_HEAD then EgtSetMachiningParam( MCH_MP.STARTPOS, 80) @@ -730,18 +741,18 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster end -- recupero alcune informazioni utili dalla lavorazione attuale - local bIsCurrentBladeCW + local bIsCurrentBladeCCW if bIsTopBladeCurrent then EgtMdbSetCurrMachining( sCutting) else EgtMdbSetCurrMachining( sCuttingDn) end - bIsCurrentBladeCW = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) < 0 + bIsCurrentBladeCCW = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) < 0 -- 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 bIsCurrentBladeCW then + if bIsCurrentBladeCCW then nWorkSide = MCH_MILL_WS.LEFT bInvert = true dSal, dEal = dEal, dSal @@ -750,7 +761,7 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster bInvert = false end else - if bIsCurrentBladeCW then + if bIsCurrentBladeCCW then nWorkSide = MCH_MILL_WS.LEFT bInvert = false else @@ -1095,18 +1106,21 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster local nPos = EgtIf( i == 1, j, nC - j + 1) local dSal = EgtIf( nPos == 1, - EgtIf( i == nIni, dStartDist, dEndDist), - EgtIf( i == nIni, dStartAccDist, dEndAccDist) - ( nPos - 2) * dC + EgtIf( bSide, dOverLapExtend, 0)) local dEal = EgtIf( nPos == nC, - EgtIf( i == nIni, dEndDist, dStartDist), - EgtIf( i == nIni, dEndAccDist, dStartAccDist) - ( nC - nPos - 1) * dC + EgtIf( bSide, dOverLapExtend, 0)) + if nSide == -1 then + dSal, dEal = dEal, dSal + end -- Posizione braccio portatesta local nSCC = MCH_SCC.NONE if not BD.C_SIMM then if not BD.TURN then nSCC = EgtIf( ( j == 1 or j == nC - 1), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) else - if nSide == 1 then - nSCC = EgtIf( vtN[vOrd[i]]:getY() < 0, MCH_SCC.ADIR_YM, MCH_SCC.ADIR_YP) - elseif nSide == -1 then - nSCC = EgtIf( vtN[vOrd[i]]:getY() < 0, MCH_SCC.ADIR_YM, MCH_SCC.ADIR_YP) + if nSide == 1 or nSide == -1 then + local bFromYM = (( vtN[vOrd[i]]:getY() < 0 and bConvex) or ( vtN[vOrd[i]]:getY() > 0 and not bConvex)) + nSCC = EgtIf( bFromYM, MCH_SCC.ADIR_YM, MCH_SCC.ADIR_YP) else - nSCC = EgtIf( vtN[vOrd[i]]:getZ() < 0, MCH_SCC.ADIR_ZM, MCH_SCC.ADIR_ZP) + local bFromZM = (( vtN[vOrd[i]]:getZ() < 0 and bConvex) or ( vtN[vOrd[i]]:getZ() > 0 and not bConvex)) + nSCC = EgtIf( bFromZM, MCH_SCC.ADIR_ZM, MCH_SCC.ADIR_ZP) end end end @@ -1178,11 +1192,11 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster end -- se facce principali convesse, eventuale lavorazione della faccia limitante l'inizio (a destra) if bConvex and j == 1 and not bStartFixed then - MakeSideFace( Proc.Id, tFaceLong[vOrd[i]], 1, sMilling, dToolDiam, nSide, bIsAnyFaceUpsideDown) + MakeSideFace( Proc.Id, tFaceLong[vOrd[i]], 1, i, sMilling, dToolDiam, nSide, bIsAnyFaceUpsideDown) end -- se facce principali convesse, eventuale lavorazione della faccia limitante la fine (a sinistra) if bConvex and j == nC and not bEndFixed then - MakeSideFace( Proc.Id, tFaceLong[vOrd[i]], -1, sMilling, dToolDiam, nSide, bIsAnyFaceUpsideDown) + MakeSideFace( Proc.Id, tFaceLong[vOrd[i]], -1, i, sMilling, dToolDiam, nSide, bIsAnyFaceUpsideDown) end end end @@ -1620,11 +1634,11 @@ function ProcessLong2Cut.Make( Proc, nPhase, nRawId, nPartId, bForcedBladeMaster end -- se facce principali convesse, eventuale lavorazione della faccia limitante l'inizio (a destra) if bConvex and j == 1 and not bStartFixed and bRemoveToolRadius then - MakeSideFace( Proc.Id, tFaceLong[vOrd[i]], 1, sMilling, dToolDiam) + MakeSideFace( Proc.Id, tFaceLong[vOrd[i]], 1, i, sMilling, dToolDiam) end -- se facce principali convesse, eventuale lavorazione della faccia limitante la fine (a sinistra) if bConvex and j == nC and not bEndFixed and bRemoveToolRadius then - MakeSideFace( Proc.Id, tFaceLong[vOrd[i]], -1, sMilling, dToolDiam) + MakeSideFace( Proc.Id, tFaceLong[vOrd[i]], -1, i, sMilling, dToolDiam) end end end diff --git a/LuaLibs/ProcessMortise.lua b/LuaLibs/ProcessMortise.lua index 5309722..a524dd4 100644 --- a/LuaLibs/ProcessMortise.lua +++ b/LuaLibs/ProcessMortise.lua @@ -1,4 +1,4 @@ --- ProcessMortise.lua by Egaltech s.r.l. 2022/12/12 +-- ProcessMortise.lua by Egaltech s.r.l. 2023/05/11 -- Gestione calcolo mortase per Travi -- 2021/07/20 Aggiunta gestione rinvio angolare su FAST. -- 2021/12/01 Se frontale aggiungo taglio con Grp e Proc di vero taglio (per aggiornare ingombro di testa /coda). @@ -9,6 +9,8 @@ -- 2022/12/12 Migliorato controllo necessità CleanCorners. -- 2023/01/31 Aggiunta gestione lavorazione in doppio. -- 2023/01/31 Creata la funzione ConvertToClosedCurve (parte della ProcessMortise.Make) e spostata in BeamLib. +-- 2023/05/11 Se lavorazione in doppio e precedente no oppure di tipo diverso, forzo risalita a Zmax. +-- 2023/06/27 Esclusa la ricerca lati aperti per le mortase passanti, per le quali il contorno finisce sulla faccia e il riconoscimento sbaglia. -- Tabella per definizione modulo local ProcessMortise = {} @@ -293,13 +295,6 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtOutLog( sErr) return false, sErr end - -- recupero versore estrusione della curva supplementare - local vtExtr = EgtCurveExtrusion( AuxId, GDB_ID.ROOT) - -- se curva di contorno aperta la rendo chiusa - local _, bModif = BL.ConvertToClosedCurve( Proc, AuxId) - if not bModif then - BL.SetOpenSide( AuxId, b3Solid) - end -- verifico se frontale local bFront = ( Proc.Prc == 51) -- recupero i dati della faccia di fondo @@ -310,8 +305,16 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) ptC = frMor:getOrigin() vtN = frMor:getVersZ() end + -- recupero versore estrusione della curva supplementare + local vtExtr = EgtCurveExtrusion( AuxId, GDB_ID.ROOT) -- Confronto le direzioni dei 2 versori : se diverse la faccia 0 non è il fondo => mortasa passante local bOpenBtm = not AreSameVectorApprox( vtExtr, vtN) + -- se curva di contorno aperta la rendo chiusa + local _, bModif = BL.ConvertToClosedCurve( Proc, AuxId) + -- se la mortasa passante il contorno è sulla faccia della trave e il riconoscimento lati aperti non è corretto + if not bModif and not bOpenBtm then + BL.SetOpenSide( AuxId, b3Solid) + end if bOpenBtm then -- creo superficie chiusa local nFlat = EgtSurfTmByFlatContour( EgtGetParent( AuxId), AuxId, 0.05) @@ -506,6 +509,9 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- se lavorazione in doppio if Proc.Double and Proc.Double > 0 then sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', Proc.Double) + if Proc.Double ~= Proc.PrevDouble then + sUserNotes = EgtSetValInNotes( sUserNotes, 'StartZmax', 2) + end end EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- eseguo @@ -526,7 +532,7 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) return false, sErr end -- faccio la copia e la metto nel layer dedicato alle geometrie aggiunte - local AuxId_oppo = EgtCopyGlob( AuxId, BL.GetAddGroup(nPartId)) + local AuxId_oppo = EgtCopyGlob( AuxId, BL.GetAddGroup(nPartId)) -- inverto la direzione estrusione di questa EgtModifyCurveExtrusion( AuxId_oppo, - vtExtr, GDB_ID.ROOT) -- aggiungo geometria diff --git a/LuaLibs/ProcessProfConcave.lua b/LuaLibs/ProcessProfConcave.lua index cac5e93..d7a6616 100644 --- a/LuaLibs/ProcessProfConcave.lua +++ b/LuaLibs/ProcessProfConcave.lua @@ -1,10 +1,11 @@ --- ProcessProfConcave.lua by Egaltech s.r.l. 2022/05/28 +-- ProcessProfConcave.lua by Egaltech s.r.l. 2023/05/25 -- Gestione calcolo profilo concavo per Travi -- 2021/05/03 Aggiunta gestione smusso da sopra e sotto per macchina con testa da sotto. -- 2021/06/28 Per macchine con testa sotto, smussi di lato con questa testa se non c'è lav.ne da sopra. -- 2022/02/02 Aggiunta funzione OnlyChamfer. -- 2022/05/24 Aggiunta fresatura da sotto su macchine con testa da sotto. -- 2022/05/28 Aggiunto calcolo svuotatura da modulo di libreria. +-- 2023/05/25 Sistemazione SCC per TURN. -- Tabella per definizione modulo local ProcessProfConcave = {} @@ -195,6 +196,25 @@ local function VerifyCham( Proc, AuxId, nRawId, bMakeVertCham, sDephtCham, sOnly return nChamfer, dDepth, sMilling, sMilling2 end +--------------------------------------------------------------------- +function GetSccForTurn( vtN, sType) + local nSCC + if abs( vtN:getZ()) > abs( vtN:getY()) then + if sType == 'V' then + nSCC = EgtIf( vtN:getZ() > 0, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_ZM) + else + nSCC = EgtIf( vtN:getZ() > 0, MCH_SCC.ADIR_ZP, MCH_SCC.ADIR_ZM) + end + else + if sType == 'V' then + nSCC = EgtIf( vtN:getY() > 0, MCH_SCC.ADIR_ZM, MCH_SCC.ADIR_ZP) + else + nSCC = EgtIf( vtN:getY() > 0, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) + end + end + return nSCC +end + --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) @@ -490,7 +510,7 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) -- posizione braccio porta testa local nSCC = EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) - if BD.TURN then nSCC = MCH_SCC.ADIR_ZP end + if BD.TURN then nSCC = GetSccForTurn( vtN) end EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale local bFinish @@ -591,7 +611,7 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end -- posizione braccio porta testa local nSCC = EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) - if BD.TURN then nSCC = MCH_SCC.ADIR_ZP end + if BD.TURN then nSCC = GetSccForTurn( vtN) end EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale local bFinish @@ -656,14 +676,25 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_BACK) else EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTUP_TOP) - EgtSetMachiningParam( MCH_MP.WORKSIDE, 1) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( (dToolMaxDepth/2), 1)) end EgtSetMachiningParam( MCH_MP.INVERT, false) EgtSetMachiningParam( MCH_MP.DEPTH_STR, 'TH') EgtSetMachiningParam( MCH_MP.STEP, 0) EgtSetMachiningParam( MCH_MP.OFFSR, 0) - if BD.TURN then EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_ZP) end + if BD.TURN then + local nSCC = GetSccForTurn( vtN) + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- modifico attacco e uscita per forzare risalita + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dToolDiam / 2) + EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.TANGENT) + EgtSetMachiningParam( MCH_MP.LITANG, 20) + EgtSetMachiningParam( MCH_MP.LIPERP, 20) + EgtSetMachiningParam( MCH_MP.LIELEV, 20) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dToolDiam / 2) + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.AS_LI) + end -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -697,7 +728,10 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.STEP, 0) EgtSetMachiningParam( MCH_MP.OFFSR, 0) EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dWidth, 1)) - if BD.TURN then EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_ZP) end + if BD.TURN then + local nSCC = GetSccForTurn( vtN) + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + end -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() diff --git a/LuaLibs/ProcessProfConvex.lua b/LuaLibs/ProcessProfConvex.lua index 80af9e2..2c7d072 100644 --- a/LuaLibs/ProcessProfConvex.lua +++ b/LuaLibs/ProcessProfConvex.lua @@ -1,10 +1,11 @@ --- ProcessProfConvex.lua by Egaltech s.r.l. 2022/05/28 +-- ProcessProfConvex.lua by Egaltech s.r.l. 2023/05/25 -- Gestione calcolo profilo convesso per Travi -- 2021/05/03 Aggiunta gestione smusso da sopra e sotto per macchina con testa da sotto. -- 2021/06/28 Per macchine con testa sotto, smussi di lato con questa testa se non c'è lav.ne da sopra. -- 2022/02/02 Aggiunta funzione OnlyChamfer. -- 2022/05/24 Aggiunta fresatura da sotto su macchine con testa da sotto. -- 2022/05/28 Aggiunto calcolo svuotatura da modulo di libreria. +-- 2023/05/25 Sistemazione SCC per TURN. -- Tabella per definizione modulo local ProcessProfConvex = {} @@ -195,6 +196,25 @@ local function VerifyCham( Proc, AuxId, nRawId, bMakeVertCham, sDephtCham, sOnly return nChamfer, dDepth, sMilling, sMilling2 end +--------------------------------------------------------------------- +function GetSccForTurn( vtN, sType) + local nSCC + if abs( vtN:getZ()) > abs( vtN:getY()) then + if sType == 'V' then + nSCC = EgtIf( vtN:getZ() > 0, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_ZM) + else + nSCC = EgtIf( vtN:getZ() > 0, MCH_SCC.ADIR_ZP, MCH_SCC.ADIR_ZM) + end + else + if sType == 'V' then + nSCC = EgtIf( vtN:getY() > 0, MCH_SCC.ADIR_ZM, MCH_SCC.ADIR_ZP) + else + nSCC = EgtIf( vtN:getY() > 0, MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) + end + end + return nSCC +end + --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) @@ -490,7 +510,7 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) -- posizione braccio porta testa local nSCC = EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) - if BD.TURN then nSCC = MCH_SCC.ADIR_ZP end + if BD.TURN then nSCC = GetSccForTurn( vtN) end EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale local bFinish @@ -591,7 +611,7 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end -- posizione braccio porta testa local nSCC = EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM) - if BD.TURN then nSCC = MCH_SCC.ADIR_ZP end + if BD.TURN then nSCC = GetSccForTurn( vtN) end EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale local bFinish @@ -656,14 +676,25 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_BACK) else EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTUP_TOP) - EgtSetMachiningParam( MCH_MP.WORKSIDE, 1) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( (dToolMaxDepth/2), 1)) end EgtSetMachiningParam( MCH_MP.INVERT, false) EgtSetMachiningParam( MCH_MP.DEPTH_STR, 'TH') EgtSetMachiningParam( MCH_MP.STEP, 0) EgtSetMachiningParam( MCH_MP.OFFSR, 0) - if BD.TURN then EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_ZP) end + if BD.TURN then + local nSCC = GetSccForTurn( vtN, 'V') + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- modifico attacco e uscita per forzare risalita + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dToolDiam / 2) + EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.TANGENT) + EgtSetMachiningParam( MCH_MP.LITANG, 20) + EgtSetMachiningParam( MCH_MP.LIPERP, 20) + EgtSetMachiningParam( MCH_MP.LIELEV, 20) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dToolDiam / 2) + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.AS_LI) + end -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -697,7 +728,10 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.STEP, 0) EgtSetMachiningParam( MCH_MP.OFFSR, 0) EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dWidth, 1)) - if BD.TURN then EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_ZP) end + if BD.TURN then + local nSCC = GetSccForTurn( vtN) + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + end -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() diff --git a/LuaLibs/ProcessRidgeLap.lua b/LuaLibs/ProcessRidgeLap.lua index 0e5a666..0a42616 100644 --- a/LuaLibs/ProcessRidgeLap.lua +++ b/LuaLibs/ProcessRidgeLap.lua @@ -1,4 +1,4 @@ --- ProcessRidgeLap.lua by Egaltech s.r.l. 2021/09/10 +-- ProcessRidgeLap.lua by Egaltech s.r.l. 2023/05/18 -- Gestione calcolo mezzolegno di testa per Travi -- Tabella per definizione modulo @@ -26,8 +26,8 @@ end --------------------------------------------------------------------- -- Classificazione della feature function ProcessRidgeLap.Classify( Proc, b3Raw) - -- se PF con testa da sotto, ammessa qualunque orientazione - if BD.C_SIMM and BD.DOWN_HEAD then + -- se PF con testa da sotto oppure TURN, ammessa qualunque orientazione + if ( BD.C_SIMM and BD.DOWN_HEAD) or BD.TURN then return true, false end -- Se più corta del limite si può fare anche da sotto diff --git a/LuaLibs/ProcessRoundArch.lua b/LuaLibs/ProcessRoundArch.lua index 31477a5..5b4efe0 100644 --- a/LuaLibs/ProcessRoundArch.lua +++ b/LuaLibs/ProcessRoundArch.lua @@ -1,4 +1,4 @@ --- ProcessRoundArch.lua by Egaltech s.r.l. 2021/01/29 +-- ProcessRoundArch.lua by Egaltech s.r.l. 2023/05/18 -- Gestione calcolo archi per Travi -- Tabella per definizione modulo @@ -93,6 +93,8 @@ function ProcessRoundArch.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) EgtOutLog( sErr) return false, sErr end + -- normale alla superficie nel mezzo + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, Proc.Fct // 2, GDB_RT.GLOB) -- recupero e verifico l'entità curva local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') if AuxId then AuxId = AuxId + Proc.Id end @@ -222,13 +224,27 @@ function ProcessRoundArch.Make( Proc, nPhase, nRawId, nPartId, dOvmHead) EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) end -- posizione braccio porta testa - if Proc.Head then - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP) - elseif Proc.Tail then - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XM) - elseif AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP) + local nSCC = MCH_SCC.NONE + if not BD.C_SIMM and not BD.TURN then + if Proc.Head then + nSCC = MCH_SCC.ADIR_XP + elseif Proc.Tail then + nSCC = MCH_SCC.ADIR_XM + elseif AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then + nSCC = MCH_SCC.ADIR_YP + end + elseif BD.TURN then + if vtN:getZ() > 0.707 then + nSCC = MCH_SCC.ADIR_ZP + elseif vtN:getZ() < -0.707 then + nSCC = MCH_SCC.ADIR_ZM + elseif vtN:getY() > 0.707 then + nSCC = MCH_SCC.ADIR_YP + elseif vtN:getY() < -0.707 then + nSCC = MCH_SCC.ADIR_YM + end end + EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() diff --git a/LuaLibs/ProcessSplit.lua b/LuaLibs/ProcessSplit.lua index a7354bd..3a02d19 100644 --- a/LuaLibs/ProcessSplit.lua +++ b/LuaLibs/ProcessSplit.lua @@ -1,4 +1,4 @@ --- ProcessSplit.lua by Egaltech s.r.l. 2022/11/30 +-- ProcessSplit.lua by Egaltech s.r.l. 2023/05/09 -- Gestione calcolo tagli di separazione per Travi -- 2022/05/31 Aggiunta gestione sezioni alte e larghe con taglio con sega a catena seguito da rifinitura con lama (aggiunta funzione MakeSplitByChainSaw); gestione eventuale creazione nuova fase dall'interno della Make. -- 2022/06/10 Per sezioni alte e larghe aggiunta gestione finitura in base a sovramateriale e a parametro Q05 dell' eventuale lavorazione sostituita. @@ -8,6 +8,10 @@ -- 2022/11/10 Corrette finiture lama per BigSection con trave alta -- 2022/11/16 Correzioni per travi larghe -- 2022/11/30 Correzione per tagli su grandi sezioni (dopo taglio con sega a catena senza finitura aggiungeva uno split con lama). +-- 2023/04/04 Modifiche per travi con sezioni molto grandi e materiale inferiore allo spessore lama. +-- 2023/04/20 Per travi alte aggiunti tagli orizzontali per ridurre le dimensioni degli scarti. +-- 2023/05/09 Aggiunta richiesta risalita preliminare a Zmax per tagli da sopra su macchine PF e ONE. +-- 2023/06/13 Corrette note Precut e Cut per tagli aggiuntivi orizzontali. -- Tabella per definizione modulo local ProcessSplit = {} @@ -121,7 +125,7 @@ local function MakeChamfer( nOriId, Proc, nPhase, nRawId, nPartId, dOvmHead) -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) + EgtSetOperationMode( nMch1Id, false) return false, sErr end -- Inserisco la lavorazione del lato opposto @@ -144,7 +148,7 @@ local function MakeChamfer( nOriId, Proc, nPhase, nRawId, nPartId, dOvmHead) -- eseguo if not ML.ApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) + EgtSetOperationMode( nMch1Id, false) return false, sErr end return true, nil @@ -298,14 +302,15 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt local nNextRawId = EgtGetNextRawPart( nRawId) local bSplit = ( nNextRawId and ( EgtGetPartInRawPartCount( nNextRawId) > 0 or EgtGetRawPartBBox( nNextRawId):getDimX() >= BD.MinRaw)) -- determino se più tagli con offset + local dLenEndRaw = dOvmTail local nCuts = 1 local dOffsL = 0 if not bSplit then -- cerco grezzo successivo che sia nella fase if nNextRawId and EgtVerifyRawPartPhase( nNextRawId, nPhase) then local b3NextRaw = EgtGetRawPartBBox( nNextRawId) - local dLenEndRaw = ptC:getX() - b3NextRaw:getMin():getX() - nCuts = ceil( dLenEndRaw / BD.MAX_LEN_SCRAP) + dLenEndRaw = ptC:getX() - b3NextRaw:getMin():getX() + nCuts = ceil( dLenEndRaw / ( BD.MAX_LEN_SCRAP + 0.5)) dOffsL = dLenEndRaw / nCuts -- aggiorno ingombro del grezzo corrente con quello del successivo b3Raw:Add( b3NextRaw) @@ -396,21 +401,22 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt sNotesFinal = 'Cut;' end local nQ05 = EgtGetInfo( nOriId or GDB_ID.NULL, 'Q05', 'i') or 0 + -- determinazione materiale da asportare + local dSawThickCheck = dSawThick + if dSawThick2 > 0 and bDoubleHorizCut then + dSawThickCheck = min( dSawThick, dSawThick2) + end + local dMaxElev = 0 + if vtN:getX() > 0 then + dMaxElev = b3Raw:getMax():getX() - Proc.Box:getMin():getX() + else + dMaxElev = Proc.Box:getMax():getX() - b3Raw:getMin():getX() + end -- se finitura con lama - if nQ05 == 1 or nQ05 == 0 or not bSplit then - local dSawThickCheck = dSawThick - if dSawThick2 > 0 and bDoubleHorizCut then - dSawThickCheck = min( dSawThick, dSawThick2) - end - local dMaxElev = 0 - if vtN:getX() > 0 then - dMaxElev = b3Raw:getMax():getX() - Proc.Box:getMin():getX() - else - dMaxElev = Proc.Box:getMax():getX() - b3Raw:getMin():getX() - end + if nQ05 == 1 or nQ05 == 0 or ( not bSplit and dMaxElev > dSawThickCheck) then -- controllo se è necessario un taglio con dicing o si deve proseguire ai casi standard if bSplit or dMaxElev > dSawThickCheck then - local bOk, sErr = Cut.Make( Proc, nNewPhase, nRawId, nPartId, dLenEndRaw, nil, false, true, b3Raw, sNotes, dCurrOvmT) + local bOk, sErr = Cut.Make( Proc, nNewPhase, nRawId, nPartId, dMaxElev, nil, false, true, b3Raw, sNotes, dCurrOvmT) if sNotesFinal then EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesFinal) end @@ -424,15 +430,20 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt EgtOutLog( sErr) return false, sErr end - local sPocketing = ML.FindPocketing( 'OpenPocket', nil, 0) + local sPocketing, dTDiam = ML.FindPocketing( 'OpenPocket', nil, 0) if not sPocketing then local sErr = 'Error : pocketing not found in library' EgtOutLog( sErr) return false, sErr end - local bOk, sErr = Pocket.Make( Proc, Proc.Id, 0, sPocketing, nPartId, b3Solid) + local dOpenMinSafe + if BD.C_SIMM and b3Raw:getDimZ() > 600 then + dOpenMinSafe = 230 - dTDiam / 2 + end + local bOk, sErr = Pocket.Make( Proc, Proc.Id, 0, sPocketing, nPartId, b3Solid, dOpenMinSafe) if sNotesFinal then - EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesFinal) + local sNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) .. sNotesFinal + EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) end return bOk, sErr, nNewPhase end @@ -446,7 +457,12 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt local dCutExtra = 0 local dAccStart = 0 local dAccEnd = 0 - if b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL or b3Raw:getDimY() < 2 * BD.MAX_DIM_HTCUT_HBEAM + 10 * GEO.EPS_SMALL then + if bBigSectionCut and BD.C_SIMM then + -- qui arrivano sezioni molto grandi su macchine tipo PF con materiale da asportare inferiore allo spessore lama + local dSawRad = dSawDiam / 2 + dCutExtra = - ( b3Raw:getDimY() - dSawRad) + dAccEnd = dSawRad + elseif b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL or b3Raw:getDimY() < 2 * BD.MAX_DIM_HTCUT_HBEAM + 10 * GEO.EPS_SMALL then dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY() + BD.CUT_EXTRA_MIN, BD.CUT_EXTRA) else dCutExtra = - ( b3Raw:getDimY() - dMaxDepth) @@ -458,6 +474,39 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt dAccStart = sqrt( max( dSawRad * dSawRad - dKL * dKL, 0)) end end + + -- per travi alte faccio faccio dei tagli orizzontali aggiuntivi + local _, _, dimV = BL.GetFaceHvRefDim( Proc.Id, 0, b3Raw) + local dMinTailScrapForHorizontalCuts = 10.123 + local bAreHorizontalCutsNeeded = not bSplit and ( dimV > BD.MAX_LEN_DICE) and not bBigSectionCut and ( dLenEndRaw > dMinTailScrapForHorizontalCuts - 10 * GEO.EPS_SMALL) + if bAreHorizontalCutsNeeded then + local nHorizontalCuts = ceil ( dimV / BD.MAX_DIM_DICE) - 1 + local dHorizontalSliceHeight = dimV / ( nHorizontalCuts + 1) + for i = nCuts, 1, -1 do + local dCutXOffset = ( i - 1) * dOffsL + -- tagli orizzontali + for j = nHorizontalCuts, 1, -1 do + local nFaceUse = MCH_MILL_FU.PARAL_DOWN + local dHorizontalCutOffset = dHorizontalSliceHeight * -j + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0 , sCutting, dSawDiam, nFaceUse, nil, -0.1 - dCutXOffset, BD.CUT_SIC, dHorizontalCutOffset, 0, 0, 'Precut;', b3Raw) + if not bOk then return false, sErr end + end + -- se necessario taglio verticale doppio, eseguo l'opposto + if bDoubleCut then + -- gli accorciamenti vanno invertiti per il taglio opposto + local dAccStartDoubleCut, dAccEndDoubleCut = dAccEnd, dAccStart + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_FRONT, nil, dCutExtra, BD.CUT_SIC, dCutXOffset, dAccStartDoubleCut, dAccEndDoubleCut, 'Precut;', b3Raw, true) + if not bOk then return false, sErr end + end + -- taglio verticale + local sInfo = 'PreCut;' + if i == 1 then sInfo = 'Cut;' end + local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutXOffset, dAccStart, dAccEnd, sInfo, b3Raw) + if not bOk then return false, sErr end + end + return true, sWarn, nNewPhase + end + -- se necessari tagli in doppio, eseguo gli opposti if bDoubleCut then -- gli accorciamenti vanno invertiti per il taglio opposto @@ -478,6 +527,10 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId, nOrd, sDownOrSideOrSt else sNotes = EgtIf( i == 1, 'Cut;', 'Precut;') end + -- se primo taglio da sopra e PF o ONE richiedo risalita preliminare a Zmax + if i == nCuts and bHorizCut and BD.C_SIMM and not BD.DOWN_HEAD then + sNotes = EgtSetValInNotes( sNotes, 'StartZmax', 2) + end local bOk, sErr = Fbs.MakeOne( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, dAccEnd, sNotes, b3Raw) if not bOk then return false, sErr end end diff --git a/Process.lua b/Process.lua index 65c66fd..09d5b8f 100644 --- a/Process.lua +++ b/Process.lua @@ -62,7 +62,7 @@ local function MyProcessInputData() end end if not bFound then - table.insert( vBeam, { Id = nPartId, Name = ( EgtGetName( nPartId) or ( 'Id=' .. tonumber( nPartId)))}) + table.insert( vBeam, { Ind = #vBeam + 1, Id = nPartId, Name = ( EgtGetName( nPartId) or ( 'Id=' .. tonumber( nPartId)))}) end end nId = EgtGetNextSelectedObj() @@ -116,7 +116,13 @@ local function MyProcessInputData() EgtDeselectAll() -- Le ordino in senso di lunghezza crescente - table.sort( vBeam, function( B1, B2) return B1.Box:getDimX() < B2.Box:getDimX() end) + table.sort( vBeam, function( B1, B2) + if abs( B1.Box:getDimX() - B2.Box:getDimX()) < 1 then + return B1.Ind < B2.Ind + else + return B1.Box:getDimX() < B2.Box:getDimX() + end + end) do local sOut = '' for i = 1, #vBeam do diff --git a/UpdateLog.txt b/UpdateLog.txt new file mode 100644 index 0000000..53f106a --- /dev/null +++ b/UpdateLog.txt @@ -0,0 +1,61 @@ + ==== Beam Update Log ==== + +Versione 2.5f4 (21/06/2023) +- Fixed : corretto attacco speciale in FreeContour +- Added : aggiunti tagli speciali per evitare il rischio che il cubetto rimanga appoggiato al motore. + +Versione 2.5f3 (16/06/2023) +- Fixed : correzione scelta di approccio lama in casi speciali +- Fixed : correzione a tagli aggiuntivi orizzontali negli split. + +Versione 2.5f2 (12/06/2023) +- Fixed : in LapJoint corretto il recupero dati utensile che, in alcune funzioni, puntava all'utensile errato +- Fixed : In BeamLib -> ChangeOrOpenStart corretta ricerca segmento più lungo. + +Versione 2.5f1 (08/05/2023) +- Fixed : in LongDoubleCut corretta scelta SCC (orientamento braccio testa) per macchine TURN nel caso di concavi +- Modif : in Process (esecuzione manuale da Cam5) ordinamento travi di lunghezza praticamente uguale dipende da ordine di selezione +- Modif : in LapJoint limiti su svuotature tasche a L 4 facce come per L 3 facce +- Modif : in LapJoint su svuotature aggiunto recupero UserNotes da libreria per MaxOptSize. + +Versione 2.5e5 (26/05/2023) +- Fixed : correzioni a Profili Concavo e Convesso per TURN +- Fixed : correzione a foratura per ignorare fori annegati nel pezzo +- Modif : riconoscimento fori da sotto anche dalla faccia di ingresso +- Modif : in foratura se TURN aggiunta possibilità di forare da sotto. + +Versione 2.5e4 (23/05/2023) +- Modif : in LongCut migliorato calcolo e verifica affondamento per lavorazione con lama con codolo in mezzo +- Fixed : correzione SCC lama per macchina Turn [Ticket #1258] + +Versione 2.5e3 (11/05/2023) +- Modif : in taglio di separazione aggiunta richiesta risalita preliminare a Zmax quando da sopra su macchine PF e ONE +- Fixed : in lavorazioni in doppio correzione riconoscimento per possibile lavorazione in doppio di tasche che si toccano sul fondo +- Fixed : in lavorazioni in doppio con lavorazione precedente differente forzata risalita a Zmax per vitare problemi di riposizionamento [Ticket #1062] + +Versione 2.5e2 (04/05/2023) +- Modif : Piccola modifica a SCC per LongCut derivanti da Cut + +Versione 2.5e1 (03/05/2023) +- Modif : in TS3v7 tolleranza su quote sezione portata a 0.1 mm +- Fixed : Corretto SCC in caso di asse utensile allineato con Z [Ticket #1232] + +Versione 2.5d2 (20/04/2023) +- Added : nei tagli di testa e coda, nel caso di travi alte, aggiunti tagli orizzontali per diminuire la dimensione degli sfridi [Ticket #1175, #1185] +- Modif : unificata gestione lato testa per tagli longitudinali [Ticket #1167]. + +Versione 2.5d1 (06/04/23) +- Added : in svuotatura aggiunta possibilità di impostare una distanza di sicurezza minima su attacco da lato aperto +- Modif : in split per travi con sezioni molto grandi e materiale inferiore allo spessore lama, miglioramenti volti ad evitare collisioni prevedibili +- Modif : in taglio con lama piccola miglioria nella scelta della direzione di approccio per pezzi corti +- Fixed : in LapJoint correzione al calcolo della distanza di collisione nel caso in cui il gambo sia più piccolo dell'utensile [Ticket #1150] +- Fixed : corretto ordinamento per fori di coda da lasciare in coda +- Fixed : correzione per gestire la lama principale sulla testa secondaria quando questa non è una testa da sotto [Ticket #1161] +- Fixed : modifiche a Split per travi con sezioni molto grandi e materiale inferiore allo spessore lama. + +Versione 2.5c8 (30/03/23) +- Modif : nei tenoni (standard e coda di rondine) migliorate e unificate condizioni scelta pretaglio con lama o fresa [Ticket #1131] +- Modif : le mortase a coda di rondine sono ora anticipate a prima dei tagli longitudinali indipendentemente dalla sovrapposizione in Y +- Modif : modificato l'ingombro dei tagli inclinati per macchine con trascinatori tipo PF +- Fixed : nelle mortase a coda di rondine corretto calcolo larghezza della mortasa per derivare numero e step passate [Ticket #1126, #1143] +- Fixed : nei tenoni a coda di rondine corretto calcolo distanza lato da lavorare quando la faccia di base è divisa in più parti. \ No newline at end of file diff --git a/Version.lua b/Version.lua index 2374e2c..7d145e9 100644 --- a/Version.lua +++ b/Version.lua @@ -1,6 +1,6 @@ --- Version.lua by Egaltech s.r.l. 2023/03/23 +-- Version.lua by Egaltech s.r.l. 2023/06/08 -- Gestione della versione di Beam NAME = 'Beam' -VERSION = '2.5c7' +VERSION = '2.5f4' MIN_EXE = '2.5c1' diff --git a/bin/Images/.placeholder b/bin/Images/.placeholder deleted file mode 100644 index e69de29..0000000 diff --git a/bin/LuaLibs/.placeholder b/bin/LuaLibs/.placeholder deleted file mode 100644 index e69de29..0000000