DataBeam :
- primo rilascio.
This commit is contained in:
@@ -0,0 +1,243 @@
|
||||
-- ProcessProfConcave.lua by Egaltech s.r.l. 2019/04/01
|
||||
-- Gestione calcolo profilo caudato per Travi
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
local ProcessProfConcave = {}
|
||||
|
||||
-- Include
|
||||
require( 'EgtBase')
|
||||
local BL = require( 'BeamLib')
|
||||
local Cut = require( 'ProcessCut')
|
||||
|
||||
EgtOutLog( ' ProcessProfConcave started', 1)
|
||||
|
||||
-- Dati
|
||||
local BD = require( 'BeamData')
|
||||
local Millings = require( 'MillingData')
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Riconoscimento della feature
|
||||
function ProcessProfConcave.Identify( Proc)
|
||||
return (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 101)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function FindMilling( sType)
|
||||
for i = 1, #Millings do
|
||||
local Milling = Millings[i]
|
||||
if Milling.Type == sType then
|
||||
return i, Milling.Name
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function GetSawCutData( AuxId, vtN)
|
||||
-- comincio con la normale a 45deg
|
||||
local vtNP = Vector3d( vtN)
|
||||
for i = 1, 3 do
|
||||
if vtNP[i] > GEO.EPS_SMALL then
|
||||
vtNP[i] = 1
|
||||
elseif vtNP[i] < -GEO.EPS_SMALL then
|
||||
vtNP[i] = -1
|
||||
end
|
||||
end
|
||||
vtNP:normalize()
|
||||
-- assegno un punto di passaggio
|
||||
local ptStart = EgtMP( AuxId, GDB_ID.ROOT)
|
||||
local frOCS = Frame3d( ptStart, vtNP) ;
|
||||
local b3Box = EgtGetBBoxRef( AuxId, GDB_BB.STANDARD, frOCS)
|
||||
ptStart = ptStart + vtNP * ( b3Box:getDimZ() + 10.0)
|
||||
-- restituisco i dati del piano
|
||||
return ptStart, vtNP
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Applicazione della lavorazione
|
||||
function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH)
|
||||
-- ingombro del grezzo
|
||||
local b3Raw = EgtGetRawPartBBox( nRawId)
|
||||
-- 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) & GDB_FY.GEO_CURVE) == 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 profilo
|
||||
local dDepth = abs( EgtCurveThickness( AuxId))
|
||||
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
|
||||
local nFirstFacet = 0 -- faccia iniziale
|
||||
local nLastFacet = EgtSurfTmFacetCount( Proc.Id) - 1 -- faccia finale
|
||||
local nMidFacet = ( nLastFacet + 1) / 2 -- faccia a metà circa
|
||||
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nMidFacet, GDB_ID.ROOT)
|
||||
-- verifico se in testa o coda
|
||||
local bHead = ( vtN:getX() > 0)
|
||||
-- verifico se profilo orientato verso l'alto (1), il basso (-1) o di fianco (0)
|
||||
local nSide = 0
|
||||
if vtN:getZ() > 0.1 then
|
||||
nSide = 1
|
||||
elseif vtN:getZ() < -0.1 then
|
||||
nSide = -1
|
||||
end
|
||||
-- verifico se necessari ripassi agli estremi negli angoli
|
||||
local _, _, _, dFirstAng = EgtSurfTmFacetsContact( Proc.Id, nFirstFacet, nFirstFacet + 1, GDB_ID.ROOT)
|
||||
local bFirstTrim = ( dFirstAng and dFirstAng < -30)
|
||||
local _, _, _, dLastAng = EgtSurfTmFacetsContact( Proc.Id, nLastFacet, nLastFacet - 1, GDB_ID.ROOT)
|
||||
local bLastTrim = ( dLastAng and dLastAng < -30)
|
||||
-- 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
|
||||
-- aggiungo taglio di lama di sgrossatura e lo lavoro
|
||||
local ptStart, vtNP = GetSawCutData( AuxId, vtN)
|
||||
local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD)
|
||||
local AddId = EgtSurfTmPlaneInBBox( EgtGetParent( Proc.Id), ptStart, vtNP, b3Solid, GDB_RT.GLOB)
|
||||
if AddId then
|
||||
EgtRelocate( AddId, nAddGrpId)
|
||||
EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id))
|
||||
-- applico la lavorazione
|
||||
local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg}
|
||||
local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0)
|
||||
if not bOk then return bOk, sErr end
|
||||
end
|
||||
-- recupero la lavorazione
|
||||
local nMill, sMilling = FindMilling( 'Prof')
|
||||
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 = 'Prof_' .. ( 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
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
||||
-- se lavorazione da sopra
|
||||
if nSide == 1 then
|
||||
-- se lavorazione a destra di fronte o sinistra da dietro, inverto
|
||||
if ( vtN:getX() > 0 and vtExtr:getY() < -0.1) or
|
||||
( vtN:getX() < 0 and vtExtr:getY() > 0.1) then
|
||||
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
end
|
||||
-- altrimenti lavorazione dal davanti o dal dietro
|
||||
else
|
||||
-- se fresa verso il basso, la porto verso l'alto
|
||||
if vtExtr:getZ() < 0 then
|
||||
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
end
|
||||
-- se lavorazione a destra da dietro o sinistra di fronte, inverto
|
||||
if ( vtN:getX() > 0 and vtN:getY() > 0.1) or
|
||||
( vtN:getX() < 0 and vtN:getY() < -0.1) then
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, true)
|
||||
end
|
||||
end
|
||||
-- posizione braccio porta testa
|
||||
EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM))
|
||||
-- imposto parametri di attacco e uscita
|
||||
local bInvert = EgtGetMachiningParam( MCH_MP.INVERT)
|
||||
local dLiPerp = 0
|
||||
if ( not bInvert and not bFirstTrim) or ( bInvert and not bLastTrim) then dLiPerp = 5 end
|
||||
local dLoPerp = 0
|
||||
if ( not bInvert and not bLastTrim) or ( bInvert and not bFirstTrim) then dLoPerp = 5 end
|
||||
EgtSetMachiningParam( MCH_MP.LIPERP, dLiPerp)
|
||||
EgtSetMachiningParam( MCH_MP.LOPERP, dLoPerp)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchId, false)
|
||||
return false, sErr
|
||||
end
|
||||
-- eventuale finitura faccia finale (ortogonale alla trave)
|
||||
if nSide ~= -1 and bLastTrim then
|
||||
sName = 'ProfV_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMchVId = EgtAddMachining( sName, sMilling)
|
||||
if not nMchVId then
|
||||
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ Proc.Id, nLastFacet}})
|
||||
-- aggiusto i parametri
|
||||
if vtN:getZ() > 0.1 then
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_DOWN)
|
||||
elseif vtN:getY() > 0.1 then
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_FRONT)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_BACK)
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, false)
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH_STR, 'TH')
|
||||
EgtSetMachiningParam( MCH_MP.STEP, 0)
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, 0)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchVId, false)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
-- eventuale finitura faccia iniziale (parallela alla trave)
|
||||
if nSide ~= -1 and bFirstTrim then
|
||||
sName = 'ProfV2_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMchV2Id = EgtAddMachining( sName, sMilling)
|
||||
if not nMchV2Id then
|
||||
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- calcolo massima elevazione
|
||||
local _, _, _, _, _, _, dWidth = EgtSurfTmFacetOppositeSide( Proc.Id, 0, EgtIf( bHead, X_AX(), - X_AX()), GDB_ID.ROOT)
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ Proc.Id, nFirstFacet}})
|
||||
-- aggiusto i parametri
|
||||
if bHead then
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_LEFT)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.PARAL_RIGHT)
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, false)
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH_STR, 'TH')
|
||||
EgtSetMachiningParam( MCH_MP.STEP, 0)
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, 0)
|
||||
EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dWidth, 1))
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchV2Id, false)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
-- aggiorno ingombro testa o coda per presa
|
||||
if nSide ~= 1 then
|
||||
if bHead then
|
||||
BL.UpdateHCING( nRawId, b3Raw:getMax():getX() - dCurrOvmH - Proc.Box:getMin():getX())
|
||||
else
|
||||
BL.UpdateTCING( nRawId, Proc.Box:getMax():getX() - b3Raw:getMin():getX())
|
||||
end
|
||||
else
|
||||
if bHead then
|
||||
BL.UpdateHCING( nRawId, b3Raw:getMax():getX() - dCurrOvmH - Proc.Box:getMax():getX())
|
||||
else
|
||||
BL.UpdateTCING( nRawId, Proc.Box:getMin():getX() - b3Raw:getMin():getX())
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
return ProcessProfConcave
|
||||
Reference in New Issue
Block a user