0d31c0bbd9
- mortasa di coda va eseguita dopo tutte le altre lavorazioni - in taglio con lama corretto angolo per passare ad Up (da 46deg portato a 44.9deg) - in DtMortise direzione feature viene derivata da estrusione curva associata - in LapJoint corretto calcolo step per passate con lama.
111 lines
4.2 KiB
Lua
111 lines
4.2 KiB
Lua
-- ProcessMortise.lua by Egaltech s.r.l. 2019/11/12
|
|
-- Gestione calcolo mortase a coda di rondice per Travi
|
|
|
|
-- Tabella per definizione modulo
|
|
local ProcessDtMortise = {}
|
|
|
|
-- Include
|
|
require( 'EgtBase')
|
|
|
|
EgtOutLog( ' ProcessDtMortise started', 1)
|
|
|
|
-- Dati
|
|
local BD = require( 'BeamData')
|
|
local ML = require( 'MachiningLib')
|
|
|
|
---------------------------------------------------------------------
|
|
-- Riconoscimento della feature
|
|
function ProcessDtMortise.Identify( Proc)
|
|
return ( (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 55) or
|
|
(( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 56))
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
-- Classificazione della feature
|
|
function ProcessDtMortise.Classify( Proc)
|
|
-- recupero i dati della curva di contorno della faccia di fondo
|
|
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i')
|
|
if not AuxId then return false end
|
|
AuxId = AuxId + Proc.Id
|
|
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
|
|
-- verifico se la mortasa è lavorabile solo da sotto
|
|
local bDown = ( vtExtr:getZ() < - 0.1)
|
|
return true, bDown
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
-- Applicazione della lavorazione
|
|
function ProcessDtMortise.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
|
|
-- recupero i dati della curva e del top
|
|
local dDepth = abs( EgtCurveThickness( AuxId))
|
|
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
|
|
-- verifico che la mortasa non sia orientata verso il basso (-5 deg)
|
|
if vtExtr:getZ() < - 0.1 then
|
|
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' DtMortise from bottom impossible'
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
-- recupero la lavorazione
|
|
local sMilling = ML.FindMilling( 'DtMortise')
|
|
if not sMilling then
|
|
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library'
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
-- recupero il diametro dell'utensile
|
|
local dToolDiam = 10
|
|
if EgtMdbSetCurrMachining( sMilling) then
|
|
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
|
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
|
|
dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dToolDiam
|
|
end
|
|
end
|
|
dToolDiam = max( dToolDiam, 10)
|
|
-- verifico se necessarie più passate (distanza all'imbocco ortogonale all'asse)
|
|
local vtDiff = EgtEP( AuxId, GDB_RT.GLOB) - EgtSP( AuxId, GDB_RT.GLOB)
|
|
local vtAx = EgtEV( AuxId, GDB_RT.GLOB) - EgtSV( AuxId, GDB_RT.GLOB)
|
|
vtAx:normalize()
|
|
local vtOrtDiff = vtDiff - vtDiff * vtAx * vtAx
|
|
local dDist = vtOrtDiff:len()
|
|
if dDist < dToolDiam + 0.5 then
|
|
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Dt mortise too narrow'
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
local nPass = ceil( dDist / ( 1.9 * dToolDiam))
|
|
local dStep = ( dDist - 0.95 * dToolDiam) / ( 2 * nPass)
|
|
for i = nPass, 1, -1 do
|
|
-- inserisco la lavorazione di contornatura
|
|
local sNameF = 'DtMt_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( nPass)
|
|
local nMchFId = EgtAddMachining( sNameF, sMilling)
|
|
if not nMchFId then
|
|
local sErr = 'Error adding machining ' .. sNameF .. '-' .. sMilling
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
-- imposto offset
|
|
local dOffs = ( i - 1) * dStep
|
|
EgtSetMachiningParam( MCH_MP.OFFSR, dOffs)
|
|
-- aggiungo geometria
|
|
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
|
-- eseguo
|
|
if not EgtApplyMachining( true, false) then
|
|
local _, sErr = EgtGetLastMachMgrError()
|
|
EgtSetOperationMode( nMchFId, false)
|
|
return false, sErr
|
|
end
|
|
end
|
|
return true
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
return ProcessDtMortise
|