Files
DataWall/LuaLibs/WProcessLapJoint.lua
T
Dario Sassi ea9f74c0ad DataWall :
- aggiunta gestione tasche (solo svuotatura).
2020-06-30 17:37:29 +00:00

124 lines
4.4 KiB
Lua

-- WProcessLapJoint.lua by Egaltech s.r.l. 2020/06/30
-- Gestione calcolo mezzo-legno per Pareti
-- Tabella per definizione modulo
local WPL = {}
-- Include
require( 'EgtBase')
local WL = require( 'WallLib')
EgtOutLog( ' WProcessLapJoint started', 1)
-- Dati
local WD = require( 'WallData')
local WM = require( 'WMachiningLib')
---------------------------------------------------------------------
-- Riconoscimento della feature
function WPL.Identify( Proc)
return ( ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 30)
end
---------------------------------------------------------------------
-- Classificazione della feature
function WPL.Classify( Proc, b3Raw)
-- se 1 faccia
if Proc.Fct == 1 then
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
-- verifico se è lavorabile da sopra
return vtN:getZ() >= WD.NZ_MINA
-- se 2 facce
elseif Proc.Fct == 2 then
-- dati delle facce
local ptC = {}
local vtN = {}
ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
-- verifico se è lavorabile da sopra
return vtN[1]:getZ() >= WD.NZ_MINA or vtN[2]:getZ() >= WD.NZ_MINA
-- se più di 2 facce
else
local nFacInd, dElev, nFacInd2, dElev2 = WL.GetFaceWithMostAdj( Proc.Id, Proc.PartId)
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
-- verifico se è lavorabile da sopra
return vtN:getZ() >= WD.NZ_MINA
end
end
---------------------------------------------------------------------
local function MakePocketing( Proc, nFacet, nRawId, b3Raw)
-- recupero i dati della curva e del profilo
local dElev = WL.GetFaceElevation( Proc.Id, nFacet, nPartId)
-- recupero la lavorazione
local sPocketing = WM.FindPocketing( 'Pocket', nil, dDepth)
if not sPocketing then
local sErr = 'Error : pocketing not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- recupero i dati dell'utensile
local dMillDiam = 20
local dMaxDepth = 0
if EgtMdbSetCurrMachining( sPocketing) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
end
end
-- inserisco la lavorazione di svuotatura
local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchFId = EgtAddMachining( sName, sPocketing)
if not nMchFId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sPocketing
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, nFacet}})
-- imposto posizione braccio porta testa
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP)
-- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente
local dDepth = 0
if dElev > dMaxDepth + 10 * GEO.EPS_SMALL then
dDepth = dMaxDepth - dElev
local sWarn = 'Warning : elevation bigger than max tool depth'
EgtOutLog( sWarn)
end
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
-- imposto elevazione
EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( min( dElev, dMaxDepth), 1) .. ';')
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
return true
end
---------------------------------------------------------------------
-- Applicazione della lavorazione
function WPL.Make( Proc, nRawId, b3Raw)
-- svuotatura della faccia principale
local nFacet
if Proc.Fct == 1 then
nFacet = 0
elseif Proc.Fct >= 2 then
local nFacInd, _, nFacInd2 = WL.GetFaceWithMostAdj( Proc.Id, Proc.PartId)
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT)
if vtN:getZ() >= WD.NZ_MINA then
nFacet = nFacInd
else
nFacet = nFacInd2
end
end
return MakePocketing( Proc, nFacet, nRawId, b3Raw)
end
---------------------------------------------------------------------
return WPL