From 09127ce5766918d40bdf2c294c67f1c58abf78e2 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 9 Oct 2024 18:09:02 +0200 Subject: [PATCH 01/11] - in WallExec aggiunta squadratura, da completare --- LuaLibs/WallExec.lua | 131 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index b8fdb51..863d856 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -57,6 +57,7 @@ local Text = require( 'WProcessText') local FreeContour = require( 'WProcessFreeContour') local Variant = require( 'WProcessVariant') +local Squaring = {} ------------------------------------------------------------------------------------------------------------- -- *** Inserimento delle pareti nel pannello *** @@ -132,6 +133,7 @@ function WallExec.ProcessWalls( dRawL, dRawW, dRawH, vWall, bMachGroupOk, bNewPr nRaw = EgtAddRawPart( Point3d( 0, 0, 0), dRawL, dRawW, dRawH, WD.RAWCOL) end EgtMoveToCornerRawPart( nRaw, OrigOnTab, nCorner) + EgtSetInfo( nRaw, 'ORIGCORNER', sOrigCorner) EgtSetInfo( nRaw, 'ORD', 1) -- Inserimento dei pezzi nel grezzo for i = 1, #vWall do @@ -1077,6 +1079,108 @@ local function SetMirroredOperations() end end +------------------------------------------------------------------------------------------------------------- +function Squaring.GetMachining( dDepth) + local Machining = {} + local nSquaringToolType = 0 + if WD.SQUARING_EXTEND_Z and type( WD.SQUARING_EXTEND_Z) == "number" then + dDepth = dDepth + WD.SQUARING_EXTEND_Z + end + + -- ricerca lavorazione di squadratura in base alle preferenze utente + if WD.SQUARING_TOOL and type( WD.SQUARING_TOOL) == "number" then + nSquaringToolType = WD.SQUARING_TOOL + end + -- lama + if nSquaringToolType == 0 or nSquaringToolType == 1 then + Machining.sSquaring = WM.FindCutting( 'Squaring', dDepth) + if Machining.sSquaring then + Machining.sToolType = 'Blade' + end + end + -- fresa + if not Machining.sSquaring and ( nSquaringToolType == 0 or nSquaringToolType == 2) then + Machining.sSquaring = WM.FindMilling( 'Squaring', dDepth, nil, nil, nil, nil, true) + if Machining.sSquaring then + Machining.sToolType = 'Mill' + end + end + -- truciolatore + if not Machining.sSquaring and ( nSquaringToolType == 0 or nSquaringToolType == 3) then + Machining.sSquaring = WM.FindMilling( 'Squaring', dDepth, nil, nil, nil, nil, false) + if Machining.sSquaring then + Machining.sToolType = 'Diskmill' + end + end + + -- recupero informazioni utensile + if Machining.sSquaring and EgtMdbSetCurrMachining( Machining.sSquaring) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + local dSpeed = ( EgtTdbGetCurrToolParam( MCH_TP.SPEED)) + Machining.bIsToolCCW = dSpeed < 0 + end + end + + return Machining +end + +------------------------------------------------------------------------------------------------------------- +function Squaring.CreateGeometry( RawPart) + -- TODO gestire squadratura sulle dimensioni massime dei pezzi (shrinktoparts) invece che sul master panel + local SquaringGeometries = {} + local dDimX = RawPart.b3:getDimX() + local dDimY = RawPart.b3:getDimY() + local bShrinkToParts = ( WD.SQUARING_TYPE == 2) + local dOffsetXY = 0 + local dExtendZ = 0 + if WD.SQUARING_OFFSET_XY and type( WD.SQUARING_OFFSET_XY) == "number" then + dOffsetXY = WD.SQUARING_OFFSET_XY + end + if WD.SQUARING_EXTEND_Z and type( WD.SQUARING_EXTEND_Z) == "number" then + dExtendZ = WD.SQUARING_EXTEND_Z + end + + local pt1 = RawPart.b3:getMin() + Point3d( -dOffsetXY, -dOffsetXY, -dExtendZ) + local pt2 = pt1 + Point3d( dDimX + 2 * dOffsetXY, 0, 0) + local pt3 = pt2 + Point3d( 0, dDimY + 2 * dOffsetXY,0 ) + local pt4 = pt3 + Point3d( -dDimX - 2 * dOffsetXY, 0, 0) + local nFrontLineId = EgtLine( RawPart.nId, pt1, pt2, GDB_RT.GLOB) + local nRightLineId = EgtLine( RawPart.nId, pt2, pt3, GDB_RT.GLOB) + local nBackLinedId = EgtLine( RawPart.nId, pt3, pt4, GDB_RT.GLOB) + local nLeftLineId = EgtLine( RawPart.nId, pt4, pt1, GDB_RT.GLOB) + EgtSetName( nFrontLineId, 'SquaringGeometry' ) + EgtSetName( nRightLineId, 'SquaringGeometry' ) + EgtSetName( nBackLinedId, 'SquaringGeometry' ) + EgtSetName( nLeftLineId, 'SquaringGeometry' ) + + for i = 1, 4 do + SquaringGeometries[i] = {} + end + -- di default l'ordine è per lama CCW (o fresa CW) e partenza vicino al parcheggio della macchina + SquaringGeometries[1].nId = nLeftLineId + SquaringGeometries[1].sType = 'Left' + SquaringGeometries[2].nId = nBackLinedId + SquaringGeometries[2].sType = 'Back' + SquaringGeometries[3].nId = nRightLineId + SquaringGeometries[3].sType = 'Right' + SquaringGeometries[4].nId = nFrontLineId + SquaringGeometries[4].sType = 'Front' + + return SquaringGeometries +end + +------------------------------------------------------------------------------------------------------------- +function Squaring.AddMachinings( sSquaring, SquaringGeometries, nFirstOperationId) + + for i = 1, #SquaringGeometries do + local nSquaringOperationId = EgtAddMachining('SQUARING', sSquaring) + EgtSetMachiningGeometry( SquaringGeometries[i].nId) + EgtApplyMachining( true, false) + EgtRelocateGlob( nSquaringOperationId, nFirstOperationId, GDB_IN.BEFORE) + end +end + ------------------------------------------------------------------------------------------------------------- function WallExec.ProcessFeatures() -- errori e stato @@ -1226,6 +1330,33 @@ function WallExec.ProcessFeatures() -- ordinamento standard SortMachinings( nPhase, PrevMch) + -- squadratura, se richiesta + if WD.SQUARING_TYPE and WD.SQUARING_TYPE > 0 then + local nFirstOperationId = EgtGetNextOperation( EgtGetPhaseDisposition( nPhase)) + local dDepth = b3Raw:getDimZ() + + -- ricerca lavorazione + local Machining = Squaring.GetMachining( dDepth) + if Machining.sSquaring then + -- creazione percorsi + local RawPart = { nId = nRawId, b3 = b3Raw} + local SquaringGeometries = Squaring.CreateGeometry( RawPart) + + -- applicazione lavorazioni + local bIsApplyOk = Squaring.AddMachinings( Machining.sSquaring, SquaringGeometries, nFirstOperationId) + + -- pulizia sfridi alla prima lavorazione dopo la squadratura + EgtSetCurrMachining( nFirstOperationId) + local sMachiningNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + sMachiningNotes = sMachiningNotes .. 'ScrapRemove=1;' + EgtSetMachiningParam( MCH_MP.USERNOTES, sMachiningNotes) + else + local sErr = 'Error : Squaring not found in library' + EgtOutLog( sErr) + table.insert( Stats, {Err=1, Msg=sErr, Rot=0, CutId=0, TaskId=0}) + end + end + -- Aggiornamento finale di tutto if nGetPriorityFromBtl > 0 then InsertScrapRemoval( nPhase) From 5c9e199c5ad977200a9f67dbce176c23643a7951 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 11 Oct 2024 11:36:24 +0200 Subject: [PATCH 02/11] - in squadratura aggiunta gestione della direzione di percorrenza delle geometrie in base a rotazione utensile e riferimento; altri miglioramenti --- LuaLibs/WallExec.lua | 100 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 79 insertions(+), 21 deletions(-) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 863d856..03da372 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -1095,49 +1095,53 @@ function Squaring.GetMachining( dDepth) if nSquaringToolType == 0 or nSquaringToolType == 1 then Machining.sSquaring = WM.FindCutting( 'Squaring', dDepth) if Machining.sSquaring then - Machining.sToolType = 'Blade' + Machining.sType = 'Sawing' end end -- fresa if not Machining.sSquaring and ( nSquaringToolType == 0 or nSquaringToolType == 2) then Machining.sSquaring = WM.FindMilling( 'Squaring', dDepth, nil, nil, nil, nil, true) if Machining.sSquaring then - Machining.sToolType = 'Mill' + Machining.sType = 'Milling' end end -- truciolatore if not Machining.sSquaring and ( nSquaringToolType == 0 or nSquaringToolType == 3) then Machining.sSquaring = WM.FindMilling( 'Squaring', dDepth, nil, nil, nil, nil, false) if Machining.sSquaring then - Machining.sToolType = 'Diskmill' + Machining.sType = 'Milling' end end -- recupero informazioni utensile + local bIsToolCCW if Machining.sSquaring and EgtMdbSetCurrMachining( Machining.sSquaring) then local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then local dSpeed = ( EgtTdbGetCurrToolParam( MCH_TP.SPEED)) - Machining.bIsToolCCW = dSpeed < 0 + bIsToolCCW = dSpeed < 0 end end + Machining.bIsPathCW = ( not( bIsToolCCW) and Machining.sType == 'Milling') or ( bIsToolCCW and Machining.sType ~= 'Milling') return Machining end ------------------------------------------------------------------------------------------------------------- -function Squaring.CreateGeometry( RawPart) +function Squaring.CreateGeometry( RawPart, Machining) -- TODO gestire squadratura sulle dimensioni massime dei pezzi (shrinktoparts) invece che sul master panel local SquaringGeometries = {} local dDimX = RawPart.b3:getDimX() local dDimY = RawPart.b3:getDimY() + local sOrigCorner = EgtGetInfo( RawPart.nId, 'ORIGCORNER') local bShrinkToParts = ( WD.SQUARING_TYPE == 2) + local bSquaringStartsOnReference = type( WD.SQUARING_STARTS_ON_REFERENCE) == "boolean" and ( WD.SQUARING_STARTS_ON_REFERENCE == true) local dOffsetXY = 0 local dExtendZ = 0 - if WD.SQUARING_OFFSET_XY and type( WD.SQUARING_OFFSET_XY) == "number" then + if type( WD.SQUARING_OFFSET_XY) == "number" then dOffsetXY = WD.SQUARING_OFFSET_XY end - if WD.SQUARING_EXTEND_Z and type( WD.SQUARING_EXTEND_Z) == "number" then + if type( WD.SQUARING_EXTEND_Z) == "number" then dExtendZ = WD.SQUARING_EXTEND_Z end @@ -1157,25 +1161,79 @@ function Squaring.CreateGeometry( RawPart) for i = 1, 4 do SquaringGeometries[i] = {} end - -- di default l'ordine è per lama CCW (o fresa CW) e partenza vicino al parcheggio della macchina - SquaringGeometries[1].nId = nLeftLineId - SquaringGeometries[1].sType = 'Left' - SquaringGeometries[2].nId = nBackLinedId - SquaringGeometries[2].sType = 'Back' - SquaringGeometries[3].nId = nRightLineId - SquaringGeometries[3].sType = 'Right' - SquaringGeometries[4].nId = nFrontLineId - SquaringGeometries[4].sType = 'Front' + -- l'ordine di percorrenza delle linee dipende dal verso di percorrenza e, se attivato, dal riferimento utilizzato + if Machining.bIsPathCW then + if bSquaringStartsOnReference and ( sOrigCorner == 'BL' or sOrigCorner == 'BM') then + SquaringGeometries[1].nId = nFrontLineId + SquaringGeometries[2].nId = nLeftLineId + SquaringGeometries[3].nId = nBackLinedId + SquaringGeometries[4].nId = nRightLineId + elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then + SquaringGeometries[1].nId = nBackLinedId + SquaringGeometries[2].nId = nRightLineId + SquaringGeometries[3].nId = nFrontLineId + SquaringGeometries[4].nId = nLeftLineId + elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then + SquaringGeometries[1].nId = nRightLineId + SquaringGeometries[2].nId = nFrontLineId + SquaringGeometries[3].nId = nLeftLineId + SquaringGeometries[4].nId = nBackLinedId + else + SquaringGeometries[1].nId = nLeftLineId + SquaringGeometries[2].nId = nBackLinedId + SquaringGeometries[3].nId = nRightLineId + SquaringGeometries[4].nId = nFrontLineId + end + else + if bSquaringStartsOnReference and ( sOrigCorner == 'TL' or sOrigCorner == 'TM') then + SquaringGeometries[1].nId = nBackLinedId + SquaringGeometries[2].nId = nLeftLineId + SquaringGeometries[3].nId = nFrontLineId + SquaringGeometries[4].nId = nRightLineId + elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then + SquaringGeometries[1].nId = nRightLineId + SquaringGeometries[2].nId = nBackLinedId + SquaringGeometries[3].nId = nLeftLineId + SquaringGeometries[4].nId = nFrontLineId + elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then + SquaringGeometries[1].nId = nFrontLineId + SquaringGeometries[2].nId = nRightLineId + SquaringGeometries[3].nId = nBackLinedId + SquaringGeometries[4].nId = nLeftLineId + else + SquaringGeometries[1].nId = nLeftLineId + SquaringGeometries[2].nId = nFrontLineId + SquaringGeometries[3].nId = nRightLineId + SquaringGeometries[4].nId = nBackLinedId + end + end return SquaringGeometries end ------------------------------------------------------------------------------------------------------------- -function Squaring.AddMachinings( sSquaring, SquaringGeometries, nFirstOperationId) - +function Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationId) for i = 1, #SquaringGeometries do - local nSquaringOperationId = EgtAddMachining('SQUARING', sSquaring) + local nSquaringOperationId = EgtAddMachining('SQUARING', Machining.sSquaring) EgtSetMachiningGeometry( SquaringGeometries[i].nId) + -- in base al verso di percorrenza modifico i parametri significativi di lavorazione + if Machining.bIsPathCW then + if Machining.sType == 'Sawing' then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_SAW_WS.LEFT) + EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.LEFT) + elseif Machining.sType == 'Milling' then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + end + EgtSetMachiningParam( MCH_MP.INVERT, true) + else + if Machining.sType == 'Sawing' then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_SAW_WS.RIGHT) + EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.RIGHT) + elseif Machining.sType == 'Milling' then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + end + EgtSetMachiningParam( MCH_MP.INVERT, false) + end EgtApplyMachining( true, false) EgtRelocateGlob( nSquaringOperationId, nFirstOperationId, GDB_IN.BEFORE) end @@ -1340,10 +1398,10 @@ function WallExec.ProcessFeatures() if Machining.sSquaring then -- creazione percorsi local RawPart = { nId = nRawId, b3 = b3Raw} - local SquaringGeometries = Squaring.CreateGeometry( RawPart) + local SquaringGeometries = Squaring.CreateGeometry( RawPart, Machining) -- applicazione lavorazioni - local bIsApplyOk = Squaring.AddMachinings( Machining.sSquaring, SquaringGeometries, nFirstOperationId) + local bIsApplyOk = Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationId) -- pulizia sfridi alla prima lavorazione dopo la squadratura EgtSetCurrMachining( nFirstOperationId) From bfaa85bbf20844212392ed1e2224c9a4ec2eea7b Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 14 Oct 2024 14:26:58 +0200 Subject: [PATCH 03/11] - in squadratura aggiunta gestione truciolatore e ritorno errori --- LuaLibs/WallExec.lua | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 03da372..d1976e4 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -1107,9 +1107,9 @@ function Squaring.GetMachining( dDepth) end -- truciolatore if not Machining.sSquaring and ( nSquaringToolType == 0 or nSquaringToolType == 3) then - Machining.sSquaring = WM.FindMilling( 'Squaring', dDepth, nil, nil, nil, nil, false) + Machining.sSquaring = WM.FindMilling( 'Squaring', nil, nil, nil, nil, nil, nil, dDepth) if Machining.sSquaring then - Machining.sType = 'Milling' + Machining.sType = 'DiskMilling' end end @@ -1153,6 +1153,12 @@ function Squaring.CreateGeometry( RawPart, Machining) local nRightLineId = EgtLine( RawPart.nId, pt2, pt3, GDB_RT.GLOB) local nBackLinedId = EgtLine( RawPart.nId, pt3, pt4, GDB_RT.GLOB) local nLeftLineId = EgtLine( RawPart.nId, pt4, pt1, GDB_RT.GLOB) + if Machining.sType == 'DiskMilling' then + EgtModifyCurveExtrusion( nFrontLineId, -Y_AX(), GDB_RT.GLOB) + EgtModifyCurveExtrusion( nRightLineId, X_AX(), GDB_RT.GLOB) + EgtModifyCurveExtrusion( nBackLinedId, Y_AX(), GDB_RT.GLOB) + EgtModifyCurveExtrusion( nLeftLineId, -X_AX(), GDB_RT.GLOB) + end EgtSetName( nFrontLineId, 'SquaringGeometry' ) EgtSetName( nRightLineId, 'SquaringGeometry' ) EgtSetName( nBackLinedId, 'SquaringGeometry' ) @@ -1213,16 +1219,21 @@ end ------------------------------------------------------------------------------------------------------------- function Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationId) + local nNotOkCount = 0 + local sMsgTotal = '' + for i = 1, #SquaringGeometries do local nSquaringOperationId = EgtAddMachining('SQUARING', Machining.sSquaring) EgtSetMachiningGeometry( SquaringGeometries[i].nId) -- in base al verso di percorrenza modifico i parametri significativi di lavorazione if Machining.bIsPathCW then - if Machining.sType == 'Sawing' then + if Machining.sType == 'Sawing'then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_SAW_WS.LEFT) EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.LEFT) elseif Machining.sType == 'Milling' then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + elseif Machining.sType == 'DiskMilling' then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) end EgtSetMachiningParam( MCH_MP.INVERT, true) else @@ -1231,12 +1242,21 @@ function Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationI EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.RIGHT) elseif Machining.sType == 'Milling' then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + elseif Machining.sType == 'DiskMilling' then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) end EgtSetMachiningParam( MCH_MP.INVERT, false) end - EgtApplyMachining( true, false) + local bOk = EgtApplyMachining( true, false) EgtRelocateGlob( nSquaringOperationId, nFirstOperationId, GDB_IN.BEFORE) + if not bOk then + local _, sMsg = EgtGetLastMachMgrError() + nNotOkCount = nNotOkCount + 1 + sMsgTotal = sMsgTotal ..'\n' .. ( sMsg or '') + end end + + return ( nNotOkCount < 1), sMsgTotal end ------------------------------------------------------------------------------------------------------------- @@ -1401,7 +1421,15 @@ function WallExec.ProcessFeatures() local SquaringGeometries = Squaring.CreateGeometry( RawPart, Machining) -- applicazione lavorazioni - local bIsApplyOk = Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationId) + local bIsApplyOk, sMsg = Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationId) + if not bIsApplyOk then + nTotErr = nTotErr + 1 + table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=0, TaskId=0}) + elseif sMsg and #sMsg > 0 then + table.insert( Stats, {Err=-1, Msg=sMsg, Rot=0, CutId=0, TaskId=0}) + else + table.insert( Stats, {Err=0, Msg='', Rot=0, CutId=0, TaskId=0}) + end -- pulizia sfridi alla prima lavorazione dopo la squadratura EgtSetCurrMachining( nFirstOperationId) From 6e7c4ffda182c0083a9a2d1030bb3a14531fd004 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 16 Oct 2024 16:59:17 +0200 Subject: [PATCH 04/11] - modifiche parziali a squadratura per contemplare casi in doppio --- LuaLibs/Squaring.lua | 196 ++++++++++++++++++++++++++++++++++++++ LuaLibs/WallExec.lua | 218 +++++++++---------------------------------- 2 files changed, 238 insertions(+), 176 deletions(-) create mode 100644 LuaLibs/Squaring.lua diff --git a/LuaLibs/Squaring.lua b/LuaLibs/Squaring.lua new file mode 100644 index 0000000..c31063d --- /dev/null +++ b/LuaLibs/Squaring.lua @@ -0,0 +1,196 @@ +-- Squaring.lua by Egaltech s.r.l. 2024/10/15 +-- Libreria squadratura pareti + +-- Tabella per definizione modulo +local Squaring = {} + +-- Include +require( 'EgtBase') + +EgtOutLog( ' Squaring started', 1) + +-- Dati +local WD = require( 'WallData') + +------------------------------------------------------------------------------------------------------------- +function Squaring.GetMachining( dDepth) + local Machining = {} + local nSquaringToolType = 0 + if WD.SQUARING_EXTEND_Z and type( WD.SQUARING_EXTEND_Z) == "number" then + dDepth = dDepth + WD.SQUARING_EXTEND_Z + end + + -- ricerca lavorazione di squadratura in base alle preferenze utente + if WD.SQUARING_TOOL and type( WD.SQUARING_TOOL) == "number" then + nSquaringToolType = WD.SQUARING_TOOL + end + -- lama + if nSquaringToolType == 0 or nSquaringToolType == 1 then + Machining.sSquaring = WM.FindCutting( 'Squaring', dDepth) + if Machining.sSquaring then + Machining.sType = 'Sawing' + end + end + -- fresa + if not Machining.sSquaring and ( nSquaringToolType == 0 or nSquaringToolType == 2) then + Machining.sSquaring = WM.FindMilling( 'Squaring', dDepth, nil, nil, nil, nil, true) + if Machining.sSquaring then + Machining.sType = 'Milling' + end + end + -- truciolatore + if not Machining.sSquaring and ( nSquaringToolType == 0 or nSquaringToolType == 3) then + Machining.sSquaring = WM.FindMilling( 'Squaring', nil, nil, nil, nil, nil, nil, dDepth) + if Machining.sSquaring then + Machining.sType = 'DiskMilling' + end + end + + -- recupero informazioni utensile + local bIsToolCCW + if Machining.sSquaring and EgtMdbSetCurrMachining( Machining.sSquaring) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + local dSpeed = ( EgtTdbGetCurrToolParam( MCH_TP.SPEED)) + bIsToolCCW = dSpeed < 0 + end + end + Machining.bIsPathCW = ( not( bIsToolCCW) and Machining.sType == 'Milling') or ( bIsToolCCW and Machining.sType ~= 'Milling') + + return Machining +end + +------------------------------------------------------------------------------------------------------------- +function Squaring.CreateGeometry( RawPart, Machining) + -- TODO gestire squadratura sulle dimensioni massime dei pezzi (shrinktoparts) invece che sul master panel + local SquaringGeometries = {} + local dDimX = RawPart.b3:getDimX() + local dDimY = RawPart.b3:getDimY() + local sOrigCorner = EgtGetInfo( RawPart.nId, 'ORIGCORNER') + local bShrinkToParts = ( WD.SQUARING_TYPE == 2) + local bSquaringStartsOnReference = type( WD.SQUARING_STARTS_ON_REFERENCE) == "boolean" and ( WD.SQUARING_STARTS_ON_REFERENCE == true) + local dOffsetXY = 0 + local dExtendZ = 0 + if type( WD.SQUARING_OFFSET_XY) == "number" then + dOffsetXY = WD.SQUARING_OFFSET_XY + end + if type( WD.SQUARING_EXTEND_Z) == "number" then + dExtendZ = WD.SQUARING_EXTEND_Z + end + + local pt1 = RawPart.b3:getMin() + Point3d( -dOffsetXY, -dOffsetXY, -dExtendZ) + local pt2 = pt1 + Point3d( dDimX + 2 * dOffsetXY, 0, 0) + local pt3 = pt2 + Point3d( 0, dDimY + 2 * dOffsetXY,0 ) + local pt4 = pt3 + Point3d( -dDimX - 2 * dOffsetXY, 0, 0) + local nFrontLineId = EgtLine( RawPart.nId, pt1, pt2, GDB_RT.GLOB) + local nRightLineId = EgtLine( RawPart.nId, pt2, pt3, GDB_RT.GLOB) + local nBackLinedId = EgtLine( RawPart.nId, pt3, pt4, GDB_RT.GLOB) + local nLeftLineId = EgtLine( RawPart.nId, pt4, pt1, GDB_RT.GLOB) + if Machining.sType == 'DiskMilling' or Machining.sType == 'Milling' then + EgtModifyCurveExtrusion( nFrontLineId, -Y_AX(), GDB_RT.GLOB) + EgtModifyCurveExtrusion( nRightLineId, X_AX(), GDB_RT.GLOB) + EgtModifyCurveExtrusion( nBackLinedId, Y_AX(), GDB_RT.GLOB) + EgtModifyCurveExtrusion( nLeftLineId, -X_AX(), GDB_RT.GLOB) + end + EgtSetName( nFrontLineId, 'SquaringGeometry' ) + EgtSetName( nRightLineId, 'SquaringGeometry' ) + EgtSetName( nBackLinedId, 'SquaringGeometry' ) + EgtSetName( nLeftLineId, 'SquaringGeometry' ) + + for i = 1, 4 do + SquaringGeometries[i] = {} + end + -- l'ordine di percorrenza delle linee dipende dal verso di percorrenza e, se attivato, dal riferimento utilizzato + if Machining.bIsPathCW then + if bSquaringStartsOnReference and ( sOrigCorner == 'BL' or sOrigCorner == 'BM') then + SquaringGeometries[1].nId = nFrontLineId + SquaringGeometries[2].nId = nLeftLineId + SquaringGeometries[3].nId = nBackLinedId + SquaringGeometries[4].nId = nRightLineId + elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then + SquaringGeometries[1].nId = nBackLinedId + SquaringGeometries[2].nId = nRightLineId + SquaringGeometries[3].nId = nFrontLineId + SquaringGeometries[4].nId = nLeftLineId + elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then + SquaringGeometries[1].nId = nRightLineId + SquaringGeometries[2].nId = nFrontLineId + SquaringGeometries[3].nId = nLeftLineId + SquaringGeometries[4].nId = nBackLinedId + else + SquaringGeometries[1].nId = nLeftLineId + SquaringGeometries[2].nId = nBackLinedId + SquaringGeometries[3].nId = nRightLineId + SquaringGeometries[4].nId = nFrontLineId + end + else + if bSquaringStartsOnReference and ( sOrigCorner == 'TL' or sOrigCorner == 'TM') then + SquaringGeometries[1].nId = nBackLinedId + SquaringGeometries[2].nId = nLeftLineId + SquaringGeometries[3].nId = nFrontLineId + SquaringGeometries[4].nId = nRightLineId + elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then + SquaringGeometries[1].nId = nRightLineId + SquaringGeometries[2].nId = nBackLinedId + SquaringGeometries[3].nId = nLeftLineId + SquaringGeometries[4].nId = nFrontLineId + elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then + SquaringGeometries[1].nId = nFrontLineId + SquaringGeometries[2].nId = nRightLineId + SquaringGeometries[3].nId = nBackLinedId + SquaringGeometries[4].nId = nLeftLineId + else + SquaringGeometries[1].nId = nLeftLineId + SquaringGeometries[2].nId = nFrontLineId + SquaringGeometries[3].nId = nRightLineId + SquaringGeometries[4].nId = nBackLinedId + end + end + + return SquaringGeometries +end + +------------------------------------------------------------------------------------------------------------- +function Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationId) + local nNotOkCount = 0 + local sMsgTotal = '' + + for i = 1, #SquaringGeometries do + local nSquaringOperationId = EgtAddMachining('SQUARING', Machining.sSquaring) + EgtSetMachiningGeometry( SquaringGeometries[i].nId) + -- in base al verso di percorrenza modifico i parametri significativi di lavorazione + if Machining.bIsPathCW then + if Machining.sType == 'Sawing'then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_SAW_WS.LEFT) + EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.LEFT) + elseif Machining.sType == 'Milling' then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + elseif Machining.sType == 'DiskMilling' then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + end + EgtSetMachiningParam( MCH_MP.INVERT, true) + else + if Machining.sType == 'Sawing' then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_SAW_WS.RIGHT) + EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.RIGHT) + elseif Machining.sType == 'Milling' then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + elseif Machining.sType == 'DiskMilling' then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + end + EgtSetMachiningParam( MCH_MP.INVERT, false) + end + local bOk = EgtApplyMachining( true, false) + EgtRelocateGlob( nSquaringOperationId, nFirstOperationId, GDB_IN.BEFORE) + if not bOk then + local _, sMsg = EgtGetLastMachMgrError() + nNotOkCount = nNotOkCount + 1 + sMsgTotal = sMsgTotal ..'\n' .. ( sMsg or '') + end + end + + return ( nNotOkCount < 1), sMsgTotal +end + +------------------------------------------------------------------------------------------------------------- +return Squaring \ No newline at end of file diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index d1976e4..0352166 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -45,6 +45,7 @@ _G.package.loaded.WProcessVariant = nil local WM = require( 'WMachiningLib') local WL = require( 'WallLib') local Topology = require( 'WFeatureTopology') +local Squaring = require( 'Squaring') local Cut = require( 'WProcessCut') local DoubleCut = require( 'WProcessDoubleCut') local SawCut = require( 'WProcessSawCut') @@ -57,8 +58,6 @@ local Text = require( 'WProcessText') local FreeContour = require( 'WProcessFreeContour') local Variant = require( 'WProcessVariant') -local Squaring = {} - ------------------------------------------------------------------------------------------------------------- -- *** Inserimento delle pareti nel pannello *** ------------------------------------------------------------------------------------------------------------- @@ -1080,183 +1079,10 @@ local function SetMirroredOperations() end ------------------------------------------------------------------------------------------------------------- -function Squaring.GetMachining( dDepth) - local Machining = {} - local nSquaringToolType = 0 - if WD.SQUARING_EXTEND_Z and type( WD.SQUARING_EXTEND_Z) == "number" then - dDepth = dDepth + WD.SQUARING_EXTEND_Z - end +local function AddSquaring( sSquaringTool, RawPart, nFirstOperationId) - -- ricerca lavorazione di squadratura in base alle preferenze utente - if WD.SQUARING_TOOL and type( WD.SQUARING_TOOL) == "number" then - nSquaringToolType = WD.SQUARING_TOOL - end - -- lama - if nSquaringToolType == 0 or nSquaringToolType == 1 then - Machining.sSquaring = WM.FindCutting( 'Squaring', dDepth) - if Machining.sSquaring then - Machining.sType = 'Sawing' - end - end - -- fresa - if not Machining.sSquaring and ( nSquaringToolType == 0 or nSquaringToolType == 2) then - Machining.sSquaring = WM.FindMilling( 'Squaring', dDepth, nil, nil, nil, nil, true) - if Machining.sSquaring then - Machining.sType = 'Milling' - end - end - -- truciolatore - if not Machining.sSquaring and ( nSquaringToolType == 0 or nSquaringToolType == 3) then - Machining.sSquaring = WM.FindMilling( 'Squaring', nil, nil, nil, nil, nil, nil, dDepth) - if Machining.sSquaring then - Machining.sType = 'DiskMilling' - end - end - -- recupero informazioni utensile - local bIsToolCCW - if Machining.sSquaring and EgtMdbSetCurrMachining( Machining.sSquaring) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - local dSpeed = ( EgtTdbGetCurrToolParam( MCH_TP.SPEED)) - bIsToolCCW = dSpeed < 0 - end - end - Machining.bIsPathCW = ( not( bIsToolCCW) and Machining.sType == 'Milling') or ( bIsToolCCW and Machining.sType ~= 'Milling') - return Machining -end - -------------------------------------------------------------------------------------------------------------- -function Squaring.CreateGeometry( RawPart, Machining) - -- TODO gestire squadratura sulle dimensioni massime dei pezzi (shrinktoparts) invece che sul master panel - local SquaringGeometries = {} - local dDimX = RawPart.b3:getDimX() - local dDimY = RawPart.b3:getDimY() - local sOrigCorner = EgtGetInfo( RawPart.nId, 'ORIGCORNER') - local bShrinkToParts = ( WD.SQUARING_TYPE == 2) - local bSquaringStartsOnReference = type( WD.SQUARING_STARTS_ON_REFERENCE) == "boolean" and ( WD.SQUARING_STARTS_ON_REFERENCE == true) - local dOffsetXY = 0 - local dExtendZ = 0 - if type( WD.SQUARING_OFFSET_XY) == "number" then - dOffsetXY = WD.SQUARING_OFFSET_XY - end - if type( WD.SQUARING_EXTEND_Z) == "number" then - dExtendZ = WD.SQUARING_EXTEND_Z - end - - local pt1 = RawPart.b3:getMin() + Point3d( -dOffsetXY, -dOffsetXY, -dExtendZ) - local pt2 = pt1 + Point3d( dDimX + 2 * dOffsetXY, 0, 0) - local pt3 = pt2 + Point3d( 0, dDimY + 2 * dOffsetXY,0 ) - local pt4 = pt3 + Point3d( -dDimX - 2 * dOffsetXY, 0, 0) - local nFrontLineId = EgtLine( RawPart.nId, pt1, pt2, GDB_RT.GLOB) - local nRightLineId = EgtLine( RawPart.nId, pt2, pt3, GDB_RT.GLOB) - local nBackLinedId = EgtLine( RawPart.nId, pt3, pt4, GDB_RT.GLOB) - local nLeftLineId = EgtLine( RawPart.nId, pt4, pt1, GDB_RT.GLOB) - if Machining.sType == 'DiskMilling' then - EgtModifyCurveExtrusion( nFrontLineId, -Y_AX(), GDB_RT.GLOB) - EgtModifyCurveExtrusion( nRightLineId, X_AX(), GDB_RT.GLOB) - EgtModifyCurveExtrusion( nBackLinedId, Y_AX(), GDB_RT.GLOB) - EgtModifyCurveExtrusion( nLeftLineId, -X_AX(), GDB_RT.GLOB) - end - EgtSetName( nFrontLineId, 'SquaringGeometry' ) - EgtSetName( nRightLineId, 'SquaringGeometry' ) - EgtSetName( nBackLinedId, 'SquaringGeometry' ) - EgtSetName( nLeftLineId, 'SquaringGeometry' ) - - for i = 1, 4 do - SquaringGeometries[i] = {} - end - -- l'ordine di percorrenza delle linee dipende dal verso di percorrenza e, se attivato, dal riferimento utilizzato - if Machining.bIsPathCW then - if bSquaringStartsOnReference and ( sOrigCorner == 'BL' or sOrigCorner == 'BM') then - SquaringGeometries[1].nId = nFrontLineId - SquaringGeometries[2].nId = nLeftLineId - SquaringGeometries[3].nId = nBackLinedId - SquaringGeometries[4].nId = nRightLineId - elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then - SquaringGeometries[1].nId = nBackLinedId - SquaringGeometries[2].nId = nRightLineId - SquaringGeometries[3].nId = nFrontLineId - SquaringGeometries[4].nId = nLeftLineId - elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then - SquaringGeometries[1].nId = nRightLineId - SquaringGeometries[2].nId = nFrontLineId - SquaringGeometries[3].nId = nLeftLineId - SquaringGeometries[4].nId = nBackLinedId - else - SquaringGeometries[1].nId = nLeftLineId - SquaringGeometries[2].nId = nBackLinedId - SquaringGeometries[3].nId = nRightLineId - SquaringGeometries[4].nId = nFrontLineId - end - else - if bSquaringStartsOnReference and ( sOrigCorner == 'TL' or sOrigCorner == 'TM') then - SquaringGeometries[1].nId = nBackLinedId - SquaringGeometries[2].nId = nLeftLineId - SquaringGeometries[3].nId = nFrontLineId - SquaringGeometries[4].nId = nRightLineId - elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then - SquaringGeometries[1].nId = nRightLineId - SquaringGeometries[2].nId = nBackLinedId - SquaringGeometries[3].nId = nLeftLineId - SquaringGeometries[4].nId = nFrontLineId - elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then - SquaringGeometries[1].nId = nFrontLineId - SquaringGeometries[2].nId = nRightLineId - SquaringGeometries[3].nId = nBackLinedId - SquaringGeometries[4].nId = nLeftLineId - else - SquaringGeometries[1].nId = nLeftLineId - SquaringGeometries[2].nId = nFrontLineId - SquaringGeometries[3].nId = nRightLineId - SquaringGeometries[4].nId = nBackLinedId - end - end - - return SquaringGeometries -end - -------------------------------------------------------------------------------------------------------------- -function Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationId) - local nNotOkCount = 0 - local sMsgTotal = '' - - for i = 1, #SquaringGeometries do - local nSquaringOperationId = EgtAddMachining('SQUARING', Machining.sSquaring) - EgtSetMachiningGeometry( SquaringGeometries[i].nId) - -- in base al verso di percorrenza modifico i parametri significativi di lavorazione - if Machining.bIsPathCW then - if Machining.sType == 'Sawing'then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_SAW_WS.LEFT) - EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.LEFT) - elseif Machining.sType == 'Milling' then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - elseif Machining.sType == 'DiskMilling' then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - end - EgtSetMachiningParam( MCH_MP.INVERT, true) - else - if Machining.sType == 'Sawing' then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_SAW_WS.RIGHT) - EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.RIGHT) - elseif Machining.sType == 'Milling' then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - elseif Machining.sType == 'DiskMilling' then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - end - EgtSetMachiningParam( MCH_MP.INVERT, false) - end - local bOk = EgtApplyMachining( true, false) - EgtRelocateGlob( nSquaringOperationId, nFirstOperationId, GDB_IN.BEFORE) - if not bOk then - local _, sMsg = EgtGetLastMachMgrError() - nNotOkCount = nNotOkCount + 1 - sMsgTotal = sMsgTotal ..'\n' .. ( sMsg or '') - end - end - - return ( nNotOkCount < 1), sMsgTotal end ------------------------------------------------------------------------------------------------------------- @@ -1410,6 +1236,46 @@ function WallExec.ProcessFeatures() -- squadratura, se richiesta if WD.SQUARING_TYPE and WD.SQUARING_TYPE > 0 then + local RawPart = { nId = nRawId, b3 = b3Raw} + local nFirstOperationId = EgtGetNextOperation( EgtGetPhaseDisposition( nPhase)) + local bOk, sMsg + + if WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 1 then + bOk, sMsg = AddSquaring( 'DoubleDiskmill', RawPart, nFirstOperationId) + end + if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 2) then + bOk, sMsg = AddSquaring( 'DoubleDiskmillAndBlade', RawPart, nFirstOperationId) + end + if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 3) then + bOk, sMsg = AddSquaring( 'DoubleBlade', RawPart, nFirstOperationId) + end + if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 4) then + bOk, sMsg = AddSquaring( 'Diskmill', RawPart, nFirstOperationId) + end + if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 5) then + bOk, sMsg = AddSquaring( 'Blade', RawPart, nFirstOperationId) + end + if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 6) then + bOk, sMsg = AddSquaring( 'DoubleMill', RawPart, nFirstOperationId) + end + if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 7) then + bOk, sMsg = AddSquaring( 'Mill', RawPart, nFirstOperationId) + end + + if not bOk then + nTotErr = nTotErr + 1 + table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=0, TaskId=0}) + elseif sMsg and #sMsg > 0 then + table.insert( Stats, {Err=-1, Msg=sMsg, Rot=0, CutId=0, TaskId=0}) + else + table.insert( Stats, {Err=0, Msg='', Rot=0, CutId=0, TaskId=0}) + end + + + + + + local nFirstOperationId = EgtGetNextOperation( EgtGetPhaseDisposition( nPhase)) local dDepth = b3Raw:getDimZ() From fdd114a8cd4ffaff5e1e367b3240d8e63ce05442 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 21 Oct 2024 12:43:28 +0200 Subject: [PATCH 05/11] - in WallExec -> squadratura aggiunta funzione AddSquaring che verifica e aggiunge la squadratura in base al caso specifico - in Squaring aggiunte funzioni per ricerca e controllo correttezza utensili in base al caso specifico --- LuaLibs/Squaring.lua | 136 +++++++++++++++++++++++++++++-------------- LuaLibs/WallExec.lua | 46 ++++++++++++--- 2 files changed, 129 insertions(+), 53 deletions(-) diff --git a/LuaLibs/Squaring.lua b/LuaLibs/Squaring.lua index c31063d..e70b620 100644 --- a/LuaLibs/Squaring.lua +++ b/LuaLibs/Squaring.lua @@ -13,51 +13,99 @@ EgtOutLog( ' Squaring started', 1) local WD = require( 'WallData') ------------------------------------------------------------------------------------------------------------- -function Squaring.GetMachining( dDepth) - local Machining = {} - local nSquaringToolType = 0 - if WD.SQUARING_EXTEND_Z and type( WD.SQUARING_EXTEND_Z) == "number" then - dDepth = dDepth + WD.SQUARING_EXTEND_Z +local function IsToolOk( Tool, dMachiningDepth) + local bIsToolOk = false + local bToolExists = false + local dToolMaxDepth = 0 + + bToolExists = Tool ~= {} + if bToolExists then + if Tool.nType == MCH_TY.MILL_NOTIP then + dToolMaxDepth = Tool.dThickness + else + dToolMaxDepth = Tool.dMaxDepth + end + end + bIsToolOk = bToolExists and ( dToolMaxDepth > dMachiningDepth - 10 * GEO.EPS_SMALL) + + return bIsToolOk +end + +------------------------------------------------------------------------------------------------------------- +function Squaring.GetTools() + local Tool = {} + local SquaringTools = {} + SquaringTools.Blade = {} + SquaringTools.Diskmill = {} + SquaringTools.Mill = {} + SquaringTools.Blade.H1 = {} + SquaringTools.Blade.H2 = {} + SquaringTools.Blade.H7 = {} + SquaringTools.Diskmill.H1 = {} + SquaringTools.Diskmill.H7 = {} + SquaringTools.Mill.H1 = {} + SquaringTools.Mill.H7 = {} + + Tool.sName = EgtTdbGetFirstTool( MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE) + while Tool.sName ~= '' do + EgtTdbSetCurrTool( Tool.sName) + local bToolLoadedOnSetup = EgtFindToolInCurrSetup( Tool.sName) + local bIsSquaringTool = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SQUARING', 'b') or false + + Tool.nType = EgtTdbGetCurrToolParam( MCH_TP.TYPE) + Tool.dThickness = EgtTdbGetCurrToolParam( MCH_TP.THICK) + Tool.dMaxMaterial = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) + Tool.dMaxDepth = EgtTdbGetCurrToolMaxDepth() or Tool.dMaxMaterial + Tool.sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) + Tool.bIsCcw = EgtTdbGetCurrToolParam( MCH_TP.SPEED) < 0 + + if bToolLoadedOnSetup and Tool.nType and bIsSquaringTool then + -- lame + if Tool.nType == MCH_TY.SAW_FLAT or Tool.nType == MCH_TY.SAW_STD then + SquaringTools.Blade[Tool.sHead] = Tool + -- frese standard + elseif Tool.nType == MCH_TY.MILL_STD then + SquaringTools.Mill[Tool.sHead] = Tool + -- truciolatori + elseif Tool.nType == MCH_TY.MILL_NOTIP then + SquaringTools.Diskmill[Tool.sHead] = Tool + end + end + + Tool = {} + Tool.sName = EgtTdbGetNextTool( MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE) end - -- ricerca lavorazione di squadratura in base alle preferenze utente - if WD.SQUARING_TOOL and type( WD.SQUARING_TOOL) == "number" then - nSquaringToolType = WD.SQUARING_TOOL - end - -- lama - if nSquaringToolType == 0 or nSquaringToolType == 1 then - Machining.sSquaring = WM.FindCutting( 'Squaring', dDepth) - if Machining.sSquaring then - Machining.sType = 'Sawing' - end - end - -- fresa - if not Machining.sSquaring and ( nSquaringToolType == 0 or nSquaringToolType == 2) then - Machining.sSquaring = WM.FindMilling( 'Squaring', dDepth, nil, nil, nil, nil, true) - if Machining.sSquaring then - Machining.sType = 'Milling' - end - end - -- truciolatore - if not Machining.sSquaring and ( nSquaringToolType == 0 or nSquaringToolType == 3) then - Machining.sSquaring = WM.FindMilling( 'Squaring', nil, nil, nil, nil, nil, nil, dDepth) - if Machining.sSquaring then - Machining.sType = 'DiskMilling' - end + return SquaringTools +end + +------------------------------------------------------------------------------------------------------------- +function Squaring.AreToolsOk( sSquaringTool, SquaringTools, dMachiningDepth) + local bAreToolsOk = false + + if sSquaringTool == 'DoubleDiskmill' then + bAreToolsOk = ( IsToolOk( SquaringTools.Blade.H2, dMachiningDepth) + and IsToolOk( SquaringTools.Diskmill.H1, WD.SQUARING_MAX_OVERMATERIAL) + and IsToolOk( SquaringTools.Diskmill.H7, WD.SQUARING_MAX_OVERMATERIAL)) + elseif sSquaringTool == 'DoubleDiskmillAndBlade' then + bAreToolsOk = ( IsToolOk( SquaringTools.Blade.H2, dMachiningDepth) + and ( IsToolOk( SquaringTools.Diskmill.H1, WD.SQUARING_MAX_OVERMATERIAL) or IsToolOk( SquaringTools.Diskmill.H7, WD.SQUARING_MAX_OVERMATERIAL))) + elseif sSquaringTool == 'DoubleBlade' then + bAreToolsOk = ( IsToolOk( SquaringTools.Blade.H2, dMachiningDepth) + and ( IsToolOk( SquaringTools.Blade.H1, dMachiningDepth) or IsToolOk( SquaringTools.Blade.H7, dMachiningDepth))) + elseif sSquaringTool == 'Diskmill' then + bAreToolsOk = IsToolOk( SquaringTools.Diskmill.H1, WD.SQUARING_MAX_OVERMATERIAL) or IsToolOk( SquaringTools.Diskmill.H7, WD.SQUARING_MAX_OVERMATERIAL) + elseif sSquaringTool == 'Blade' then + bAreToolsOk = IsToolOk( SquaringTools.Blade.H2, dMachiningDepth) + elseif sSquaringTool == 'DoubleMill' then + bAreToolsOk = IsToolOk( SquaringTools.Mill.H1, dMachiningDepth) and IsToolOk( SquaringTools.Mill.H7, dMachiningDepth) + elseif sSquaringTool == 'Mill' then + bAreToolsOk = IsToolOk( SquaringTools.Mill.H1, dMachiningDepth) or IsToolOk( SquaringTools.Mill.H7, dMachiningDepth) + else + error( 'Squaring Tool not recognized') end - -- recupero informazioni utensile - local bIsToolCCW - if Machining.sSquaring and EgtMdbSetCurrMachining( Machining.sSquaring) then - local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - local dSpeed = ( EgtTdbGetCurrToolParam( MCH_TP.SPEED)) - bIsToolCCW = dSpeed < 0 - end - end - Machining.bIsPathCW = ( not( bIsToolCCW) and Machining.sType == 'Milling') or ( bIsToolCCW and Machining.sType ~= 'Milling') - - return Machining + return bAreToolsOk end ------------------------------------------------------------------------------------------------------------- @@ -86,7 +134,7 @@ function Squaring.CreateGeometry( RawPart, Machining) local nRightLineId = EgtLine( RawPart.nId, pt2, pt3, GDB_RT.GLOB) local nBackLinedId = EgtLine( RawPart.nId, pt3, pt4, GDB_RT.GLOB) local nLeftLineId = EgtLine( RawPart.nId, pt4, pt1, GDB_RT.GLOB) - if Machining.sType == 'DiskMilling' or Machining.sType == 'Milling' then + if Machining.sType == 'Diskmilling' or Machining.sType == 'Milling' then EgtModifyCurveExtrusion( nFrontLineId, -Y_AX(), GDB_RT.GLOB) EgtModifyCurveExtrusion( nRightLineId, X_AX(), GDB_RT.GLOB) EgtModifyCurveExtrusion( nBackLinedId, Y_AX(), GDB_RT.GLOB) @@ -165,7 +213,7 @@ function Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationI EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.LEFT) elseif Machining.sType == 'Milling' then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - elseif Machining.sType == 'DiskMilling' then + elseif Machining.sType == 'Diskmilling' then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) end EgtSetMachiningParam( MCH_MP.INVERT, true) @@ -175,7 +223,7 @@ function Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationI EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.RIGHT) elseif Machining.sType == 'Milling' then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - elseif Machining.sType == 'DiskMilling' then + elseif Machining.sType == 'Diskmilling' then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) end EgtSetMachiningParam( MCH_MP.INVERT, false) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 0352166..364c5e1 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -1079,10 +1079,39 @@ local function SetMirroredOperations() end ------------------------------------------------------------------------------------------------------------- -local function AddSquaring( sSquaringTool, RawPart, nFirstOperationId) +local function AddSquaring( sSquaringTool, RawPart) + local dMachiningDepth = RawPart.b3:getDimZ() + local bOk + local sMsg = '' + local SquaringTools = {} + local Geometry = {} + local OperationsId = {} + SquaringTools = Squaring.GetTools() + bOk = Squaring.AreToolsOk( sSquaringTool, SquaringTools, dMachiningDepth) + if not bOk then + sMsg = 'Squaring failed: cannot find matching tools' + return false, sMsg + end + bOk, Geometry = Squaring.CreateGeometry( sSquaringTool, RawPart, SquaringTools) + if not bOk then + sMsg = 'Squaring failed: cannot create geometry' + return false, sMsg + end + bOk, sMsg, OperationsId = Squaring.AddMachinings( sSquaringTool, SquaringTools, Geometry) + if not bOk then + for i = 1, #OperationsId do + EgtRemoveOperation( i) + end + sMsg = 'Squaring failed: cannot apply machinings' + return false, sMsg + end + + Squaring.AddScrapRemoval() + + return true, sMsg end ------------------------------------------------------------------------------------------------------------- @@ -1237,29 +1266,28 @@ function WallExec.ProcessFeatures() -- squadratura, se richiesta if WD.SQUARING_TYPE and WD.SQUARING_TYPE > 0 then local RawPart = { nId = nRawId, b3 = b3Raw} - local nFirstOperationId = EgtGetNextOperation( EgtGetPhaseDisposition( nPhase)) local bOk, sMsg if WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 1 then - bOk, sMsg = AddSquaring( 'DoubleDiskmill', RawPart, nFirstOperationId) + bOk, sMsg = AddSquaring( 'DoubleDiskmill', RawPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 2) then - bOk, sMsg = AddSquaring( 'DoubleDiskmillAndBlade', RawPart, nFirstOperationId) + bOk, sMsg = AddSquaring( 'DoubleDiskmillAndBlade', RawPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 3) then - bOk, sMsg = AddSquaring( 'DoubleBlade', RawPart, nFirstOperationId) + bOk, sMsg = AddSquaring( 'DoubleBlade', RawPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 4) then - bOk, sMsg = AddSquaring( 'Diskmill', RawPart, nFirstOperationId) + bOk, sMsg = AddSquaring( 'Diskmill', RawPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 5) then - bOk, sMsg = AddSquaring( 'Blade', RawPart, nFirstOperationId) + bOk, sMsg = AddSquaring( 'Blade', RawPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 6) then - bOk, sMsg = AddSquaring( 'DoubleMill', RawPart, nFirstOperationId) + bOk, sMsg = AddSquaring( 'DoubleMill', RawPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 7) then - bOk, sMsg = AddSquaring( 'Mill', RawPart, nFirstOperationId) + bOk, sMsg = AddSquaring( 'Mill', RawPart) end if not bOk then From b4b3df0f5ea3c3aadd6671da5e544af441a09208 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 23 Oct 2024 12:13:39 +0200 Subject: [PATCH 06/11] - in Squaring modifiche a GetTools e CreateGeometry per contemplare tutti i casi specifici --- LuaLibs/Squaring.lua | 309 ++++++++++++++++++++++++++++++------------- LuaLibs/WallExec.lua | 12 +- 2 files changed, 223 insertions(+), 98 deletions(-) diff --git a/LuaLibs/Squaring.lua b/LuaLibs/Squaring.lua index e70b620..142f11c 100644 --- a/LuaLibs/Squaring.lua +++ b/LuaLibs/Squaring.lua @@ -58,17 +58,25 @@ function Squaring.GetTools() Tool.dMaxDepth = EgtTdbGetCurrToolMaxDepth() or Tool.dMaxMaterial Tool.sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) Tool.bIsCcw = EgtTdbGetCurrToolParam( MCH_TP.SPEED) < 0 + Tool.dFeed = EgtTdbGetCurrToolParam( MCH_TP.FEED) + Tool.dStartFeed = EgtTdbGetCurrToolParam( MCH_TP.STARTFEED) + Tool.dEndFeed = EgtTdbGetCurrToolParam( MCH_TP.ENDFEED) + Tool.dTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) + Tool.dMinFeed = EgtTdbGetCurrToolParam( MCH_TP.MINFEED) if bToolLoadedOnSetup and Tool.nType and bIsSquaringTool then -- lame if Tool.nType == MCH_TY.SAW_FLAT or Tool.nType == MCH_TY.SAW_STD then SquaringTools.Blade[Tool.sHead] = Tool + Tool.bIsPathCw = not Tool.bIsCcw -- frese standard elseif Tool.nType == MCH_TY.MILL_STD then SquaringTools.Mill[Tool.sHead] = Tool + Tool.bIsPathCw = Tool.bIsCcw -- truciolatori elseif Tool.nType == MCH_TY.MILL_NOTIP then SquaringTools.Diskmill[Tool.sHead] = Tool + Tool.bIsPathCw = not Tool.bIsCcw end end @@ -109,9 +117,10 @@ function Squaring.AreToolsOk( sSquaringTool, SquaringTools, dMachiningDepth) end ------------------------------------------------------------------------------------------------------------- -function Squaring.CreateGeometry( RawPart, Machining) +function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) -- TODO gestire squadratura sulle dimensioni massime dei pezzi (shrinktoparts) invece che sul master panel local SquaringGeometries = {} + local dDimX = RawPart.b3:getDimX() local dDimY = RawPart.b3:getDimY() local sOrigCorner = EgtGetInfo( RawPart.nId, 'ORIGCORNER') @@ -126,72 +135,166 @@ function Squaring.CreateGeometry( RawPart, Machining) dExtendZ = WD.SQUARING_EXTEND_Z end + local Front = { Side = 'Front'} + local Right = { Side = 'Right'} + local Back = { Side = 'Back'} + local Left = { Side = 'Left'} local pt1 = RawPart.b3:getMin() + Point3d( -dOffsetXY, -dOffsetXY, -dExtendZ) local pt2 = pt1 + Point3d( dDimX + 2 * dOffsetXY, 0, 0) local pt3 = pt2 + Point3d( 0, dDimY + 2 * dOffsetXY,0 ) local pt4 = pt3 + Point3d( -dDimX - 2 * dOffsetXY, 0, 0) - local nFrontLineId = EgtLine( RawPart.nId, pt1, pt2, GDB_RT.GLOB) - local nRightLineId = EgtLine( RawPart.nId, pt2, pt3, GDB_RT.GLOB) - local nBackLinedId = EgtLine( RawPart.nId, pt3, pt4, GDB_RT.GLOB) - local nLeftLineId = EgtLine( RawPart.nId, pt4, pt1, GDB_RT.GLOB) - if Machining.sType == 'Diskmilling' or Machining.sType == 'Milling' then - EgtModifyCurveExtrusion( nFrontLineId, -Y_AX(), GDB_RT.GLOB) - EgtModifyCurveExtrusion( nRightLineId, X_AX(), GDB_RT.GLOB) - EgtModifyCurveExtrusion( nBackLinedId, Y_AX(), GDB_RT.GLOB) - EgtModifyCurveExtrusion( nLeftLineId, -X_AX(), GDB_RT.GLOB) - end - EgtSetName( nFrontLineId, 'SquaringGeometry' ) - EgtSetName( nRightLineId, 'SquaringGeometry' ) - EgtSetName( nBackLinedId, 'SquaringGeometry' ) - EgtSetName( nLeftLineId, 'SquaringGeometry' ) + Front.nId = EgtLine( RawPart.nId, pt1, pt2, GDB_RT.GLOB) + Right.nId = EgtLine( RawPart.nId, pt2, pt3, GDB_RT.GLOB) + Back.nId = EgtLine( RawPart.nId, pt3, pt4, GDB_RT.GLOB) + Left.nId = EgtLine( RawPart.nId, pt4, pt1, GDB_RT.GLOB) + EgtModifyCurveExtrusion( Front.nId, -Y_AX(), GDB_RT.GLOB) + EgtModifyCurveExtrusion( Right.nId, X_AX(), GDB_RT.GLOB) + EgtModifyCurveExtrusion( Back.nId, Y_AX(), GDB_RT.GLOB) + EgtModifyCurveExtrusion( Left.nId, -X_AX(), GDB_RT.GLOB) + EgtSetName( Front.nId, 'SquaringGeometry') + EgtSetName( Right.nId, 'SquaringGeometry') + EgtSetName( Back.nId, 'SquaringGeometry') + EgtSetName( Left.nId, 'SquaringGeometry') - for i = 1, 4 do - SquaringGeometries[i] = {} + -- in base al caso si assegna l'utensile al lato + if sSquaringTool == 'DoubleDiskmill' then + Left.Tool = SquaringTools.Diskmill.H1 + Right.Tool = SquaringTools.Blade.H2 + Front.Tool = SquaringTools.Diskmill.H1 + Front.ToolDouble = SquaringTools.Diskmill.H7 + elseif sSquaringTool == 'DoubleDiskmillAndBlade' then + Left.Tool = SquaringTools.Diskmill.H1 or SquaringTools.Diskmill.H7 + Right.Tool = SquaringTools.Blade.H2 + Front.Tool = SquaringTools.Blade.H2 + Front.ToolDouble = SquaringTools.Diskmill.H1 or SquaringTools.Diskmill.H7 + elseif sSquaringTool == 'DoubleBlade' then + Left.Tool = SquaringTools.Blade.H2 + Right.Tool = SquaringTools.Blade.H2 + Front.Tool = SquaringTools.Blade.H2 + Front.ToolDouble = SquaringTools.Blade.H1 or SquaringTools.Blade.H7 + elseif sSquaringTool == 'Diskmill' then + Left.Tool = SquaringTools.Diskmill.H1 or SquaringTools.Diskmill.H7 + Back.Tool = SquaringTools.Diskmill.H1 or SquaringTools.Diskmill.H7 + Right.Tool = SquaringTools.Blade.H2 + Front.Tool = SquaringTools.Diskmill.H1 or SquaringTools.Diskmill.H7 + elseif sSquaringTool == 'Blade' then + Left.Tool = SquaringTools.Blade.H2 + Back.Tool = SquaringTools.Blade.H2 + Right.Tool = SquaringTools.Blade.H2 + Front.Tool = SquaringTools.Blade.H2 + elseif sSquaringTool == 'DoubleMill' then + Left.Tool = SquaringTools.Mill.H1 + Right.Tool = SquaringTools.Mill.H1 + Front.Tool = SquaringTools.Mill.H1 + Front.ToolDouble = SquaringTools.Mill.H7 + elseif sSquaringTool == 'Mill' then + Left.Tool = SquaringTools.Mill.H1 or SquaringTools.Mill.H7 + Back.Tool = SquaringTools.Mill.H1 or SquaringTools.Mill.H7 + Right.Tool = SquaringTools.Mill.H1 or SquaringTools.Mill.H7 + Front.Tool = SquaringTools.Mill.H1 or SquaringTools.Mill.H7 end - -- l'ordine di percorrenza delle linee dipende dal verso di percorrenza e, se attivato, dal riferimento utilizzato - if Machining.bIsPathCW then - if bSquaringStartsOnReference and ( sOrigCorner == 'BL' or sOrigCorner == 'BM') then - SquaringGeometries[1].nId = nFrontLineId - SquaringGeometries[2].nId = nLeftLineId - SquaringGeometries[3].nId = nBackLinedId - SquaringGeometries[4].nId = nRightLineId - elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then - SquaringGeometries[1].nId = nBackLinedId - SquaringGeometries[2].nId = nRightLineId - SquaringGeometries[3].nId = nFrontLineId - SquaringGeometries[4].nId = nLeftLineId - elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then - SquaringGeometries[1].nId = nRightLineId - SquaringGeometries[2].nId = nFrontLineId - SquaringGeometries[3].nId = nLeftLineId - SquaringGeometries[4].nId = nBackLinedId - else - SquaringGeometries[1].nId = nLeftLineId - SquaringGeometries[2].nId = nBackLinedId - SquaringGeometries[3].nId = nRightLineId - SquaringGeometries[4].nId = nFrontLineId + + -- l'ordinamento delle linee dipende dal verso di percorrenza e, se attivato, dal riferimento utilizzato + -- con doppio l'ordine cambia + -- lato lungo lavorato in doppio + if not Back.Tool then + for i = 1, 3 do + SquaringGeometries[i] = {} end - else - if bSquaringStartsOnReference and ( sOrigCorner == 'TL' or sOrigCorner == 'TM') then - SquaringGeometries[1].nId = nBackLinedId - SquaringGeometries[2].nId = nLeftLineId - SquaringGeometries[3].nId = nFrontLineId - SquaringGeometries[4].nId = nRightLineId - elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then - SquaringGeometries[1].nId = nRightLineId - SquaringGeometries[2].nId = nBackLinedId - SquaringGeometries[3].nId = nLeftLineId - SquaringGeometries[4].nId = nFrontLineId - elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then - SquaringGeometries[1].nId = nFrontLineId - SquaringGeometries[2].nId = nRightLineId - SquaringGeometries[3].nId = nBackLinedId - SquaringGeometries[4].nId = nLeftLineId + if Front.Tool.bIsPathCw then + if bSquaringStartsOnReference and ( sOrigCorner == 'BL' or sOrigCorner == 'BM') then + SquaringGeometries[1] = Front + SquaringGeometries[2] = Left + SquaringGeometries[3] = Right + elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then + SquaringGeometries[1] = Right + SquaringGeometries[2] = Front + SquaringGeometries[3] = Left + elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then + SquaringGeometries[1] = Right + SquaringGeometries[2] = Front + SquaringGeometries[3] = Left + elseif bSquaringStartsOnReference and ( sOrigCorner == 'TL' or sOrigCorner == 'TM') then + SquaringGeometries[1] = Left + SquaringGeometries[2] = Front + SquaringGeometries[3] = Right + else + SquaringGeometries[1] = Right + SquaringGeometries[2] = Front + SquaringGeometries[3] = Left + end else - SquaringGeometries[1].nId = nLeftLineId - SquaringGeometries[2].nId = nFrontLineId - SquaringGeometries[3].nId = nRightLineId - SquaringGeometries[4].nId = nBackLinedId + if bSquaringStartsOnReference and ( sOrigCorner == 'BL' or sOrigCorner == 'BM') then + SquaringGeometries[1] = Left + SquaringGeometries[2] = Front + SquaringGeometries[3] = Right + elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then + SquaringGeometries[1] = Front + SquaringGeometries[2] = Right + SquaringGeometries[3] = Left + elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then + SquaringGeometries[1] = Front + SquaringGeometries[2] = Right + SquaringGeometries[3] = Left + elseif bSquaringStartsOnReference and ( sOrigCorner == 'TL' or sOrigCorner == 'TM') then + SquaringGeometries[1] = Left + SquaringGeometries[2] = Front + SquaringGeometries[3] = Right + else + SquaringGeometries[1] = Left + SquaringGeometries[2] = Front + SquaringGeometries[3] = Right + end + end + -- doppio non attivo + else + for i = 1, 4 do + SquaringGeometries[i] = {} + end + if Front.Tool.bIsPathCw then + if bSquaringStartsOnReference and ( sOrigCorner == 'BL' or sOrigCorner == 'BM') then + SquaringGeometries[1] = Front + SquaringGeometries[2] = Left + SquaringGeometries[3] = Back + SquaringGeometries[4] = Right + elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then + SquaringGeometries[1] = Back + SquaringGeometries[2] = Right + SquaringGeometries[3] = Front + SquaringGeometries[4] = Left + elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then + SquaringGeometries[1] = Right + SquaringGeometries[2] = Front + SquaringGeometries[3] = Left + SquaringGeometries[4] = Back + else + SquaringGeometries[1] = Left + SquaringGeometries[2] = Back + SquaringGeometries[3] = Right + SquaringGeometries[4] = Front + end + else + if bSquaringStartsOnReference and ( sOrigCorner == 'TL' or sOrigCorner == 'TM') then + SquaringGeometries[1] = Back + SquaringGeometries[2] = Left + SquaringGeometries[3] = Front + SquaringGeometries[4] = Right + elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then + SquaringGeometries[1] = Right + SquaringGeometries[2] = Back + SquaringGeometries[3] = Left + SquaringGeometries[4] = Front + elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then + SquaringGeometries[1] = Front + SquaringGeometries[2] = Right + SquaringGeometries[3] = Back + SquaringGeometries[4] = Left + else + SquaringGeometries[1] = Left + SquaringGeometries[2] = Front + SquaringGeometries[3] = Right + SquaringGeometries[4] = Back + end end end @@ -199,45 +302,67 @@ function Squaring.CreateGeometry( RawPart, Machining) end ------------------------------------------------------------------------------------------------------------- -function Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationId) +function Squaring.AddMachinings( MachiningGeometries) local nNotOkCount = 0 local sMsgTotal = '' - for i = 1, #SquaringGeometries do - local nSquaringOperationId = EgtAddMachining('SQUARING', Machining.sSquaring) - EgtSetMachiningGeometry( SquaringGeometries[i].nId) - -- in base al verso di percorrenza modifico i parametri significativi di lavorazione - if Machining.bIsPathCW then - if Machining.sType == 'Sawing'then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_SAW_WS.LEFT) - EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.LEFT) - elseif Machining.sType == 'Milling' then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - elseif Machining.sType == 'Diskmilling' then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - end - EgtSetMachiningParam( MCH_MP.INVERT, true) - else - if Machining.sType == 'Sawing' then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_SAW_WS.RIGHT) - EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.RIGHT) - elseif Machining.sType == 'Milling' then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - elseif Machining.sType == 'Diskmilling' then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - end - EgtSetMachiningParam( MCH_MP.INVERT, false) - end - local bOk = EgtApplyMachining( true, false) - EgtRelocateGlob( nSquaringOperationId, nFirstOperationId, GDB_IN.BEFORE) - if not bOk then - local _, sMsg = EgtGetLastMachMgrError() - nNotOkCount = nNotOkCount + 1 - sMsgTotal = sMsgTotal ..'\n' .. ( sMsg or '') - end + for i = 1, #MachiningGeometries do + local nOperationId = EgtCreateMachining( 'SQUARING', MCH_AT.LINEAR, MACHININGS[i].Machining.sToolName) end + + + + + + + + + + + + + + return ( nNotOkCount < 1), sMsgTotal + + + + -- for i = 1, #SquaringGeometries do + -- local nSquaringOperationId = EgtAddMachining('SQUARING', Machining.sSquaring) + -- EgtSetMachiningGeometry( SquaringGeometries[i].nId) + -- -- in base al verso di percorrenza modifico i parametri significativi di lavorazione + -- if Machining.bIsPathCw then + -- if Machining.sType == 'Sawing'then + -- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_SAW_WS.LEFT) + -- EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.LEFT) + -- elseif Machining.sType == 'Milling' then + -- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + -- elseif Machining.sType == 'Diskmilling' then + -- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + -- end + -- EgtSetMachiningParam( MCH_MP.INVERT, true) + -- else + -- if Machining.sType == 'Sawing' then + -- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_SAW_WS.RIGHT) + -- EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.RIGHT) + -- elseif Machining.sType == 'Milling' then + -- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + -- elseif Machining.sType == 'Diskmilling' then + -- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + -- end + -- EgtSetMachiningParam( MCH_MP.INVERT, false) + -- end + -- local bOk = EgtApplyMachining( true, false) + -- EgtRelocateGlob( nSquaringOperationId, nFirstOperationId, GDB_IN.BEFORE) + -- if not bOk then + -- local _, sMsg = EgtGetLastMachMgrError() + -- nNotOkCount = nNotOkCount + 1 + -- sMsgTotal = sMsgTotal ..'\n' .. ( sMsg or '') + -- end + -- end + + end ------------------------------------------------------------------------------------------------------------- diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 364c5e1..a62335b 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -1094,13 +1094,9 @@ local function AddSquaring( sSquaringTool, RawPart) return false, sMsg end - bOk, Geometry = Squaring.CreateGeometry( sSquaringTool, RawPart, SquaringTools) - if not bOk then - sMsg = 'Squaring failed: cannot create geometry' - return false, sMsg - end + MachiningGeometries = Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) - bOk, sMsg, OperationsId = Squaring.AddMachinings( sSquaringTool, SquaringTools, Geometry) + bOk, sMsg, OperationsId = Squaring.AddMachinings( MachiningGeometries) if not bOk then for i = 1, #OperationsId do EgtRemoveOperation( i) @@ -1111,6 +1107,10 @@ local function AddSquaring( sSquaringTool, RawPart) Squaring.AddScrapRemoval() + if WD.SQUARING_TYPE == 2 then + Squaring.RemoveExternalMachinings( Geometry) + end + return true, sMsg end From d2b3c32b61616d108c429471aa51e1d2a4e8d90b Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 29 Oct 2024 09:09:19 +0100 Subject: [PATCH 07/11] - in Squaring aggiunt creazione lavorazione al momento e settaggio parametri - in Squaring gestito allungamento e attacco verticale per contemplare overmaterial e altezza pezzo --- LuaLibs/Squaring.lua | 202 +++++++++++++++++++++++++++++-------------- LuaLibs/WallExec.lua | 49 ++--------- 2 files changed, 144 insertions(+), 107 deletions(-) diff --git a/LuaLibs/Squaring.lua b/LuaLibs/Squaring.lua index 142f11c..3115537 100644 --- a/LuaLibs/Squaring.lua +++ b/LuaLibs/Squaring.lua @@ -18,7 +18,7 @@ local function IsToolOk( Tool, dMachiningDepth) local bToolExists = false local dToolMaxDepth = 0 - bToolExists = Tool ~= {} + bToolExists = ( next( Tool) ~= nil) if bToolExists then if Tool.nType == MCH_TY.MILL_NOTIP then dToolMaxDepth = Tool.dThickness @@ -49,10 +49,11 @@ function Squaring.GetTools() Tool.sName = EgtTdbGetFirstTool( MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE) while Tool.sName ~= '' do EgtTdbSetCurrTool( Tool.sName) - local bToolLoadedOnSetup = EgtFindToolInCurrSetup( Tool.sName) + local bIsToolLoadedOnSetup = EgtFindToolInCurrSetup( Tool.sName) local bIsSquaringTool = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SQUARING', 'b') or false Tool.nType = EgtTdbGetCurrToolParam( MCH_TP.TYPE) + Tool.dDiameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM) Tool.dThickness = EgtTdbGetCurrToolParam( MCH_TP.THICK) Tool.dMaxMaterial = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) Tool.dMaxDepth = EgtTdbGetCurrToolMaxDepth() or Tool.dMaxMaterial @@ -63,20 +64,21 @@ function Squaring.GetTools() Tool.dEndFeed = EgtTdbGetCurrToolParam( MCH_TP.ENDFEED) Tool.dTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) Tool.dMinFeed = EgtTdbGetCurrToolParam( MCH_TP.MINFEED) + Tool.dSideStep = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDESTEP', 'd') or ( Tool.dDiameter / 2) - if bToolLoadedOnSetup and Tool.nType and bIsSquaringTool then + if bIsToolLoadedOnSetup and Tool.nType and bIsSquaringTool then -- lame if Tool.nType == MCH_TY.SAW_FLAT or Tool.nType == MCH_TY.SAW_STD then SquaringTools.Blade[Tool.sHead] = Tool - Tool.bIsPathCw = not Tool.bIsCcw + Tool.bIsPathCw = Tool.bIsCcw -- frese standard elseif Tool.nType == MCH_TY.MILL_STD then SquaringTools.Mill[Tool.sHead] = Tool - Tool.bIsPathCw = Tool.bIsCcw + Tool.bIsPathCw = not Tool.bIsCcw -- truciolatori elseif Tool.nType == MCH_TY.MILL_NOTIP then SquaringTools.Diskmill[Tool.sHead] = Tool - Tool.bIsPathCw = not Tool.bIsCcw + Tool.bIsPathCw = Tool.bIsCcw end end @@ -135,10 +137,10 @@ function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) dExtendZ = WD.SQUARING_EXTEND_Z end - local Front = { Side = 'Front'} - local Right = { Side = 'Right'} - local Back = { Side = 'Back'} - local Left = { Side = 'Left'} + local Front = { sSide = 'Front'} + local Right = { sSide = 'Right'} + local Back = { sSide = 'Back'} + local Left = { sSide = 'Left'} local pt1 = RawPart.b3:getMin() + Point3d( -dOffsetXY, -dOffsetXY, -dExtendZ) local pt2 = pt1 + Point3d( dDimX + 2 * dOffsetXY, 0, 0) local pt3 = pt2 + Point3d( 0, dDimY + 2 * dOffsetXY,0 ) @@ -147,10 +149,12 @@ function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) Right.nId = EgtLine( RawPart.nId, pt2, pt3, GDB_RT.GLOB) Back.nId = EgtLine( RawPart.nId, pt3, pt4, GDB_RT.GLOB) Left.nId = EgtLine( RawPart.nId, pt4, pt1, GDB_RT.GLOB) - EgtModifyCurveExtrusion( Front.nId, -Y_AX(), GDB_RT.GLOB) - EgtModifyCurveExtrusion( Right.nId, X_AX(), GDB_RT.GLOB) - EgtModifyCurveExtrusion( Back.nId, Y_AX(), GDB_RT.GLOB) - EgtModifyCurveExtrusion( Left.nId, -X_AX(), GDB_RT.GLOB) + if not ( sSquaringTool == 'DoubleMill') and not ( sSquaringTool == 'Mill') then + EgtModifyCurveExtrusion( Front.nId, -Y_AX(), GDB_RT.GLOB) + EgtModifyCurveExtrusion( Right.nId, X_AX(), GDB_RT.GLOB) + EgtModifyCurveExtrusion( Back.nId, Y_AX(), GDB_RT.GLOB) + EgtModifyCurveExtrusion( Left.nId, -X_AX(), GDB_RT.GLOB) + end EgtSetName( Front.nId, 'SquaringGeometry') EgtSetName( Right.nId, 'SquaringGeometry') EgtSetName( Back.nId, 'SquaringGeometry') @@ -162,16 +166,19 @@ function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) Right.Tool = SquaringTools.Blade.H2 Front.Tool = SquaringTools.Diskmill.H1 Front.ToolDouble = SquaringTools.Diskmill.H7 + Front.sSide = 'Front+Back' elseif sSquaringTool == 'DoubleDiskmillAndBlade' then Left.Tool = SquaringTools.Diskmill.H1 or SquaringTools.Diskmill.H7 Right.Tool = SquaringTools.Blade.H2 Front.Tool = SquaringTools.Blade.H2 Front.ToolDouble = SquaringTools.Diskmill.H1 or SquaringTools.Diskmill.H7 + Front.sSide = 'Front+Back' elseif sSquaringTool == 'DoubleBlade' then Left.Tool = SquaringTools.Blade.H2 Right.Tool = SquaringTools.Blade.H2 Front.Tool = SquaringTools.Blade.H2 Front.ToolDouble = SquaringTools.Blade.H1 or SquaringTools.Blade.H7 + Front.sSide = 'Front+Back' elseif sSquaringTool == 'Diskmill' then Left.Tool = SquaringTools.Diskmill.H1 or SquaringTools.Diskmill.H7 Back.Tool = SquaringTools.Diskmill.H1 or SquaringTools.Diskmill.H7 @@ -187,6 +194,7 @@ function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) Right.Tool = SquaringTools.Mill.H1 Front.Tool = SquaringTools.Mill.H1 Front.ToolDouble = SquaringTools.Mill.H7 + Front.sSide = 'Front+Back' elseif sSquaringTool == 'Mill' then Left.Tool = SquaringTools.Mill.H1 or SquaringTools.Mill.H7 Back.Tool = SquaringTools.Mill.H1 or SquaringTools.Mill.H7 @@ -302,67 +310,129 @@ function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) end ------------------------------------------------------------------------------------------------------------- -function Squaring.AddMachinings( MachiningGeometries) +function Squaring.AddMachinings( SquaringGeometries, RawPart, nFirstOperationId) local nNotOkCount = 0 local sMsgTotal = '' - - for i = 1, #MachiningGeometries do - local nOperationId = EgtCreateMachining( 'SQUARING', MCH_AT.LINEAR, MACHININGS[i].Machining.sToolName) + local dRawPartWidth = RawPart.b3:getDimY() + local dRawPartHeight = RawPart.b3:getDimZ() + local dExtendPath = 0 + local dMaxOvermaterial = 0 + if type( WD.SQUARING_MAX_OVERMATERIAL) == "number" then + dMaxOvermaterial = WD.SQUARING_MAX_OVERMATERIAL end + for i = 1, #SquaringGeometries do + local dToolRadius = SquaringGeometries[i].Tool.dDiameter / 2 + local vtExtr = EgtCurveExtrusion( SquaringGeometries[i].nId, GDB_RT.GLOB) + local nOperationId = EgtCreateMachining( 'SQUARING_' .. SquaringGeometries[i].sSide, MCH_OY.MILLING, SquaringGeometries[i].Tool.sName) + -- geometria + EgtSetMachiningGeometry( SquaringGeometries[i].nId) + -- profondità di lavoro + EgtSetMachiningParam( MCH_MP.DEPTH_STR, 0) + -- workside e inversione + if SquaringGeometries[i].Tool.bIsPathCw then + if SquaringGeometries[i].Tool.nType == MCH_TY.MILL_STD then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + end + EgtSetMachiningParam( MCH_MP.INVERT, true) + else + if SquaringGeometries[i].Tool.nType == MCH_TY.MILL_STD then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + end + EgtSetMachiningParam( MCH_MP.INVERT, false) + end + -- distanza di sicurezza + if AreSameVectorApprox( vtExtr, Z_AX()) then + EgtSetMachiningParam( MCH_MP.STARTPOS, WD.CUT_SIC + RawPart.b3:getDimZ()) + else + EgtSetMachiningParam( MCH_MP.STARTPOS, WD.CUT_SIC) + end + -- overlap + EgtSetMachiningParam( MCH_MP.OVERL, 0) + -- tipo di step + EgtSetMachiningParam( MCH_MP.STEPTYPE, MCH_MILL_ST.ONEWAY) + -- step + EgtSetMachiningParam( MCH_MP.STEP, SquaringGeometries[i].Tool.dMaxMaterial) + -- offset radiale + EgtSetMachiningParam( MCH_MP.OFFSR, 0) + -- offset longitudinale + EgtSetMachiningParam( MCH_MP.OFFSL, 0) + -- inversione utensile + EgtSetMachiningParam( MCH_MP.TOOLINVERT, false) + -- faceuse + EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.NONE) + -- angoli suggeriti + EgtSetMachiningParam( MCH_MP.INITANGS, '') + -- asse bloccato + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, '') + -- SCC + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE) + -- calcolo estensione percorso + if AreSameVectorApprox( vtExtr, Z_AX()) then + -- per utensili che lavorano di fianco, si deve partire fuori dall'altezza del grezzo + dExtendPath = dMaxOvermaterial + dToolRadius + WD.COLL_SIC + else + -- si calcola l'impronta utensile per uscire quanto basta a garantire il maxOvermaterial, con una distanza di sicurezza + dExtendPath = dMaxOvermaterial + WD.COLL_SIC + dToolRadius - ( dToolRadius - sqrt( dToolRadius * dToolRadius - ( ( dToolRadius - dRawPartHeight) * ( dToolRadius - dRawPartHeight)))) + end + -- approccio + EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR) + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dExtendPath) + EgtSetMachiningParam( MCH_MP.LITANG, 0) + if AreSameVectorApprox( vtExtr, Z_AX()) then + EgtSetMachiningParam( MCH_MP.LIPERP, 0) + else + -- per utensili che lavorano di fianco, si deve partire fuori dall'altezza del grezzo + EgtSetMachiningParam( MCH_MP.LIPERP, WD.CUT_SIC + RawPart.b3:getDimZ()) + end + EgtSetMachiningParam( MCH_MP.LIELEV, 0) + EgtSetMachiningParam( MCH_MP.LICOMPLEN, 0) + -- retrazione + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.LINEAR) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dExtendPath) + EgtSetMachiningParam( MCH_MP.LOTANG, 0) + if AreSameVectorApprox( vtExtr, Z_AX()) then + EgtSetMachiningParam( MCH_MP.LOPERP, 0) + else + -- per utensili che lavorano di fianco, si deve partire fuori dall'altezza del grezzo + EgtSetMachiningParam( MCH_MP.LOPERP, WD.CUT_SIC + RawPart.b3:getDimZ()) + end + EgtSetMachiningParam( MCH_MP.LOELEV, 0) + EgtSetMachiningParam( MCH_MP.LOCOMPLEN, 0) + -- note utente + local sUserNotes = '' + sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + if SquaringGeometries[i].ToolDouble then + sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', 2) + sUserNotes = EgtSetValInNotes( sUserNotes, 'MirrorAx', dRawPartWidth / 2) + sUserNotes = EgtSetValInNotes( sUserNotes, 'TOOLDOUBLE', SquaringGeometries[i].ToolDouble.sName) + end + EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) - - - - - - - - - - - + local bOk = EgtApplyMachining( true, false) + EgtRelocateGlob( nOperationId, nFirstOperationId, GDB_IN.BEFORE) + if not bOk then + local _, sMsg = EgtGetLastMachMgrError() + nNotOkCount = nNotOkCount + 1 + sMsgTotal = sMsgTotal ..'\n' .. ( sMsg or '') + end + end return ( nNotOkCount < 1), sMsgTotal +end - - - -- for i = 1, #SquaringGeometries do - -- local nSquaringOperationId = EgtAddMachining('SQUARING', Machining.sSquaring) - -- EgtSetMachiningGeometry( SquaringGeometries[i].nId) - -- -- in base al verso di percorrenza modifico i parametri significativi di lavorazione - -- if Machining.bIsPathCw then - -- if Machining.sType == 'Sawing'then - -- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_SAW_WS.LEFT) - -- EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.LEFT) - -- elseif Machining.sType == 'Milling' then - -- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - -- elseif Machining.sType == 'Diskmilling' then - -- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - -- end - -- EgtSetMachiningParam( MCH_MP.INVERT, true) - -- else - -- if Machining.sType == 'Sawing' then - -- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_SAW_WS.RIGHT) - -- EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.RIGHT) - -- elseif Machining.sType == 'Milling' then - -- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) - -- elseif Machining.sType == 'Diskmilling' then - -- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) - -- end - -- EgtSetMachiningParam( MCH_MP.INVERT, false) - -- end - -- local bOk = EgtApplyMachining( true, false) - -- EgtRelocateGlob( nSquaringOperationId, nFirstOperationId, GDB_IN.BEFORE) - -- if not bOk then - -- local _, sMsg = EgtGetLastMachMgrError() - -- nNotOkCount = nNotOkCount + 1 - -- sMsgTotal = sMsgTotal ..'\n' .. ( sMsg or '') - -- end - -- end - - +------------------------------------------------------------------------------------------------------------- +function Squaring.AddScrapRemoval( nFirstOperationId) + -- pulizia sfridi alla prima lavorazione dopo la squadratura + EgtSetCurrMachining( nFirstOperationId) + local sMachiningNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + sMachiningNotes = sMachiningNotes .. 'ScrapRemove=1;' + EgtSetMachiningParam( MCH_MP.USERNOTES, sMachiningNotes) end ------------------------------------------------------------------------------------------------------------- diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index a62335b..81c9750 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -1080,6 +1080,7 @@ end ------------------------------------------------------------------------------------------------------------- local function AddSquaring( sSquaringTool, RawPart) + local nFirstOperationId = EgtGetNextOperation( EgtGetPhaseDisposition( 1)) local dMachiningDepth = RawPart.b3:getDimZ() local bOk local sMsg = '' @@ -1094,9 +1095,9 @@ local function AddSquaring( sSquaringTool, RawPart) return false, sMsg end - MachiningGeometries = Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) + SquaringGeometries = Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) - bOk, sMsg, OperationsId = Squaring.AddMachinings( MachiningGeometries) + bOk, sMsg, OperationsId = Squaring.AddMachinings( SquaringGeometries, RawPart, nFirstOperationId) if not bOk then for i = 1, #OperationsId do EgtRemoveOperation( i) @@ -1105,7 +1106,7 @@ local function AddSquaring( sSquaringTool, RawPart) return false, sMsg end - Squaring.AddScrapRemoval() + Squaring.AddScrapRemoval( nFirstOperationId) if WD.SQUARING_TYPE == 2 then Squaring.RemoveExternalMachinings( Geometry) @@ -1272,7 +1273,10 @@ function WallExec.ProcessFeatures() bOk, sMsg = AddSquaring( 'DoubleDiskmill', RawPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 2) then - bOk, sMsg = AddSquaring( 'DoubleDiskmillAndBlade', RawPart) + -- attualmente non gestito, va modificata la configurazione macchina e non si sa se sia gestito in macchina (PLC) + bOk = false + sMsg = 'Squaring not possible : double blade + diskmill not supported' + --bOk, sMsg = AddSquaring( 'DoubleDiskmillAndBlade', RawPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 3) then bOk, sMsg = AddSquaring( 'DoubleBlade', RawPart) @@ -1298,43 +1302,6 @@ function WallExec.ProcessFeatures() else table.insert( Stats, {Err=0, Msg='', Rot=0, CutId=0, TaskId=0}) end - - - - - - - local nFirstOperationId = EgtGetNextOperation( EgtGetPhaseDisposition( nPhase)) - local dDepth = b3Raw:getDimZ() - - -- ricerca lavorazione - local Machining = Squaring.GetMachining( dDepth) - if Machining.sSquaring then - -- creazione percorsi - local RawPart = { nId = nRawId, b3 = b3Raw} - local SquaringGeometries = Squaring.CreateGeometry( RawPart, Machining) - - -- applicazione lavorazioni - local bIsApplyOk, sMsg = Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationId) - if not bIsApplyOk then - nTotErr = nTotErr + 1 - table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=0, TaskId=0}) - elseif sMsg and #sMsg > 0 then - table.insert( Stats, {Err=-1, Msg=sMsg, Rot=0, CutId=0, TaskId=0}) - else - table.insert( Stats, {Err=0, Msg='', Rot=0, CutId=0, TaskId=0}) - end - - -- pulizia sfridi alla prima lavorazione dopo la squadratura - EgtSetCurrMachining( nFirstOperationId) - local sMachiningNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) - sMachiningNotes = sMachiningNotes .. 'ScrapRemove=1;' - EgtSetMachiningParam( MCH_MP.USERNOTES, sMachiningNotes) - else - local sErr = 'Error : Squaring not found in library' - EgtOutLog( sErr) - table.insert( Stats, {Err=1, Msg=sErr, Rot=0, CutId=0, TaskId=0}) - end end -- Aggiornamento finale di tutto From b325ebcd32ce69da6e79063643ae52d54e337ec2 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 29 Oct 2024 13:14:00 +0100 Subject: [PATCH 08/11] - in MachiningLib aggiunta funzione GetMachiningSteps per il calcolo degli stepdi lavorazione - in Squaring aggiunti step verticali con lavorazioni aggiuntive - in WallExec gestito default per parametro di squadratura TOOL --- LuaLibs/Squaring.lua | 206 +++++++++++++++++++++----------------- LuaLibs/WMachiningLib.lua | 12 +++ LuaLibs/WallExec.lua | 3 + 3 files changed, 129 insertions(+), 92 deletions(-) diff --git a/LuaLibs/Squaring.lua b/LuaLibs/Squaring.lua index 3115537..5ba3e4c 100644 --- a/LuaLibs/Squaring.lua +++ b/LuaLibs/Squaring.lua @@ -11,6 +11,7 @@ EgtOutLog( ' Squaring started', 1) -- Dati local WD = require( 'WallData') +local WM = require( 'WMachiningLib') ------------------------------------------------------------------------------------------------------------- local function IsToolOk( Tool, dMachiningDepth) @@ -64,7 +65,8 @@ function Squaring.GetTools() Tool.dEndFeed = EgtTdbGetCurrToolParam( MCH_TP.ENDFEED) Tool.dTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) Tool.dMinFeed = EgtTdbGetCurrToolParam( MCH_TP.MINFEED) - Tool.dSideStep = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDESTEP', 'd') or ( Tool.dDiameter / 2) + Tool.dStep = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'STEP', 'd') or ( Tool.dMaxMaterial / 3) + Tool.dSideStep = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDESTEP', 'd') or ( Tool.dDiameter / 6) if bIsToolLoadedOnSetup and Tool.nType and bIsSquaringTool then -- lame @@ -127,7 +129,7 @@ function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) local dDimY = RawPart.b3:getDimY() local sOrigCorner = EgtGetInfo( RawPart.nId, 'ORIGCORNER') local bShrinkToParts = ( WD.SQUARING_TYPE == 2) - local bSquaringStartsOnReference = type( WD.SQUARING_STARTS_ON_REFERENCE) == "boolean" and ( WD.SQUARING_STARTS_ON_REFERENCE == true) + local bSquaringStartsOnReference = ( type( WD.SQUARING_STARTS_ON_REFERENCE) == "boolean") and ( WD.SQUARING_STARTS_ON_REFERENCE == true) local dOffsetXY = 0 local dExtendZ = 0 if type( WD.SQUARING_OFFSET_XY) == "number" then @@ -320,106 +322,126 @@ function Squaring.AddMachinings( SquaringGeometries, RawPart, nFirstOperationId) if type( WD.SQUARING_MAX_OVERMATERIAL) == "number" then dMaxOvermaterial = WD.SQUARING_MAX_OVERMATERIAL end + local bUseZigZagStep = ( type( WD.SQUARING_USE_ZIGZAG) == "boolean") and ( WD.SQUARING_USE_ZIGZAG == true) for i = 1, #SquaringGeometries do local dToolRadius = SquaringGeometries[i].Tool.dDiameter / 2 local vtExtr = EgtCurveExtrusion( SquaringGeometries[i].nId, GDB_RT.GLOB) + local bIsVerticalMilling = false + if AreSameVectorApprox( vtExtr, Z_AX()) then + bIsVerticalMilling = true + end + -- calcolo step laterale + local MachiningSteps = { nCount = 1, dStep = 0} + if not bIsVerticalMilling then + MachiningSteps = WM.GetMachiningSteps( dRawPartHeight, SquaringGeometries[i].Tool.dSideStep) + end - local nOperationId = EgtCreateMachining( 'SQUARING_' .. SquaringGeometries[i].sSide, MCH_OY.MILLING, SquaringGeometries[i].Tool.sName) - -- geometria - EgtSetMachiningGeometry( SquaringGeometries[i].nId) - -- profondità di lavoro - EgtSetMachiningParam( MCH_MP.DEPTH_STR, 0) - -- workside e inversione - if SquaringGeometries[i].Tool.bIsPathCw then - if SquaringGeometries[i].Tool.nType == MCH_TY.MILL_STD then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + for j = 1, MachiningSteps.nCount do + local nOperationId = EgtCreateMachining( 'SQUARING_' .. SquaringGeometries[i].sSide, MCH_OY.MILLING, SquaringGeometries[i].Tool.sName) + -- geometria + EgtSetMachiningGeometry( SquaringGeometries[i].nId) + -- profondità di lavoro + EgtSetMachiningParam( MCH_MP.DEPTH_STR, 0) + -- workside e inversione + if SquaringGeometries[i].Tool.bIsPathCw then + if SquaringGeometries[i].Tool.nType == MCH_TY.MILL_STD then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + end + EgtSetMachiningParam( MCH_MP.INVERT, true) else - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + if SquaringGeometries[i].Tool.nType == MCH_TY.MILL_STD then + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + else + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + end + EgtSetMachiningParam( MCH_MP.INVERT, false) end - EgtSetMachiningParam( MCH_MP.INVERT, true) - else - if SquaringGeometries[i].Tool.nType == MCH_TY.MILL_STD then - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) + -- distanza di sicurezza + if bIsVerticalMilling then + EgtSetMachiningParam( MCH_MP.STARTPOS, WD.CUT_SIC + RawPart.b3:getDimZ()) else - EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + EgtSetMachiningParam( MCH_MP.STARTPOS, WD.CUT_SIC) end - EgtSetMachiningParam( MCH_MP.INVERT, false) - end - -- distanza di sicurezza - if AreSameVectorApprox( vtExtr, Z_AX()) then - EgtSetMachiningParam( MCH_MP.STARTPOS, WD.CUT_SIC + RawPart.b3:getDimZ()) - else - EgtSetMachiningParam( MCH_MP.STARTPOS, WD.CUT_SIC) - end - -- overlap - EgtSetMachiningParam( MCH_MP.OVERL, 0) - -- tipo di step - EgtSetMachiningParam( MCH_MP.STEPTYPE, MCH_MILL_ST.ONEWAY) - -- step - EgtSetMachiningParam( MCH_MP.STEP, SquaringGeometries[i].Tool.dMaxMaterial) - -- offset radiale - EgtSetMachiningParam( MCH_MP.OFFSR, 0) - -- offset longitudinale - EgtSetMachiningParam( MCH_MP.OFFSL, 0) - -- inversione utensile - EgtSetMachiningParam( MCH_MP.TOOLINVERT, false) - -- faceuse - EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.NONE) - -- angoli suggeriti - EgtSetMachiningParam( MCH_MP.INITANGS, '') - -- asse bloccato - EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, '') - -- SCC - EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE) - -- calcolo estensione percorso - if AreSameVectorApprox( vtExtr, Z_AX()) then - -- per utensili che lavorano di fianco, si deve partire fuori dall'altezza del grezzo - dExtendPath = dMaxOvermaterial + dToolRadius + WD.COLL_SIC - else - -- si calcola l'impronta utensile per uscire quanto basta a garantire il maxOvermaterial, con una distanza di sicurezza - dExtendPath = dMaxOvermaterial + WD.COLL_SIC + dToolRadius - ( dToolRadius - sqrt( dToolRadius * dToolRadius - ( ( dToolRadius - dRawPartHeight) * ( dToolRadius - dRawPartHeight)))) - end - -- approccio - EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR) - EgtSetMachiningParam( MCH_MP.STARTADDLEN, dExtendPath) - EgtSetMachiningParam( MCH_MP.LITANG, 0) - if AreSameVectorApprox( vtExtr, Z_AX()) then - EgtSetMachiningParam( MCH_MP.LIPERP, 0) - else - -- per utensili che lavorano di fianco, si deve partire fuori dall'altezza del grezzo - EgtSetMachiningParam( MCH_MP.LIPERP, WD.CUT_SIC + RawPart.b3:getDimZ()) - end - EgtSetMachiningParam( MCH_MP.LIELEV, 0) - EgtSetMachiningParam( MCH_MP.LICOMPLEN, 0) - -- retrazione - EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.LINEAR) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, dExtendPath) - EgtSetMachiningParam( MCH_MP.LOTANG, 0) - if AreSameVectorApprox( vtExtr, Z_AX()) then - EgtSetMachiningParam( MCH_MP.LOPERP, 0) - else - -- per utensili che lavorano di fianco, si deve partire fuori dall'altezza del grezzo - EgtSetMachiningParam( MCH_MP.LOPERP, WD.CUT_SIC + RawPart.b3:getDimZ()) - end - EgtSetMachiningParam( MCH_MP.LOELEV, 0) - EgtSetMachiningParam( MCH_MP.LOCOMPLEN, 0) - -- note utente - local sUserNotes = '' - sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) - if SquaringGeometries[i].ToolDouble then - sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', 2) - sUserNotes = EgtSetValInNotes( sUserNotes, 'MirrorAx', dRawPartWidth / 2) - sUserNotes = EgtSetValInNotes( sUserNotes, 'TOOLDOUBLE', SquaringGeometries[i].ToolDouble.sName) - end - EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) + -- overlap + EgtSetMachiningParam( MCH_MP.OVERL, 0) + -- tipo di step + if bIsVerticalMilling and bUseZigZagStep then + EgtSetMachiningParam( MCH_MP.STEPTYPE, MCH_MILL_ST.ZIGZAG) + else + EgtSetMachiningParam( MCH_MP.STEPTYPE, MCH_MILL_ST.ONEWAY) + end + -- step + EgtSetMachiningParam( MCH_MP.STEP, SquaringGeometries[i].Tool.dStep) + -- offset radiale + local dRadialOffset = 0 + if not bIsVerticalMilling then + dRadialOffset = ( MachiningSteps.nCount - j) * MachiningSteps.dStep + end + EgtSetMachiningParam( MCH_MP.OFFSR, dRadialOffset) + -- offset longitudinale + EgtSetMachiningParam( MCH_MP.OFFSL, 0) + -- inversione utensile + EgtSetMachiningParam( MCH_MP.TOOLINVERT, false) + -- faceuse + EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.NONE) + -- angoli suggeriti + EgtSetMachiningParam( MCH_MP.INITANGS, '') + -- asse bloccato + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, '') + -- SCC + EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE) + -- calcolo estensione percorso + if bIsVerticalMilling then + -- per utensili che lavorano di fianco, si deve partire fuori dall'altezza del grezzo + dExtendPath = dMaxOvermaterial + dToolRadius + WD.COLL_SIC + else + -- si calcola l'impronta utensile per uscire quanto basta a garantire il maxOvermaterial, con una distanza di sicurezza + dExtendPath = dMaxOvermaterial + WD.COLL_SIC + dToolRadius - ( dToolRadius - sqrt( dToolRadius * dToolRadius - ( ( dToolRadius - dRawPartHeight) * ( dToolRadius - dRawPartHeight)))) + end + -- approccio + EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR) + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dExtendPath) + EgtSetMachiningParam( MCH_MP.LITANG, 0) + if bIsVerticalMilling then + EgtSetMachiningParam( MCH_MP.LIPERP, 0) + else + -- per utensili che lavorano di fianco, si deve partire fuori dall'altezza del grezzo + EgtSetMachiningParam( MCH_MP.LIPERP, WD.CUT_SIC + RawPart.b3:getDimZ()) + end + EgtSetMachiningParam( MCH_MP.LIELEV, 0) + EgtSetMachiningParam( MCH_MP.LICOMPLEN, 0) + -- retrazione + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.LINEAR) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dExtendPath) + EgtSetMachiningParam( MCH_MP.LOTANG, 0) + if bIsVerticalMilling then + EgtSetMachiningParam( MCH_MP.LOPERP, 0) + else + -- per utensili che lavorano di fianco, si deve partire fuori dall'altezza del grezzo + EgtSetMachiningParam( MCH_MP.LOPERP, WD.CUT_SIC + RawPart.b3:getDimZ()) + end + EgtSetMachiningParam( MCH_MP.LOELEV, 0) + EgtSetMachiningParam( MCH_MP.LOCOMPLEN, 0) + -- note utente + local sUserNotes = '' + sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + if SquaringGeometries[i].ToolDouble then + sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', 2) + sUserNotes = EgtSetValInNotes( sUserNotes, 'MirrorAx', dRawPartWidth / 2) + sUserNotes = EgtSetValInNotes( sUserNotes, 'TOOLDOUBLE', SquaringGeometries[i].ToolDouble.sName) + end + EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) - local bOk = EgtApplyMachining( true, false) - EgtRelocateGlob( nOperationId, nFirstOperationId, GDB_IN.BEFORE) - if not bOk then - local _, sMsg = EgtGetLastMachMgrError() - nNotOkCount = nNotOkCount + 1 - sMsgTotal = sMsgTotal ..'\n' .. ( sMsg or '') + local bOk = EgtApplyMachining( true, false) + EgtRelocateGlob( nOperationId, nFirstOperationId, GDB_IN.BEFORE) + if not bOk then + local _, sMsg = EgtGetLastMachMgrError() + nNotOkCount = nNotOkCount + 1 + sMsgTotal = sMsgTotal ..'\n' .. ( sMsg or '') + end end end diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index d4cbf8d..d5ed5c5 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -266,5 +266,17 @@ function WMachiningLib.IsMachiningOkForDouble( sMachining) return bDoubleOk end +------------------------------------------------------------------------------------------------------------- +function WMachiningLib.GetMachiningSteps( dMachiningDepth, dStep) + local MachiningSteps = {} + MachiningSteps.dStep = 0 + MachiningSteps.nCount = ceil( ( dMachiningDepth - 10 * GEO.EPS_SMALL) / dStep) + if MachiningSteps.nCount > 1 then + MachiningSteps.dStep = ( dMachiningDepth - dStep) / ( MachiningSteps.nCount - 1) + end + + return MachiningSteps +end + ------------------------------------------------------------------------------------------------------------- return WMachiningLib diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 81c9750..d8ca49c 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -1268,6 +1268,9 @@ function WallExec.ProcessFeatures() if WD.SQUARING_TYPE and WD.SQUARING_TYPE > 0 then local RawPart = { nId = nRawId, b3 = b3Raw} local bOk, sMsg + if type( WD.SQUARING_TOOL ~= "number") then + WD.SQUARING_TOOL = 0 + end if WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 1 then bOk, sMsg = AddSquaring( 'DoubleDiskmill', RawPart) From b1dd88789929489cecc78a418e8381c5c1a185a2 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 29 Oct 2024 17:38:31 +0100 Subject: [PATCH 09/11] =?UTF-8?q?-=20in=20Squaring=20implementata=20modali?= =?UTF-8?q?t=C3=A0=20ShrinkToParts;=20manca=20la=20rimozione=20delle=20lav?= =?UTF-8?q?orazioni=20fuori=20dall'area=20squadrata?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/Squaring.lua | 38 +++++++++++++++++++++++--------------- LuaLibs/WallExec.lua | 20 ++++++++++---------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/LuaLibs/Squaring.lua b/LuaLibs/Squaring.lua index 5ba3e4c..cd0d3e9 100644 --- a/LuaLibs/Squaring.lua +++ b/LuaLibs/Squaring.lua @@ -121,12 +121,9 @@ function Squaring.AreToolsOk( sSquaringTool, SquaringTools, dMachiningDepth) end ------------------------------------------------------------------------------------------------------------- -function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) +function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart, vPart) -- TODO gestire squadratura sulle dimensioni massime dei pezzi (shrinktoparts) invece che sul master panel local SquaringGeometries = {} - - local dDimX = RawPart.b3:getDimX() - local dDimY = RawPart.b3:getDimY() local sOrigCorner = EgtGetInfo( RawPart.nId, 'ORIGCORNER') local bShrinkToParts = ( WD.SQUARING_TYPE == 2) local bSquaringStartsOnReference = ( type( WD.SQUARING_STARTS_ON_REFERENCE) == "boolean") and ( WD.SQUARING_STARTS_ON_REFERENCE == true) @@ -143,7 +140,16 @@ function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) local Right = { sSide = 'Right'} local Back = { sSide = 'Back'} local Left = { sSide = 'Left'} - local pt1 = RawPart.b3:getMin() + Point3d( -dOffsetXY, -dOffsetXY, -dExtendZ) + local b3Squaring = BBox3d( RawPart.b3) + if bShrinkToParts then + b3Squaring = BBox3d( RawPart.b3:getCenter()) + for i = 1, #vPart do + b3Squaring:Add( vPart[i].Box) + end + end + local dDimX = b3Squaring:getDimX() + local dDimY = b3Squaring:getDimY() + local pt1 = b3Squaring:getMin() + Point3d( -dOffsetXY, -dOffsetXY, -dExtendZ) local pt2 = pt1 + Point3d( dDimX + 2 * dOffsetXY, 0, 0) local pt3 = pt2 + Point3d( 0, dDimY + 2 * dOffsetXY,0 ) local pt4 = pt3 + Point3d( -dDimX - 2 * dOffsetXY, 0, 0) @@ -308,15 +314,14 @@ function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) end end - return SquaringGeometries + return SquaringGeometries, b3Squaring end ------------------------------------------------------------------------------------------------------------- -function Squaring.AddMachinings( SquaringGeometries, RawPart, nFirstOperationId) +function Squaring.AddMachinings( SquaringGeometries, b3Squaring, nFirstOperationId) local nNotOkCount = 0 local sMsgTotal = '' - local dRawPartWidth = RawPart.b3:getDimY() - local dRawPartHeight = RawPart.b3:getDimZ() + local dSquaringHeight = b3Squaring:getDimZ() local dExtendPath = 0 local dMaxOvermaterial = 0 if type( WD.SQUARING_MAX_OVERMATERIAL) == "number" then @@ -334,7 +339,7 @@ function Squaring.AddMachinings( SquaringGeometries, RawPart, nFirstOperationId) -- calcolo step laterale local MachiningSteps = { nCount = 1, dStep = 0} if not bIsVerticalMilling then - MachiningSteps = WM.GetMachiningSteps( dRawPartHeight, SquaringGeometries[i].Tool.dSideStep) + MachiningSteps = WM.GetMachiningSteps( dSquaringHeight, SquaringGeometries[i].Tool.dSideStep) end for j = 1, MachiningSteps.nCount do @@ -361,7 +366,7 @@ function Squaring.AddMachinings( SquaringGeometries, RawPart, nFirstOperationId) end -- distanza di sicurezza if bIsVerticalMilling then - EgtSetMachiningParam( MCH_MP.STARTPOS, WD.CUT_SIC + RawPart.b3:getDimZ()) + EgtSetMachiningParam( MCH_MP.STARTPOS, WD.CUT_SIC + dSquaringHeight) else EgtSetMachiningParam( MCH_MP.STARTPOS, WD.CUT_SIC) end @@ -399,7 +404,7 @@ function Squaring.AddMachinings( SquaringGeometries, RawPart, nFirstOperationId) dExtendPath = dMaxOvermaterial + dToolRadius + WD.COLL_SIC else -- si calcola l'impronta utensile per uscire quanto basta a garantire il maxOvermaterial, con una distanza di sicurezza - dExtendPath = dMaxOvermaterial + WD.COLL_SIC + dToolRadius - ( dToolRadius - sqrt( dToolRadius * dToolRadius - ( ( dToolRadius - dRawPartHeight) * ( dToolRadius - dRawPartHeight)))) + dExtendPath = dMaxOvermaterial + WD.COLL_SIC + dToolRadius - ( dToolRadius - sqrt( dToolRadius * dToolRadius - ( ( dToolRadius - dSquaringHeight) * ( dToolRadius - dSquaringHeight)))) end -- approccio EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR) @@ -409,7 +414,7 @@ function Squaring.AddMachinings( SquaringGeometries, RawPart, nFirstOperationId) EgtSetMachiningParam( MCH_MP.LIPERP, 0) else -- per utensili che lavorano di fianco, si deve partire fuori dall'altezza del grezzo - EgtSetMachiningParam( MCH_MP.LIPERP, WD.CUT_SIC + RawPart.b3:getDimZ()) + EgtSetMachiningParam( MCH_MP.LIPERP, WD.CUT_SIC + dSquaringHeight) end EgtSetMachiningParam( MCH_MP.LIELEV, 0) EgtSetMachiningParam( MCH_MP.LICOMPLEN, 0) @@ -421,7 +426,7 @@ function Squaring.AddMachinings( SquaringGeometries, RawPart, nFirstOperationId) EgtSetMachiningParam( MCH_MP.LOPERP, 0) else -- per utensili che lavorano di fianco, si deve partire fuori dall'altezza del grezzo - EgtSetMachiningParam( MCH_MP.LOPERP, WD.CUT_SIC + RawPart.b3:getDimZ()) + EgtSetMachiningParam( MCH_MP.LOPERP, WD.CUT_SIC + dSquaringHeight) end EgtSetMachiningParam( MCH_MP.LOELEV, 0) EgtSetMachiningParam( MCH_MP.LOCOMPLEN, 0) @@ -429,8 +434,11 @@ function Squaring.AddMachinings( SquaringGeometries, RawPart, nFirstOperationId) local sUserNotes = '' sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) if SquaringGeometries[i].ToolDouble then + local dYMirrorAx + local b3Tab = EgtGetTableArea() + dYMirrorAx = b3Squaring:getCenter():getY() - b3Tab:getMin():getY() sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', 2) - sUserNotes = EgtSetValInNotes( sUserNotes, 'MirrorAx', dRawPartWidth / 2) + sUserNotes = EgtSetValInNotes( sUserNotes, 'MirrorAx', dYMirrorAx) sUserNotes = EgtSetValInNotes( sUserNotes, 'TOOLDOUBLE', SquaringGeometries[i].ToolDouble.sName) end EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index d8ca49c..2e2e458 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -1079,7 +1079,7 @@ local function SetMirroredOperations() end ------------------------------------------------------------------------------------------------------------- -local function AddSquaring( sSquaringTool, RawPart) +local function AddSquaring( sSquaringTool, RawPart, vPart) local nFirstOperationId = EgtGetNextOperation( EgtGetPhaseDisposition( 1)) local dMachiningDepth = RawPart.b3:getDimZ() local bOk @@ -1095,9 +1095,9 @@ local function AddSquaring( sSquaringTool, RawPart) return false, sMsg end - SquaringGeometries = Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart) + local SquaringGeometries, b3Squaring = Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart, vPart) - bOk, sMsg, OperationsId = Squaring.AddMachinings( SquaringGeometries, RawPart, nFirstOperationId) + bOk, sMsg, OperationsId = Squaring.AddMachinings( SquaringGeometries, b3Squaring, nFirstOperationId) if not bOk then for i = 1, #OperationsId do EgtRemoveOperation( i) @@ -1268,12 +1268,12 @@ function WallExec.ProcessFeatures() if WD.SQUARING_TYPE and WD.SQUARING_TYPE > 0 then local RawPart = { nId = nRawId, b3 = b3Raw} local bOk, sMsg - if type( WD.SQUARING_TOOL ~= "number") then + if type( WD.SQUARING_TOOL) ~= "number" then WD.SQUARING_TOOL = 0 end if WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 1 then - bOk, sMsg = AddSquaring( 'DoubleDiskmill', RawPart) + bOk, sMsg = AddSquaring( 'DoubleDiskmill', RawPart, vPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 2) then -- attualmente non gestito, va modificata la configurazione macchina e non si sa se sia gestito in macchina (PLC) @@ -1282,19 +1282,19 @@ function WallExec.ProcessFeatures() --bOk, sMsg = AddSquaring( 'DoubleDiskmillAndBlade', RawPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 3) then - bOk, sMsg = AddSquaring( 'DoubleBlade', RawPart) + bOk, sMsg = AddSquaring( 'DoubleBlade', RawPart, vPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 4) then - bOk, sMsg = AddSquaring( 'Diskmill', RawPart) + bOk, sMsg = AddSquaring( 'Diskmill', RawPart, vPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 5) then - bOk, sMsg = AddSquaring( 'Blade', RawPart) + bOk, sMsg = AddSquaring( 'Blade', RawPart, vPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 6) then - bOk, sMsg = AddSquaring( 'DoubleMill', RawPart) + bOk, sMsg = AddSquaring( 'DoubleMill', RawPart, vPart) end if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 7) then - bOk, sMsg = AddSquaring( 'Mill', RawPart) + bOk, sMsg = AddSquaring( 'Mill', RawPart, vPart) end if not bOk then From 4f2ffec3ab54489b7684639490d8a682c0bbbd02 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 31 Oct 2024 16:04:15 +0100 Subject: [PATCH 10/11] - in Squaring migliorie varie - aggiunta rimozione lavorazioni fuori dall'area di squadratura - in WallExec squadratura suddivisa prima e dopo le altre lavorazioni - in FreeContour aggiunta funzione IsFaceOutsideSquaring per evitare di lavorare le facce che finiscono fuori dall'area di squadratura --- LuaLibs/Squaring.lua | 222 ++++++++++++++++++-------------- LuaLibs/WProcessFreeContour.lua | 34 +++-- LuaLibs/WallExec.lua | 134 +++++++++++-------- 3 files changed, 230 insertions(+), 160 deletions(-) diff --git a/LuaLibs/Squaring.lua b/LuaLibs/Squaring.lua index cd0d3e9..7d0225d 100644 --- a/LuaLibs/Squaring.lua +++ b/LuaLibs/Squaring.lua @@ -14,26 +14,34 @@ local WD = require( 'WallData') local WM = require( 'WMachiningLib') ------------------------------------------------------------------------------------------------------------- -local function IsToolOk( Tool, dMachiningDepth) +local function IsToolOk( Tool, dRawPartHeight) local bIsToolOk = false local bToolExists = false - local dToolMaxDepth = 0 + local bToolCanReachDepth = false + local dMaxOvermaterial = 0 + if type( WD.SQUARING_MAX_OVERMATERIAL) == "number" then + dMaxOvermaterial = WD.SQUARING_MAX_OVERMATERIAL + end bToolExists = ( next( Tool) ~= nil) if bToolExists then if Tool.nType == MCH_TY.MILL_NOTIP then - dToolMaxDepth = Tool.dThickness + bToolCanReachDepth = ( Tool.dThickness > dMaxOvermaterial - 10 * GEO.EPS_SMALL) + and ( Tool.dSideDepth > dRawPartHeight - 10 * GEO.EPS_SMALL) else - dToolMaxDepth = Tool.dMaxDepth + bToolCanReachDepth = Tool.dMaxDepth > dRawPartHeight - 10 * GEO.EPS_SMALL end end - bIsToolOk = bToolExists and ( dToolMaxDepth > dMachiningDepth - 10 * GEO.EPS_SMALL) + bIsToolOk = bToolExists and bToolCanReachDepth return bIsToolOk end ------------------------------------------------------------------------------------------------------------- function Squaring.GetTools() + -- TODO vedere se questo valore è coerente sulle diverse macchine + local dHeadEncumberance = 130 + local Tool = {} local SquaringTools = {} SquaringTools.Blade = {} @@ -67,12 +75,15 @@ function Squaring.GetTools() Tool.dMinFeed = EgtTdbGetCurrToolParam( MCH_TP.MINFEED) Tool.dStep = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'STEP', 'd') or ( Tool.dMaxMaterial / 3) Tool.dSideStep = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDESTEP', 'd') or ( Tool.dDiameter / 6) + Tool.dSideDepth = Tool.dDiameter / 2 - dHeadEncumberance if bIsToolLoadedOnSetup and Tool.nType and bIsSquaringTool then -- lame if Tool.nType == MCH_TY.SAW_FLAT or Tool.nType == MCH_TY.SAW_STD then SquaringTools.Blade[Tool.sHead] = Tool Tool.bIsPathCw = Tool.bIsCcw + Tool.dSideStep = Tool.dStep + Tool.dStep = Tool.dThickness -- frese standard elseif Tool.nType == MCH_TY.MILL_STD then SquaringTools.Mill[Tool.sHead] = Tool @@ -92,27 +103,27 @@ function Squaring.GetTools() end ------------------------------------------------------------------------------------------------------------- -function Squaring.AreToolsOk( sSquaringTool, SquaringTools, dMachiningDepth) +function Squaring.AreToolsOk( sSquaringTool, SquaringTools, dRawPartHeight) local bAreToolsOk = false if sSquaringTool == 'DoubleDiskmill' then - bAreToolsOk = ( IsToolOk( SquaringTools.Blade.H2, dMachiningDepth) - and IsToolOk( SquaringTools.Diskmill.H1, WD.SQUARING_MAX_OVERMATERIAL) - and IsToolOk( SquaringTools.Diskmill.H7, WD.SQUARING_MAX_OVERMATERIAL)) + bAreToolsOk = ( IsToolOk( SquaringTools.Blade.H2, dRawPartHeight) + and IsToolOk( SquaringTools.Diskmill.H1, dRawPartHeight) + and IsToolOk( SquaringTools.Diskmill.H7, dRawPartHeight)) elseif sSquaringTool == 'DoubleDiskmillAndBlade' then - bAreToolsOk = ( IsToolOk( SquaringTools.Blade.H2, dMachiningDepth) - and ( IsToolOk( SquaringTools.Diskmill.H1, WD.SQUARING_MAX_OVERMATERIAL) or IsToolOk( SquaringTools.Diskmill.H7, WD.SQUARING_MAX_OVERMATERIAL))) + bAreToolsOk = ( IsToolOk( SquaringTools.Blade.H2, dRawPartHeight) + and ( IsToolOk( SquaringTools.Diskmill.H1, dRawPartHeight) or IsToolOk( SquaringTools.Diskmill.H7, dRawPartHeight))) elseif sSquaringTool == 'DoubleBlade' then - bAreToolsOk = ( IsToolOk( SquaringTools.Blade.H2, dMachiningDepth) - and ( IsToolOk( SquaringTools.Blade.H1, dMachiningDepth) or IsToolOk( SquaringTools.Blade.H7, dMachiningDepth))) + bAreToolsOk = ( IsToolOk( SquaringTools.Blade.H2, dRawPartHeight) + and ( IsToolOk( SquaringTools.Blade.H1, dRawPartHeight) or IsToolOk( SquaringTools.Blade.H7, dRawPartHeight))) elseif sSquaringTool == 'Diskmill' then - bAreToolsOk = IsToolOk( SquaringTools.Diskmill.H1, WD.SQUARING_MAX_OVERMATERIAL) or IsToolOk( SquaringTools.Diskmill.H7, WD.SQUARING_MAX_OVERMATERIAL) + bAreToolsOk = IsToolOk( SquaringTools.Diskmill.H1, dRawPartHeight) or IsToolOk( SquaringTools.Diskmill.H7, dRawPartHeight) elseif sSquaringTool == 'Blade' then - bAreToolsOk = IsToolOk( SquaringTools.Blade.H2, dMachiningDepth) + bAreToolsOk = IsToolOk( SquaringTools.Blade.H2, dRawPartHeight) elseif sSquaringTool == 'DoubleMill' then - bAreToolsOk = IsToolOk( SquaringTools.Mill.H1, dMachiningDepth) and IsToolOk( SquaringTools.Mill.H7, dMachiningDepth) + bAreToolsOk = IsToolOk( SquaringTools.Mill.H1, dRawPartHeight) and IsToolOk( SquaringTools.Mill.H7, dRawPartHeight) elseif sSquaringTool == 'Mill' then - bAreToolsOk = IsToolOk( SquaringTools.Mill.H1, dMachiningDepth) or IsToolOk( SquaringTools.Mill.H7, dMachiningDepth) + bAreToolsOk = IsToolOk( SquaringTools.Mill.H1, dRawPartHeight) or IsToolOk( SquaringTools.Mill.H7, dRawPartHeight) else error( 'Squaring Tool not recognized') end @@ -121,15 +132,14 @@ function Squaring.AreToolsOk( sSquaringTool, SquaringTools, dMachiningDepth) end ------------------------------------------------------------------------------------------------------------- -function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart, vPart) - -- TODO gestire squadratura sulle dimensioni massime dei pezzi (shrinktoparts) invece che sul master panel - local SquaringGeometries = {} +function Squaring.CalculateParameters( sSquaringTool, SquaringTools, RawPart, vPart) + local SquaringParameters = {} local sOrigCorner = EgtGetInfo( RawPart.nId, 'ORIGCORNER') local bShrinkToParts = ( WD.SQUARING_TYPE == 2) local bSquaringStartsOnReference = ( type( WD.SQUARING_STARTS_ON_REFERENCE) == "boolean") and ( WD.SQUARING_STARTS_ON_REFERENCE == true) local dOffsetXY = 0 local dExtendZ = 0 - if type( WD.SQUARING_OFFSET_XY) == "number" then + if type( WD.SQUARING_OFFSET_XY) == "number" and ( WD.SQUARING_TYPE < 2) then dOffsetXY = WD.SQUARING_OFFSET_XY end if type( WD.SQUARING_EXTEND_Z) == "number" then @@ -141,8 +151,9 @@ function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart, vPart) local Back = { sSide = 'Back'} local Left = { sSide = 'Left'} local b3Squaring = BBox3d( RawPart.b3) + -- se squadratura sui pezzi invece che sul master panel, si costruisce il box minimo che contiene tutti i pezzi if bShrinkToParts then - b3Squaring = BBox3d( RawPart.b3:getCenter()) + b3Squaring = BBox3d( vPart[1].Box:getCenter()) for i = 1, #vPart do b3Squaring:Add( vPart[i].Box) end @@ -153,6 +164,10 @@ function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart, vPart) local pt2 = pt1 + Point3d( dDimX + 2 * dOffsetXY, 0, 0) local pt3 = pt2 + Point3d( 0, dDimY + 2 * dOffsetXY,0 ) local pt4 = pt3 + Point3d( -dDimX - 2 * dOffsetXY, 0, 0) + b3Squaring:Add( pt1) + b3Squaring:Add( pt2) + b3Squaring:Add( pt3) + b3Squaring:Add( pt4) Front.nId = EgtLine( RawPart.nId, pt1, pt2, GDB_RT.GLOB) Right.nId = EgtLine( RawPart.nId, pt2, pt3, GDB_RT.GLOB) Back.nId = EgtLine( RawPart.nId, pt3, pt4, GDB_RT.GLOB) @@ -215,110 +230,110 @@ function Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart, vPart) -- lato lungo lavorato in doppio if not Back.Tool then for i = 1, 3 do - SquaringGeometries[i] = {} + SquaringParameters[i] = {} end if Front.Tool.bIsPathCw then if bSquaringStartsOnReference and ( sOrigCorner == 'BL' or sOrigCorner == 'BM') then - SquaringGeometries[1] = Front - SquaringGeometries[2] = Left - SquaringGeometries[3] = Right + SquaringParameters[1] = Front + SquaringParameters[2] = Left + SquaringParameters[3] = Right elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then - SquaringGeometries[1] = Right - SquaringGeometries[2] = Front - SquaringGeometries[3] = Left + SquaringParameters[1] = Right + SquaringParameters[2] = Front + SquaringParameters[3] = Left elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then - SquaringGeometries[1] = Right - SquaringGeometries[2] = Front - SquaringGeometries[3] = Left + SquaringParameters[1] = Right + SquaringParameters[2] = Front + SquaringParameters[3] = Left elseif bSquaringStartsOnReference and ( sOrigCorner == 'TL' or sOrigCorner == 'TM') then - SquaringGeometries[1] = Left - SquaringGeometries[2] = Front - SquaringGeometries[3] = Right + SquaringParameters[1] = Left + SquaringParameters[2] = Front + SquaringParameters[3] = Right else - SquaringGeometries[1] = Right - SquaringGeometries[2] = Front - SquaringGeometries[3] = Left + SquaringParameters[1] = Right + SquaringParameters[2] = Front + SquaringParameters[3] = Left end else if bSquaringStartsOnReference and ( sOrigCorner == 'BL' or sOrigCorner == 'BM') then - SquaringGeometries[1] = Left - SquaringGeometries[2] = Front - SquaringGeometries[3] = Right + SquaringParameters[1] = Left + SquaringParameters[2] = Front + SquaringParameters[3] = Right elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then - SquaringGeometries[1] = Front - SquaringGeometries[2] = Right - SquaringGeometries[3] = Left + SquaringParameters[1] = Front + SquaringParameters[2] = Right + SquaringParameters[3] = Left elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then - SquaringGeometries[1] = Front - SquaringGeometries[2] = Right - SquaringGeometries[3] = Left + SquaringParameters[1] = Front + SquaringParameters[2] = Right + SquaringParameters[3] = Left elseif bSquaringStartsOnReference and ( sOrigCorner == 'TL' or sOrigCorner == 'TM') then - SquaringGeometries[1] = Left - SquaringGeometries[2] = Front - SquaringGeometries[3] = Right + SquaringParameters[1] = Left + SquaringParameters[2] = Front + SquaringParameters[3] = Right else - SquaringGeometries[1] = Left - SquaringGeometries[2] = Front - SquaringGeometries[3] = Right + SquaringParameters[1] = Left + SquaringParameters[2] = Front + SquaringParameters[3] = Right end end -- doppio non attivo else for i = 1, 4 do - SquaringGeometries[i] = {} + SquaringParameters[i] = {} end if Front.Tool.bIsPathCw then if bSquaringStartsOnReference and ( sOrigCorner == 'BL' or sOrigCorner == 'BM') then - SquaringGeometries[1] = Front - SquaringGeometries[2] = Left - SquaringGeometries[3] = Back - SquaringGeometries[4] = Right + SquaringParameters[1] = Front + SquaringParameters[2] = Left + SquaringParameters[3] = Back + SquaringParameters[4] = Right elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then - SquaringGeometries[1] = Back - SquaringGeometries[2] = Right - SquaringGeometries[3] = Front - SquaringGeometries[4] = Left + SquaringParameters[1] = Back + SquaringParameters[2] = Right + SquaringParameters[3] = Front + SquaringParameters[4] = Left elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then - SquaringGeometries[1] = Right - SquaringGeometries[2] = Front - SquaringGeometries[3] = Left - SquaringGeometries[4] = Back + SquaringParameters[1] = Right + SquaringParameters[2] = Front + SquaringParameters[3] = Left + SquaringParameters[4] = Back else - SquaringGeometries[1] = Left - SquaringGeometries[2] = Back - SquaringGeometries[3] = Right - SquaringGeometries[4] = Front + SquaringParameters[1] = Left + SquaringParameters[2] = Back + SquaringParameters[3] = Right + SquaringParameters[4] = Front end else if bSquaringStartsOnReference and ( sOrigCorner == 'TL' or sOrigCorner == 'TM') then - SquaringGeometries[1] = Back - SquaringGeometries[2] = Left - SquaringGeometries[3] = Front - SquaringGeometries[4] = Right + SquaringParameters[1] = Back + SquaringParameters[2] = Left + SquaringParameters[3] = Front + SquaringParameters[4] = Right elseif bSquaringStartsOnReference and ( sOrigCorner == 'TR' or sOrigCorner == 'TN') then - SquaringGeometries[1] = Right - SquaringGeometries[2] = Back - SquaringGeometries[3] = Left - SquaringGeometries[4] = Front + SquaringParameters[1] = Right + SquaringParameters[2] = Back + SquaringParameters[3] = Left + SquaringParameters[4] = Front elseif bSquaringStartsOnReference and ( sOrigCorner == 'BR' or sOrigCorner == 'BN') then - SquaringGeometries[1] = Front - SquaringGeometries[2] = Right - SquaringGeometries[3] = Back - SquaringGeometries[4] = Left + SquaringParameters[1] = Front + SquaringParameters[2] = Right + SquaringParameters[3] = Back + SquaringParameters[4] = Left else - SquaringGeometries[1] = Left - SquaringGeometries[2] = Front - SquaringGeometries[3] = Right - SquaringGeometries[4] = Back + SquaringParameters[1] = Left + SquaringParameters[2] = Front + SquaringParameters[3] = Right + SquaringParameters[4] = Back end end end - return SquaringGeometries, b3Squaring + return SquaringParameters, b3Squaring end ------------------------------------------------------------------------------------------------------------- -function Squaring.AddMachinings( SquaringGeometries, b3Squaring, nFirstOperationId) +function Squaring.AddMachinings( SquaringParameters, b3Squaring, nFirstOperationId) local nNotOkCount = 0 local sMsgTotal = '' local dSquaringHeight = b3Squaring:getDimZ() @@ -329,9 +344,9 @@ function Squaring.AddMachinings( SquaringGeometries, b3Squaring, nFirstOperation end local bUseZigZagStep = ( type( WD.SQUARING_USE_ZIGZAG) == "boolean") and ( WD.SQUARING_USE_ZIGZAG == true) - for i = 1, #SquaringGeometries do - local dToolRadius = SquaringGeometries[i].Tool.dDiameter / 2 - local vtExtr = EgtCurveExtrusion( SquaringGeometries[i].nId, GDB_RT.GLOB) + for i = 1, #SquaringParameters do + local dToolRadius = SquaringParameters[i].Tool.dDiameter / 2 + local vtExtr = EgtCurveExtrusion( SquaringParameters[i].nId, GDB_RT.GLOB) local bIsVerticalMilling = false if AreSameVectorApprox( vtExtr, Z_AX()) then bIsVerticalMilling = true @@ -339,25 +354,25 @@ function Squaring.AddMachinings( SquaringGeometries, b3Squaring, nFirstOperation -- calcolo step laterale local MachiningSteps = { nCount = 1, dStep = 0} if not bIsVerticalMilling then - MachiningSteps = WM.GetMachiningSteps( dSquaringHeight, SquaringGeometries[i].Tool.dSideStep) + MachiningSteps = WM.GetMachiningSteps( dSquaringHeight, SquaringParameters[i].Tool.dSideStep) end for j = 1, MachiningSteps.nCount do - local nOperationId = EgtCreateMachining( 'SQUARING_' .. SquaringGeometries[i].sSide, MCH_OY.MILLING, SquaringGeometries[i].Tool.sName) + local nOperationId = EgtCreateMachining( 'SQUARING_' .. SquaringParameters[i].sSide, MCH_OY.MILLING, SquaringParameters[i].Tool.sName) -- geometria - EgtSetMachiningGeometry( SquaringGeometries[i].nId) + EgtSetMachiningGeometry( SquaringParameters[i].nId) -- profondità di lavoro EgtSetMachiningParam( MCH_MP.DEPTH_STR, 0) -- workside e inversione - if SquaringGeometries[i].Tool.bIsPathCw then - if SquaringGeometries[i].Tool.nType == MCH_TY.MILL_STD then + if SquaringParameters[i].Tool.bIsPathCw then + if SquaringParameters[i].Tool.nType == MCH_TY.MILL_STD then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) else EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) end EgtSetMachiningParam( MCH_MP.INVERT, true) else - if SquaringGeometries[i].Tool.nType == MCH_TY.MILL_STD then + if SquaringParameters[i].Tool.nType == MCH_TY.MILL_STD then EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) else EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) @@ -379,7 +394,11 @@ function Squaring.AddMachinings( SquaringGeometries, b3Squaring, nFirstOperation EgtSetMachiningParam( MCH_MP.STEPTYPE, MCH_MILL_ST.ONEWAY) end -- step - EgtSetMachiningParam( MCH_MP.STEP, SquaringGeometries[i].Tool.dStep) + if bIsVerticalMilling then + EgtSetMachiningParam( MCH_MP.STEP, SquaringParameters[i].Tool.dStep) + else + EgtSetMachiningParam( MCH_MP.STEP, 0) + end -- offset radiale local dRadialOffset = 0 if not bIsVerticalMilling then @@ -433,13 +452,16 @@ function Squaring.AddMachinings( SquaringGeometries, b3Squaring, nFirstOperation -- note utente local sUserNotes = '' sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) - if SquaringGeometries[i].ToolDouble then + if SquaringParameters[i].ToolDouble then local dYMirrorAx local b3Tab = EgtGetTableArea() dYMirrorAx = b3Squaring:getCenter():getY() - b3Tab:getMin():getY() sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', 2) sUserNotes = EgtSetValInNotes( sUserNotes, 'MirrorAx', dYMirrorAx) - sUserNotes = EgtSetValInNotes( sUserNotes, 'TOOLDOUBLE', SquaringGeometries[i].ToolDouble.sName) + sUserNotes = EgtSetValInNotes( sUserNotes, 'TOOLDOUBLE', SquaringParameters[i].ToolDouble.sName) + end + if not bIsVerticalMilling then + sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', 0) end EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) diff --git a/LuaLibs/WProcessFreeContour.lua b/LuaLibs/WProcessFreeContour.lua index b03a6de..bebaf61 100644 --- a/LuaLibs/WProcessFreeContour.lua +++ b/LuaLibs/WProcessFreeContour.lua @@ -175,6 +175,22 @@ local function IsPointOnRawLongEdges( ptCen, b3Raw) return ( abs( ptCen:getY() - b3Raw:getMin():getY()) < 0.1 or abs( ptCen:getY() - b3Raw:getMax():getY()) < 0.1) end +--------------------------------------------------------------------- +local function IsFaceOutsideSquaring( Proc, Face, b3Squaring) + -- faccia esterna al box di squadratura + if b3Squaring then + local b3SquaringReduced = BBox3d( b3Squaring) + b3SquaringReduced:expand( -0.1) + local b3Face = EgtSurfTmGetFacetBBoxGlob( Proc.Id, Face.Fac, GDB_BB.STANDARD) + if not OverlapsXY( b3SquaringReduced, b3Face) then + EgtOutLog( 'Proc ' .. Proc.Id .. ': skipped face ' .. Face.Fac .. ' outside squaring' ) + return true + end + else + return false + end +end + --------------------------------------------------------------------- local function GetOtherRegions( nPartId) local vOthers = {} @@ -1705,13 +1721,13 @@ local function AddSawings( sSawing, vFace, Proc, nRawId, b3Raw) end --------------------------------------------------------------------- -local function AddCuts( sCutting, vFace, Proc, nRawId, b3Raw, dSawThick) +local function AddCuts( sCutting, vFace, Proc, nRawId, b3Raw, dSawThick, b3Squaring) -- verifico se ciclo chiuso local bClosed = ( abs( vFace[1].PrevAng) > 0.1) -- ciclo di inserimento dei tagli sulle facce del contorno in esame for i = 1, #vFace do - -- verifico se faccia da saltare, perchè macchina travi e faccia su bordo longitudinale esterno già finito - local bToSkip = ( WD.BEAM_MACHINE and IsPointOnRawLongEdges( vFace[i].Cen, b3Raw)) + -- verifico se faccia da saltare, perchè macchina travi e faccia su bordo longitudinale esterno già finito oppure se faccia fuori dal box di squadratura + local bToSkip = ( WD.BEAM_MACHINE and IsPointOnRawLongEdges( vFace[i].Cen, b3Raw)) or IsFaceOutsideSquaring( Proc, vFace[i], b3Squaring) -- se non è faccia da saltare, inserisco il taglio di lama if not bToSkip and vFace[i].Type ~= 4 then -- indice del successivo @@ -1841,7 +1857,7 @@ local function AddCuts( sCutting, vFace, Proc, nRawId, b3Raw, dSawThick) end --------------------------------------------------------------------- -local function MakeByCut( Proc, nRawId, b3Raw) +local function MakeByCut( Proc, nRawId, b3Raw, b3Squaring) local sWarn = '' -- ingombro del pezzo local Ls = EgtGetFirstNameInGroup( Proc.PartId, 'Box') @@ -1887,9 +1903,9 @@ local function MakeByCut( Proc, nRawId, b3Raw) -- gruppo ausiliario local nAddGrpId = WL.GetAddGroup( Proc.PartId) -- recupero i dati di tutte le facce - local vFace, dMaxWidth, nNewProc = GetFacesData( Proc, bOpposite, true, dSawDiam, dSawMaxDepth, dSawThick, nAddGrpId, b3Raw, nil) + local vFace, dMaxWidth, nNewProc = GetFacesData( Proc, bOpposite, true, dSawDiam, dSawMaxDepth, dSawThick, nAddGrpId, b3Raw) -- inserimento dei tagli di lama - local bCtOk, sCtErr = AddCuts( sCutting, vFace, Proc, nRawId, b3Raw, dSawThick) + local bCtOk, sCtErr = AddCuts( sCutting, vFace, Proc, nRawId, b3Raw, dSawThick, b3Squaring) if not bCtOk then return bCtOk, sCtErr end -- se richiesta solo lama, esco local nCntType = EgtGetInfo( Proc.Id, 'CNT_TYPE', 'i') or 0 @@ -2426,7 +2442,7 @@ local function MakeByPocket( Proc, nRawId, b3Raw) EgtErase( nAddedBottomSurface) end if not nFacet then - return MakeByMill( Proc, nRawId, b3Raw) + return MakeByMill( Proc, nRawId, b3Raw, b3Squaring) end -- se ho creato la faccia di fondo utilizzo quella local nSurfId = nProcTmWithAddedBottomSurfaceId or Proc.Id @@ -2573,7 +2589,7 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione -function WPF.Make( Proc, nRawId, b3Raw, vNLO) +function WPF.Make( Proc, nRawId, b3Raw, vNLO, b3Squaring) -- recupero la tipologia (contorno o tasca) local bPocket = ( EgtGetInfo( Proc.Id, 'PCKT', 'i') == 1) -- se svuotatura @@ -2596,7 +2612,7 @@ function WPF.Make( Proc, nRawId, b3Raw, vNLO) return MakeByNail( Proc, nRawId, b3Raw, vNLO) -- altrimenti, taglio con lama e pulizia angoli con fresa else - return MakeByCut( Proc, nRawId, b3Raw) + return MakeByCut( Proc, nRawId, b3Raw, b3Squaring) end end end diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 2e2e458..ec2c812 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -178,7 +178,7 @@ end ------------------------------------------------------------------------------------------------------------- -- *** Inserimento delle lavorazioni nelle pareti *** ------------------------------------------------------------------------------------------------------------- -function WallExec.CollectFeatures( PartId, b3Raw) +function WallExec.CollectFeatures( PartId, b3Raw, b3Squaring) -- recupero le feature local vProc = {} local LayerId = {} @@ -227,6 +227,14 @@ function WallExec.CollectFeatures( PartId, b3Raw) end if Proc.Box and not Proc.Box:isEmpty() then table.insert( vProc, Proc) + -- se squadratura sui pezzi, si annullano le lavorazioni esterne al box di squadratura + if b3Squaring then + local b3SquaringReduced = BBox3d( b3Squaring) + b3SquaringReduced:expand( -0.1) + if not OverlapsXY( Proc.Box, b3SquaringReduced) then + Proc.Flag = 0 + end + end -- se foro if Drill.Identify( Proc) then -- assegno diametro e facce di ingresso e uscita (dati tabelle sempre per riferimento) @@ -352,7 +360,7 @@ local function PrintFeatures( vProc) end ------------------------------------------------------------------------------------------------------------- -local function AddFeatureMachining( Proc, nRawId, b3Raw, vNLO) +local function AddFeatureMachining( Proc, nRawId, b3Raw, vNLO, b3Squaring) local bOk = true local sErr = '' EgtOutLog( ' * Process ' .. tostring( Proc.Id) .. ' *', 1) @@ -395,7 +403,7 @@ local function AddFeatureMachining( Proc, nRawId, b3Raw, vNLO) -- se contorno libero, outline o apertura ( 0/3/4-250/251/252-X) elseif FreeContour.Identify( Proc) then -- esecuzione contorno libero - bOk, sErr = FreeContour.Make( Proc, nRawId, b3Raw, vNLO) + bOk, sErr = FreeContour.Make( Proc, nRawId, b3Raw, vNLO, b3Squaring) -- se feature custom (Variant) elseif Variant.Identify( Proc) then -- esecuzione @@ -1079,25 +1087,38 @@ local function SetMirroredOperations() end ------------------------------------------------------------------------------------------------------------- -local function AddSquaring( sSquaringTool, RawPart, vPart) - local nFirstOperationId = EgtGetNextOperation( EgtGetPhaseDisposition( 1)) - local dMachiningDepth = RawPart.b3:getDimZ() +local function CalculateSquaring( sSquaringTool, RawPart, vPart) + local dRawPartHeight = RawPart.b3:getDimZ() local bOk local sMsg = '' local SquaringTools = {} - local Geometry = {} - local OperationsId = {} + local SquaringParameters = {} + local b3Squaring SquaringTools = Squaring.GetTools() - bOk = Squaring.AreToolsOk( sSquaringTool, SquaringTools, dMachiningDepth) + bOk = Squaring.AreToolsOk( sSquaringTool, SquaringTools, dRawPartHeight) if not bOk then sMsg = 'Squaring failed: cannot find matching tools' - return false, sMsg + return false, {}, nil, sMsg end - local SquaringGeometries, b3Squaring = Squaring.CreateGeometry( sSquaringTool, SquaringTools, RawPart, vPart) + SquaringParameters, b3Squaring = Squaring.CalculateParameters( sSquaringTool, SquaringTools, RawPart, vPart) + if not SquaringParameters or next( SquaringParameters) == nil then + sMsg = 'Squaring failed: cannot calculate parameters' + return false, {}, nil, sMsg + end - bOk, sMsg, OperationsId = Squaring.AddMachinings( SquaringGeometries, b3Squaring, nFirstOperationId) + return true, SquaringParameters, b3Squaring, sMsg +end + +------------------------------------------------------------------------------------------------------------- +local function AddSquaring( SquaringParameters, b3Squaring) + local nFirstOperationId = EgtGetNextOperation( EgtGetPhaseDisposition( 1)) + local bOk + local sMsg = '' + local OperationsId = {} + + bOk, sMsg, OperationsId = Squaring.AddMachinings( SquaringParameters, b3Squaring, nFirstOperationId) if not bOk then for i = 1, #OperationsId do EgtRemoveOperation( i) @@ -1108,10 +1129,6 @@ local function AddSquaring( sSquaringTool, RawPart, vPart) Squaring.AddScrapRemoval( nFirstOperationId) - if WD.SQUARING_TYPE == 2 then - Squaring.RemoveExternalMachinings( Geometry) - end - return true, sMsg end @@ -1132,11 +1149,57 @@ function WallExec.ProcessFeatures() table.insert( vPart, {Id=nPartId, Box=b3Solid}) nPartId = EgtGetNextPartInRawPart( nPartId) end + + -- calcolo i parametri della squadratura, se richiesta + local SquaringParameters = {} + local b3Squaring + if WD.SQUARING_TYPE and WD.SQUARING_TYPE > 0 then + local RawPart = { nId = nRawId, b3 = b3Raw} + local bOk, sMsg + if type( WD.SQUARING_TOOL) ~= "number" then + WD.SQUARING_TOOL = 0 + end + + if WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 1 then + bOk, SquaringParameters, b3Squaring, sMsg = CalculateSquaring( 'DoubleDiskmill', RawPart, vPart) + end + if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 2) then + -- attualmente non gestito, va modificata la configurazione macchina e non si sa se sia gestito in macchina (PLC) + bOk = false + sMsg = 'Squaring not possible : double blade + diskmill not supported' + --SquaringParameters, b3Squaring, sMsg = CalculateSquaring( 'DoubleDiskmillAndBlade', RawPart) + end + if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 3) then + bOk, SquaringParameters, b3Squaring, sMsg = CalculateSquaring( 'DoubleBlade', RawPart, vPart) + end + if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 4) then + bOk, SquaringParameters, b3Squaring, sMsg = CalculateSquaring( 'Diskmill', RawPart, vPart) + end + if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 5) then + bOk, SquaringParameters, b3Squaring, sMsg = CalculateSquaring( 'Blade', RawPart, vPart) + end + if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 6) then + bOk, SquaringParameters, b3Squaring, sMsg = CalculateSquaring( 'DoubleMill', RawPart, vPart) + end + if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 7) then + bOk, SquaringParameters, b3Squaring, sMsg = CalculateSquaring( 'Mill', RawPart, vPart) + end + + if not bOk then + nTotErr = nTotErr + 1 + table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=0, TaskId=0}) + elseif sMsg and #sMsg > 0 then + table.insert( Stats, {Err=-1, Msg=sMsg, Rot=0, CutId=0, TaskId=0}) + else + table.insert( Stats, {Err=0, Msg='', Rot=0, CutId=0, TaskId=0}) + end + end + -- raccolgo l'elenco delle feature da lavorare, ciclando sui pezzi local vProc = {} for i = 1, #vPart do -- recupero le feature di lavorazione della parete - local vPartProc = WallExec.CollectFeatures( vPart[i].Id, b3Raw) + local vPartProc = WallExec.CollectFeatures( vPart[i].Id, b3Raw, b3Squaring) vProc = EgtJoinTables( vProc, vPartProc) end -- classifico topologicamente le feature @@ -1163,7 +1226,7 @@ function WallExec.ProcessFeatures() -- creo la lavorazione local Proc = vProc[i] if Proc.Flg ~= 0 then - local bOk, sMsg = AddFeatureMachining( Proc, nRawId, b3Raw, vNLO) + local bOk, sMsg = AddFeatureMachining( Proc, nRawId, b3Raw, vNLO, b3Squaring) if not bOk then nTotErr = nTotErr + 1 table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) @@ -1263,39 +1326,9 @@ function WallExec.ProcessFeatures() end -- ordinamento standard SortMachinings( nPhase, PrevMch) - -- squadratura, se richiesta - if WD.SQUARING_TYPE and WD.SQUARING_TYPE > 0 then - local RawPart = { nId = nRawId, b3 = b3Raw} - local bOk, sMsg - if type( WD.SQUARING_TOOL) ~= "number" then - WD.SQUARING_TOOL = 0 - end - - if WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 1 then - bOk, sMsg = AddSquaring( 'DoubleDiskmill', RawPart, vPart) - end - if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 2) then - -- attualmente non gestito, va modificata la configurazione macchina e non si sa se sia gestito in macchina (PLC) - bOk = false - sMsg = 'Squaring not possible : double blade + diskmill not supported' - --bOk, sMsg = AddSquaring( 'DoubleDiskmillAndBlade', RawPart) - end - if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 3) then - bOk, sMsg = AddSquaring( 'DoubleBlade', RawPart, vPart) - end - if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 4) then - bOk, sMsg = AddSquaring( 'Diskmill', RawPart, vPart) - end - if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 5) then - bOk, sMsg = AddSquaring( 'Blade', RawPart, vPart) - end - if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 6) then - bOk, sMsg = AddSquaring( 'DoubleMill', RawPart, vPart) - end - if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 7) then - bOk, sMsg = AddSquaring( 'Mill', RawPart, vPart) - end + if SquaringParameters and next( SquaringParameters) ~= nil then + local bOk, sMsg = AddSquaring( SquaringParameters, b3Squaring) if not bOk then nTotErr = nTotErr + 1 @@ -1306,7 +1339,6 @@ function WallExec.ProcessFeatures() table.insert( Stats, {Err=0, Msg='', Rot=0, CutId=0, TaskId=0}) end end - -- Aggiornamento finale di tutto if nGetPriorityFromBtl > 0 then InsertScrapRemoval( nPhase) From 5791bea4b5d8699e38bd580265e5a0a59146b214 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 4 Nov 2024 15:35:15 +0100 Subject: [PATCH 11/11] in Squaring modifiche a lettura parametri utensili --- LuaLibs/Squaring.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LuaLibs/Squaring.lua b/LuaLibs/Squaring.lua index 7d0225d..8caa5bb 100644 --- a/LuaLibs/Squaring.lua +++ b/LuaLibs/Squaring.lua @@ -63,8 +63,8 @@ function Squaring.GetTools() Tool.nType = EgtTdbGetCurrToolParam( MCH_TP.TYPE) Tool.dDiameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - Tool.dThickness = EgtTdbGetCurrToolParam( MCH_TP.THICK) Tool.dMaxMaterial = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) + Tool.dThickness = EgtIf( ( Tool.nType == MCH_TY.SAW_FLAT or Tool.nType == MCH_TY.SAW_STD), EgtTdbGetCurrToolParam( MCH_TP.THICK), Tool.dMaxMaterial) Tool.dMaxDepth = EgtTdbGetCurrToolMaxDepth() or Tool.dMaxMaterial Tool.sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) Tool.bIsCcw = EgtTdbGetCurrToolParam( MCH_TP.SPEED) < 0 @@ -73,8 +73,8 @@ function Squaring.GetTools() Tool.dEndFeed = EgtTdbGetCurrToolParam( MCH_TP.ENDFEED) Tool.dTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) Tool.dMinFeed = EgtTdbGetCurrToolParam( MCH_TP.MINFEED) - Tool.dStep = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'STEP', 'd') or ( Tool.dMaxMaterial / 3) - Tool.dSideStep = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDESTEP', 'd') or ( Tool.dDiameter / 6) + Tool.dStep = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'STEP', 'd') or EgtIf( ( Tool.nType == MCH_TY.SAW_FLAT or Tool.nType == MCH_TY.SAW_STD), ( Tool.dDiameter / 3), ( Tool.dMaxMaterial / 3)) + Tool.dSideStep = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDESTEP', 'd') or ( Tool.dDiameter / 3) Tool.dSideDepth = Tool.dDiameter / 2 - dHeadEncumberance if bIsToolLoadedOnSetup and Tool.nType and bIsSquaringTool then