Files
DataBeam/LuaLibs/ProcessDecor.lua
T
Dario Sassi 6eaba8a577 DataBeam :
- primo rilascio.
2019-04-01 15:18:51 +00:00

93 lines
3.0 KiB
Lua

-- ProcessDecor.lua by Egaltech s.r.l. 2018/04/18
-- Gestione calcolo decoro per Travi
-- Tabella per definizione modulo
local ProcessDecor = {}
-- Include
require( 'EgtBase')
EgtOutLog( ' ProcessDecor started', 1)
-- Dati
local BD = require( 'BeamData')
local Millings = require( 'MillingData')
---------------------------------------------------------------------
local function FindMilling( sType)
for i = 1, #Millings do
local Milling = Millings[i]
if Milling.Type == sType then
return i, Milling.Name
end
end
return 0
end
---------------------------------------------------------------------
-- Riconoscimento della feature
function ProcessDecor.Identify( Proc)
return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 959)
end
---------------------------------------------------------------------
-- Classificazione della feature
function ProcessDecor.Classify( Proc)
-- recupero i dati della decorazione
local vtExtr = EgtCurveExtrusion( Proc.Id, GDB_RT.GLOB)
-- verifico sia una decorazione
if not vtExtr then
return false
end
-- verifico se la decorazione è lavorabile solo da sotto
local bDown = (( vtExtr:getZ() < -0.1))
return true, bDown
end
---------------------------------------------------------------------
-- Applicazione della lavorazione
function ProcessDecor.Make( Proc, nPhase, nRawId, nPartId)
-- recupero i dati della decorazione
local vtExtr = EgtCurveExtrusion( Proc.Id, GDB_RT.GLOB)
-- verifico che la decorazione non sia orientata verso il basso (-5 deg)
if vtExtr:getZ() < - 0.1 then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Decor from bottom impossible'
EgtOutLog( sErr)
return false, sErr
end
-- recupero la lavorazione
local sToFind = EgtGetInfo( Proc.Id, 'P15')
local nMill, sMilling = FindMilling( sToFind)
if not sMilling then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- inserisco la lavorazione di fresatura
local sName = 'Decor_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchFId = EgtAddMachining( sName, sMilling)
if not nMchFId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, -1}})
-- imposto posizione braccio porta testa
if vtExtr:getY() <= 0 then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
else
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
end
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
return true
end
---------------------------------------------------------------------
return ProcessDecor