DataWall :
- prima versione che inserisce alcune lavorazioni.
This commit is contained in:
@@ -0,0 +1,189 @@
|
||||
-- ProcessDrill.lua by Egaltech s.r.l. 2020/06/24
|
||||
-- Gestione calcolo forature per Pareti
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
local ProcessDrill = {}
|
||||
|
||||
-- Include
|
||||
require( 'EgtBase')
|
||||
|
||||
EgtOutLog( ' ProcessDrill started', 1)
|
||||
|
||||
-- Dati
|
||||
local WD = require( 'WallData')
|
||||
local ML = require( 'MachiningLib')
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Riconoscimento della feature
|
||||
function ProcessDrill.Identify( Proc)
|
||||
return ( ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 40)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Recupero dati foro e adattamento se speciale
|
||||
function ProcessDrill.GetData( Proc)
|
||||
-- verifico se foro da adattare
|
||||
if EgtExistsInfo( Proc.Id, 'DiamUser') then
|
||||
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i')
|
||||
if AuxId then AuxId = AuxId + Proc.Id end
|
||||
if AuxId and EgtGetType( AuxId) == GDB_TY.CRV_ARC and WD.USER_HOLE_DIAM and WD.USER_HOLE_DIAM > 1 then
|
||||
EgtModifyArcRadius( AuxId, WD.USER_HOLE_DIAM / 2)
|
||||
EgtSetInfo( Proc.Id, 'P12', WD.USER_HOLE_DIAM)
|
||||
end
|
||||
end
|
||||
-- recupero diametro
|
||||
local dDiam = EgtGetInfo( Proc.Id, 'P12', 'd') or 0
|
||||
-- recupero faccia di entrata e uscita
|
||||
local nFcs = EgtGetInfo( Proc.Id, 'FCS', 'i') or 0
|
||||
local nFce = EgtGetInfo( Proc.Id, 'FCE', 'i') or 0
|
||||
return dDiam, nFcs, nFce
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Classificazione della feature
|
||||
function ProcessDrill.Classify( Proc, b3Raw)
|
||||
-- recupero e verifico l'entità foro
|
||||
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0
|
||||
if AuxId then AuxId = AuxId + Proc.Id end
|
||||
if not AuxId or EgtGetType( AuxId) ~= GDB_TY.CRV_ARC then
|
||||
return false
|
||||
end
|
||||
-- recupero i dati del foro
|
||||
local dDiam = 2 * EgtArcRadius( AuxId)
|
||||
local dLen = abs( EgtCurveThickness( AuxId))
|
||||
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
|
||||
local ptCen = EgtCP( AuxId, GDB_RT.GLOB)
|
||||
-- verifico se troppo inclinato e quindi non lavorabile
|
||||
if not ( Proc.Fcs == 5 or Proc.Fcs == 6 or Proc.Fce == 5 or Proc.Fce == 6) and abs( vtExtr:getX()) > WD.DRILL_VX_MAX then
|
||||
return false
|
||||
end
|
||||
local bOpen = ( Proc.Fce ~= 0)
|
||||
local bFaceDown = ( ptCen:getZ() < b3Raw:getMin():getZ() + 2)
|
||||
-- verifico se il foro è sotto e quindi va spostato o sopra o sul fianco
|
||||
if (( vtExtr:getZ() < WD.DRILL_VZ_MIN or bFaceDown) and not bOpen) then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Applicazione della lavorazione
|
||||
function ProcessDrill.Make( Proc, nRawId, b3Raw)
|
||||
-- recupero e verifico l'entità foro
|
||||
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0
|
||||
if AuxId then AuxId = AuxId + Proc.Id end
|
||||
if not AuxId or EgtGetType( AuxId) ~= GDB_TY.CRV_ARC then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing drill geometry'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- recupero i dati del foro
|
||||
local dDiam = 2 * EgtArcRadius( AuxId)
|
||||
local dLen = abs( EgtCurveThickness( AuxId))
|
||||
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
|
||||
local bOpen = ( Proc.Fcs ~= 0 and Proc.Fce ~= 0)
|
||||
-- verifico che il foro non sia fattibile solo da sotto
|
||||
local bToInvert = ( vtExtr:getZ() < 0)
|
||||
if bToInvert and ( not bOpen or Proc.Flg ~= 1) then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' drilling from bottom impossible'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
if Proc.Fcs == 0 then bToInvert = true end
|
||||
if bToInvert then vtExtr = - vtExtr end
|
||||
-- recupero la lavorazione
|
||||
local sDrilling, nType = ML.FindDrilling( dDiam)
|
||||
if not sDrilling then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' drilling not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- recupero i dati dell'utensile
|
||||
local dMaxDepth = 20
|
||||
local dDiamTh = 35
|
||||
if EgtMdbSetCurrMachining( sDrilling) then
|
||||
local bIsDrilling = ( EgtMdbGetCurrMachiningParam( MCH_MP.TYPE) == MCH_MY.DRILLING)
|
||||
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
||||
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
|
||||
if bIsDrilling then
|
||||
dMaxDepth = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxDepth
|
||||
else
|
||||
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
|
||||
end
|
||||
dDiamTh = EgtTdbGetCurrToolThDiam()
|
||||
end
|
||||
end
|
||||
-- se foro intermedio e inclinato, limito il massimo affondamento
|
||||
if not ( ( Proc.Fcs == 5 or Proc.Fcs == 6) or ( bToInvert and ( Proc.Fce == 5 or Proc.Fce == 6))) then
|
||||
local CosB = abs( vtExtr:getX())
|
||||
if CosB < WD.DRILL_VX_MAX then
|
||||
local TgA = CosB / sqrt( 1 - CosB * CosB)
|
||||
dMaxDepth = dMaxDepth - dDiamTh / 2 * TgA
|
||||
else
|
||||
dMaxDepth = 0
|
||||
end
|
||||
end
|
||||
-- inserisco la lavorazione
|
||||
local sName = 'Drill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMchId = EgtAddMachining( sName, sDrilling)
|
||||
if not nMchId then
|
||||
local sErr = 'Error adding machining ' .. sName .. '-' .. sDrilling
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
||||
-- eventuale inversione
|
||||
if nType == 'Drill' then
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, bToInvert)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.TOOLINVERT, bToInvert)
|
||||
end
|
||||
-- imposto posizione braccio porta testa
|
||||
local nSCC = MCH_SCC.ADIR_YM
|
||||
if vtExtr:getY() > 100 * GEO.EPS_ZERO then
|
||||
nSCC = MCH_SCC.ADIR_YP
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
|
||||
-- aggiusto l'affondamento
|
||||
local sMyWarn
|
||||
local dDepth = dLen
|
||||
if dDepth > dMaxDepth + 10 * GEO.EPS_SMALL then
|
||||
sMyWarn = 'Warning in drill : depth (' .. EgtNumToString( dDepth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')'
|
||||
dDepth = dMaxDepth
|
||||
EgtOutLog( sMyWarn .. ' (process ' .. tostring( Proc.Id) .. ')')
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
|
||||
-- Note utente con dichiarazione nessuna generazione sfridi per Vmill
|
||||
local sUserNotes = 'VMRS=0;'
|
||||
-- se foratura
|
||||
if nType == 'Drill' then
|
||||
-- aggiungo alle note massima elevazione (coincide con affondamento)
|
||||
sUserNotes = sUserNotes .. 'MaxElev=' .. EgtNumToString( dDepth, 1) .. ';'
|
||||
-- se foro passante, aggiungo questa qualifica alle note
|
||||
if bOpen then
|
||||
sUserNotes = sUserNotes .. 'Open=1;'
|
||||
end
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchId, false)
|
||||
return false, sErr
|
||||
else
|
||||
local _, sWarn = EgtGetMachMgrWarning( 0)
|
||||
if EgtIsMachiningEmpty() then
|
||||
EgtSetOperationMode( nMchId, false)
|
||||
return false, sWarn
|
||||
else
|
||||
return true, ( sMyWarn or sWarn)
|
||||
end
|
||||
end
|
||||
|
||||
return true, sMyWarn
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
return ProcessDrill
|
||||
Reference in New Issue
Block a user