DataBeam :
- primo rilascio.
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
-- ProcessMortise.lua by Egaltech s.r.l. 2018/03/23
|
||||
-- Gestione calcolo mortase per Travi
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
local ProcessMortise = {}
|
||||
|
||||
-- Include
|
||||
require( 'EgtBase')
|
||||
|
||||
EgtOutLog( ' ProcessMortise started', 1)
|
||||
|
||||
-- Dati
|
||||
local BD = require( 'BeamData')
|
||||
local Pocketings = require( 'PocketingData')
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function FindPocketing( sType)
|
||||
for i = 1, #Pocketings do
|
||||
local Pocketing = Pocketings[i]
|
||||
if Pocketing.Type == sType then
|
||||
return i, Pocketing.Name
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Riconoscimento della feature
|
||||
function ProcessMortise.Identify( Proc)
|
||||
return ( (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 50) or
|
||||
(( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 51) or
|
||||
(( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 53))
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Classificazione della feature
|
||||
function ProcessMortise.Classify( Proc)
|
||||
-- recupero i dati della faccia di fondo
|
||||
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
|
||||
-- verifico sia una superficie
|
||||
if not vtN then
|
||||
return false
|
||||
end
|
||||
-- verifico se la mortasa è lavorabile solo da sotto
|
||||
local bDown = ( vtN:getZ() < - 0.1)
|
||||
return true, bDown
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Applicazione della lavorazione
|
||||
function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId)
|
||||
-- recupero e verifico l'entità curva
|
||||
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i')
|
||||
if AuxId then AuxId = AuxId + Proc.Id end
|
||||
if not AuxId or ( EgtGetType( AuxId) & 256) == 0 then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- se curva aperta la allungo e chiudo
|
||||
if not EgtCurveIsClosed( AuxId) then
|
||||
local EXTRA_LEN = 30
|
||||
EgtExtendCurveStartByLen( AuxId, EXTRA_LEN)
|
||||
EgtExtendCurveEndByLen( AuxId, EXTRA_LEN)
|
||||
EgtCloseCurveCompo( AuxId)
|
||||
end
|
||||
-- recupero i dati della curva e del top
|
||||
local dDepth = abs( EgtCurveThickness( AuxId))
|
||||
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
|
||||
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
|
||||
EgtOutLog( 'ptC=' .. tostring( ptC) ..' vtN=' .. tostring( vtN), 3)
|
||||
-- verifico che la mortasa non sia orientata verso il basso (-5 deg)
|
||||
if vtN:getZ() < - 0.1 then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Mortise from bottom impossible'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- recupero la lavorazione
|
||||
local nPocket, sPocketing = FindPocketing( 'Mortise')
|
||||
if not sPocketing then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- inserisco la lavorazione di svuotatura
|
||||
local sName = 'Mort_' .. ( 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( {{ AuxId, -1}})
|
||||
-- imposto posizione braccio porta testa
|
||||
if vtN:getY() < - GEO.EPS_SMALL 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 ProcessMortise
|
||||
Reference in New Issue
Block a user