Files
DataWall/LuaLibs/WProcessVariant.lua
T
Dario Sassi ed80dccaf0 DataWall 3.1a1 :
- aggiunta gestione sgrossatura superfici per Feature Variant 1 (se lav.ne abilitata da Ini macchina).
2026-01-22 08:08:00 +01:00

131 lines
4.8 KiB
Lua

-- WProcessVariant.lua by Egaltech s.r.l. 2021/08/27
-- Gestione calcolo Feature Custom (Variant) per Pareti
-- 2023/05/25 Funzioni EgtAddMachining sostituite da WM.AddMachining in modo da trascrivere le priorità da btl alle lavorazioni.
-- Tabella per definizione modulo
local WPV = {}
-- Include
require( 'EgtBase')
local WL = require( 'WallLib')
EgtOutLog( ' WProcessVariant started', 1)
-- Dati
local WD = require( 'WallData')
local WM = require( 'WMachiningLib')
---------------------------------------------------------------------
-- Riconoscimento della feature
function WPV.Identify( Proc)
return (( Proc.Grp == 0 or Proc.Grp == 1 or Proc.Grp == 2 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 900)
end
---------------------------------------------------------------------
-- Classificazione della feature: decide se la feature è in una posizione lavorabile
local function ClassifyCode_1( Proc, b3Raw)
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i')
if AuxId then
AuxId = AuxId + Proc.Id
end
if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then
local sErr = 'Error : missing containement geometry'
EgtOutLog( sErr)
return false
end
local vtExtr = EgtCurveExtrusion( AuxId or GDB_ID.NULL, GDB_ID.ROOT)
return ( vtExtr:getZ() > -0.01)
end
---------------------------------------------------------------------
function WPV.Classify( Proc, b3Raw)
-- recupero il codice identificativo
local sCode = EgtGetInfo( Proc.Id, 'DES')
-- gestione in base al codice
if sCode == '1' then
return ClassifyCode_1( Proc, b3Raw)
else
return false
end
end
---------------------------------------------------------------------
-- Applicazione della lavorazione
local function MakeCode_1( Proc, nRawId, b3Raw)
local sWarn
-- recupero e verifico l'entità curva associata
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i')
if AuxId then
AuxId = AuxId + Proc.Id
end
if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then
local sErr = 'Error : missing containement geometry'
EgtOutLog( sErr)
return false, sErr
end
local vtExtr = EgtCurveExtrusion( AuxId or GDB_ID.NULL, GDB_ID.ROOT)
-- cerco e applico le lavorazioni di superficie opportune
local sMachIni = EgtGetCurrMachineDir()..'\\'..EgtGetCurrMachineName()..'.ini'
local bSurfRough = ( EgtGetNumberFromIni( 'Machinings', 'SurfRoughing', 0, sMachIni) >= 1)
local SurfLav = { { Type='Roughing', Name='SurfRou_', Err=true}, { Type='Finishing', Name='SurfFin_', Err=true}}
local nStart = EgtIf( bSurfRough, 1, 2)
for i = nStart, 2 do
-- recupero la lavorazione
local sSurfLav = WM.FindSurfacing( SurfLav[i].Type)
if not sSurfLav then
if SurfLav[i].Err then
local sErr = 'Error : surface '.. SurfLav[i].Type .. ' not found in library'
EgtOutLog( sErr)
return false, sErr
else
sWarn = 'Warning : surface '.. SurfLav[i].Type .. ' not found in library'
EgtOutLog( sWarn)
end
else
-- inserisco la lavorazione di superficie
local sName = SurfLav[i].Name .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchFId = WM.AddMachining( Proc, sName, sSurfLav)
if not nMchFId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sSurfLav
EgtOutLog( sErr)
return false, sErr
end
EgtSetInfo( nMchFId, 'Part', Proc.PartId)
-- se lavorazione di fianco setto la nota per spostarla dopo i tagli di lama
if vtExtr:getZ() < WD.NZ_MINA then
EgtSetInfo( nMchFId, 'MOVE_AFTER', 1)
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, -1},{AuxId, -1}})
-- imposto posizione braccio porta testa
local nSCC = MCH_SCC.ADIR_ZP
if AreSameVectorApprox( vtExtr, Z_AX()) then
nSCC = EgtIf( Proc.Box:getDimX() >= Proc.Box:getDimY(), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_XP)
end
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
end
end
return true, sWarn
end
---------------------------------------------------------------------
function WPV.Make( Proc, nRawId, b3Raw)
-- recupero il codice identificativo
local sCode = EgtGetInfo( Proc.Id, 'DES')
-- gestione in base al codice
if sCode == '1' then
return MakeCode_1( Proc, nRawId, b3Raw)
else
return false, 'Feature Id Code non recognized for machining'
end
end
---------------------------------------------------------------------
return WPV