6eaba8a577
- primo rilascio.
98 lines
3.1 KiB
Lua
98 lines
3.1 KiB
Lua
-- ProcessText.lua by Egaltech s.r.l. 2018/04/17
|
|
-- Gestione calcolo testi per Travi
|
|
|
|
-- Tabella per definizione modulo
|
|
local ProcessText = {}
|
|
|
|
-- Include
|
|
require( 'EgtBase')
|
|
|
|
EgtOutLog( ' ProcessText 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 ProcessText.Identify( Proc)
|
|
return ( Proc.Grp == 4 and Proc.Prc == 61)
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
-- Classificazione della feature
|
|
function ProcessText.Classify( Proc)
|
|
-- recupero i dati del testo
|
|
local vtN = EgtTextNormVersor( Proc.Id, GDB_ID.ROOT)
|
|
-- verifico sia un testo
|
|
if not vtN then
|
|
return false
|
|
end
|
|
-- verifico se il testo è lavorabile solo da sotto
|
|
local bDown = (( vtN:getZ() < -0.1))
|
|
return true, bDown
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
-- Applicazione della lavorazione
|
|
function ProcessText.Make( Proc, nPhase, nRawId, nPartId)
|
|
-- recupero i dati del testo
|
|
local vtN = EgtTextNormVersor( Proc.Id, GDB_ID.ROOT)
|
|
-- verifico sia un testo
|
|
if not vtN then
|
|
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Text with geometry type not accepted'
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
-- verifico che il testo non sia orientato verso il basso (-5 deg)
|
|
if vtN:getZ() < - 0.1 then
|
|
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Text from bottom impossible'
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
-- recupero la lavorazione
|
|
local nMill, sMilling = FindMilling( 'Text')
|
|
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 = 'Text_' .. ( 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 vtN: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 ProcessText
|