e0d802d07d
- piccole modifiche ai fori per testa da sotto - correzione ai LapJoint per tagli con sega a catena passanti (variabili non inizializzate) - in forature corretta gestione Invert con testa da sotto e migliorato calcolo ingombro portautensile - in mortase a coda di rondine migliorata scelta lavorazione in presenza di testa da sotto - in lapjoint correzioni ribasso a U con testa da sotto - a FindMilling e FindPocketing aggiunto parametro opzionale dMaxTotLen - in LapJoint aggiunta gestione massima lunghezza fresa da sotto su svuotature.
131 lines
5.6 KiB
Lua
131 lines
5.6 KiB
Lua
-- MachiningLib.lua by Egaltech s.r.l. 2021/04/14
|
|
-- Libreria ricerca lavorazioni per Travi
|
|
|
|
-- Tabella per definizione modulo
|
|
local MachiningLib = {}
|
|
|
|
-- Include
|
|
require( 'EgtBase')
|
|
|
|
EgtOutLog( ' MachiningLib started', 1)
|
|
|
|
-- Dati
|
|
local BD = require( 'BeamData')
|
|
local Cuttings = require( 'CutData')
|
|
local Millings = require( 'MillingData')
|
|
local Pocketings = require( 'PocketingData')
|
|
local Sawings = require( 'SawingData')
|
|
local Drillings = require( 'DrillData')
|
|
|
|
---------------------------------------------------------------------
|
|
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 MachiningLib.FindCutting( sType)
|
|
for i = 1, #Cuttings do
|
|
local Cutting = Cuttings[i]
|
|
if Cutting.On and Cutting.Type == sType and SetCurrMachiningAndTool( Cutting.Name) then
|
|
return Cutting.Name
|
|
end
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function MachiningLib.FindMilling( sType, dDepth, sTuuidMstr, dMaxDiam, dMaxTotLen)
|
|
for i = 1, #Millings do
|
|
local Milling = Millings[i]
|
|
if Milling.On and Milling.Type == sType and SetCurrMachiningAndTool( Milling.Name) then
|
|
local sTuuid = EgtGetMachiningParam( MCH_MP.TUUID)
|
|
local dTMaxDepth = EgtTdbGetCurrToolMaxDepth()
|
|
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
|
|
local dTTotLen = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN)
|
|
if ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and
|
|
( not sTuuidMstr or sTuuidMstr == sTuuid) and
|
|
( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and
|
|
( not dMaxTotLen or dTTotLen < dMaxTotLen + GEO.EPS_SMALL) then
|
|
return Milling.Name, dTMaxDepth, dTDiam
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function MachiningLib.FindPocketing( sType, dMaxDiam, dDepth, dMaxTotLen)
|
|
for i = 1, #Pocketings do
|
|
local Pocketing = Pocketings[i]
|
|
if Pocketing.On and Pocketing.Type == sType and SetCurrMachiningAndTool( Pocketing.Name) then
|
|
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
|
|
local dTMaxDepth = EgtTdbGetCurrToolMaxDepth()
|
|
local dTTotLen = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN)
|
|
if ( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and
|
|
( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and
|
|
( not dMaxTotLen or dTTotLen < dMaxTotLen + GEO.EPS_SMALL) then
|
|
return Pocketing.Name, dTDiam, dTMaxDepth
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function MachiningLib.FindSawing( sType)
|
|
for i = 1, #Sawings do
|
|
local Sawing = Sawings[i]
|
|
if Sawing.On and Sawing.Type == sType and SetCurrMachiningAndTool( Sawing.Name) then
|
|
return Sawing.Name
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function MachiningLib.FindDrilling( dDiam, dDepth, bDown)
|
|
-- ricerca sulle forature, dal diametro maggiore al minore
|
|
local sDrType = 'Drill' .. EgtIf( bDown, '_H2', '')
|
|
for i = #Drillings, 1, -1 do
|
|
local Drilling = Drillings[i]
|
|
if Drilling.On and Drilling.Type == sDrType and SetCurrMachiningAndTool( Drilling.Name) then
|
|
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
|
|
local dTMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)
|
|
local dMaxToolLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN)
|
|
local dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
|
|
local dDiamTh = EgtTdbGetCurrToolThDiam()
|
|
local dLenTh = 72
|
|
if EgtTdbGetCurrToolThLength then dLenTh = EgtTdbGetCurrToolThLength() end
|
|
local dFreeLen = EgtTdbGetCurrToolParam( MCH_TP.LEN) - dLenTh - EgtMdbGetGeneralParam( MCH_GP.MAXDEPTHSAFE)
|
|
if dTDiam < dDiam + 10 * GEO.EPS_SMALL and dTDiam > dDiam - BD.DRILL_TOL - 10 * GEO.EPS_SMALL then
|
|
if not dDepth or dTMaxMat > dDepth - GEO.EPS_SMALL then
|
|
return Drilling.Name, Drilling.Type, dTMaxMat, dMaxToolLength, dToolDiam, dDiamTh, dFreeLen
|
|
end
|
|
end
|
|
end
|
|
end
|
|
-- ricerca sulle svuotature, dal diametro maggiore al minore
|
|
local sPkType = 'Pocket' .. EgtIf( bDown, '_H2', '')
|
|
for i = #Drillings, 1, -1 do
|
|
local Drilling = Drillings[i]
|
|
if Drilling.On and Drilling.Type == sPkType and SetCurrMachiningAndTool( Drilling.Name) then
|
|
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
|
|
local dTMaxDepth = EgtTdbGetCurrToolMaxDepth()
|
|
local dMaxToolLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN)
|
|
local dToolDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
|
|
local dDiamTh = EgtTdbGetCurrToolThDiam()
|
|
local dFreeLen = dTMaxDepth
|
|
if dTDiam < dDiam - 10 * GEO.EPS_SMALL then
|
|
if not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL then
|
|
return Drilling.Name, Drilling.Type, dTMaxDepth, dMaxToolLength, dToolDiam, dDiamTh, dFreeLen
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
return MachiningLib
|