e4c5a2e06d
- piccoli aggiustamenti per TURN.
93 lines
3.1 KiB
Lua
93 lines
3.1 KiB
Lua
-- ProcessText.lua by Egaltech s.r.l. 2021/05/03
|
|
-- Gestione calcolo testi per Travi
|
|
-- 2021/05/03 Aggiunta gestione testa da sotto.
|
|
|
|
-- Tabella per definizione modulo
|
|
local ProcessText = {}
|
|
|
|
-- Include
|
|
require( 'EgtBase')
|
|
|
|
EgtOutLog( ' ProcessText started', 1)
|
|
|
|
-- Dati
|
|
local BD = require( 'BeamData')
|
|
local ML = require( 'MachiningLib')
|
|
|
|
---------------------------------------------------------------------
|
|
-- 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 and not BD.DOWN_HEAD and not BD.TURN then
|
|
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Text from bottom impossible'
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
-- abilitazione lavorazione da sotto
|
|
local bMillUp = ( BD.DOWN_HEAD and vtN:getZ() > -0.259)
|
|
local bMillDown = ( BD.DOWN_HEAD and vtN:getZ() < 0.174)
|
|
-- recupero la lavorazione
|
|
local sMillType = 'Text'
|
|
--local sMchExt = EgtIf( bMillDown, '_H2', '')
|
|
local sMilling = ML.FindMilling( sMillType, nil, nil, nil, nil, bMillUp, bMillDown)
|
|
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 ML.ApplyMachining( true, false) then
|
|
local _, sErr = EgtGetLastMachMgrError()
|
|
EgtSetOperationMode( nMchFId, false)
|
|
return false, sErr
|
|
end
|
|
return true
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
return ProcessText
|