From 09127ce5766918d40bdf2c294c67f1c58abf78e2 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 9 Oct 2024 18:09:02 +0200 Subject: [PATCH] - 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)