Files
DataBeam/LuaLibs/ProcessChamfer.lua
T
Dario Sassi dbb43355c3 DataBeam :
- correzioni e migliorie varie
- aggiunta gestione lavorazioni BlockHausFront e FrenchRidgeLap.
2020-02-12 09:10:51 +00:00

141 lines
5.3 KiB
Lua

-- ProcessChamfer.lua by Egaltech s.r.l. 2020/02/11
-- Gestione calcolo profilo libero per Travi
-- Tabella per definizione modulo
local ProcessChamfer = {}
-- Include
require( 'EgtBase')
local BL = require( 'BeamLib')
EgtOutLog( ' ProcessChamfer started', 1)
-- Dati
local BD = require( 'BeamData')
local ML = require( 'MachiningLib')
---------------------------------------------------------------------
-- Riconoscimento della feature
function ProcessChamfer.Identify( Proc)
return ( ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 36)
end
---------------------------------------------------------------------
-- Applicazione della lavorazione
function ProcessChamfer.Make( Proc, nPhase, nRawId, nPartId)
-- verifico se ha geometria ausiliaria (onde)
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i')
if AuxId then AuxId = AuxId + Proc.Id end
-- recupero la lavorazione
local sMilling = ML.FindMilling( 'Chamfer')
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
local sName = 'Chm_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchId = EgtAddMachining( sName, sMilling)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
end
-- recupero i dati dell'utensile
local dMillDiam = 10
local dMaxMat = 20
if EgtMdbSetCurrMachining( sMilling) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam
dMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxMat
end
end
-- se onde
if AuxId then
-- impongo lavorazione dall'alto
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
if vtExtr:getZ() < 0 then
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
EgtSetMachiningParam( MCH_MP.INVERT, true)
end
-- lavoro tenendo l'utensile a sinistra
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
-- imposto lavorazione a metà tagliente e senza step
EgtSetMachiningParam( MCH_MP.DEPTH, dMaxMat / 2)
EgtSetMachiningParam( MCH_MP.STEP, 0)
-- imposto attacchi e uscite
EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0)
EgtSetMachiningParam( MCH_MP.LIPERP, 3)
EgtSetMachiningParam( MCH_MP.LITANG, 6)
EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.TANGENT)
EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0)
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.AS_LI)
-- aggiungo geometria
EgtSetMachiningGeometry( {{ AuxId, -1}})
-- altrimenti smusso standard
else
-- normale ed elevazione della faccia principale
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
local _, dElev = BL.GetPointDirDepth( nPartId, ptC, vtN)
-- limitazioni su inizio e fine derivanti da altre facce
local bLimXmin = false
local bLimXmax = false
if Proc.Fct >= 3 then
bLimXmin = true
bLimXmax = true
elseif Proc.Fct >= 2 then
local ptC1, vtN1 = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
if vtN1:getX() > 0 then
bLimXmin = true
else
bLimXmax = true
end
end
-- calcolo eventuali accorciamenti per facce limitanti
local dAllExtr
if dElev < dMillDiam / 2 then
dAllExtr = -sqrt( dMillDiam * dElev - dElev * dElev)
else
dAllExtr = -dMillDiam / 2
end
local dStartAll = 0
local dEndAll = 0
if vtN:getY() < 0 then
if bLimXmax then dStartAll = dAllExtr end
if bLimXmin then dEndAll = dAllExtr end
else
if bLimXmax then dEndAll = dAllExtr end
if bLimXmin then dStartAll = dAllExtr end
end
-- lavoro tenendo l'utensile a sinistra
EgtSetMachiningParam( MCH_MP.INVERT, true)
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
-- imposto lavorazione un poco sotto
local sDepth = 'TH+'..EgtNumToString( BD.CUT_EXTRA)
EgtSetMachiningParam( MCH_MP.DEPTH_STR, sDepth)
EgtSetMachiningParam( MCH_MP.STEP, 0)
-- imposto utilizzo faccia
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN)
-- imposto attacchi e uscite
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dStartAll)
EgtSetMachiningParam( MCH_MP.LIPERP, dMillDiam / 4)
EgtSetMachiningParam( MCH_MP.LITANG, 0)
EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR)
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEndAll)
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.AS_LI)
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, 0}})
end
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
return true
end
---------------------------------------------------------------------
return ProcessChamfer