Files
Dario Sassi cc55202ec5 DataDoors 2.7c1 :
- primo commit con versione corrente.
2025-03-18 17:02:20 +01:00

1590 lines
61 KiB
Lua

--
-- EEEEEEEEEE GGGGGG wwww wwww
-- EEEEEEEEEE GGGGGGGGGG wwww wwww
-- EEEE GGGG GGGG wwww wwww wwww
-- EEEE GGGG wwww wwww wwww
-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww
-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww
-- EEEE GGGG GGGG wwww wwwwwwww wwww
-- EEEE GGGG GGGG wwww wwww wwww wwww
-- EEEEEEEEEE GGGGGGGGGG wwwwwwww wwwwwwww
-- EEEEEEEEEE GGGGGG wwwwwww wwwwwww
--
-- EPT.lua by EgalWare s.r.l. 2017.03.13
-- Autore: Filippo Monchi
-- EPT
-- 2018.02.16 V1.018 FM Fix problem when both P3 and P4 have both extradeep value
-- 2018.04.05 V1.019 FM Manage info (KeepBackSet) for adjust probe on Z
-- 2018.10.17 V1.01a FM Add parameter to show into message 402
-- 2018.10.22 V1.01b FM Manage better the big radius fillet parameter
-- 2018.11.06 V1.01c FM Manage parameter posp to make probe point external to face
-- 2018.11.08 V1.01d FM Manage better insert probe point in case face or mortise are disabled (It checks also bores)
-- 2018.12.20 V1.01e FM Manage interax parameters for horizontal bored
-- 2019.10.02 V1.01f FM Manage steel option (disable to generate pocket paths, mortise and bores)
-- 2019.10.18 V2.000 FM Manage use Materials
-- 2019.10.28 V2.001 FM Add clean corner geometries
-- 2019.12.18 V2.002 FM Use new parameter DGC.Eah that allow insert template also on bullnose ans convex profiles
-- 2020.04.29 V2.003 FM Update for aluminum material
-- 2020.05.04 V2.004 FM Manage extra bores
-- 2020.05.25 V2.005 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side
-- 2020.06.18 V2.006 FM Manage better checking mortise dpeth with tool depth when parameter mfp is on or off
-- 2020.06.18 V2.006 FM fix wrong error message number (now 407 instead of 404)
-- 2020.07.01 V2.007 FM Disable Warning message on frames if parameter DGD.Spd is <= 0
-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false
-- 2021.01.25 V3.001 FM Fix error when variable posp is not defined (disabled from hardware manager)
-- 2021.03.12 V3.002 FM Manage rotation parameters on extra bores/buttonhole
-- 2021.03.12 V3.002 FM Add missing functions DrawLocAddLineDrawCircle and DrawLocAddCircleDrawCircle
-- 2021.11.24 V3.003 FM Manage side probe option if variable DGC.Pms > 2
-- 2022.07.27 V3.004 FM Modification to use compiled code
-- 2024.07.19 V3.005 FM Set note 'NotCheckDir' to pocketing and buttonhole pocketing
-- 2024.10.29 V3.006 FM Manage new DGC.Fpd CurrDoorCustomData variable to force shuttle probe geometry to stay horizontal
-- Tavola per definizione modulo (serve ma non usata)
local EPT = {}
-- Intestazioni
require( 'EgtBase')
EgtEnableDebug( false)
-- per messaggi
-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua')
EgtAddToPackagePath( DGD.BASEDIR .. '?.lua')
-- Valori limite
local DgMin = 4. -- valore minimo diametro utensile
local PtMin = 0.1
local PtMax = 1.0
local function DrawLocAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev,
nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2)
local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC)
if idTable then
table.insert( idTable, nLine)
end
if bPrev then
if bDrawFirst then
local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC)
EgtSetColor( nCircle1, cColor1)
end
if bDrawLast then
local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC)
EgtSetColor( nCircle2, cColor2)
end
end
return nLine
end
local function DrawLocAddCircleDrawCircle( pCenter, dRadius, dAngIni, dAngCen, nGroup, idTable, bPrev, nGroupCirc,
nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar)
local nCircle = EgtArc( nGroup, pCenter, dRadius, dAngIni, dAngCen, 0, GDB_RT.LOC)
local nNumCircle
if idTable then
table.insert( idTable, nCircle)
-- se devo inserire una variazione nell'entità
if sMVar then
nNumCircle = #idTable
end
end
if bPrev then
if bDrawFirst then
local nCircle1 = EgtCircle( nGroupCirc, EgtSP( nCircle), nRad , GDB_RT.LOC)
EgtSetColor( nCircle1, cColor1)
end
if bDrawLast then
local nCircle2 = EgtCircle( nGroupCirc, EgtEP( nCircle), nRad , GDB_RT.LOC)
EgtSetColor( nCircle2, cColor2)
end
end
return nCircle, nNumCircle, sMVar
end
local function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName)
local EgtDoorsMsg = require( 'EgtDoorsMsg')
local sMessage = ''
if dOriDiamTool then
if nErrorId == -1 then -- lavorazione non presente in tabella
sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool))
elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria
sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool))
elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione
sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool))
elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione
sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool))
elseif nErrorId == -5 then -- diametro utensile non trovato
sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool))
elseif nErrorId == -6 then -- nome geometria non presente in tabella
sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool))
elseif nErrorId == -7 then -- altezza massima utensile non trovata
sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool))
elseif nErrorId == -8 then -- tabella non presente nelle note
sMessage = string.format(EgtDoorsMsg[509], nIdLogErr)
end
elseif nErrorId == -1 then -- lavorazione non presente in tabella
sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName)
elseif nErrorId == -2 then -- errore nel settare la lavorazione
sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName)
elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione
sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName)
elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione
sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName)
elseif nErrorId == -5 then -- diametro utensile non trovato
sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName)
elseif nErrorId == -6 then -- nome geometria non presente in tabella
sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName)
elseif nErrorId == -7 then -- altezza massima utensile non trovata
sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName)
elseif nErrorId == -8 then -- tabella non presente nelle note
sMessage = string.format(EgtDoorsMsg[509], nIdLogErr)
end
return sMessage
end
-- Funzione creazione foro o asola o rampa per asola
local function MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10,
EBH10, EB10, PX10, Int10, D10,
dParH, PY10, T10, RP10, AR10,
RCI10, kbs, bEqualTh, HB10, dws,
pbs)
local pIni, pEnd, pCen
local hint3, hint5
local tPath = {}
local tPathPok = {}
if IY10 > 0 and EBH10 ~= '' then -- se parametri asola presenti
pIni = Point3d((PX10+Int10+(D10/2)),(dParH+PY10),0)
pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10-(IY10/2)),0)
DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED())
pIni = pEnd
pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+PY10-(IY10/2)),0)
pCen = Point3d((PX10+Int10),(dParH+PY10-(IY10/2)),0)
DrawLocAddCircleDrawCircle( pCen, (D10/2), 0,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED())
pIni = pEnd
pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+PY10+(IY10/2)),0)
DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED())
pIni = pEnd
pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10+(IY10/2)),0)
pCen = Point3d((PX10+Int10),(dParH+PY10+(IY10/2)),0)
DrawLocAddCircleDrawCircle( pCen, (D10/2), 180,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED())
pIni = pEnd
pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10),0)
DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED())
pIni = pEnd
hint3 = EgtCurveCompo( Lg, tPath, true)
EgtModifyCurveThickness( hint3, -T10)
-- se rotazione attiva
if AR10 ~= 0 then
-- rotazione in centro all'interasse
if RCI10 then
EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto
-- rotazione in centro all'asola
else
EgtRotate( hint3, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto
end
end
if nDrawMach > 0 and RP10 and RP10 > 0 and (RP10/2) < T10 then --se parametro step è valido, creao il percorso a zig-zag centrale
EgtSetName( hint3,'_'..EBH10) -- aggiungo _ per disabilitare lavorazione
local nStep = ceil(T10/RP10) -- numero di passate
local dStep = (T10/nStep) -- passo ricalcolato
local nPass = 1
local dZedStart = 0
local dZedWork
local nInv = 1
pIni = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedStart)
while nPass <= nStep do
dZedWork = dZedStart - (dStep/2)
nInv = -nInv
pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedWork)
DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED())
pIni = pEnd
dZedWork = dZedStart - dStep
nInv = -nInv
pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedWork)
DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED())
pIni = pEnd
-- se ho altri passi scendo in z
if nPass < nStep then
dZedStart = dZedWork
end
nPass = nPass + 1
end
-- faccio passata di ritorno
nInv = -nInv
pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),-T10)
DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED())
hint5 = EgtCurveCompo( Lg, tPathPok, true)
EgtModifyCurveThickness( hint5, 0)
EgtSetName( hint5, EBH10)
EgtSetInfo( hint5, 'NotCheckDir', '1')
-- se rotazione attiva
if AR10 ~= 0 then
-- rotazione in centro all'interasse
if RCI10 then
EgtRotate( hint5, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto
-- rotazione in centro all'asola
else
EgtRotate( hint5, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto
end
end
else
EgtSetName( hint3, EBH10)
end
elseif EB10 ~= '' then
hint3 = EgtCircle( Lg, Point3d((PX10+Int10),(dParH+PY10),0), D10/2 , GDB_RT.LOC)
EgtModifyCurveThickness( hint3, -T10)
EgtSetName( hint3, EB10)
-- se rotazione in centro all'interasse (sono questo caso perchè non ha senso ruotare un foro in centro a se stesso)
if AR10 ~= 0 and RCI10 then
EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto
end
end
-- se mantiene backset
if kbs and kbs > 0 then
EgtSetInfo( hint3, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
if hint5 then
EgtSetInfo( hint5, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
end
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( hint3, 'ProbeSide', '1')
if hint5 then
EgtSetInfo( hint5, 'ProbeSide', '1')
end
end
if HB10 then
EgtSetInfo( hint3, 'SideDoor', 'LockLH')
if hint5 then
EgtSetInfo( hint5, 'SideDoor', 'LockLH')
end
else
EgtSetInfo (hint3, 'SideDoor', 'SideLH')
if hint5 then
EgtSetInfo( hint5, 'SideDoor', 'SideLH')
end
end
if dws then
local nIdSideBoxUp = EgtCopyGlob( hint3, Lg)
EgtSetName( nIdSideBoxUp, 'upper')
EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper')
if hint5 then
nIdSideBoxUp = EgtCopyGlob( hint5, Lg)
EgtSetName( nIdSideBoxUp, 'upper')
EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper')
end
end
end
-- Funzione di sistemazione parametri
function EPT.AdjustParams( tMhPar)
local EgtDoorsMsg = require( 'EgtDoorsMsg')
local dMaxMat0
local dMaxMat1
local dMaxMat2
local dMaxMat3
local dMaxMat4
local dNumMessage
local dNumLog = 0
local sMessToOut = ''
local nTempT0
local nTempT1
local nTempT2
local nTempT3
local nTempT4
local sMchngName0
local sMchngName1
local sMchngName2
local sMchngName3
local sMchngName4
-- do errore se profilo diverso da SQ o BU o BD
-- do errore se profilo tipo bullnose e convesso e non è ammesso
if not DGC.Eah and ( DGD.tProfs.hingeedge.trimming == 'CV' or
DGD.tProfs.hingeedge.trimming == '1B' or DGD.tProfs.hingeedge.trimming == '2B' or
DGD.tProfs.hingeedge.trimming == '3B' or DGD.tProfs.hingeedge.trimming == '4B' or
DGD.tProfs.hingeedge.trimming == '5B' or DGD.tProfs.hingeedge.trimming == '6B' or
DGD.tProfs.hingeedge.trimming == '7B' or DGD.tProfs.hingeedge.trimming == '8B') then
return tMhPar, 1699, string.format(EgtDoorsMsg[589], tMhPar.Nome, DGD.tProfs.hingeedge.trimming)
end
-- parametro disposizione frame su lato wide (se = nil è sulla porta, se true dispsizione frame sul lato wide, se false dispsozione su lato narrow)
tMhPar.Dws = DGD.Dws
if tMhPar.Dws then -- se disposto sul lato wide, calcolo lo spessore relativo
if DGD.nTypePz == 3 or DGD.nTypePz == 4 then
tMhPar.dThD = DGD.dW
elseif DGD.nTypePz == 5 or DGD.nTypePz == 6 then
tMhPar.dThD = DGD.dH
end
end
-- se profilo bevel disabilito la giunzione tra face e mortise a meno del parametro di adattamento mortise
if DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BU' or
DGD.tProfs.hingeedge.trimming == 'BDEB' or DGD.tProfs.hingeedge.trimming == 'BUEB' then
-- se parametro non presente o false disattivo la giunzione
if not tMhPar.mfp then
tMhPar.jnb = false -- giunzione non possibile
else
tMhPar.jnb = true -- giunzione possibile
end
else
tMhPar.jnb = true -- giunzione possibile
end
local bLockOnRight = DGD.Lock == 'R'
if ( DGD.Lock == 'R' or not DGD.Push) and
( DGD.Lock == 'R' ~= not DGD.Push) then
if tMhPar.D_X then
tMhPar.D_X = -tMhPar.D_X
end
if tMhPar.DB_X then
tMhPar.DB_X = -tMhPar.DB_X
end
end
if tMhPar.D_Y then
tMhPar.D_Y = -tMhPar.D_Y
end
if tMhPar.DB_Y then
tMhPar.DB_Y = -tMhPar.DB_Y
end
-- se non ho il parametro D_XE lo setto a 0
if not tMhPar.D_XE then
tMhPar.D_XE = 0
end
-- se non esistono setto gli interassi a 0
if not tMhPar.IB3_X then
tMhPar.IB3_X = 0
end
if not tMhPar.IB4_X then
tMhPar.IB4_X = 0
end
-- setto il parametro a 0 in modo da non spostare la geometria come per le concealed hinges
tMhPar.D = 0
-- calcolo la posizione del centro foro sullo spessore porta
tMhPar.posh = DGD.FACETOCL - (DGD.dT/2)
-- se non ho il parametro lo setto disattivato
if not tMhPar.ech then
tMhPar.ech = false
end
-- se ho arrotondamento disabilito il chisel e il cleancorner
if tMhPar.CL then
tMhPar.ech = false
tMhPar.clc = nil
tMhPar.CLH = nil
end
if not tMhPar.rf then
tMhPar.rf = 0
if tMhPar.CL and tMhPar.H then
tMhPar.rf = tMhPar.H/2
end
end
-- se non c'è la variabile suffisso
if not tMhPar.CH then
tMhPar.CH = '_Chisel'
end
tMhPar.sopp = ( DGD.Lock == 'L' and DGD.Push) or ( DGD.Lock == 'R' and not DGD.Push)
if DGD.sFrame then -- se è un assemblato
-- leggo la nota con il tipo di pezzo
local nTypePiece = EgtGetInfo( DGD.PZ, 'Piece Type', 'i')
if nTypePiece == 4 or nTypePiece == 3 then
tMhPar.sopp = not tMhPar.sopp
end
end
-- se porta steel o aluminum disabilito la svuotatura, la mortasa e i fori e modifico il nome geometria
if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then
tMhPar.LM = nil
tMhPar.LA = nil
tMhPar.ech = false
tMhPar.CH = nil
tMhPar.est = true
tMhPar.d2 = nil
tMhPar.H3 = nil
tMhPar.H4 = nil
else
tMhPar.est = nil
end
-- Regola applicazione chiseling:
-- se ho impostato un raccordo, anche se poi viene annullato perché inferiore del raggio fresa
-- disabilito il chiseling perché se c'è un valore di raccordo non devo fare il chiseling
-- se ho il raggio valido disabilito il chiseling e,
-- se è attivo l'arrotondamento, anche il clean corner
if tMhPar.rf > 0 then
tMhPar.ech = false
if tMhPar.CL then
tMhPar.clc = nil
tMhPar.CLH = nil
end
end
-- Assegno parametri da dati utensili in macchina
local MB = require( 'MachiningBase')
local sLG
local nLGi = 1
local sLM
local nLMi = 1
local sLA
local nLAi = 1
local sLG3
local nLG3i = 1
local sLG4
local nLG4i = 1
-- se profilo cerniere bevel up
if DGD.tProfs.hingeedge.trimming == 'BU' or DGD.tProfs.hingeedge.trimming == 'BUEB' then
nLGi = 2
nLMi = 2
if tMhPar.mfp then
nLAi = 2
nLG3i = 2
nLG4i = 2
end
elseif DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BDEB' then -- se profilo cerniere bevel down
nLGi = 3
nLMi = 3
if tMhPar.mfp then
nLAi = 3
nLG3i = 3
nLG4i = 3
end
end
if tMhPar.est and tMhPar.LG then
sLG = tMhPar.LG
if DGD.MachEn > 0 and tMhPar.d then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end
end
if tMhPar.LM then
sLM = tMhPar.LM
if DGD.MachEn > 0 and tMhPar.d then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLM, nLMi) end
end
if tMhPar.LA then
sLA = tMhPar.LA
if DGD.MachEn > 0 and tMhPar.d2 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLA, nLAi) end
end
if tMhPar.LG3 then
sLG3 = tMhPar.LG3
if DGD.MachEn > 0 then nTempT3, dMaxMat3, sMchngName3 = MB.GetToolDataFromAttrib( sLG3, nLG3i) end
end
if tMhPar.LG4 then
sLG4 = tMhPar.LG4
if DGD.MachEn > 0 then nTempT4, dMaxMat4, sMchngName4 = MB.GetToolDataFromAttrib( sLG4, nLG4i) end
end
-- se devo disegnare le geometrie di lavorazione
if DGD.MachEn > 0 then
-- gestisco il risultato della lettura utensili
if DGD.bProoduce and tMhPar.est and tMhPar.d and nTempT0 <= 0 then
dNumLog = -1695
sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT0, sLG, nLGi, tMhPar.d, dNumLog, sMchngName0)
elseif tMhPar.est and nTempT0 then
tMhPar.d = nTempT0
end
--------------------------------------------------------------------------------
-- se c'è materiale steel faccio in modo che non assegni il diametro utensile
--------------------------------------------------------------------------------
-- gestisco il risultato della lettura utensili
if DGD.bProoduce and not tMhPar.est and tMhPar.d and nTempT1 and nTempT1 <= 0 then
dNumLog = -1695
sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName2)
elseif not tMhPar.est and nTempT1 then
tMhPar.d = nTempT1
end
if not tMhPar.est and tMhPar.d2 and nTempT2 and nTempT2 <= 0 then
if DGD.bProoduce and not tMhPar.jn then -- se non si concatenano i due percorsi
dNumLog = -1695
sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2)
end
elseif not tMhPar.est and nTempT2 then
tMhPar.d2 = nTempT2
end
-- se la profondità della face per steel è maggiore della capacità utensile limito la profondità ed emetto un warning
if tMhPar.est and tMhPar.T and dMaxMat0 and tMhPar.T > dMaxMat0 then
dNumLog = -1694
dNumMessage = 460
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat0))
tMhPar.T = dMaxMat0
end
-- se la profondità della face è maggiore della capacità utensile limito la profondità ed emetto un warning
if tMhPar.T and dMaxMat1 and tMhPar.T > dMaxMat1 then
dNumLog = -1698
dNumMessage = 460
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1))
tMhPar.T = dMaxMat1 - 0.02 -- tolgo 0.02 per permettere la lavorazione
end
-- se mortise concatenata a face e la profondità della mortise è maggiore della capacità utensile,
-- limito la profondità ed emetto un warning
if tMhPar.jn and tMhPar.jnb and tMhPar.T2 and dMaxMat1 and tMhPar.T2 > dMaxMat1 then
dNumLog = -1697
dNumMessage = 461
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat1))
tMhPar.T2 = dMaxMat1
end
-- se mortise non concatenata a face e la profondità della mortise è maggiore della capacità utensile,
-- limito la profondità ed emetto un warning
if ( not tMhPar.jn or not tMhPar.jnb) and tMhPar.T2 and dMaxMat2 and tMhPar.T2 > dMaxMat2 then
dNumLog = -1696
dNumMessage = 461
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat2))
tMhPar.T2 = dMaxMat2
end
-- se primo foro abilitato e profondità foro è maggiore della capacità utensile,
-- limito la profondità ed emetto un warning
if tMhPar.T3 and dMaxMat3 and tMhPar.T3 > dMaxMat3 then
dNumLog = -1693
dNumMessage = 463
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T3), EgtToUiUnits(dMaxMat3))
tMhPar.T3 = dMaxMat3
end
-- se secondo foro abilitato e profondità foro è maggiore della capacità utensile,
-- limito la profondità ed emetto un warning
if tMhPar.T4 and dMaxMat4 and tMhPar.T4 > dMaxMat4 then
dNumLog = -1692
dNumMessage = 463
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T4), EgtToUiUnits(dMaxMat4))
tMhPar.T4 = dMaxMat4
end
-- se ho altro materiale annullo i raccordi se sono più piccoli del raggio utensile
if tMhPar.est and tMhPar.rf and tMhPar.rf > 0 and tMhPar.CL and tMhPar.d and tMhPar.rf < ((tMhPar.d/2)+0.02) then
tMhPar.rf = 0
end
if tMhPar.CLH and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.H or tMhPar.clc >= tMhPar.L) then
tMhPar.clc = nil
elseif not tMhPar.CLH then
tMhPar.clc = nil
end
-- setto un valore di poco inferiore allo spessore per non fresare le ventose
local sPieceName
if tMhPar.Dws then
tMhPar.TTP = tMhPar.dThD - DGD.Spd
if DGD.nTypePz == 3 then sPieceName = 'left Jamb'
elseif DGD.nTypePz == 4 then sPieceName = 'right Jamb'
elseif DGD.nTypePz == 5 then sPieceName = 'Frame header'
else sPieceName = 'Threshold' end
end
-- controllo se le profondità delle geometrie non superano lo spessore frame
if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T and abs(tMhPar.T) > tMhPar.TTP then
dNumLog = -1691
dNumMessage = 681
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T', EgtToUiUnits(tMhPar.T), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD))
tMhPar.T = tMhPar.TTP
end
if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T2 and abs(tMhPar.T2) > tMhPar.TTP then
dNumLog = -1691
dNumMessage = 681
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T2', EgtToUiUnits(tMhPar.T2), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD))
tMhPar.T2 = tMhPar.TTP
end
if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T3 and abs(tMhPar.T3) > tMhPar.TTP then
dNumLog = -1691
dNumMessage = 681
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T3', EgtToUiUnits(tMhPar.T3), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD))
tMhPar.T3 = tMhPar.TTP
end
if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T4 and abs(tMhPar.T4) > tMhPar.TTP then
dNumLog = -1691
dNumMessage = 681
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T4', EgtToUiUnits(tMhPar.T4), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD))
tMhPar.T4 = tMhPar.TTP
end
end
-- se non ho parametro step o è 0 lo assegno uguale allo spessore cava
if tMhPar.T and ( not tMhPar.sf or abs(tMhPar.sf) < GEO.EPS_SMALL) then
tMhPar.sf = tMhPar.T
end
if dNumLog ~= 0 then
return tMhPar, dNumLog, sMessToOut
end
return tMhPar, 0, ''
end
-- Funzione di disegno
function EPT.Draw( tEpcParameter, bPreview, bRunByCompo, nDrawMach, dThickDoor)
-- setto un parametro atteso nel componente _latch
tEpcParameter.invG = 1
-- Assegno le dimensioni
local L = tEpcParameter.L
local H = tEpcParameter.H
local T = tEpcParameter.T
local D = tEpcParameter.D
local L2 = tEpcParameter.L2
local H2 = tEpcParameter.H2
local T2 = tEpcParameter.T2
local sf = tEpcParameter.sf
local rf = tEpcParameter.rf
local clc = tEpcParameter.clc
local ccr = tEpcParameter.ccr
local s = tEpcParameter.s
local d = tEpcParameter.d
local p = tEpcParameter.p
local jn = tEpcParameter.jn -- flag per giunzione prima cava face con seconda cava (mortasa)
local jnb = tEpcParameter.jnb -- flag che indica se profilo tipo bevel o no
local mfp = tEpcParameter.mfp -- flag che indica se la mortasa deve seguire il profilo
local d2 = tEpcParameter.d2
local p2 = tEpcParameter.p2
local CL = tEpcParameter.CL
local D_X = tEpcParameter.D_X -- delta on X pos on mortise
local D_Y = tEpcParameter.D_Y -- delta on X pos on mortise
local H3 = tEpcParameter.H3
local T3 = tEpcParameter.T3
local IB3_X = tEpcParameter.IB3_X
local H4 = tEpcParameter.H4
local T4 = tEpcParameter.T4
local IB4_X = tEpcParameter.IB4_X
local posh = tEpcParameter.posh -- posizione in Y del foro di tastatura
local posp = tEpcParameter.posp -- posizione in X del foro di tastatura
local DB_X = tEpcParameter.DB_X -- delta on X pos on bores
local DB_Y = tEpcParameter.DB_Y -- delta on Y pos on bores
local D_XE = tEpcParameter.D_XE -- Extra delta on X pos for all geometries
local invG = tEpcParameter.invG
local ech = tEpcParameter.ech
local est = tEpcParameter.est
local kbs = tEpcParameter.kbs -- keep backset/thickness (0: none, 1: only face, 2: all)
local pbs = tEpcParameter.pbs
local sopp = tEpcParameter.sopp
local dws = tEpcParameter.Dws
local dthd = tEpcParameter.dThD
local ttp = tEpcParameter.TTP
local tExtraBore = {}
table.insert( tExtraBore, { tEpcParameter.D5, tEpcParameter.T5, tEpcParameter.I5, tEpcParameter.PX5, tEpcParameter.PY5, tEpcParameter.EB5, tEpcParameter.HB5})
table.insert( tExtraBore, { tEpcParameter.D6, tEpcParameter.IY6, tEpcParameter.T6, tEpcParameter.I6, tEpcParameter.PX6, tEpcParameter.PY6, tEpcParameter.RP6, tEpcParameter.EB6, tEpcParameter.EBH6, tEpcParameter.HB6, tEpcParameter.AR6, tEpcParameter.RCI6})
table.insert( tExtraBore, { tEpcParameter.D7, tEpcParameter.IY7, tEpcParameter.T7, tEpcParameter.I7, tEpcParameter.PX7, tEpcParameter.PY7, tEpcParameter.RP7, tEpcParameter.EB7, tEpcParameter.EBH7, tEpcParameter.HB7, tEpcParameter.AR7, tEpcParameter.RCI7})
table.insert( tExtraBore, { tEpcParameter.D8, tEpcParameter.IY8, tEpcParameter.T8, tEpcParameter.I8, tEpcParameter.PX8, tEpcParameter.PY8, tEpcParameter.RP8, tEpcParameter.EB8, tEpcParameter.EBH8, tEpcParameter.HB8, tEpcParameter.AR8, tEpcParameter.RCI8})
-- Assegno i nomi dei layer
local LG = tEpcParameter.LG
local LM = tEpcParameter.LM
local LG2 = tEpcParameter.LG2
local LA = tEpcParameter.LA
local CLH = tEpcParameter.CLH
local LG3 = tEpcParameter.LG3
local LG4 = tEpcParameter.LG4
local CH = tEpcParameter.CH
local LH = 'Hinge_Probe'
local DM = 'DUMMY'
-- variabili per messaggi e settaggi vari
local sCompoName = tEpcParameter.Nome
local nCompoNpar = tEpcParameter.Npar
local sCompoPath = tEpcParameter.Path
-- eventuale messaggio errore rilevato nell'adjust
local nCodAdj = tEpcParameter.nCod
local sCodAdj = tEpcParameter.sCod
-- nomi parametri per messaggi
local sNamePar1 = tEpcParameter.N1 or 'L'
local sNamePar2 = tEpcParameter.N2 or 'H'
local sNamePar3 = tEpcParameter.N3 or 'T'
local sNamePar4 = tEpcParameter.N4 or 'D'
local sNamePar5 = tEpcParameter.N5 or 'L2'
local sNamePar6 = tEpcParameter.N6 or 'T2'
local sNamePar7 = tEpcParameter.N7 or 's'
local sNamePar8 = tEpcParameter.N8 or 'd'
local sNamePar9 = tEpcParameter.N9 or 'p'
local sNamePar11 = tEpcParameter.N11 or 'd2'
local sNamePar12 = tEpcParameter.N12 or 'sf'
local sNamePar13 = tEpcParameter.N13 or 'D_X'
local sNamePar14 = tEpcParameter.N14 or 'D_Y'
local sNamePar15 = tEpcParameter.N15 or 'H2'
local sNamePar16 = tEpcParameter.N16 or 'H3'
local sNamePar17 = tEpcParameter.N17 or 'T3'
local sNamePar18 = tEpcParameter.N18 or 'DB_X'
local sNamePar19 = tEpcParameter.N19 or 'DB_Y'
local sNamePar20 = tEpcParameter.N20 or 'H4'
local sNamePar21 = tEpcParameter.N21 or 'rf'
local sNamePar22 = tEpcParameter.N22 or 'p2'
local sNamePar23 = tEpcParameter.N23 or 'T4'
local sNamePar24 = tEpcParameter.N24 or 'clc'
local sNamePar25 = tEpcParameter.N25 or 'ccr'
-- RunByComponetInterface
local RC = true
-- Messaggi codice errori
local EM = ' '
local EC = 0
local ErrorBase = 1650
-- Variabili per risalita distaccata
local nDeltaMovX = 2
local nDeltaMovY = 2
-- variabili che abilitano la creazione della geometria
local bMakeFaceGeom = true
local bMakeMortGeom = true
-- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi
if not L or not H then
bMakeFaceGeom = false
jn = false -- disattivo il join tra face e mortasa
tEpcParameter.jn = false
clc = nil
CLH = nil
end
-- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili
if bMakeFaceGeom then
if L >= H then
if rf > (H/2) then
rf = (H/2)
tEpcParameter.rf = rf
end
else
if rf > (L/2) then
rf = (L/2)
tEpcParameter.rf = rf
end
end
end
if not bRunByCompo then RC = false end
if not T then T = 0 end
if not T2 then T2 = 0 end
if not T3 then T3 = 0 end
if not T4 then T4 = 0 end
-- se junzione impossibilitata disattivo il join tra face e mortasa
if not jnb then
jn = false
tEpcParameter.jn = false
end
if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione
nDrawMach = 0
end
local nForceMakeFace = nDrawMach
-- se ho abilitato il chiseling modifico il nome geometria
if ech then
LG = LG .. CH
tEpcParameter.LG = LG
if nDrawMach == 1 then -- se ho abilitato solo le geometrie di lavorazione
nForceMakeFace = 2
end
end
--------------------------------------------------------
-- set parametri attesi nel componente _latch o _mortise
-- o che potrebbero non esserci nei vecchi lua
--------------------------------------------------------
-- posizione in X mortasa dal centro face
if not D_X then
D_X = 0
tEpcParameter.D_X = 0
end
-- posizione in Y mortasa dal centro face
if not D_Y then
D_Y = 0
tEpcParameter.D_Y = 0
end
-- qui utilizzo un bool ma nel componente _latch uso un numero per definire l'arrotondamento
if bMakeFaceGeom and CL then
cl = 3 -- setto entrambe gli estremi raccordati
tEpcParameter.cl = 3
else
cl = 0 -- setto nessun estremo raccordato
tEpcParameter.cl = 0
end
-- altezza mortise, setto come altezza face per compatibilità con i vecchi lua
if not H2 then
H2 = H
tEpcParameter.H2 = H
end
if est or ( not L2 or not H2) then
bMakeMortGeom = false
-- disattivo il join
jn = false
tEpcParameter.jn = false
end
-- se prima e seconda cava giuntate assegno il diametro della seconda cava uguale alla prima
if jn and bMakeFaceGeom and bMakeMortGeom then
d2 = d
p2 = p
elseif not p2 and bMakeMortGeom then
p2 = p
end
-- posizione in X seconda mortise dal centro mortise
if ( H3 or H4) and not DB_X then
DB_X = 0
if bMakeMortGeom then
DB_X = D_X
end
tEpcParameter.DB_X = DB_X
end
-- posizione in Y seconda mortise dal centro mortise
if ( H3 or H4) and not DB_Y then
DB_Y = 0
if bMakeMortGeom then
DB_Y = D_Y
end
tEpcParameter.DB_Y = DB_Y
end
local EgtDoorsMsg = require( 'EgtDoorsMsg')
-- Verifica delle dimensioni, alcune condizioni vengono verificate solo se è abilitata la creazione dei percorsi di lavorazione
if bMakeFaceGeom and nDrawMach > 0 and d < DgMin then
EM = string.format(EgtDoorsMsg[400],sNamePar8,EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile 'd' deve essere >= di
EC = 1
d = DgMin
elseif bMakeMortGeom and nDrawMach > 0 and d2 < DgMin then
EM = string.format(EgtDoorsMsg[400],sNamePar11,EgtToUiUnits(d2),EgtToUiUnits(DgMin)) -- il diametro utensile 'd2' deve essere >= di
EC = 2
d2 = DgMin
elseif bMakeFaceGeom and nDrawMach > 0 and H < d then
if DGD.bProoduce then
EM = string.format(EgtDoorsMsg[405],sNamePar2,EgtToUiUnits(H),EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere >= del diametro utensile
EC = 3
H = d
else
d = H - 0.002
end
elseif bMakeMortGeom and nDrawMach > 0 and H2 < d2 then
if DGD.bProoduce then
EM = string.format(EgtDoorsMsg[405],sNamePar15,EgtToUiUnits(H2),EgtToUiUnits(d2), sCompoPath) -- il parametro 'H2' deve essere >= del diametro utensile
EC = 4
H2 = d2
else
d2 = H2 - 0.002
end
elseif bMakeFaceGeom and nDrawMach > 0 and L <= d then
if DGD.bProoduce then
EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar8,EgtToUiUnits(d), sCompoPath) -- il parametro 'L' deve essere maggiore al diametro utensile
EC = 5
L = d + 0.002
else
d = L - 0.002
end
elseif bMakeMortGeom and nDrawMach > 0 and L2 <= d2 then
if DGD.bProoduce then
EM = string.format(EgtDoorsMsg[402],sNamePar5,EgtToUiUnits(L2),sNamePar11,EgtToUiUnits(d2), sCompoPath) -- il parametro 'L2' deve essere maggiore al diametro utensile
EC = 6
L2 = d2 + 0.002
else
d2 = L2 - 0.002
end
elseif bMakeFaceGeom and nDrawMach > 0 and ( p < PtMin or p > PtMax) then
EM = string.format(EgtDoorsMsg[403],sNamePar9,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra
EC = 7
p = 0.8
elseif bMakeMortGeom and nDrawMach > 0 and p2 and ( p2 < PtMin or p2 > PtMax) then
EM = string.format(EgtDoorsMsg[403],sNamePar22,p2,PtMin,PtMax, sCompoPath) -- il parametro 'p2' deve essere compreso tra
EC = 8
p2 = 0.8
elseif bMakeFaceGeom and T < 0 then
EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0
EC = 9
T = 0
elseif bMakeMortGeom and T2 <= 0 then
EM = string.format(EgtDoorsMsg[401],sNamePar6,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T2' deve essere > 0
EC = 10
T2 = 0.1
elseif H3 and T3 < 0 then
EM = string.format(EgtDoorsMsg[404],sNamePar17,EgtToUiUnits(T3), sCompoPath) -- il parametro 'T3' deve essere >= 0
EC = 11
T3 = 0
elseif H4 and T4 < 0 then
EM = string.format(EgtDoorsMsg[404],sNamePar23,EgtToUiUnits(T4), sCompoPath) -- il parametro 'T4' deve essere >= 0
EC = 12
T4 = 0
elseif D < 0 then
EM = string.format(EgtDoorsMsg[404],sNamePar4,EgtToUiUnits(D), sCompoPath) -- il parametro 'D' deve essere >= 0
EC = 13
D = 0
elseif bMakeFaceGeom and bMakeMortGeom and L2 >= L then
EM = string.format(EgtDoorsMsg[406],sNamePar5,EgtToUiUnits(L2),sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L2' deve essere < 'L'
EC = 14
L2 = L - 0.1
elseif bMakeFaceGeom and bMakeMortGeom and not dws and T2 < T then
EM = string.format(EgtDoorsMsg[407],sNamePar6,EgtToUiUnits(T2),sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T2' deve essere > 'T'
EC = 15
T2 = T + 0.1
elseif bMakeMortGeom and H3 and not dws and T3 < T2 then
EM = string.format(EgtDoorsMsg[407],sNamePar17,EgtToUiUnits(T3),sNamePar6,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T3' deve essere > 'T2'
EC = 16
T3 = T2 + 0.1
elseif H3 and H4 and not dws and T4 < T3 then
EM = string.format(EgtDoorsMsg[407],sNamePar23,EgtToUiUnits(T4),sNamePar17,EgtToUiUnits(T3), sCompoPath) -- il parametro 'T4' deve essere > 'T3'
EC = 17
T4 = T3 + 0.1
elseif bMakeFaceGeom and nDrawMach > 0 and sf and sf <= 0 then
EM = string.format(EgtDoorsMsg[401],sNamePar12,EgtToUiUnits(sf), sCompoPath) -- il parametro 'sf' deve essere > 0
EC = 18
sf = d
elseif bMakeMortGeom and nDrawMach > 0 and s and s <= 0 then
EM = string.format(EgtDoorsMsg[401],sNamePar7,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0
EC = 19
s = d2
elseif bMakeFaceGeom and CL and rf < 0 then
EM = string.format(EgtDoorsMsg[404],sNamePar21,EgtToUiUnits(rf), sCompoPath) -- il parametro 'rf' deve essere >= 0
EC = 20
rf = H/2
elseif bMakeFaceGeom and CL and abs(rf - (H/2)) < GEO.EPS_SMALL and L <= H then
EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'L' deve essere > 'H'
EC = 21
L = H+5
elseif bMakeFaceGeom and CL and rf < (H/2) and L <= (rf*2) then
EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar21..'*2',EgtToUiUnits(rf)*2, sCompoPath) -- il parametro 'L' deve essere > 'rf*2'
EC = 22
L = (rf*2)+5
elseif bMakeFaceGeom and bMakeMortGeom and L < (L2+(2*abs(D_X))) then
EM = string.format(EgtDoorsMsg[423],sNamePar13,EgtToUiUnits(D_X),EgtToUiUnits((L-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore:
EC = 23
D_X = 0
elseif bMakeFaceGeom and bMakeMortGeom and H2 > H then
EM = string.format(EgtDoorsMsg[422],sNamePar2,EgtToUiUnits(H),sNamePar15,EgtToUiUnits(H2), sCompoPath) -- il parametro 'H' deve essere >= del parametro 'H2'
EC = 24
H2 = H
elseif bMakeMortGeom and H3 and H3 > H2 then
EM = string.format(EgtDoorsMsg[422],sNamePar15,EgtToUiUnits(H2),sNamePar16,EgtToUiUnits(H3), sCompoPath) -- il parametro 'H2' deve essere >= del parametro 'H3'
EC = 25
H3 = H2
elseif H3 and H4 and H4 > H3 then
EM = string.format(EgtDoorsMsg[422],sNamePar16,EgtToUiUnits(H3),sNamePar20,EgtToUiUnits(H4), sCompoPath) -- il parametro 'H3' deve essere >= del parametro 'H4'
EC = 26
H4 = H3
elseif bMakeMortGeom and nDrawMach > 0 and jn and H < (H2+abs(2*D_Y)) then
EM = string.format(EgtDoorsMsg[423],sNamePar14,EgtToUiUnits(abs(D_Y)),EgtToUiUnits((H-H2)/2), sCompoPath) -- il parametro 'D_Y' é troppo grande, max valore:
EC = 27
D_Y = 0
elseif bMakeFaceGeom and H3 and H3 > H then
EM = string.format(EgtDoorsMsg[422],sNamePar2,EgtToUiUnits(H),sNamePar16,EgtToUiUnits(H3), sCompoPath) -- il parametro 'H' deve essere >= del parametro 'H3'
EC = 28
H3 = H
elseif bMakeFaceGeom and CLH and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then
EC = 29
EM = string.format(EgtDoorsMsg[407],sNamePar24,EgtToUiUnits(clc),'',EgtToUiUnits(2*(ccr*sin(45))), sCompoPath) -- il parametro 'clc' deve essere > 'crc'
clc = (2*(ccr*sin(45)))+0.2
end
if not bPreview and EC ~= 0 then
return (ErrorBase+EC), EM
end
-- Se Preview cancello tutto
if bPreview then
EgtNewFile()
EgtSetDefaultMaterial( BLACK())
end
-- Pezzo e Layer
local Pz
if bPreview then
Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo
else
if not RC then
Pz = EgtGetCurrPart() -- pezzo corrente
end
if not Pz then
Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo
end
end
-- variabili dei percorsi geometrici
local nGeom1, nGeom2, nGeom3, nGeom4, nGeom31, nGeom41, nAS1, nAS2
local nPkToJoin1, nPkToJoin2, nPkToJoin
local nPkJoin1
local Lg, Dm
local sRequireCompoName
Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale
EgtSetName(Lg,sCompoName)
if nDrawMach > 0 then -- se abilitata geometria lavorazione
Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante il diametro utensile
EgtSetName( Dm, DM)
end
tEpcParameter.Dws = nil -- disabilito per non creare geometrie (doppie) inerenti il calcolo regioni nei componenti chiamati
sRequireCompoName = '_Latch'
if bMakeFaceGeom then
-- lancio il primo componente base
MHgen = require( sRequireCompoName)
nGeom1, nPkToJoin1, nAS1, nAS2 = MHgen.Draw( EC, EM, tEpcParameter, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor)
-- setto le note che indicano su che lato della porta devono essere messe le geometrie
if nGeom1 then EgtSetInfo(nGeom1,'SideDoor','SideLH') end
if nPkToJoin1 then EgtSetInfo(nPkToJoin1,'SideDoor','SideLH') end
-- Clean corner
if nDrawMach >= 0 then -- se abilitata geometria
if CLH and clc and clc > 0 and clc < H and clc < L then
local CLC1 = MakeClcPath( clc, ccr, CLH, Lg, -T)
if CLC1 then
-- se mantiene backset
if kbs and kbs > 0 then
EgtSetInfo( CLC1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( CLC1, 'ProbeSide', '1')
end
if mfp then
EgtSetInfo( CLC1,'SideDoor','SideLH')
else
EgtSetInfo( CLC1,'SideDoor','LockLH')
end
-- angolo x+y+
local CLC2 = EgtCopyGlob( CLC1, Lg)
EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90)
EgtMove( CLC2, Point3d((L/2),(H/2),0) - ORIG())
-- angolo x+y-
local CLC3 = EgtCopyGlob( CLC1, Lg)
EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180)
EgtMove( CLC3, Point3d((L/2),-(H/2),0) - ORIG())
-- angolo x-y-
local CLC4 = EgtCopyGlob( CLC1, Lg)
EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90)
EgtMove( CLC4, Point3d(-(L/2),-(H/2),0) - ORIG())
-- angolo x-y+
EgtMove( CLC1, Point3d(-(L/2),(H/2),0) - ORIG())
end
end
end
else
-- disattivo il join dei percorsi
jn = false
end
if bMakeMortGeom then
-- cava mortasa
local dMortise = {}
-- assegno i valori coerenti con la tabella del componente
dMortise.T = T
dMortise.L2 = L2
dMortise.H2 = H2
dMortise.T2 = T2
dMortise.s = s
dMortise.d = d2
dMortise.p = p2
dMortise.jn = jn
dMortise.d3 = d2
dMortise.p3 = p2
dMortise.invG = invG
dMortise.mkrev = false -- disabilito la creazione del percorso in senso contrario
dMortise.L3 = L2
dMortise.H3 = H2
dMortise.LGM = LG2
dMortise.LMM = LA
dMortise.Nome = sCompoName
dMortise.jne = false
dMortise.D_X = D_X
dMortise.mfp = mfp
-- lancio il secondo componente base
MHgen = require('_Mortise')
nGeom2, nPkToJoin2 = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor)
-- setto le note che indicano su che lato della porta devono essere messe le geometrie
if nGeom2 then
if mfp then
EgtSetInfo(nGeom2,'SideDoor','SideLH')
else
EgtSetInfo(nGeom2,'SideDoor','LockLH')
end
end
if nPkToJoin2 then
if mfp then
EgtSetInfo(nPkToJoin2,'SideDoor','SideLH')
else
EgtSetInfo(nPkToJoin2,'SideDoor','LockLH')
end
end
end
if EC == 0 and ( nGeom2 or nPkToJoin2) then
if D_X ~= 0 or D_Y ~= 0 then
if nGeom2 then
EgtMove( nGeom2, Point3d(D_X,D_Y,0) - ORIG())
end
if nPkToJoin2 then
EgtMove( nPkToJoin2, Point3d(D_X,D_Y,0) - ORIG())
end
end
end
if H3 then
if abs(IB3_X) <= H3 then -- se interasse minore del diametro lo setto a 0
IB3_X = 0
end
nGeom3 = EgtCircle( Lg, Point3d(-(IB3_X/2),0,0), H3/2 , GDB_RT.LOC)
EgtModifyCurveThickness( nGeom3, -T3)
EgtSetName( nGeom3, LG3)
-- se interasse maggiore del diametro creo secondo foro
if abs(IB3_X) > H3 then
nGeom31 = EgtCircle( Lg, Point3d((IB3_X/2),0,0), H3/2 , GDB_RT.LOC)
EgtModifyCurveThickness( nGeom31, -T3)
EgtSetName( nGeom31, LG3)
end
end
-- se foro fatto correttamente lo posiziono
if EC == 0 and ( nGeom3 or nGeom31) then
if nGeom3 then
if mfp then
EgtSetInfo(nGeom3,'SideDoor','SideLH')
else
EgtSetInfo(nGeom3,'SideDoor','LockLH')
end
if DB_X ~= 0 or DB_Y ~= 0 then
EgtMove( nGeom3, Point3d(DB_X,DB_Y,0) - ORIG())
end
-- se mantiene backset su mortise
if kbs and kbs > 0 then
EgtSetInfo( nGeom3, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( nGeom3, 'ProbeSide', '1')
end
end
if nGeom31 then
if mfp then
EgtSetInfo(nGeom31,'SideDoor','SideLH')
else
EgtSetInfo(nGeom31,'SideDoor','LockLH')
end
if DB_X ~= 0 or DB_Y ~= 0 then
EgtMove( nGeom31, Point3d(DB_X,DB_Y,0) - ORIG())
end
-- se mantiene backset su mortise
if kbs and kbs > 0 then
EgtSetInfo( nGeom31, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( nGeom31, 'ProbeSide', '1')
end
end
end
if H4 then
if abs(IB4_X) <= H4 then -- se interasse minore del diametro lo setto a 0
IB4_X = 0
end
nGeom4 = EgtCircle( Lg, Point3d(-(IB4_X/2),0,0), H4/2 , GDB_RT.LOC)
EgtModifyCurveThickness( nGeom4, -T4)
EgtSetName( nGeom4, LG4)
-- se interasse maggiore del diametro creao secondo foro
if abs(IB4_X) > H4 then
nGeom41 = EgtCircle( Lg, Point3d((IB4_X/2),0,0), H4/2 , GDB_RT.LOC)
EgtModifyCurveThickness( nGeom41, -T4)
EgtSetName( nGeom41, LG4)
end
end
-- se foro fatto correttamente lo posiziono
if EC == 0 and ( nGeom4 or nGeom41) then
if nGeom4 then
if mfp then
EgtSetInfo(nGeom4,'SideDoor','SideLH')
else
EgtSetInfo(nGeom4,'SideDoor','LockLH')
end
if DB_X ~= 0 or DB_Y ~= 0 then
EgtMove( nGeom4, Point3d(DB_X,DB_Y,0) - ORIG())
end
-- se mantiene backset su mortise
if kbs and kbs > 0 then
EgtSetInfo( nGeom4, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( nGeom4, 'ProbeSide', '1')
end
end
if nGeom41 then
if mfp then
EgtSetInfo(nGeom41,'SideDoor','SideLH')
else
EgtSetInfo(nGeom41,'SideDoor','LockLH')
end
if DB_X ~= 0 or DB_Y ~= 0 then
EgtMove( nGeom41, Point3d(DB_X,DB_Y,0) - ORIG())
end
-- se mantiene backset su mortise
if kbs and kbs > 0 then
EgtSetInfo( nGeom41, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( nGeom41, 'ProbeSide', '1')
end
end
end
-- se percorsi fatti con lo stesso utensile, li concateno
if jn and EC == 0 and nDrawMach > 0 and nPkToJoin1 and nPkToJoin2 then
nPkToJoin = EgtCurveCompo( Lg, {nPkToJoin1,nPkToJoin2}, true)
if nPkToJoin then
EgtSetName( nPkToJoin, LM)
EgtSetInfo( nPkToJoin, 'SideDoor', 'SideLH')
EgtSetInfo( nPkToJoin, 'NotCheckDir', '1')
-- se mantiene backset anche su face
if kbs and kbs > 0 then
EgtSetInfo( nPkToJoin, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
EgtSetInfo( nGeom1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
EgtSetInfo( nGeom2, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( nPkToJoin, 'ProbeSide', '1')
EgtSetInfo( nGeom1, 'ProbeSide', '1')
EgtSetInfo( nGeom2, 'ProbeSide', '1')
end
else
EC = ErrorBase + 34
EM = string.format(EgtDoorsMsg[426], sCompoPath)
end
elseif not jn and EC == 0 and nDrawMach > 0 then -- altrimenti se non devo concatenare
-- se mantiene backset su face
if kbs and kbs > 0 and nPkToJoin1 then
EgtSetInfo( nPkToJoin1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
EgtSetInfo( nGeom1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
-- se mantiene backset su face e mortise
elseif kbs and kbs > 0 then
if nPkToJoin1 then
EgtSetInfo( nPkToJoin1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
EgtSetInfo( nGeom1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
end
if nPkToJoin2 then
EgtSetInfo( nPkToJoin2, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
EgtSetInfo( nGeom2, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide
end
end
if pbs and pbs > 0 and nPkToJoin1 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( nPkToJoin1, 'ProbeSide', '1')
EgtSetInfo( nGeom1, 'ProbeSide', '1')
elseif pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
if nPkToJoin1 then
EgtSetInfo( nPkToJoin1, 'ProbeSide', '1')
EgtSetInfo( nGeom1, 'ProbeSide', '1')
end
if nPkToJoin2 then
EgtSetInfo( nPkToJoin2, 'ProbeSide', '1')
EgtSetInfo( nGeom2, 'ProbeSide', '1')
end
end
end
-- aggiungo fori extra
if EC == 0 and nDrawMach >= 0 then
-- fori ( viti o passaggio filo elettrico)
for k = 1, 4 do
local D10
local IY10
local T10
local I10
local PX10
local PY10
local RP10
local EB10
local EBH10
local HB10
local AR10
local RCI10
if k == 1 then
D10 = tExtraBore[k][1]
T10 = tExtraBore[k][2]
I10 = tExtraBore[k][3]
PX10 = tExtraBore[k][4]
PY10 = tExtraBore[k][5]
EB10 = tExtraBore[k][6]
HB10 = tExtraBore[k][7]
else
D10 = tExtraBore[k][1]
IY10 = tExtraBore[k][2]
T10 = tExtraBore[k][3]
I10 = tExtraBore[k][4]
PX10 = tExtraBore[k][5]
PY10 = tExtraBore[k][6]
RP10 = tExtraBore[k][7]
EB10 = tExtraBore[k][8]
EBH10 = tExtraBore[k][9]
HB10 = tExtraBore[k][10]
AR10 = tExtraBore[k][11]
RCI10 = tExtraBore[k][12]
end
if dws and T10 and abs(T10) > ttp then
T10 = ttp
end
if D10 and T10 and ( EB10 or EBH10) then
if D10 > 0 and T10 ~= 0 and ( EB10 ~= '' or EBH10 ~= '') then
if not IY10 then IY10 = 0 end
if not I10 then I10 = 0 end
if not PX10 then PX10 = 0 end
if not PY10 then PY10 = 0 end
if not AR10 then AR10 = 0 end
local dInt10 = (I10/2)
local dPosX10 = PX10 * EgtIf( sopp, 1, -1)
if abs(AR10) >= 360 then
while abs(AR10) >= 360 do
AR10 = AR10 + EgtIf( AR10 > 0, -360, 360)
end
end
-- creo foro o asola con eventuale svuotatura a rampa
MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, dInt10, D10, 0, -PY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, pbs)
-- se l'interasse è valido
if abs(I10) > GEO.EPS_SMALL then
-- creo foro o asola con eventuale svuotatura a rampa
MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, -dInt10, D10, 0, -PY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, pbs)
end
end
end
end
end
if EC == 0 and nDrawMach > 0 then
if dws then -- se frame viene disposto sul lato wide
local nIdSideBoxUp
if nGeom1 then
nIdSideBoxUp = EgtCopyGlob( nGeom1, Lg)
EgtSetName( nIdSideBoxUp, 'upper')
EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper')
end
if nGeom2 then
nIdSideBoxUp = EgtCopyGlob( nGeom2, Lg)
EgtSetName( nIdSideBoxUp, 'upper')
EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper')
end
if nGeom3 then
nIdSideBoxUp = EgtCopyGlob( nGeom3, Lg)
EgtSetName( nIdSideBoxUp, 'upper')
EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper')
end
if nGeom31 then
nIdSideBoxUp = EgtCopyGlob( nGeom31, Lg)
EgtSetName( nIdSideBoxUp, 'upper')
EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper')
end
if nGeom4 then
nIdSideBoxUp = EgtCopyGlob( nGeom4, Lg)
EgtSetName( nIdSideBoxUp, 'upper')
EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper')
end
if nGeom41 then
nIdSideBoxUp = EgtCopyGlob( nGeom41, Lg)
EgtSetName( nIdSideBoxUp, 'upper')
EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper')
end
end
end
-- aggiungo foro probe
if EC == 0 and nDrawMach > 0 and posh then
local dPosProbe = 0
local sPositiveSuffixProbe = ''
local sNegativeSuffixProbe = ''
local dHalfGeom = 0
if bMakeFaceGeom and L then
dHalfGeom = L/2
elseif bMakeMortGeom and L2 then
dHalfGeom = L2/2
elseif nGeom3 and H3 then
dHalfGeom = (H3+IB3_X)/2
if nGeom4 and H4 and (H4+IB4_X) > (H3+IB3_X) then
dHalfGeom = (H4+IB4_X)/2
end
elseif nGeom4 and H4 then
dHalfGeom = (H4+IB4_X)/2
end
if posp and posp > 0 then
dPosProbe = dHalfGeom + posp
sPositiveSuffixProbe = '_POS'
sNegativeSuffixProbe = '_NEG'
end
local pCentr = Point3d( dPosProbe,posh,0)
local hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC)
-- verifico se devo forzare direzione orizzontale o seguire il profilo
local sSideDoorInfo = 'SideLH'
if DGC.Fpd then
sSideDoorInfo = 'LockLH'
end
if hintPr then
EgtModifyCurveThickness( hintPr, -10)
EgtSetName( hintPr,LH..sPositiveSuffixProbe)
EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo)
end
if dPosProbe ~= 0 then
pCentr = Point3d(-(dHalfGeom+(posp or 0)),posh,0)
hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC)
if hintPr then
EgtModifyCurveThickness( hintPr, -10)
EgtSetName( hintPr, LH..sNegativeSuffixProbe)
EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo)
end
end
end
if EC == 0 and D_XE and D_XE ~= 0 then
-- muovo tutte le geometrie del layer
local nIdGeom = EgtGetFirstInGroup( Lg)
while nIdGeom do
EgtMove( nIdGeom, Point3d( (D_XE * EgtIf( sopp, 1, -1)),0,0) - ORIG())
nIdGeom = EgtGetNext(nIdGeom)
end
end
-- Se non Preview
if not bPreview and EC == 0 then
if bRunByCompo then
-- scrivo i parametri nelle info del pezzo
WriteCompoDataToPart( Pz, sCompoName, nCompoNpar)
end
-- scrivo note nel layer della cerniera
EgtSetInfo(Lg,'Type' ,'SPT')
EgtSetInfo(Lg,'Nome' ,sCompoName)
EgtSetInfo(Lg,'L' ,L)
EgtSetInfo(Lg,'H' ,H)
EgtSetInfo(Lg,'T' ,T)
EgtSetInfo(Lg,'D' ,D)
EgtSetInfo(Lg,'rf' ,rf)
EgtSetInfo(Lg,'clc' ,clc)
EgtSetInfo(Lg,'ccr' ,ccr)
EgtSetInfo(Lg,'sf' ,sf)
EgtSetInfo(Lg,'L2' ,L2)
EgtSetInfo(Lg,'H2' ,H2)
EgtSetInfo(Lg,'T2' ,T2)
EgtSetInfo(Lg,'s' ,s)
EgtSetInfo(Lg,'d' ,d)
EgtSetInfo(Lg,'p' ,p)
EgtSetInfo(Lg,'jn' ,jn)
EgtSetInfo(Lg,'jnb' ,jnb)
EgtSetInfo(Lg,'mfp' ,mfp)
EgtSetInfo(Lg,'d2' ,d2)
EgtSetInfo(Lg,'p2' ,p2)
EgtSetInfo(Lg,'D_X' ,D_X)
EgtSetInfo(Lg,'D_Y' ,D_Y)
EgtSetInfo(Lg,'H3' ,H3)
EgtSetInfo(Lg,'T3' ,T3)
EgtSetInfo(Lg,'posh' ,posh)
EgtSetInfo(Lg,'posp' ,posp)
EgtSetInfo(Lg,'ech' ,ech)
EgtSetInfo(Lg,'est' ,est)
EgtSetInfo(Lg,'kbs' ,kbs)
EgtSetInfo(Lg,'pbs' ,pbs)
EgtSetInfo(Lg,'sopp' ,sopp)
EgtSetInfo(Lg,'dws' ,dws)
EgtSetInfo(Lg,'dthd' ,dthd)
EgtSetInfo(Lg,'ttp' ,ttp)
EgtSetInfo(Lg,'DB_X' ,DB_X)
EgtSetInfo(Lg,'DB_Y' ,DB_Y)
EgtSetInfo(Lg,'IB3_X' ,IB3_X)
EgtSetInfo(Lg,'IB4_X' ,IB4_X)
EgtSetInfo(Lg,'invG' ,invG)
EgtSetInfo(Lg,'D_XE' ,D_XE)
EgtSetInfo(Lg,'LG' ,LG)
EgtSetInfo(Lg,'LM' ,LM)
EgtSetInfo(Lg,'LG2' ,LG2)
EgtSetInfo(Lg,'LA' ,LA)
EgtSetInfo(Lg,'LG3' ,LG3)
EgtSetInfo(Lg,'LG4' ,LG4)
EgtSetInfo(Lg,'CLH' ,CLH)
EgtSetInfo(Lg,'LH' ,LH)
EgtSetInfo(Lg,'CH' ,CH)
EgtSetInfo(Lg,'Path' ,sCompoPath)
-- cancello le parti ausiliarie se disegnate
if Dm then
EgtErase( Dm)
end
elseif not bPreview then
-- cancello le parti ausiliarie se disegnate
if Dm then
EgtErase( Dm)
end
end
if EC == 0 and nCodAdj and nCodAdj < 0 then
EC = nCodAdj
EM = sCodAdj
end
return EC, EM, Lg
end
return EPT