199 lines
9.5 KiB
Lua
199 lines
9.5 KiB
Lua
-- MachiningLib.lua by Egaltech s.r.l. 2022/01/12
|
|
-- Libreria ricerca lavorazioni per Pareti
|
|
-- 2023/03/09 Piccola correzione alla SideDepth in FindMilling
|
|
-- In FindMilling aggiunta gestione spessore e massimo materiale nel caso di lam
|
|
-- 2023/05/25 Aggiunta funzione AddMachining che incapsula EgtAddMachining trascrivendo le priorità btl dalle feature alle lavorazioni.
|
|
-- 2023/06/07 Alla funzione AddMachining aggiunta la scrittura dell'info ISOUTLINE alle lavorazioni.
|
|
|
|
-- Tabella per definizione modulo
|
|
local WMachiningLib = {}
|
|
|
|
-- Include
|
|
require( 'EgtBase')
|
|
|
|
EgtOutLog( ' WMachiningLib started', 1)
|
|
|
|
-- Dati
|
|
local WD = require( 'WallData')
|
|
local Cuttings = require( 'CutData')
|
|
local Millings = require( 'MillingData')
|
|
local Pocketings = require( 'PocketingData')
|
|
local Sawings = require( 'SawingData')
|
|
local Drillings = require( 'DrillData')
|
|
local Surfacings
|
|
if EgtExistsFile( EgtGetCurrMachineDir() .. '\\Wall\\SurfacingData.lua') then
|
|
Surfacings = require( 'SurfacingData')
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
local function SetCurrMachiningAndTool( sMachName)
|
|
if not EgtMdbSetCurrMachining( sMachName) then return false end
|
|
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
|
local sTool = EgtTdbGetToolFromUUID( sTuuid)
|
|
if not sTool then return false end
|
|
if not EgtTdbSetCurrTool( sTool) then return false end
|
|
return EgtTdbGetCurrToolParam( MCH_TP.ACTIVE)
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function WMachiningLib.FindCutting( sType, dDepth, nTool_ID)
|
|
for i = 1, #Cuttings do
|
|
local Cutting = Cuttings[i]
|
|
if Cutting.On and Cutting.Type == sType and SetCurrMachiningAndTool( Cutting.Name) then
|
|
local nMchType = EgtMdbGetCurrMachiningParam( MCH_MP.TYPE)
|
|
local dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or 0
|
|
local dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or 0
|
|
local dSawMaxDepth = EgtTdbGetCurrToolMaxDepth() or 0
|
|
local nMyTool_ID = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i')
|
|
if nMchType == MCH_MY.SAWING and
|
|
( not dDepth or dSawMaxDepth > dDepth - 10 * GEO.EPS_SMALL) and
|
|
( not nTool_ID or nTool_ID == 0 or nTool_ID == nMyTool_ID) then
|
|
return Cutting.Name, dSawDiam, dSawThick, dSawMaxDepth
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function WMachiningLib.FindMilling( sType, dDepth, sTuuid, nTool_ID, dMaxDiam, dMaxMat, bTipFeed, dMinSideElev)
|
|
for i = 1, #Millings do
|
|
local Milling = Millings[i]
|
|
if Milling.On and Milling.Type == sType and SetCurrMachiningAndTool( Milling.Name) then
|
|
local bIsBlade = ( EgtTdbGetCurrToolParam( MCH_TP.TYPE) & MCH_TF.SAWBLADE ~= 0) or false
|
|
local nMchType = EgtMdbGetCurrMachiningParam( MCH_MP.TYPE)
|
|
local sMyTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
|
local dTMaxMat = EgtIf( bIsBlade, EgtTdbGetCurrToolParam( MCH_TP.THICK), EgtTdbGetCurrToolParam( MCH_TP.MAXMAT))
|
|
local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, dTMaxMat, EgtTdbGetCurrToolMaxDepth())
|
|
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
|
|
local dTDiamTh = EgtTdbGetCurrToolThDiam() or 0
|
|
local dTTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED)
|
|
local dTMaxDepthOnSide = EgtIf( bIsBlade, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiam - dTDiamTh)))
|
|
local nMyTool_ID = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i')
|
|
if nMchType == MCH_MY.MILLING and
|
|
( not sTuuid or sTuuid == sMyTuuid) and
|
|
( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and
|
|
( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and
|
|
( not dMaxMat or dTMaxMat < dMaxMat + GEO.EPS_SMALL) and
|
|
( not bTipFeed or dTTipFeed > 1) and
|
|
( not dMinSideElev or dTMaxDepthOnSide > dMinSideElev - GEO.EPS_SMALL) and
|
|
( not nTool_ID or nTool_ID == 0 or nTool_ID == nMyTool_ID) then
|
|
return Milling.Name, dTMaxDepth, dTMaxMat, dTDiam
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function WMachiningLib.FindNailing( nType)
|
|
for i = 1, #Millings do
|
|
local Milling = Millings[i]
|
|
if Milling.On and Milling.Type == 'Nailing' and SetCurrMachiningAndTool( Milling.Name) then
|
|
local nMchType = EgtMdbGetCurrMachiningParam( MCH_MP.TYPE)
|
|
local sTName = EgtTdbGetCurrToolParam( MCH_TP.NAME)
|
|
if nMchType == MCH_MY.MILLING and
|
|
sTName == tostring( nType) then
|
|
return Milling.Name
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID)
|
|
for i = 1, #Pocketings do
|
|
local Pocketing = Pocketings[i]
|
|
if Pocketing.On and Pocketing.Type == sType and SetCurrMachiningAndTool( Pocketing.Name) then
|
|
local nMchType = EgtMdbGetCurrMachiningParam( MCH_MP.TYPE)
|
|
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
|
|
local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), EgtTdbGetCurrToolMaxDepth())
|
|
local nMyTool_ID = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i')
|
|
if nMchType == MCH_MY.POCKETING and
|
|
( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and
|
|
( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and
|
|
( not nTool_ID or nTool_ID == 0 or nTool_ID == nMyTool_ID) then
|
|
return Pocketing.Name, dTDiam, dTMaxDepth
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function WMachiningLib.FindSawing( sType)
|
|
for i = 1, #Sawings do
|
|
local Sawing = Sawings[i]
|
|
if Sawing.On and Sawing.Type == sType and SetCurrMachiningAndTool( Sawing.Name) then
|
|
local nMchType = EgtMdbGetCurrMachiningParam( MCH_MP.TYPE)
|
|
if nMchType == MCH_MY.MORTISING then
|
|
return Sawing.Name
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function WMachiningLib.FindDrilling( dDiam, dDepth, sHead, bOnlyPockets)
|
|
if bOnlyPockets == nil or not bOnlyPockets then
|
|
-- ricerca sulle forature, dal diametro maggiore al minore
|
|
for i = #Drillings, 1, -1 do
|
|
local Drilling = Drillings[i]
|
|
if Drilling.On and Drilling.Type == 'Drill' and SetCurrMachiningAndTool( Drilling.Name) then
|
|
local nMchType = EgtMdbGetCurrMachiningParam( MCH_MP.TYPE)
|
|
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
|
|
local dTMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)
|
|
local sMyHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD)
|
|
if nMchType == MCH_MY.DRILLING and
|
|
dTDiam < dDiam + 10 * GEO.EPS_SMALL and dTDiam > dDiam - WD.DRILL_TOL - 10 * GEO.EPS_SMALL and
|
|
( not dDepth or dTMaxMat > dDepth - GEO.EPS_SMALL) and
|
|
(( not sHead and sMyHead ~= 'H5' and sMyHead ~= 'H6') or sHead == sMyHead) then
|
|
return Drilling.Name, Drilling.Type, dTMaxMat
|
|
end
|
|
end
|
|
end
|
|
end
|
|
-- ricerca sulle svuotature, dal diametro maggiore al minore
|
|
for i = #Drillings, 1, -1 do
|
|
local Drilling = Drillings[i]
|
|
if Drilling.On and Drilling.Type == 'Pocket' and SetCurrMachiningAndTool( Drilling.Name) then
|
|
local nMchType = EgtMdbGetCurrMachiningParam( MCH_MP.TYPE)
|
|
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
|
|
local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), EgtTdbGetCurrToolMaxDepth())
|
|
local sMyHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD)
|
|
if nMchType == MCH_MY.POCKETING and
|
|
dTDiam < dDiam - 10 * GEO.EPS_SMALL and
|
|
( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and
|
|
( ( not sHead and sMyHead ~= 'H5' and sMyHead ~= 'H6') or sHead == sMyHead) then
|
|
return Drilling.Name, Drilling.Type, dTMaxDepth
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function WMachiningLib.FindSurfacing( sType)
|
|
if not Surfacings then return end
|
|
for i = 1, #Surfacings do
|
|
local Surfacing = Surfacings[i]
|
|
if Surfacing.On and Surfacing.Type == sType and SetCurrMachiningAndTool( Surfacing.Name) then
|
|
local nMchType = EgtMdbGetCurrMachiningParam( MCH_MP.TYPE)
|
|
if nMchType == MCH_MY.SURFFINISHING then
|
|
return Surfacing.Name
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- incapsulo EgtAddMachining e trascrivo alcune informazioni utili nelle note dell'operazione
|
|
---------------------------------------------------------------------
|
|
function WMachiningLib.AddMachining( Proc, sName, sMachining)
|
|
local nMchId, sFinalName = EgtAddMachining( sName, sMachining)
|
|
if type(Proc) == 'table' then
|
|
local nPriority = EgtGetInfo( Proc.Id or GDB_ID.NULL, 'PRIORITY', 'i')
|
|
EgtSetInfo( nMchId or GDB_ID.NULL, 'PRIORITY', nPriority)
|
|
EgtSetInfo( nMchId or GDB_ID.NULL, 'ISOUTLINE', Proc.IsOutline)
|
|
end
|
|
return nMchId, sFinalName
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
return WMachiningLib
|