aba419a16e
- modifiche a Split per travi con sezioni molto grandi e materiale inferiore allo spessore lama - aggiunta possibilità di minima sicurezza su attacco da lato aperto per svuotatura.
108 lines
3.8 KiB
Lua
108 lines
3.8 KiB
Lua
-- FaceByPocket.lua by Egaltech s.r.l. 2023/04/04
|
|
-- Gestione svuotatura di feature con una faccia
|
|
|
|
-- Tabella per definizione modulo
|
|
local FaceByPocket = {}
|
|
|
|
-- Include
|
|
require( 'EgtBase')
|
|
local BL = require( 'BeamLib')
|
|
|
|
EgtOutLog( ' FaceByPocket started', 1)
|
|
|
|
-- Dati
|
|
local BD = require( 'BeamData')
|
|
local ML = require( 'MachiningLib')
|
|
|
|
---------------------------------------------------------------------
|
|
local function ApplyPocket( Proc, nSurfId, nFacet, sPocketing, nInd, dMaxElev, vtN, dOpenMinSafe)
|
|
|
|
-- inserisco la lavorazione di svuotatura
|
|
local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. nInd
|
|
local nMchFId = EgtAddMachining( sName, sPocketing)
|
|
if not nMchFId then
|
|
local sErr = 'Error adding machining ' .. sName .. '-' .. sPocketing
|
|
return false, sErr
|
|
end
|
|
-- aggiungo geometria
|
|
EgtSetMachiningGeometry( {{ nSurfId, nFacet}})
|
|
-- imposto uso faccia
|
|
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_CONT)
|
|
-- imposto note utente
|
|
local sNotes = ''
|
|
-- eventuale massima elevazione
|
|
if dMaxElev > 0.1 then
|
|
sNotes = EgtSetValInNotes( sNotes, 'MaxElev', EgtNumToString( dMaxElev, 2))
|
|
end
|
|
-- eventuale minima distanza di sicurezza di attacco su lati aperti
|
|
if dOpenMinSafe then
|
|
sNotes = EgtSetValInNotes( sNotes, 'OpenMinSafe', dOpenMinSafe)
|
|
end
|
|
EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes)
|
|
-- imposto posizione braccio porta testa
|
|
local nSCC = MCH_SCC.NONE
|
|
if not BD.C_SIMM and not BD.TURN then
|
|
nSCC = EgtIf( vtN:getX() < GEO.EPS_SMALL, MCH_SCC.ADIR_XM, MCH_SCC.ADIR_XP)
|
|
end
|
|
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
|
|
-- eseguo
|
|
if not ML.ApplyMachining( true, false) then
|
|
local _, sErr = EgtGetLastMachMgrError()
|
|
EgtSetOperationMode( nMchFId, false)
|
|
return false, sErr
|
|
end
|
|
|
|
return true
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function FaceByPocket.Make( Proc, nSurfId, nFacet, sPocketing, nPartId, b3Solid, dOpenMinSafe)
|
|
local bOk = true
|
|
local sErr
|
|
-- recupero gruppo per geometria addizionale
|
|
local nAddGrpId = BL.GetAddGroup( nPartId)
|
|
if not nAddGrpId then
|
|
local sErr = 'Error : missing AddGroup'
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
-- recupero i dati dell'utensile
|
|
local dStep = 30
|
|
local dMaxDepth = 100
|
|
if EgtMdbSetCurrMachining( sPocketing) then
|
|
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
|
dStep = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) or dStep
|
|
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
|
|
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
|
|
end
|
|
end
|
|
-- dati della faccia
|
|
local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, nFacet, GDB_ID.ROOT)
|
|
local dElev = BL.GetFaceElevation( nSurfId, nFacet, nPartId)
|
|
-- determino numero e valore degli step di lavorazione
|
|
local nSurfStep = ceil( dElev / dMaxDepth)
|
|
local dSurfStep = dElev / nSurfStep
|
|
-- copio superfice al passo superfice e vi applico la lavorazione
|
|
for i = nSurfStep, 2, -1 do
|
|
local ptOn = ptC + ( dSurfStep * ( i - 1)) * vtN
|
|
local nAddIdTmp = EgtSurfTmPlaneInBBox( nAddGrpId, ptOn, vtN, b3Solid, GDB_RT.GLOB)
|
|
if nAddIdTmp then
|
|
EgtSetName( nAddIdTmp, 'AddCut_' .. tostring( Proc.Id))
|
|
EgtSetInfo( nAddIdTmp, 'TASKID', Proc.TaskId)
|
|
-- aggiungo lavorazione
|
|
bOk, sErr = ApplyPocket( Proc, nAddIdTmp, 0, sPocketing, i, dSurfStep, vtN, dOpenMinSafe)
|
|
if not bOk then
|
|
return false, sErr
|
|
end
|
|
end
|
|
end
|
|
-- faccio ultima superfice
|
|
bOk, sErr = ApplyPocket( Proc, nSurfId, nFacet, sPocketing, 1, EgtIf( nSurfStep > 1, dSurfStep, 0), vtN, dOpenMinSafe)
|
|
if not bOk then
|
|
return false, sErr
|
|
end
|
|
return true
|
|
end
|
|
|
|
return FaceByPocket
|