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

103 lines
3.3 KiB
Lua

-- ProcessMark.lua by Egaltech s.r.l. 2018/04/18
-- Gestione calcolo marcatura per Travi
-- Tabella per definizione modulo
local ProcessMark = {}
-- Include
require( 'EgtBase')
EgtOutLog( ' ProcessMark 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 ProcessMark.Identify( Proc)
return (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 60)
end
---------------------------------------------------------------------
-- Classificazione della feature
function ProcessMark.Classify( Proc)
-- recupero il versore estrusione
local vtN = EgtCurveExtrusion( Proc.Id, GDB_ID.ROOT)
-- verifico sia una curva
if not vtN then
return false
end
-- verifico se la marcatura è lavorabile solo da sotto
local bDown = (( vtN:getZ() < -0.1))
return true, bDown
end
---------------------------------------------------------------------
-- Applicazione della lavorazione
function ProcessMark.Make( Proc, nPhase, nRawId, nPartId)
-- recupero eventuale geometria ausiliaria
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i')
if AuxId then AuxId = AuxId + Proc.Id end
-- recupero i dati della marcatura
local vtExtr = EgtCurveExtrusion( Proc.Id, GDB_RT.GLOB)
-- verifico sia una curva
if not vtExtr then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Mark with geometry type not accepted'
EgtOutLog( sErr)
return false, sErr
end
-- verifico che la marcatura non sia orientata verso il basso (-5 deg)
if vtExtr:getZ() < - 0.1 then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Mark from bottom impossible'
EgtOutLog( sErr)
return false, sErr
end
-- recupero la lavorazione
local nMill, sMilling = FindMilling( 'Mark')
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
local vGeom = {{ Proc.Id, -1}}
if AuxId then vGeom[2] = { AuxId, -1} end
EgtSetMachiningGeometry( vGeom)
-- 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 ProcessMark