Files
DataBeam/LuaLibs/ProcessCut.lua
T
Dario Sassi 0d31c0bbd9 DataBeam :
- 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.
2019-11-13 07:34:51 +00:00

200 lines
7.5 KiB
Lua

-- ProcessCut.lua by Egaltech s.r.l. 2019/11/12
-- Gestione calcolo singoli tagli di lama per Travi
-- Tabella per definizione modulo
local ProcessCut = {}
-- Include
require( 'EgtBase')
local BL = require( 'BeamLib')
local DC = require( 'DiceCut')
EgtOutLog( ' ProcessCut started', 1)
-- Dati
local BD = require( 'BeamData')
local ML = require( 'MachiningLib')
---------------------------------------------------------------------
-- Riconoscimento della feature
function ProcessCut.Identify( Proc)
return ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 10)
end
---------------------------------------------------------------------
-- Classificazione della feature
function ProcessCut.Classify( Proc, b3Raw)
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
if vtN:getZ() <= - 0.5 and abs( vtN:getY()) > 0.1 then
local _, DimH, DimV = BL.GetFaceHvRefDim( Proc.Id, 0)
if DimH > BD.MAX_DIM_DICE then
return true, true
end
end
return true, false
end
---------------------------------------------------------------------
-- Applicazione della lavorazione
function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
-- ingombro del grezzo
local b3Raw = EgtGetRawPartBBox( nRawId)
-- ingombro del pezzo
local Ls = EgtGetFirstNameInGroup( nPartId, 'Box')
local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD)
if not b3Solid then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' part box not found'
EgtOutLog( sErr)
return false, sErr
end
local dNzLimDwnUp = EgtIf( b3Raw:getDimZ() < 300, -0.5, -0.258)
-- dati geometrici del taglio
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
local bDownCut = ( vtN:getZ() <= dNzLimDwnUp)
-- se taglio di testa
if Proc.Head then
-- se coincide con il taglio di separazione precedente, non va fatto
if AreSameVectorApprox( vtN, X_AX()) and abs( ptC:getX() - b3Raw:getMax():getX() + dOvmHead) < 10 * GEO.EPS_SMALL then
return true
end
-- altrimenti taglio di coda
else
-- se coincide con taglio di separazione, non va fatto
if AreSameVectorApprox( vtN, - X_AX()) and abs( ptC:getX() - b3Raw:getMin():getX()) < BD.OVM_MID + 10 * GEO.EPS_SMALL then
return true
end
end
-- recupero la lavorazione
local sCutting = ML.FindCutting( EgtIf( Proc.Head, 'HeadSide', 'TailSide'))
if not sCutting then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' cutting not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- recupero i dati dell'utensile
local dSawDiam = 400
local dMaxDepth = 0
if EgtMdbSetCurrMachining( sCutting) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
end
end
-- determino la direzione di taglio preferenziale
local _, dCutH, dCutV = BL.GetFaceHvRefDim( Proc.Id, 0)
local bHorizCut = (( dCutV < dMaxDepth + 10 * GEO.EPS_SMALL and dCutH > dCutV + 10 * GEO.EPS_SMALL) and not bDownCut)
-- verifico se necessari tagli supplementari
EgtOutLog( string.format( 'MaxDepth=%.1f CutH=%.1f CutV=%.1f', dMaxDepth, dCutH, dCutV), 3)
local vCuts = {}
if dCutH > dMaxDepth - 3 * BD.COLL_SIC or dCutV > dMaxDepth - 3 * BD.COLL_SIC then
vCuts = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC, vtN, true)
end
--DC.PrintOrderCut( vCuts)
if #vCuts > 0 then
-- recupero gruppo per geometria addizionale
local nAddGrpId = BL.GetAddGroup( nPartId)
if not nAddGrpId then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup'
EgtOutLog( sErr)
return false, sErr
end
-- sistemo posizione nel DB e nome
for i = 1, #vCuts do
for j = 1, #vCuts[i] do
EgtRelocateGlob( vCuts[i][j], nAddGrpId)
EgtSetName( vCuts[i][j], 'AddCut_' .. tostring( Proc.Id))
EgtSetInfo( vCuts[i][j], 'TASKID', Proc.TaskId)
end
end
-- eseguo
for i = 1, #vCuts do
-- determino il modo di tagliare
local vtOrthoO
if i % 2 == 1 then
vtOrthoO = Vector3d( vtN)
else
local vtO
for j = 1, #vCuts[i-1] do
_, vtO = EgtSurfTmFacetCenter( vCuts[i-1][j], 0, GDB_ID.ROOT)
break
end
if vtO then
vtOrthoO = Vector3d( vtO)
else
if bHorizCut then
vtOrthoO = Z_AX()
elseif vtN:getY() > -0.02 then
vtOrthoO = Y_AX()
else
vtOrthoO = -Y_AX()
end
end
end
-- lavoro la faccia
for j = 1, #vCuts[i] do
-- se taglio dal basso
if bDownCut then
-- se strato pari composto da 1 o 2 elementi
if i % 2 == 0 and #vCuts[i] <= 2 then
-- il primo elemento prende la direzione prevista, il secondo quella opposta
local vtNewOrthoO = Vector3d( vtOrthoO)
local dVzLimDwnUp = dNzLimDwnUp
if j ~= 1 then
vtNewOrthoO = -vtOrthoO
dVzLimDwnUp = -0.707
end
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, vtNewOrthoO, dVzLimDwnUp, 0.1, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then
return bOk, sErr
end
end
-- tutti gli altri casi vengono saltati
-- caso generale
else
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, vtOrthoO, dNzLimDwnUp, -0.1, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then
return bOk, sErr
end
end
end
end
-- altrimenti tagli diretti della faccia
else
-- lavoro la faccia
local vtOrthoO
if bHorizCut then
vtOrthoO = Z_AX()
elseif vtN:getY() > -0.02 then
vtOrthoO = Y_AX()
else
vtOrthoO = -Y_AX()
end
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, vtOrthoO, dNzLimDwnUp, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then
return bOk, sErr
end
end
-- eventuale segnalazione ingombro di testa o coda
local dMinHIng = min( 0.5 * BD.VICE_MINH, 0.5 * b3Raw:getDimZ())
if Proc.Box:getDimZ() > dMinHIng and Proc.Box:getMin():getZ() < b3Raw:getMin():getZ() + dMinHIng then
if Proc.Head then
local dOffs = b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX()
if abs( vtN:getZ()) > 0.5 then
dOffs = dOffs / 2
end
BL.UpdateHCING( nRawId, dOffs)
elseif Proc.Tail then
local dOffs = Proc.Box:getMax():getX() - b3Solid:getMin():getX()
if abs( vtN:getZ()) > 0.5 then
dOffs = dOffs / 2
end
BL.UpdateTCING( nRawId, dOffs)
end
end
return true
end
---------------------------------------------------------------------
return ProcessCut