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

3025 lines
132 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
--
-- Pivot.lua by EgalWare s.r.l. 2016.07.14
-- Autore: Filippo Monchi
-- Pivot
-- 2016.09.21 V1.011 FM Add warning messages
-- 2016.09.21 V1.012 FM not use reverse geometries '_R' on calculate tool diameter, it must have same diameter than not reverse geometries
-- 2017.12.08 V1.013 FM Manage offset position on probe geometry and duplicate it for manage probe when door is placed on left or right position
-- 2017.12.22 V1.014 FM Manage new backset application point
-- 2018.01.08 V1.015 FM Manage new R1 parameter to add a fillet on single corner
-- 2018.01.12 V1.016 FM Manage new anti splint position path when side pivot correspond to side door (on offset and offsetintermediate type)
-- 2018.02.22 V1.017 FM fix problem on calculate side distance: before into calculation was ignored the offset parameter tMhPar.D_XE define into model lua file
-- 2018.04.06 V1.018 FM Manage info (KeepBackSet) for adjust probe on Z
-- 2018.05.23 V1.019 FM Manage disposition reference point by .rp parameter for Offsetintermediate pivot
-- 2018.10.17 V1.01a FM Add parameter to show into message 402
-- 2018.10.19 V1.01b FM Manage T shape also for Offset Pivot
-- 2018.10.19 V1.01b FM Manage disposition reference point by .rp parameter also for Offset pivot
-- 2018.10.22 V1.01c FM Manage better the big radius fillet parameter
-- 2019.07.29 V1.01d FM Manage new differents pivot models and submodels: Centerhung pivot with submodel (1), Offset pivot with submodel (1) 2 3 4,
-- OffsetInpermediate with submodel (1) 3 4
-- the defalult and old one is submodel (1) for all model
-- For new Intermediate submodel 4 use _PivotL component instead of _Mortise component
-- Manage better the probe geometry disposition: calculate when there is not enough space to insert probe geometry
-- 2019.08.27 V1.01e FM Manage new parameter HB to not rotate the horizontal bore of Intermediate Pivot
-- 2019.08.27 V1.01e FM Modify the bore depth in case edge is bevel and HB parameter is true
-- 2019.09.16 V1.01f FM Fix set wrong parameter into call CheckTool for chisel tool
-- 2019.09.30 V1.020 FM Manage Rectangular shape on standard intermediate pivot (by L3 = 0)
-- 2019.10.01 V1.021 FM Manage better the position in Z when backset is set to 0 (into center door thickness)
-- 2019.10.07 V1.022 FM Allow machine convex profile only with intermediate pivot subtype 1
-- 2019.10.08 V1.023 FM Manage steel option (disable to generate pocket paths, mortise and not horizontal bore)
-- 2019.10.18 V2.000 FM Manage use Materials
-- 2019.10.21 V2.001 FM Modify the closed path start point for steel material
-- 2019.10.25 V2.002 FM Add clean corner geometries
-- 2019.12.06 V2.003 FM fix a bug to assign to variable H instead of tMhPar.H at CenterHung section
-- 2019.12.18 V2.004 FM Use new parameter DGC.Eah that allow insert template also on bullnose ans convex profiles
-- 2019.12.20 V2.005 FM fix a bug on clean corner direction path in case main path turn reverse
-- 2020.04.29 V2.006 FM Update for aluminum material
-- 2020.05.04 V2.006 FM Manage extra bores on type 1, 2, 3 and only subtype 1 (standard model)
-- 2020.05.25 V2.007 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side
-- 2020.07.01 V2.008 FM Disable Warning message on frames if parameter DGD.Spd is <= 0
-- 2020.10.14 V2.009 FM Fix error on missing parameter for CheckTool function
-- 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.08.26 V3.003 FM Compare better the wide knuckle (L3) with face tool diameter and anti-splint tool diameter
-- 2021.11.24 V3.004 FM Manage side probe option if variable DGC.Pms > 2
-- 2022.07.27 V3.005 FM Modification to use compiled code
-- 2023.03.31 V3.006 FM Manage better knuckle disabling, now it checks if L3 = 0 or H3 = 0 too
-- 2024.04.29 V3.007 FM Allow mortise to be bigger than face, but join (jn) parameter (to join face and mortise) will se to false
-- 2024.07.19 V3.008 FM Set note 'NotCheckDir' to pocketing, antisplint and buttonhole pocketing paths
-- 2024.10.29 V3.009 FM Manage new DGC.Fpd CurrDoorCustomData variable to force shuttle probe geometry to stay horizontal
-- Tavola per definizione modulo (serve ma non usata)
local Pivot = {}
-- 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 bShiftBackSetPos = true -- da richiesta MDC
local dMinDistIntpiv = 0.762
local dMinDistOffspiv = 0.5
local MB = require( 'MachiningBase')
local dExtraH = 0.5
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, HB10, ptype, 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
local sKeepMode = 'c' -- setto di default per mantenere il centro spessore
if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside
sKeepMode = 'w'
end
EgtSetInfo( hint3, 'KeepBackSet', sKeepMode)
if hint5 then
EgtSetInfo( hint5, 'KeepBackSet', sKeepMode)
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
local function CheckTool( bCheck1, bJoinCheck, nTypeCompare, dDiamTool, sNamePar,
nCodePar, sLocalMess, dThick, nNumMsg, nNumWrng,
bSetAsMaxMat, n2ndTypeCompare, dNumLog, dMaxMat, bCheck2,
sName, EgtDoorsMsg)
local nTempT1
local dMaxMat1
local sMchngName1
local nLocalLog = 0
local dDiamReturn = dDiamTool
if bCheck1 then
nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sNamePar, nCodePar)
if nTypeCompare == 1 then
if dDiamTool and nTempT1 <= 0 then
if DGD.bProoduce and bJoinCheck then
nLocalLog = -2192
sLocalMess = sLocalMess .. '\n'.. GetMachToolErrorMessage( nTempT1, sNamePar, nCodePar, dDiamTool, nLocalLog, sMchngName1)
end
else
dDiamReturn = nTempT1
end
elseif nTypeCompare == 2 then
if DGD.bProoduce and not dMaxMat1 then
nLocalLog = -2191
sLocalMess = sLocalMess .. '\n'.. GetMachToolErrorMessage( nTempT1, sNamePar, nCodePar, nil, nLocalLog, sMchngName1)
end
end
end
if n2ndTypeCompare == 1 then
-- se la profondità è maggiore della capacità utensile limito la profondità ed emetto un warning
if dThick and dMaxMat1 and dThick > dMaxMat1 then
nLocalLog = nNumWrng
dNumMessage = nNumMsg
sLocalMess = sLocalMess .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], nLocalLog, sName, EgtToUiUnits(dThick), EgtToUiUnits(dMaxMat1))
if bSetAsMaxMat then
dThick = dMaxMat1
else
dThick = dMaxMat1 - 0.02 -- tolgo 0.02 per permettere la lavorazione
dMaxMat = dMaxMat1
end
end
elseif n2ndTypeCompare == 2 then
-- se foro abilitato e la profondità è maggiore della capacità utensile,
-- limito la profondità ed emetto un warning
if bCheck2 and dThick and dMaxMat1 and dThick > dMaxMat1 then
nLocalLog = nNumWrng
dNumMessage = nNumMsg
sLocalMess = sLocalMess .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], nLocalLog, sName, EgtToUiUnits(dThick), EgtToUiUnits(dMaxMat1))
if bSetAsMaxMat then
dThick = dMaxMat1
else
dThick = dMaxMat1 - 0.02 -- tolgo 0.02 per permettere la lavorazione
dMaxMat = dMaxMat1
end
end
end
if nLocalLog == 0 and dNumLog ~= 0 then
nLocalLog = dNumLog
end
return dDiamReturn, nLocalLog, sLocalMess, dThick, dMaxMat
end
-- Funzione di sistemazione parametri
function Pivot.AdjustParams( tMhPar)
local EgtDoorsMsg = require( 'EgtDoorsMsg')
local dMaxMat
local dMaxMat0
local nTempT0
local dNumLog = 0
local sMessToOut = ''
-- se non è definito setto tipo setto per default la forma standard a L
if not tMhPar.stype then tMhPar.stype = 1 end
tMhPar.back = DGD.BACK_SET
tMhPar.oriback = DGD.BACK_SET
tMhPar.posiz = DGD.POSITION
tMhPar.rad = DGD.RADIUS
tMhPar.dhei = DGD.dOH or DGD.dH
tMhPar.invG = 1
tMhPar.fht = 0 -- setto il face h top a 0
tMhPar.fhb = 0 -- setto il face h bottom a 0
tMhPar.mkrev = false
tMhPar.stn = false -- setto il flag di pivot tangente bordo porta
tMhPar.bETh = false -- extra thickness per i sottotipi dove il knuckle è passante sullo spessore porta
-- setto parametro riferimento profondità pivot
tMhPar.drf = DGD.dT/6
if DGD.sFrame then -- se è un assemblato
tMhPar.drf = 0.1 -- in questo modo crea semre la regione da togliere relativa al materiale asportato
end
if DGD.DEPTH_F then
if string.lower(DGD.TYPE) ~= 'centerhung' then
if tMhPar.stype == 1 then
tMhPar.T = DGD.DEPTH_F
end
else
tMhPar.T = DGD.DEPTH_F
end
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
local sPieceName
if tMhPar.Dws then
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
-- setto un valore di poco inferiore allo spessore per non fresare le ventose
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.stype == 1 and tMhPar.T and abs(tMhPar.T) > tMhPar.TTP then
dNumLog = -2186
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.stype == 1 and tMhPar.T2 and abs(tMhPar.T2) > tMhPar.TTP then
dNumLog = -2186
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.tb and tMhPar.mh then
tMhPar.T2 = tMhPar.T
end
-- se non ho il parametro radius lo setto a 0
if not tMhPar.rad then
tMhPar.rad = 0
end
-- se non ho il parametro raccordo su singolo angolo lo setto a 0
if not tMhPar.R1 then
-- tMhPar.R1 = tMhPar.rad
tMhPar.R1 = 0
end
-- per face con knuckle in centro assegno il valore del raggio alla variabile di raggio interno
tMhPar.R1i = tMhPar.R1
-- se non esiste il valore della distanza del knuckle la setto a 0
if not tMhPar.D_SK then
tMhPar.D_SK = 0
end
-- prendo il valore assoluto
tMhPar.D_SK = abs(tMhPar.D_SK)
-- se non ho parametro step o è 0 lo assegno uguale allo spessore cava
if not tMhPar.sf or abs(tMhPar.sf) < GEO.EPS_SMALL then
tMhPar.sf = tMhPar.T
end
-- se non ho il parametro D_X lo setto a 0
if not tMhPar.D_X then
tMhPar.D_X = 0
end
-- se non ho il parametro D_XE lo setto a 0
if not tMhPar.D_XE then
tMhPar.D_XE = 0
end
-- se ho il raggio disabilito eventuale chiseling
if not tMhPar.ech or tMhPar.rad > 0 then
tMhPar.ech = false
end
-- se non c'è la variabile suffisso
if not tMhPar.CH then
tMhPar.CH = '_Chisel'
end
-- Assegno parametri da dati utensili in macchina
local sLM
local nLMi = 1
local sLA
local nLAi = 1
local sLG
local nLGi = 1
local sLMM
local nLMMi = 1
local sLGH
local nLGHi = 1
local sLGV
local nLGVi = 1
local sLMV
local nLMVi = 1
local sLAV
local nLAVi = 1
-- se porta steel o aluminum disabilito l'antischeggia, la svuotatura, il chisel e modifico il nome geometria
if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then
tMhPar.LM = nil
tMhPar.LA = nil
tMhPar.LMM = nil
tMhPar.LGV = nil
tMhPar.LMV = nil
tMhPar.LAV = nil
tMhPar.ech = false
tMhPar.CH = nil
tMhPar.est = true
tMhPar.d2 = nil
if string.lower(DGD.TYPE) == 'offsetintermediate' and tMhPar.mh and not tMhPar.HB then
tMhPar.d3 = nil
tMhPar.mh = false
end
else
tMhPar.est = nil
end
if tMhPar.stype == 1 then -- se sottotipo standard
if tMhPar.est and tMhPar.LG then
sLG = tMhPar.LG
end
if tMhPar.ech and tMhPar.LG then -- se chisel abilitato
sLG = tMhPar.LG .. tMhPar.CH
tMhPar.d0 = 0
end
if tMhPar.LM then
sLM = tMhPar.LM
end
if tMhPar.LA then
sLA = tMhPar.LA
end
if tMhPar.LMM then
sLMM = tMhPar.LMM
end
if tMhPar.LGH then
sLGH = tMhPar.LGH
end
else -- atri sottotipi
-- elimino il cleancorner
tMhPar.clc = nil
tMhPar.ccr = nil
tMhPar.CLC = nil
tMhPar.CLH = nil
if string.lower(DGD.TYPE) == 'offset' then
if tMhPar.est and tMhPar.LG then
sLG = tMhPar.LG
end
if tMhPar.stype == 4 then
if tMhPar.ech and tMhPar.LG then -- se chisel abilitato
sLG = tMhPar.LG .. tMhPar.CH
tMhPar.d0 = 0
end
end
if tMhPar.LM then
sLM = tMhPar.LM
end
if tMhPar.LA then
sLA = tMhPar.LA
end
if tMhPar.ech and tMhPar.LGV then -- se chisel abilitato
sLGV = tMhPar.LGV .. tMhPar.CH
tMhPar.d0 = 0
end
if tMhPar.LMV then
sLMV = tMhPar.LMV
end
if tMhPar.LAV then
sLAV = tMhPar.LAV
end
elseif string.lower(DGD.TYPE) == 'offsetintermediate' then
if tMhPar.est and tMhPar.LG then
sLG = tMhPar.LG
end
if tMhPar.stype == 4 then
if tMhPar.ech and tMhPar.LG then -- se chisel abilitato
sLG = tMhPar.LG .. tMhPar.CH
tMhPar.d0 = 0
end
end
if tMhPar.LM then
sLM = tMhPar.LM
end
if tMhPar.LA then
sLA = tMhPar.LA
end
if tMhPar.LMM then
sLMM = tMhPar.LMM
end
if tMhPar.LMV then
sLMV = tMhPar.LMV
end
if tMhPar.LAV then
sLAV = tMhPar.LAV
end
if tMhPar.stype == 3 then
if tMhPar.ech and tMhPar.LGV then -- se chisel abilitato
sLGV = tMhPar.LGV .. tMhPar.CH
tMhPar.d0 = 0
end
end
end
end
if string.lower(DGD.TYPE) == 'centerhung' then
-- do errore se profilo tipo bevel
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
return tMhPar, 2199, string.format(EgtDoorsMsg[464], tMhPar.Nome, DGD.tProfs.hingeedge.trimming)
end
if bShiftBackSetPos and tMhPar.H then
tMhPar.H3 = tMhPar.back + tMhPar.H - ( DGC.Ew / 2) -- new MDC request 22/12/2017
elseif tMhPar.H then
tMhPar.H3 = tMhPar.back + ( tMhPar.H /2)
end
if not tMhPar.rf then
tMhPar.rf = 0
if tMhPar.H then
tMhPar.rf = tMhPar.H/2
end
end
if tMhPar.rf > tMhPar.H/2 then
tMhPar.rf = tMhPar.H/2
end
tMhPar.type = 3 -- 1: offset type, 2: intermediate type, 3: center hung
if tMhPar.cl and ( tMhPar.cl == 2 or tMhPar.cl == 1) then
tMhPar.D_XT = -( tMhPar.L-(tMhPar.rf))/2 -- calcolo per spostare la geometria in modo che il centro del semicerchio sia sullo 0
elseif tMhPar.cl and tMhPar.cl == 0 then
tMhPar.D_XT = -( tMhPar.L/2) -- calcolo per spostare la geometria, bordo dx a 0
else
tMhPar.cl = 3
tMhPar.D_XT = -( tMhPar.L-tMhPar.H)/2 -- calcolo per spostare la geometria in modo che il centro del semicerchio sia sullo 0
end
-- se raggio su tutti gli angoli e raggio esistente annullo il clean corner
if tMhPar.cl == 3 and tMhPar.rf > 0 then
tMhPar.clc = 0
end
-- trovo se invertire il senso di lavorazione
if string.lower(DGD.SIDE) == 'bottom' then tMhPar.invG = -tMhPar.invG end
if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end
if not DGD.Push then tMhPar.invG = -tMhPar.invG end
elseif string.lower(DGD.TYPE) == 'offsetintermediate' then
if tMhPar.T and tMhPar.T > 0 then
tMhPar.fht = tMhPar.T
end
-- 2019.12.18 inserito controllo che permette di mettere il pivot di tipo 1 su qualsiasi tipo di profilo
-- 2019.10.07 tolto dal confronto il profilo convex ma solo se è di sottotipo 1
-- -- do errore se profilo tipo bullnose e convesso
-- if 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' or
-- DGD.tProfs.hingeedge.trimming == 'CV' then
-- 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
if tMhPar.stype == 1 then
if tMhPar.stype == 1 then
return tMhPar, 2198, string.format(EgtDoorsMsg[669], tMhPar.Nome, DGD.tProfs.hingeedge.trimming)
else
return tMhPar, 2198, string.format(EgtDoorsMsg[465], tMhPar.Nome, DGD.tProfs.hingeedge.trimming)
end
end
elseif DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BU' or
DGD.tProfs.hingeedge.trimming == 'BDEB' or DGD.tProfs.hingeedge.trimming == 'BUEB' then
if tMhPar.stype > 2 then
return tMhPar, 2199, string.format(EgtDoorsMsg[658], tMhPar.Nome, DGD.TYPE, tMhPar.stype, DGD.tProfs.hingeedge.trimming)
else
tMhPar.mkrev = true -- assegno flag per creare percorso inverso
-- se profilo cerniere bevel up
if DGD.tProfs.hingeedge.trimming == 'BU' or DGD.tProfs.hingeedge.trimming == 'BUEB' then
nLMi = 2
nLAi = 2 -- l'antischeggia avrà le tre lavorazioni identiche perché l'utensile è su aggregato orizzontale
nLMMi = 2
if tMhPar.ech then nLGi = 2 end
elseif DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BDEB' then -- se profilo cerniere bevel down
-- sLM = sLM ..'_R' -- disattivati perché si utilizza sempre la lavorazione oraria e non quella inversa
nLMi = 3
-- sLA = sLA ..'_R' -- disattivati perché si utilizza sempre la lavorazione oraria e non quella inversa
nLAi = 3 -- l'antischeggia avrà le tre lavorazioni identiche perché l'utensile è su aggregato orizzontale
nLMMi = 3
if tMhPar.ech then nLGi = 3 end
end
end
if tMhPar.T and tMhPar.T > 0 then
tMhPar.fht = tMhPar.T / cos(3)
end
tMhPar.bev = true
end
tMhPar.fhb = tMhPar.fht
tMhPar.type = 2 -- 1: offset type, 2: intermediate type, 3: center hung
tMhPar.D_XT = 0 -- setto a 0 il parametro per spostare la geometria in modo che il centro del semicerchio sia sullo 0
tMhPar.cl = 0 -- corners without fillet, not necessary on this type
-- se manca il parametro che definisce il riferimento del pivot da posizionare
if not tMhPar.rp then
tMhPar.rp = 's' -- setto il valore di default ('s'=knuckle side, 'c'=knuckle center, 'f'= face side)
end
local dDistToSub = 0
if not tMhPar.B_SK then tMhPar.B_SK = false end
if tMhPar.B_SK then -- se knuckle sulla faccia opposta
tMhPar.D_SK2 = tMhPar.D_SK
tMhPar.D_SK = tMhPar.L - tMhPar.L3 - tMhPar.D_SK
else
if tMhPar.D_SK > 0 then
tMhPar.D_SK2 = tMhPar.L - tMhPar.L3 - tMhPar.D_SK
end
end
if tMhPar.L3 then
if tMhPar.rp == 'c' then -- se riferimento in centro al knuckle
if tMhPar.B_SK then -- se knuckle sulla faccia opposta
dDistToSub = tMhPar.L3/2 + tMhPar.D_SK2
else
dDistToSub = tMhPar.L3/2 + tMhPar.D_SK
end
elseif tMhPar.rp == 's' then -- se riferimento sul bordo knuckle
if tMhPar.B_SK then -- se knuckle sulla faccia opposta
dDistToSub = tMhPar.D_SK2
else
dDistToSub = tMhPar.D_SK
end
end
end
-- se pivot è adiacente al fianco top porta annullo il valore del raggio singolo
-- e setto il flag per modifica geometria pivot
if not tMhPar.B_SK then
if ( DGD.POSITION - dDistToSub - tMhPar.D_XE) <= dMinDistIntpiv then
tMhPar.R1 = 0
tMhPar.stn = true
end
else -- se è opposto
if ( DGD.dH - (DGD.POSITION + dDistToSub + tMhPar.D_XE)) <= dMinDistIntpiv then
tMhPar.R1 = 0
tMhPar.stn = true
end
end
if tMhPar.stype == 1 or tMhPar.stype == 4 then
if bShiftBackSetPos and tMhPar.H then
-- se backset nullo o negativo lo ricalcolo per ottenere il centro spessore
if tMhPar.back <= 0 then
tMhPar.back = ( DGD.dT - tMhPar.H) /2
DGD.BACK_SET = tMhPar.back
end
tMhPar.H3 = tMhPar.back + tMhPar.H - ( DGC.Ew / 2) -- new MDC request 22/12/2017
elseif tMhPar.H then
if tMhPar.back <= 0 then
tMhPar.back = DGD.dT/2
DGD.BACK_SET = tMhPar.back
end
tMhPar.H3 = tMhPar.back + ( tMhPar.H /2)
end
end
if tMhPar.stype == 4 then
tMhPar.R1 = 0 -- forzo in ogni caso il R1 a 0
-- calcolo lo spostamento in X
local dExtraDim = 0
if tMhPar.B_SK then
tPiPar.D_X = -(tPiPar.L - tPiPar.L3 + dExtraDim) / 2
else
tPiPar.D_X = (tPiPar.L - tPiPar.L3 + dExtraDim) / 2
end
-- calcolo l'altezza della mortasa e lo spostamento in Y
tMhPar.D = (tMhPar.H2 - tMhPar.H)/2
-- se non ho parametro step o è 0 lo assegno uguale allo spessore cava
if not tMhPar.s or abs(tMhPar.s) < GEO.EPS_SMALL then
tMhPar.s = tMhPar.T2
end
elseif tMhPar.stype == 3 then
tMhPar.R1 = 0 -- forzo in ogni caso il R1 a 0
tMhPar.jn = false -- forzo di non collegare il face con la mortasa
tMhPar.H3 = DGD.dT/2 -- setto H3 come spessore porta
tMhPar.bETh = true -- setto spessore passante
tMhPar.stnb = tMhPar.stn
-- se non ho parametro step o è 0 lo assegno uguale allo spessore cava
if not tMhPar.s3 or abs(tMhPar.s3) < GEO.EPS_SMALL then
tMhPar.s3 = tMhPar.T3
end
end
-- calcolo la posizione del centro foro sullo spessore porta
if bShiftBackSetPos then
if tMhPar.stype == 3 then -- se sottotipo 3
tMhPar.posh = 0 -- 27/12/2017 New MDC request
elseif tMhPar.H then
if abs(tMhPar.oriback) <= 0.001 then
-- se non ruota su profilo bevel o non è bevel
if DGC.Fpd or not tMhPar.bev then
tMhPar.posh = tMhPar.back + ( tMhPar.H/2) - (DGD.dT/2) -- 27/12/2017 New MDC request
else
tMhPar.posh = ( ( tMhPar.back + ( tMhPar.H/2)) * cos( 3)) - (DGD.dT/2) -- 27/12/2017 New MDC request
end
else
-- se non ruota su profilo bevel o non è bevel
if DGC.Fpd or not tMhPar.bev then
tMhPar.posh = tMhPar.back + (( tMhPar.H - DGC.Ew) / 2) - (DGD.dT/2) -- 27/12/2017 New MDC request
else
tMhPar.posh = ( (tMhPar.back + (( tMhPar.H - DGC.Ew) / 2)) * cos( 3)) - (DGD.dT/2) -- 27/12/2017 New MDC request
end
end
end
else
if tMhPar.stype == 3 then -- se sottotipo 3
tMhPar.posh = 0
else
-- se non ruota su profilo bevel o non è bevel
if DGC.Fpd or not tMhPar.bev then
tMhPar.posh = tMhPar.back - (DGD.dT/2)
else
tMhPar.posh = ( tMhPar.back * cos( 3)) - (DGD.dT/2)
end
end
end
-- trovo se invertire il senso di lavorazione
if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end
if DGD.Push then tMhPar.invG = -tMhPar.invG end
else -- tipo offset
tMhPar.type = 1 -- 1: offset type, 2: intermediate type, 3: center hung
tMhPar.D_XT = 0 -- setto a 0 il parametro per spostare la geometria in modo che il centro del semicerchio sia sullo 0
tMhPar.cl = 0 -- corners without fillet, not necessary on this type
-- se sottotipo 1:top/bottom door o 2:top/bottom-back door
if tMhPar.stype == 1 or tMhPar.stype == 2 then
if tMhPar.T and tMhPar.T > 0 then
tMhPar.fht = tMhPar.T
end
if ( DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BU' or
DGD.tProfs.hingeedge.trimming == 'BDEB' or DGD.tProfs.hingeedge.trimming == 'BUEB') and
tMhPar.T and tMhPar.T > 0 then
tMhPar.fht = tMhPar.T / cos(3)
end
-- se manca il parametro che definisce il riferimento del pivot da posizionare
if not tMhPar.rp then
tMhPar.rp = 'c' -- setto il valore di default ('s'=knuckle side, 'c'=knuckle center, 'f'= face side)
end
tMhPar.fhb = tMhPar.fht
local dDistToSub = 0
if tMhPar.L3 then
if tMhPar.rp == 'c' then -- se riferimento in centro al knuckle
dDistToSub = tMhPar.L3/2 + tMhPar.D_SK
elseif tMhPar.rp == 's' then -- se riferimento sul bordo knuckle
dDistToSub = tMhPar.D_SK
end
end
-- se pivot è adiacente al fianco porta annullo il valore del raggio singolo
-- e setto il flag per modifica geometria pivot
if ( DGD.POSITION - dDistToSub - tMhPar.D_XE) <= dMinDistOffspiv then
tMhPar.R1 = 0
tMhPar.stn = true
end
if tMhPar.stype == 2 then
tMhPar.R1 = 0 -- forzo in ogni caso il R1 a 0
tMhPar.jn = false -- forzo di non collegare il face con la mortasa
tMhPar.H3 = DGD.dT/2 -- setto H3 come spessore porta
tMhPar.bETh = true -- setto spessore passante
tMhPar.stnb = tMhPar.stn
if not tMhPar.T3 then tMhPar.T3 = tMhPar.T end
-- se non ho parametro step o è 0 lo assegno uguale allo spessore cava
if not tMhPar.s3 or abs(tMhPar.s3) < GEO.EPS_SMALL then
tMhPar.s3 = tMhPar.T3
end
else
if tMhPar.D_SK > 0 then
tMhPar.D_SK2 = tMhPar.L - tMhPar.L3 - tMhPar.D_SK
end
if bShiftBackSetPos and tMhPar.H then
-- se backset nullo o negativo lo ricalcolo per ottenere il centro spessore
if tMhPar.back <= 0 then
tMhPar.back = ( DGD.dT - tMhPar.H) /2
DGD.BACK_SET = tMhPar.back
end
tMhPar.H3 = tMhPar.back + tMhPar.H - ( DGC.Ew / 2) -- new MDC request 22/12/2017
elseif tMhPar.H then
if tMhPar.back <= 0 then
tMhPar.back = DGD.dT/2
DGD.BACK_SET = tMhPar.back
end
tMhPar.H3 = tMhPar.back + ( tMhPar.H /2)
end
end
-- trovo se invertire il senso di lavorazione
if string.lower(DGD.SIDE) == 'bottom' then tMhPar.invG = -tMhPar.invG end
if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end
if not DGD.Push then tMhPar.invG = -tMhPar.invG end
elseif tMhPar.stype == 3 then -- se sotto tipo 3 top/bottom-back door
-- se manca il parametro che definisce il riferimento del pivot da posizionare
if not tMhPar.rp then
tMhPar.rp = 'c' -- setto il valore di default ('s'=knuckle side, 'c'=knuckle center, 'f'= face side)
end
local dDistToSub = 0
if tMhPar.L3 then
if tMhPar.rp == 'c' then -- se riferimento in centro al knuckle
dDistToSub = tMhPar.L3/2 + tMhPar.D_SK
elseif tMhPar.rp == 's' then -- se riferimento sul bordo knuckle
dDistToSub = tMhPar.D_SK
end
end
-- se pivot è adiacente al fianco porta annullo il valore del raggio singolo
-- e setto il flag per modifica geometria pivot
if ( DGD.POSITION - dDistToSub - tMhPar.D_XE) <= dMinDistOffspiv then
tMhPar.stn = true
end
-- controlli e settaggi aggiuntivi se larghezza corpo pivot è differente
-- Se larghezza
dDistToSub = 0
if tMhPar.AsKn then -- se larghezza body come knuckle, verifico se c'è
-- se non c'è o lunghezza nulla prendo la misura locale
if not tMhPar.L3 or ( tMhPar.L3 and abs(tMhPar.L3) < GEO.EPS_SMALL) then
if tMhPar.H then
if tMhPar.rp == 'c' then -- se riferimento in centro al knuckle
dDistToSub = tMhPar.H/2 + tMhPar.D_SK
elseif tMhPar.rp == 's' then -- se riferimento sul bordo knuckle
dDistToSub = tMhPar.D_SK
end
end
-- se pivot è adiacente al fianco porta annullo il valore del raggio singolo
-- e setto il flag per modifica geometria pivot
if ( DGD.POSITION - dDistToSub - tMhPar.D_XE) <= dMinDistOffspiv then
tMhPar.stnb = true
end
else -- se larghezza valida
tMhPar.H = tMhPar.L3
tMhPar.stnb = tMhPar.stn
end
else -- se larghezza diversa
if tMhPar.H then
if tMhPar.rp == 'c' then -- se riferimento in centro al knuckle
dDistToSub = tMhPar.H/2 + tMhPar.D_SK
elseif tMhPar.rp == 's' then -- se riferimento sul bordo knuckle
if tMhPar.L3 then
dDistToSub = tMhPar.D_SK+((tMhPar.H-tMhPar.L3)/2)
else
dDistToSub = tMhPar.D_SK
end
end
end
-- se pivot è adiacente al fianco porta annullo il valore del raggio singolo
-- e setto il flag per modifica geometria pivot
if ( DGD.POSITION - dDistToSub - tMhPar.D_XE) <= dMinDistOffspiv then
tMhPar.stnb = true
end
end
tMhPar.R1 = 0 -- forzo in ogni caso il R1 a 0
tMhPar.jn = false -- forzo di non collegare il face con la mortasa
tMhPar.H3 = DGD.dT/2 -- setto H3 come spessore porta
tMhPar.bETh = true -- setto spessore passante
if not tMhPar.T3 then tMhPar.T3 = tMhPar.T end
-- se non ho parametro step o è 0 lo assegno uguale allo spessore cava
if not tMhPar.s3 or abs(tMhPar.s3) < GEO.EPS_SMALL then
tMhPar.s3 = tMhPar.T3
end
-- trovo se invertire il senso di lavorazione
if string.lower(DGD.SIDE) == 'bottom' then tMhPar.invG = -tMhPar.invG end
if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end
if not DGD.Push then tMhPar.invG = -tMhPar.invG end
elseif tMhPar.stype == 4 then -- se sotto tipo 4 top/bottom-side door
-- do errore se profilo tipo bevel
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
return tMhPar, 2199, string.format(EgtDoorsMsg[658], tMhPar.Nome, DGD.TYPE, tMhPar.stype, DGD.tProfs.hingeedge.trimming)
end
-- forzo il tipo ad essere adiacente al bordo porta
tMhPar.stn = true
tMhPar.R1 = 0 -- forzo in ogni caso il R1 a 0
tMhPar.rp = 's' -- forzo il valore di default ('s'=knuckle side, 'c'=knuckle center, 'f'= face side)
tMhPar.jn = false -- forzo di non collegare il face con la mortasa
if not tMhPar.T3 then tMhPar.T3 = tMhPar.T end
-- se non ho parametro step o è 0 lo assegno uguale allo spessore cava
if not tMhPar.s3 or abs(tMhPar.s3) < GEO.EPS_SMALL then
tMhPar.s3 = tMhPar.T3
end
if bShiftBackSetPos and tMhPar.H then
-- se backset è nullo o negativo ricalcolo per far stare la parte body in centro allo spessore
if tMhPar.back <= 0 then
tMhPar.back = ( DGD.dT - tMhPar.H) /2
DGD.BACK_SET = tMhPar.back
end
tMhPar.H3 = tMhPar.back + tMhPar.H -- new MDC request 22/12/2017
if tMhPar.back <= dMinDistOffspiv then
tMhPar.stnb = true
end
elseif tMhPar.H then
-- se backset è nullo o negativo ricalcolo per far stare la parte body in centro allo spessore
if tMhPar.back <= 0 then
tMhPar.back = DGD.dT/2
DGD.BACK_SET = tMhPar.back
end
tMhPar.H3 = tMhPar.back + ( tMhPar.H /2)
if tMhPar.back - ( tMhPar.H /2) <= dMinDistOffspiv then
tMhPar.stnb = true
end
end
-- trovo se invertire il senso di lavorazione
if string.lower(DGD.SIDE) == 'bottom' then tMhPar.invG = -tMhPar.invG end
if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end
if not DGD.Push then tMhPar.invG = -tMhPar.invG end
end
end
-- se arrotondo entrambe le estremità disabilito il chisel
if tMhPar.cl == 3 then
tMhPar.ech = false
end
-- se raggio nullo lo azzero
if not tMhPar.rf then tMhPar.rf = 0 end
-- se devo disegnare le geometrie di lavorazione
if DGD.MachEn > 0 then
if ( tMhPar.CLC or 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.CLC and not tMhPar.CLH then
tMhPar.clc = nil
end
-- se sono pivot standard
if ( tMhPar.type <= 2 and tMhPar.stype == 1) or tMhPar.type == 3 then
-- geometria face
if tMhPar.est then
tMhPar.d, dNumLog, sMessToOut, tMhPar.T, dMaxMat = CheckTool( tMhPar.d, true, 1, tMhPar.d, sLG,
nLGi, sMessToOut, tMhPar.T, 460, -2197,
false, 1, dNumLog, dMaxMat, nil,
tMhPar.Nome, EgtDoorsMsg)
end
-- svuotatura face
if not tMhPar.est then
tMhPar.d, dNumLog, sMessToOut, tMhPar.T, dMaxMat = CheckTool( tMhPar.d, true, 1, tMhPar.d, sLM,
nLMi, sMessToOut, tMhPar.T, 460, -2197,
false, 1, dNumLog, dMaxMat, nil,
tMhPar.Nome, EgtDoorsMsg)
end
-- antisplint face
if not tMhPar.est then
tMhPar.d2, dNumLog, sMessToOut, tMhPar.T, dMaxMat = CheckTool( tMhPar.d2, true, 1, tMhPar.d2, sLA,
nLAi, sMessToOut, tMhPar.T, 462, -2196,
false, 1, dNumLog, dMaxMat, nil,
tMhPar.Nome, EgtDoorsMsg)
end
-- svuotatura mortise concatenata
if not tMhPar.est then
tMhPar.d, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( tMhPar.d, (not tMhPar.jn), 1, tMhPar.d, sLM,
nLMi, sMessToOut, tMhPar.T2, 461, -2194,
true, 2, dNumLog, dMaxMat, (tMhPar.jn and not tMhPar.mh),
tMhPar.Nome, EgtDoorsMsg)
end
-- foro (solo controllo profondità)
if not tMhPar.est or ( tMhPar.est and tMhPar.HB) then
_, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( (tMhPar.mh and tMhPar.LGH), true, 2, tMhPar.d3, sLGH,
nLGHi, sMessToOut, tMhPar.T2, 463, -2195,
true, 2, dNumLog, dMaxMat, tMhPar.mh,
tMhPar.Nome, EgtDoorsMsg)
end
-- svuotatura mortise disgiunta
if not tMhPar.est then
tMhPar.d3, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( tMhPar.d3, true, 1, tMhPar.d3, sLMM,
nLMMi, sMessToOut, tMhPar.T2, 461, -2193,
true, 2, dNumLog, dMaxMat, (not tMhPar.jn and not tMhPar.mh),
tMhPar.Nome, EgtDoorsMsg)
end
-- chisel (solo controllo diametro utensile)
if not tMhPar.est then
tMhPar.d0, dNumLog, sMessToOut, dMaxMat0, dMaxMat = CheckTool( (tMhPar.ech and tMhPar.d0), false, 1, tMhPar.d0, sLG,
nLGi, sMessToOut, tMhPar.T, 460, -2192,
false, 3, dNumLog, dMaxMat, nil,
tMhPar.Nome, EgtDoorsMsg)
end
-- se ho altro materiale modifico i raccordi se sono più piccoli del raggio utensile
if tMhPar.est then
if tMhPar.type == 3 then -- tipo centerhung
if tMhPar.rf and tMhPar.rf > 0 and tMhPar.cl > 0 and tMhPar.d and tMhPar.rf < ((tMhPar.d/2)+0.02) then
tMhPar.rf = 0
end
elseif tMhPar.type == 2 then -- tipo intermediate
if tMhPar.D_SK > 0 and tMhPar.D_SK2 > 0 then -- se ho knuckle centrato azzero solo i raggi interni
if tMhPar.rad and tMhPar.rad > 0 and tMhPar.d and tMhPar.rad < ((tMhPar.d/2)+0.02) then
tMhPar.rad = 0
end
else
if tMhPar.L3 and tMhPar.L3 > 0 then -- se a forma di L
if tMhPar.R1 and tMhPar.R1 > 0 and tMhPar.d and tMhPar.R1 < ((tMhPar.d/2)+0.02) then
tMhPar.R1 = 0
tMhPar.R1i = 0
end
end
if tMhPar.rad and tMhPar.rad > 0 and tMhPar.d and tMhPar.rad < ((tMhPar.d/2)+0.02) then
tMhPar.rad = 0
end
end
elseif tMhPar.type == 1 then -- tipo offset
if tMhPar.D_SK == 0 or tMhPar.D_SK2 == 0 then -- se a forma di L
if tMhPar.R1 and tMhPar.R1 > 0 and tMhPar.d and tMhPar.R1 < ((tMhPar.d/2)+0.02) then
tMhPar.R1 = 0
tMhPar.R1i = 0
end
end
if tMhPar.rad and tMhPar.rad > 0 and tMhPar.d and tMhPar.rad < ((tMhPar.d/2)+0.02) then
tMhPar.rad = 0
end
end
end
-- vecchio controllo
--[[
local dMaxMat1
local dMaxMat2
local dMaxMat3
local nTempT0
local nTempT1
local nTempT2
local nTempT3
local nTempT4
local sMchngName0
local sMchngName1
local sMchngName2
local sMchngName3
local sMchngName4
local dNumMessage
if tMhPar.d then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLM, nLMi) end -- svuotatura face
if tMhPar.d2 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLA, nLAi) end -- antischeggia
if tMhPar.d3 then nTempT3, dMaxMat3, sMchngName3 = MB.GetToolDataFromAttrib( sLMM, nLMMi) end -- svuotatura mortise
if tMhPar.mh and tMhPar.LGH then nTempT4, dMaxMat3, sMchngName4 = MB.GetToolDataFromAttrib( sLGH, nLGHi) end -- foro
if tMhPar.ech and tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end -- chisel su face
-- gestisco il risultato della lettura utensili
if DGD.bProoduce and tMhPar.d and nTempT1 <= 0 then
dNumLog = -2192
sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1)
elseif DGD.bProoduce then
tMhPar.d = nTempT1
end
if DGD.bProoduce and tMhPar.d2 and nTempT2 <= 0 then
dNumLog = -2192
sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2)
elseif DGD.bProoduce then
tMhPar.d2 = nTempT2
end
if tMhPar.d3 and nTempT3 <= 0 then
if DGD.bProoduce and not tMhPar.jn then -- se non si concatenano i due percorsi
dNumLog = -2192
sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLMM, nLMMi, tMhPar.d3, dNumLog, sMchngName3)
end
else
tMhPar.d3 = nTempT3
end
if DGD.bProoduce and tMhPar.mh and tMhPar.LGH and not dMaxMat3 then
dNumLog = -2191
sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT4, sLGH, nLGHi, nil, dNumLog, sMchngName4)
end
-- chiseling
-- if tMhPar.ech and tMhPar.d0 and nTempT0 > 0 then
-- tMhPar.d0 = nTempT0
-- 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 = -2197
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
dMaxMat = dMaxMat1
end
-- se la profondità antischeggia della face è maggiore della capacità utensile limito la profondità ed emetto un warning
-- if not tMhPar.mh and tMhPar.T and dMaxMat2 and tMhPar.T > dMaxMat2 then
if tMhPar.T and dMaxMat2 and tMhPar.T > dMaxMat2 then
dNumLog = -2196
dNumMessage = 462
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat2))
tMhPar.T = dMaxMat2 - 0.02 -- tolgo 0.02 per permettere la lavorazione
dMaxMat = dMaxMat2
end
-- se foro abilitato e la profondità è maggiore della capacità utensile,
-- limito la profondità ed emetto un warning
if tMhPar.mh and tMhPar.T2 and dMaxMat3 and tMhPar.T2 > dMaxMat3 then
dNumLog = -2195
dNumMessage = 463
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat3))
tMhPar.T2 = dMaxMat3
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 not tMhPar.mh and
tMhPar.T2 and dMaxMat and tMhPar.T2 > dMaxMat then
dNumLog = -2194
dNumMessage = 461
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat))
tMhPar.T2 = dMaxMat
end
-- se la mortise non è concatenate a face e la profondità della mortise è maggiore della capacità utensile,
-- limito la profondità ed emetto un warning
if not tMhPar.jn and not tMhPar.mh and
tMhPar.T2 and dMaxMat3 and tMhPar.T2 > dMaxMat3 then
dNumLog = -2193
dNumMessage = 461
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat3))
tMhPar.T2 = dMaxMat3
end
]]--
-- pivot offset speciale
elseif tMhPar.type == 1 then -- tipo offset
-- check utensile svuotatura knuckle
if not tMhPar.est then
tMhPar.d3, dNumLog, sMessToOut, tMhPar.T3 = CheckTool( tMhPar.d3, true, 1, tMhPar.d3, sLM,
nLMi, sMessToOut, tMhPar.T3, 654, -2191,
true, 1, dNumLog, nil, nil,
tMhPar.Nome, EgtDoorsMsg)
end
-- check utensile antischeggia knuckle
if not tMhPar.est then
tMhPar.d4, dNumLog, sMessToOut, tMhPar.T3 = CheckTool( tMhPar.d4, true, 1, tMhPar.d4, sLA,
nLAi, sMessToOut, tMhPar.T3, 656, -2190,
true, 1, dNumLog, nil, nil,
tMhPar.Nome, EgtDoorsMsg)
end
if tMhPar.stype == 4 then
-- chisel (solo controllo diametro utensile)
if not tMhPar.est then
tMhPar.d0, dNumLog, sMessToOut, dMaxMat0 = CheckTool( (tMhPar.ech and tMhPar.d0), false, 1, tMhPar.d0, sLG,
nLGi, sMessToOut, tMhPar.T3, 460, -2187,
false, 3, dNumLog, dMaxMat, nil,
tMhPar.Nome, EgtDoorsMsg)
end
end
-- check utensile svuotatura body
if not tMhPar.est then
tMhPar.d, dNumLog, sMessToOut, tMhPar.T = CheckTool( tMhPar.d, true, 1, tMhPar.d, sLMV,
nLMVi, sMessToOut, tMhPar.T, 655, -2189,
true, 1, dNumLog, nil, nil,
tMhPar.Nome, EgtDoorsMsg)
end
-- check utensile antischeggia body
if not tMhPar.est then
tMhPar.d2, dNumLog, sMessToOut, tMhPar.T = CheckTool( tMhPar.d2, true, 1, tMhPar.d2, sLAV,
nLAVi, sMessToOut, tMhPar.T, 657, -2190,
true, 1, dNumLog, nil, nil,
tMhPar.Nome, EgtDoorsMsg)
end
-- chisel (solo controllo diametro utensile)
if not tMhPar.est then
tMhPar.d0, dNumLog, sMessToOut, dMaxMat0 = CheckTool( (tMhPar.ech and tMhPar.d0), false, 1, tMhPar.d0, sLGV,
nLGVi, sMessToOut, tMhPar.T, 460, -2188,
false, 3, dNumLog, dMaxMat, nil,
tMhPar.Nome, EgtDoorsMsg)
end
-- pivot intermediate speciale
elseif tMhPar.type == 2 then -- tipo OffsetIntermediate
if tMhPar.stype == 4 then -- geometria simile al sottotipo 1
-- svuotatura mortise concatenata
if not tMhPar.est then
tMhPar.d, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( tMhPar.d, (not tMhPar.jn), 1, tMhPar.d, sLM,
nLMi, sMessToOut, tMhPar.T2, 461, -2194,
true, 2, dNumLog, dMaxMat, tMhPar.jn,
tMhPar.Nome, EgtDoorsMsg)
end
-- svuotatura mortise disgiunta
if not tMhPar.est then
tMhPar.d3, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( tMhPar.d3, true, 1, tMhPar.d3, sLMM,
nLMMi, sMessToOut, tMhPar.T2, 461, -2193,
true, 2, dNumLog, dMaxMat, (not tMhPar.jn),
tMhPar.Nome, EgtDoorsMsg)
end
-- check utensile antischeggia face concatenato a mortise
if not tMhPar.est then
tMhPar.d2, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( tMhPar.d2, (not tMhPar.jn), 1, tMhPar.d2, sLA,
nLAi, sMessToOut, tMhPar.T2, 462, -2196,
true, 1, dNumLog, dMaxMat, tMhPar.jn,
tMhPar.Nome, EgtDoorsMsg)
end
-- check utensile antischeggia face disgiunto a mortise
if not tMhPar.est then
tMhPar.d2, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( tMhPar.d2, true, 1, tMhPar.d2, sLA,
nLAi, sMessToOut, tMhPar.T2, 462, -2196,
true, 1, dNumLog, dMaxMat, (not tMhPar.jn),
tMhPar.Nome, EgtDoorsMsg)
end
-- check utensile svuotatura face
if not tMhPar.est then
tMhPar.d, dNumLog, sMessToOut, tMhPar.T, dMaxMat = CheckTool( tMhPar.d, true, 1, tMhPar.d, sLM,
nLMi, sMessToOut, tMhPar.T, 460, -2197,
true, 1, dNumLog, dMaxMat, nil,
tMhPar.Nome, EgtDoorsMsg)
end
-- chisel (solo controllo diametro utensile)
if not tMhPar.est then
tMhPar.d0, dNumLog, sMessToOut, dMaxMat0, dMaxMat = CheckTool( (tMhPar.ech and tMhPar.d0), false, 1, tMhPar.d0, sLG,
nLGi, sMessToOut, tMhPar.T, 460, -2192,
false, 3, dNumLog, dMaxMat, nil,
tMhPar.Nome, EgtDoorsMsg)
end
else -- sottotipo 3 simile al sottotipo 2 del tipo Offset
-- check utensile svuotatura knuckle
if not tMhPar.est then
tMhPar.d3, dNumLog, sMessToOut, tMhPar.T3 = CheckTool( tMhPar.d3, true, 1, tMhPar.d3, sLM,
nLMi, sMessToOut, tMhPar.T3, 654, -2191,
true, 1, dNumLog, nil, nil,
tMhPar.Nome, EgtDoorsMsg)
end
-- check utensile antischeggia knuckle
if not tMhPar.est then
tMhPar.d4, dNumLog, sMessToOut, tMhPar.T3 = CheckTool( tMhPar.d4, true, 1, tMhPar.d4, sLA,
nLAi, sMessToOut, tMhPar.T3, 656, -2190,
true, 1, dNumLog, nil, nil,
tMhPar.Nome, EgtDoorsMsg)
end
-- check utensile svuotatura body
if not tMhPar.est then
tMhPar.d, dNumLog, sMessToOut, tMhPar.T = CheckTool( tMhPar.d, true, 1, tMhPar.d, sLMV,
nLMVi, sMessToOut, tMhPar.T, 655, -2189,
true, 1, dNumLog, nil, nil,
tMhPar.Nome, EgtDoorsMsg)
end
-- check utensile antischeggia body
if not tMhPar.est then
tMhPar.d2, dNumLog, sMessToOut, tMhPar.T = CheckTool( tMhPar.d2, true, 1, tMhPar.d2, sLAV,
nLAVi, sMessToOut, tMhPar.T, 657, -2190,
true, 1, dNumLog, nil, nil,
tMhPar.Nome, EgtDoorsMsg)
end
-- chisel (solo controllo diametro utensile)
if not tMhPar.est then
tMhPar.d0, dNumLog, sMessToOut, dMaxMat0 = CheckTool( (tMhPar.ech and tMhPar.d0), false, 1, tMhPar.d0, sLGV,
nLGVi, sMessToOut, tMhPar.T, 460, -2188,
false, 3, dNumLog, dMaxMat, nil,
tMhPar.Nome, EgtDoorsMsg)
end
end
end
end
if dNumLog ~= 0 then
return tMhPar, dNumLog, sMessToOut
end
return tMhPar, 0, ''
end
-- Funzione di disegno
function Pivot.Draw( tPivotParam, bPreview, bRunByCompo, nDrawMach, dThickDoor)
-- Assegno le dimensioni, parametri utensili e settaggi
local L = tPivotParam.L -- lunghezza face
local H = tPivotParam.H -- larghezza face
local T = tPivotParam.T -- spessore face
local L3 = tPivotParam.L3 -- lunghezza Knuckle a forma di L
local H3 = tPivotParam.H3 -- altezza Knuckle a forma di L
local T3 = tPivotParam.T3 -- spessore Knuckle disgiunto
local radius = tPivotParam.rad -- raggio arrotondamento face a forma di L
local R1 = tPivotParam.R1 -- raggio arrotondamento face su singolo corner
local R1i = tPivotParam.R1i -- raggio interno per face con knockle centrale
local D_SK = tPivotParam.D_SK -- distanza partenza knuckle
local D_SK2 = tPivotParam.D_SK2 -- distanza rimanente da knuckle
local B_SK = tPivotParam.B_SK -- flag che indica il knuckle è opposto ( D_SK risulta già modificato)
local mkrev = tPivotParam.mkrev -- flag che indica se devono essere fatti anche percorsi inversi (cioè quando intermediate pivot è applicato su profilo bevel)
local d = tPivotParam.d -- diametro utensile face
local p = tPivotParam.p -- percentuale uso utensile face
local sf = tPivotParam.sf -- passo affondamento per face
local cl = tPivotParam.cl -- arrotondamento per face non a forma di L
local rf = tPivotParam.rf -- raggio arrotondamento per face non a forma di L
local clc = tPivotParam.clc -- lunghezza lato clean corner
local ccr = tPivotParam.ccr -- raggio su angolo cleancorner
local d2 = tPivotParam.d2 -- diametro utensile antischeggia per face
local mh = tPivotParam.mh -- abilitazione creazione mortasa/foro
local HB = tPivotParam.HB -- forzo foro a rimanere orizzontale
local stn = tPivotParam.stn -- pivot tipo offset adiacente al bordo porta
local stnb = tPivotParam.stnb -- pivot tipo offset adiacente al bordo porta
local tb = tPivotParam.tb -- abilitazione forza profondità foro come spessore face
local L2 = tPivotParam.L2 -- lunghezza mortise
local H2 = tPivotParam.H2 -- larghezza mortise
local T2 = tPivotParam.T2 -- spessore mortise
local d3 = tPivotParam.d3 -- diametro utensile per mortise o per knuckle singolo
local p3 = tPivotParam.p3 -- percentuale uso utensile per mortise
local s = tPivotParam.s -- passo affondamento per mortise
local posh = tPivotParam.posh -- posizione in Y del foro di tastatura
local posp = tPivotParam.posp -- posizione in X del foro di tastatura
local ptype = tPivotParam.type -- type of Pivot
local subtype = tPivotParam.stype -- sub type Pivot (1:top/bottom door, 2:top/bottom-back door, 3:top/bottom-back door, 4:top/bottom-side door)
local jn = tPivotParam.jn -- flag join paths, means use 'same tool' for face and mortise
local D = tPivotParam.D -- distance to edge per mortise, usato con face a forma di L
local D_X = tPivotParam.D_X -- delta on X pos on mortaise rispetto al centro face
local D_XT = tPivotParam.D_XT -- delta on X pos for all geometries
local D_XE = tPivotParam.D_XE -- Extra delta on X pos for all geometries
local invG = tPivotParam.invG -- flag per invertire il senso dei percorsi di lavorazione
local ech = tPivotParam.ech -- abilitazione chisel
local est = tPivotParam.est -- abilitazione materiale steel
local kbs = tPivotParam.kbs -- keep backset/thicknesss (0: none, 1: only face, 2: all)
local pbs = tPivotParam.pbs
local rp = tPivotParam.rp -- reference pivot
local backset = tPivotParam.back -- valore backset da ddf
local oribackset = tPivotParam.oriback
local posiz = tPivotParam.posiz -- valore posizione da ddf
local dhei = tPivotParam.dhei -- altezza porta
local fht = tPivotParam.fht
local fhb = tPivotParam.fhb
local drf = tPivotParam.drf
local dws = tPivotParam.Dws
local dthd = tPivotParam.dThD
local ttp = tPivotParam.TTP
local tExtraBore = {}
table.insert( tExtraBore, { tPivotParam.D4, tPivotParam.T4, tPivotParam.I4, tPivotParam.PX4, tPivotParam.PY4, tPivotParam.EB4, tPivotParam.HB4})
table.insert( tExtraBore, { tPivotParam.D5, tPivotParam.IY5, tPivotParam.T5, tPivotParam.I5, tPivotParam.PX5, tPivotParam.PY5, tPivotParam.RP5, tPivotParam.EB5, tPivotParam.EBH5, tPivotParam.HB5, tPivotParam.AR5, tPivotParam.RCI5})
table.insert( tExtraBore, { tPivotParam.D6, tPivotParam.IY6, tPivotParam.T6, tPivotParam.I6, tPivotParam.PX6, tPivotParam.PY6, tPivotParam.RP6, tPivotParam.EB6, tPivotParam.EBH6, tPivotParam.HB6, tPivotParam.AR6, tPivotParam.RCI6})
table.insert( tExtraBore, { tPivotParam.D7, tPivotParam.IY7, tPivotParam.T7, tPivotParam.I7, tPivotParam.PX7, tPivotParam.PY7, tPivotParam.RP7, tPivotParam.EB7, tPivotParam.EBH7, tPivotParam.HB7, tPivotParam.AR7, tPivotParam.RCI7})
-- Assegno i nomi geometrie
local LG = tPivotParam.LG -- nome geometria face
local LM = tPivotParam.LM -- nome lavorazione face
local LA = tPivotParam.LA -- nome geometria antischeggia
local LGM = tPivotParam.LGM -- nome geometria mortise
local LMM = tPivotParam.LMM -- nome lavorazione mortise
local LGH = tPivotParam.LGH -- nome geometria foro profondo
local LH = 'Pivot_Probe'
local DM = 'DUMMY'
local CH = tPivotParam.CH -- nome suffisso lavorazione chisel
local CLH = tPivotParam.CLH -- nome geometria clean corner su lato cerniera
local CLC = tPivotParam.CLC -- nome geometria clean corner su altri lati
-- variabili per messaggi e settaggi vari
local sCompoName = tPivotParam.Nome
local nCompoNpar = tPivotParam.Npar
local sCompoPath = tPivotParam.Path
-- eventuale messaggio errore rilevato nell'adjust
local nCodAdj = tPivotParam.nCod
local sCodAdj = tPivotParam.sCod
-- variabili per messaggi di errore
local sNamePar1 = tPivotParam.N1 or 'L'
local sNamePar2 = tPivotParam.N2 or 'H'
local sNamePar3 = tPivotParam.N3 or 'T'
local sNamePar4 = tPivotParam.N4 or 'd'
local sNamePar5 = tPivotParam.N5 or 'p'
local sNamePar7 = tPivotParam.N7 or 'd2'
local sNamePar8 = tPivotParam.N8 or 'L2'
local sNamePar9 = tPivotParam.N9 or 'H2'
local sNamePar10 = tPivotParam.N10 or 'T2'
local sNamePar11 = tPivotParam.N11 or 'd3'
local sNamePar12 = tPivotParam.N12 or 'p3'
local sNamePar13 = tPivotParam.N13 or 's'
local sNamePar22 = tPivotParam.N22 or 'D'
local sNamePar23 = tPivotParam.N23 or 'DX'
local sNamePar24 = tPivotParam.N24 or 'L3'
local sNamePar25 = tPivotParam.N25 or 'H3'
local sNamePar26 = tPivotParam.N26 or 'radius'
local sNamePar27 = tPivotParam.N27 or 'sf'
local sNamePar28 = tPivotParam.N28 or 'rf'
local sNamePar29 = tPivotParam.N26 or 'R1'
local sNamePar30 = tPivotParam.N27 or 'D_SK'
local sNamePar31 = tPivotParam.N28 or 's3'
local sNamePar32 = tPivotParam.N29 or 'd4'
local sNamePar33 = tPivotParam.N30 or 'T3'
local sNamePar34 = tPivotParam.N31 or 'Backset'
local sNamePar35 = tPivotParam.N35 or 'clc'
local sNamePar36 = tPivotParam.N36 or 'ccr'
-- RunByComponetInterface
local RC = true
-- Messaggi codice errori
local EM = ' '
local EC = 0
local ErrorBase = 2100
-- variabili che abilitano la creazione della geometria
local bMakeFaceGeom = true
local bMakeMortGeom = true
local bMakeKnuckle = true
local bMakeBody = true
-- variabili dei percorsi geometrici
local nGeom1, nAS1, nAS2, nAS3, nAS4, nAS5
local nPkToJoin1, nPkToJoin3
local nGeom2b, nAS1b, nAS2b, nAS3b, nAS4b
local nPkToJoin2b, nPkToJoin4b
local nGeom2
local nPkToJoin2, nPkToJoin4
local nPkToJoin, nPkToJoin_rev
local dPosMortise = D_X
if not bRunByCompo then -- controllo se lanciato da componente
RC = false
end
if subtype == 1 and ( not L or not H) then
bMakeFaceGeom = false
bMakeKnuckle = false
bMakeBody = false
clc = nil
CLC = nil
CLH = nil
elseif (not L or not H) and (not L3 or not H3) then
bMakeFaceGeom = false
bMakeKnuckle = false
bMakeBody = false
else
if (not L or not H) then -- se non è presente il body
bMakeBody = false
elseif not L3 or not H3 or L3 <= 0 or H3 <= 0 then -- se non è presente il knuckle o ha valori nulli
bMakeKnuckle = false
end
end
if est then
bMakeMortGeom = false
bMakeKnuckle = false
end
-- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi
if not T then
T = 0
end
if not T3 then
T3 = 0
tPivotParam.T3 = T3
end
-- se tipo intermediate standard e L3 nullo setto i parametri dei raccordi
if ptype == 2 and subtype == 1 and L3 == 0 then
D_SK = 0
tPivotParam.D_Y = D
rf = radius
tPivotParam.rf = rf
tPivotParam.cl = 3
cl = 3
end
-- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili
if bMakeFaceGeom and bMakeBody and cl > 0 then
if L >= H then
if rf > (H/2) then
rf = (H/2)
tPivotParam.rf = rf
end
else
if rf > (L/2) then
rf = (L/2)
tPivotParam.rf = rf
end
end
end
if not L2 or not H2 then -- se non ci sono i parametri dimensionali disabilito la mortasa e il foro
bMakeMortGeom = false
end
if not H2 and not T2 then -- se non ci sono i parametri dimensionali per il foro lo disabilito
bMakeMortGeom = false
mh = false
end
if mh then -- se abilitato il foro disabilito la mortasa
bMakeMortGeom = false
end
if ptype == 1 and subtype > 1 then -- se tipo offset e sottotipo diverso da 1 disabilito mortasa e foro
bMakeMortGeom = false
mh = false
elseif ptype == 2 and subtype == 3 then -- se tipo offsetIntermediate e sottotipo diverso da 1 disabilito mortasa e foro
bMakeMortGeom = false
mh = false
end
if not T2 then
T2 = 0
end
-- 0 solo geom esterna, 1 solo geom mach, 2 entrambe
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
tPivotParam.LG = LG
-- se ho abilitato solo le geometrie di lavorazione, abilito la generazione di entrambe per il contorno chisel
if nDrawMach == 1 then
nForceMakeFace = 2
end
end
local EgtDoorsMsg = require( 'EgtDoorsMsg')
-- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata
if bMakeFaceGeom and bMakeMortGeom and (cl == 1 or cl == 2) and (L-rf) < (L2+(2*abs(D_X))) then
jn = false
tPivotParam.jn = false
-- EC = 25
-- EM = string.format(EgtDoorsMsg[423],sNamePar23,EgtToUiUnits(D_X),EgtToUiUnits((L-rf-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore:
-- D_X = 0
elseif bMakeFaceGeom and bMakeMortGeom and subtype < 2 and H2 > H then
jn = false
tPivotParam.jn = false
-- EC = 28
-- EM = string.format(EgtDoorsMsg[422],sNamePar2,EgtToUiUnits(H),sNamePar9,EgtToUiUnits(H2), sCompoPath) -- il parametro 'T2' deve essere > del parametro 'T'
-- H2 = H
elseif bMakeBody and nDrawMach > 0 and d < DgMin then
EC = 1
EM = string.format(EgtDoorsMsg[400],sNamePar4,EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di
d = DgMin
elseif bMakeBody and nDrawMach > 0 and d2 and d2 < DgMin then
EC = 2
EM = string.format(EgtDoorsMsg[400],sNamePar7,EgtToUiUnits(d2),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di
d2 = DgMin
elseif bMakeMortGeom and nDrawMach > 0 and not jn and d3 and d3 < DgMin then
EC = 3
EM = string.format(EgtDoorsMsg[400],sNamePar11,EgtToUiUnits(d3),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di
d3 = DgMin
elseif bMakeBody and H <= 0 then
EC = 4
EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0
H = d/2
elseif bMakeBody and nDrawMach > 0 and H < d then
if DGD.bProoduce then
EC = 5
EM = string.format(EgtDoorsMsg[405],sNamePar2,EgtToUiUnits(H),EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere maggiore o uguale del diametro utensile
H = d
else
d = H - 0.002
end
elseif bMakeMortGeom and nDrawMach > 0 and jn and H2 < d then
if DGD.bProoduce then
EC = 6
EM = string.format(EgtDoorsMsg[405],sNamePar9,EgtToUiUnits(H2),EgtToUiUnits(d), sCompoPath) -- il parametro 'H2' deve essere maggiore o uguale del diametro utensile
H2 = d
else
d = H2 - 0.002
end
elseif bMakeMortGeom and nDrawMach > 0 and not jn and H2 < d3 then
if DGD.bProoduce then
EC = 7
EM = string.format(EgtDoorsMsg[405],sNamePar9,EgtToUiUnits(H2),EgtToUiUnits(d3), sCompoPath) -- il parametro 'H2' deve essere maggiore o uguale del diametro utensile
H2 = d3
else
d3 = H2 - 0.002
end
elseif bMakeBody and L <= 0 then
EC = 8
EM = string.format(EgtDoorsMsg[401],sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L' deve essere > 0
L = d
elseif bMakeBody and nDrawMach > 0 and L <= d then
if DGD.bProoduce then
EC = 9
EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar4,EgtToUiUnits(d), sCompoPath) -- il parametro 'L' deve essere maggiore del diametro utensile
L = d + 0.002
else
d = L - 0.002
end
elseif bMakeBody and nDrawMach > 0 and d2 and L <= d2 then
if DGD.bProoduce then
EC = 10
EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar7,EgtToUiUnits(d2), sCompoPath) -- il parametro 'L' deve essere maggiore del diametro utensile
L = d2 + 0.002
else
d2 = L - 0.002
end
elseif bMakeMortGeom and nDrawMach > 0 and jn and L2 <= d then
if DGD.bProoduce then
EC = 11
EM = string.format(EgtDoorsMsg[402],sNamePar8,EgtToUiUnits(L2),sNamePar4,EgtToUiUnits(d), sCompoPath) -- il parametro 'L2' deve essere maggiore del diametro utensile
L2 = d + 0.002
else
d = L2 - 0.002
end
elseif bMakeMortGeom and nDrawMach > 0 and not jn and L2 <= d3 then
if DGD.bProoduce then
EC = 12
EM = string.format(EgtDoorsMsg[402],sNamePar8,EgtToUiUnits(L2),sNamePar11,EgtToUiUnits(d3), sCompoPath) -- il parametro 'L2' deve essere maggiore del diametro utensile
L2 = d3 + 0.002
else
d3 = L2 - 0.002
end
elseif bMakeMortGeom and nDrawMach > 0 and s and s <= 0 then
EC = 13
EM = string.format(EgtDoorsMsg[401],sNamePar13,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0
s = d
elseif bMakeBody and nDrawMach > 0 and ( p < PtMin or p > PtMax) then
EC = 14
EM = string.format(EgtDoorsMsg[403],sNamePar5,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra
p = 0.8
elseif bMakeKnuckle and nDrawMach > 0 and p3 and ( p3 < PtMin or p3 > PtMax) then
EC = 15
EM = string.format(EgtDoorsMsg[403],sNamePar12,p3,PtMin,PtMax, sCompoPath) -- il parametro 'p3' deve essere compreso tra
p3 = 0.8
elseif bMakeMortGeom and nDrawMach > 0 and not jn and ( p3 < PtMin or p3 > PtMax) then
EC = 16
EM = string.format(EgtDoorsMsg[403],sNamePar12,p3,PtMin,PtMax, sCompoPath) -- il parametro 'p3' deve essere compreso tra
p3 = 0.8
elseif bMakeBody and T < 0 then
EC = 17
EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0
T = 0
elseif bMakeMortGeom and not dws and T2 <= T then
EC = 18
EM = string.format(EgtDoorsMsg[407],sNamePar10,EgtToUiUnits(T2),sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T2' deve essere > del parametro 'T'
T2 = T + 0.01
elseif bMakeFaceGeom and cl > 0 and rf < 0 then
EM = string.format(EgtDoorsMsg[404],sNamePar28,EgtToUiUnits(rf), sCompoPath) -- il parametro 'rf' deve essere >= 0
EC = 19
rf = H/2
elseif bMakeBody and cl > 0 and abs(rf - (H/2)) < GEO.EPS_SMALL and L <= H then
EC = 20
EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'L' deve essere > 'H'
L = H+5
elseif bMakeBody and cl > 0 and rf < (H/2) and L <= (rf*2) then
EC = 21
EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar28..'*2',EgtToUiUnits(rf)*2, sCompoPath) -- il parametro 'L' deve essere > 'rf*2'
L = (rf*2)+5
elseif bMakeFaceGeom and bMakeMortGeom and (cl == 1 or cl == 2) and (L-rf) < L2 then
EC = 22
EM = string.format(EgtDoorsMsg[410],sNamePar1,EgtToUiUnits(L),sNamePar8,sNamePar28,EgtToUiUnits(L2+rf), sCompoPath) -- il parametro 'L' deve essere >= 'L2' + 'rf'
L = rf+L2+5
elseif bMakeFaceGeom and bMakeMortGeom and cl == 3 and (L-(rf*2)) < L2 then
EC = 23
EM = string.format(EgtDoorsMsg[410],sNamePar1,EgtToUiUnits(L),sNamePar8,sNamePar28..'*2',EgtToUiUnits(L2+(rf*2)), sCompoPath) -- il parametro 'L' deve essere >= 'L2' + 'rf*2'
L = (rf*2)+L2+5
elseif bMakeFaceGeom and bMakeMortGeom and cl == 3 and (L-(rf*2)) < (L2+(2*abs(D_X))) then
EC = 24
EM = string.format(EgtDoorsMsg[423],sNamePar23,EgtToUiUnits(D_X),EgtToUiUnits((L-(rf*2)-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore:
D_X = 0
elseif bMakeFaceGeom and bMakeMortGeom and cl == 0 and L < L2 then
EC = 26
EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar8,EgtToUiUnits(L2), sCompoPath) -- il parametro 'L' deve essere > 'L2'
L = L2+5
elseif bMakeFaceGeom and bMakeMortGeom and cl == 0 and subtype < 2 and L < (L2+(2*abs(D_X))) then
EC = 27
EM = string.format(EgtDoorsMsg[423],sNamePar23,EgtToUiUnits(D_X),EgtToUiUnits((L-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore:
D_X = 0
elseif bMakeFaceGeom and bMakeMortGeom and ptype ~= 3 and subtype < 2 then
if not D then
EC = 29
EM = string.format(EgtDoorsMsg[591],sNamePar22, sCompoPath) -- il parametro 'D' non è definito
D = 0
elseif (H-H2) < 2*D then
EC = 30
EM = string.format(EgtDoorsMsg[423],sNamePar22,EgtToUiUnits(D),EgtToUiUnits((H-H2)/2), sCompoPath) -- il parametro 'D' é troppo grande, max valore:
D = 0
end
elseif ptype ~= 3 then
if bMakeBody and subtype < 2 and bShiftBackSetPos and backset <= 0 then
EC = 31
EM = string.format(EgtDoorsMsg[401],sNamePar34,EgtToUiUnits(backset), sCompoPath) -- il parametro 'Backset' deve essere > 0
backset = d/2
elseif bMakeBody and subtype < 2 and not bShiftBackSetPos and backset <= H/2 then
EC = 32
EM = string.format(EgtDoorsMsg[407],sNamePar34,EgtToUiUnits(backset),'H/2',EgtToUiUnits(H/2), sCompoPath) -- il parametro 'Backset' deve essere > 'H/2'
backset = H
elseif bMakeFaceGeom then
if bMakeKnuckle and not H3 then
EC = 33
EM = string.format(EgtDoorsMsg[591],sNamePar25, sCompoPath) -- il parametro 'H3' non è definito
H3 = H*1.5
elseif bMakeKnuckle and not L3 then
EC = 34
EM = string.format(EgtDoorsMsg[591],sNamePar24, sCompoPath) -- il parametro 'L3' non è definito
L3 = L/2
elseif bMakeBody and not radius then
EC = 35
EM = string.format(EgtDoorsMsg[592],sNamePar26) -- il parametro 'Radius' non è definito
radius = H/2
elseif ( subtype < 2 or subtype > 3) and bMakeKnuckle and bMakeBody and H3 <= H then
EC = 36
EM = string.format(EgtDoorsMsg[407],sNamePar25,EgtToUiUnits(H3),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H3' deve essere > 'H'
H3 = H*1.5
elseif bMakeKnuckle and bMakeBody and subtype < 3 and L3 >= L then
EC = 37
EM = string.format(EgtDoorsMsg[406],sNamePar24,EgtToUiUnits(L3),sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L3' deve essere < 'L'
L3 = L/2
elseif bMakeBody and subtype ~= 2 and radius > H/2 then
EC = 38
EM = string.format(EgtDoorsMsg[406],sNamePar26,EgtToUiUnits(radius),'H/2',EgtToUiUnits(H/2), sCompoPath) -- il parametro 'radius' deve essere < 'H/2'
radius = H/2
elseif bMakeBody and subtype == 2 and radius >= H then
EC = 39
EM = string.format(EgtDoorsMsg[406],sNamePar26,EgtToUiUnits(radius),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'radius' deve essere < 'H/2'
radius = H
elseif bMakeKnuckle and bMakeBody and subtype < 3 and L-L3 < radius then
EC = 40
EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),'L3+Radius',EgtToUiUnits(L3+radius), sCompoPath) -- il parametro 'L' deve essere > 'L3+R'
L = L3+radius
elseif bMakeBody and R1 >= L-radius then
EC = 41
EM = string.format(EgtDoorsMsg[456],sNamePar29,EgtToUiUnits(R1),'L-Radius',EgtToUiUnits(L-radius), sCompoPath) -- il parametro 'R1' deve essere <= 'L-radius'
R1 = L-radius-1.5
elseif subtype < 2 and R1 >= H3 then
EC = 42
EM = string.format(EgtDoorsMsg[406],sNamePar29,EgtToUiUnits(R1),'H3',EgtToUiUnits(H3), sCompoPath) -- il parametro 'R1' deve essere < 'H3'
R1 = H3-1.5
elseif bMakeBody and ( subtype == 1 or (ptype == 2 and subtype == 4)) and D_SK ~= 0 and not B_SK and D_SK2 ~= 0 and
( (R1i + radius) - (L-D_SK-L3)) > GEO.EPS_SMALL then
EC = 43
EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),'D_SK+L3+Radius+R1',EgtToUiUnits(D_SK+L3+radius+R1i), sCompoPath) -- il parametro 'L' deve essere > 'D_SK+L3+Radius+R1'
L = D_SK+L3+radius+R1+0.1
elseif bMakeBody and ( subtype == 1 or (ptype == 2 and subtype == 4)) and D_SK > 0 and (R1i + radius) > D_SK then
EC = 44
EM = string.format(EgtDoorsMsg[407],sNamePar30,EgtToUiUnits(D_SK),'Radius+R1',EgtToUiUnits(radius+R1i), sCompoPath) -- il parametro 'D_SK' deve essere > 'Radius+R1'
D_SK = radius+R1+0.1
elseif bMakeKnuckle and bMakeBody and ( subtype == 1 or (ptype == 2 and subtype == 4)) and D_SK > 0 and R1i > (H3-H) then
EC = 45
EM = string.format(EgtDoorsMsg[406],sNamePar29,EgtToUiUnits(R1i),'H3-H (Backset)',EgtToUiUnits(H3-H), sCompoPath) -- il parametro 'R1' deve essere < 'H3-H'
R1i = 0
R1 = 0
elseif bMakeKnuckle and nDrawMach > 0 and subtype == 4 and L3 and d3 and L3 < (d3/2) then
EC = 46
EM = string.format(EgtDoorsMsg[407],sNamePar24,EgtToUiUnits(L3),'d3/2',EgtToUiUnits(d3/2), sCompoPath) -- il parametro 'L3' deve essere > 'd3/2'
L3 = d3/2+0.1
elseif bMakeKnuckle and nDrawMach > 0 and subtype < 4 and L3 and d3 and L3 <= d3 then
EC = 47
EM = string.format(EgtDoorsMsg[407],sNamePar24,EgtToUiUnits(L3),sNamePar11,EgtToUiUnits(d3), sCompoPath) -- il parametro 'L3' deve essere > 'd3'
L3 = d3+0.1
elseif bMakeKnuckle and nDrawMach > 0 and subtype < 4 and not( stn or stnb) and L3 and d and L3 <= d then
EC = 48
EM = string.format(EgtDoorsMsg[407],sNamePar24,EgtToUiUnits(L3),sNamePar4,EgtToUiUnits(d), sCompoPath) -- il parametro 'L3' deve essere > 'd'
L3 = d+0.1
elseif bMakeKnuckle and nDrawMach > 0 and subtype < 4 and not( stn or stnb) and L3 and d2 and L3 <= ( d2 + 0.2 + ((d2/8)/tan(30))) then
EC = 49
EM = string.format(EgtDoorsMsg[407],sNamePar24,EgtToUiUnits(L3),'min large',EgtToUiUnits( d2 + 0.2 + ((d2/8)/tan(30))), sCompoPath) -- il parametro 'L3' deve essere > della componente minima
L3 = ( d2 + 0.2 + ((d2/8)/tan(30))) + 0.1
end
end
elseif bMakeBody and nDrawMach > 0 and sf and sf <= 0 then
EC = 50
EM = string.format(EgtDoorsMsg[401],sNamePar27,EgtToUiUnits(sf), sCompoPath) -- il parametro 'sf' deve essere > 0
sf = T
elseif bMakeKnuckle and T3 and T3 < 0 then
EC = 51
EM = string.format(EgtDoorsMsg[404],sNamePar33,EgtToUiUnits(T3), sCompoPath) -- il parametro 'T3' deve essere >= 0
T3 = 0
elseif bMakeKnuckle and nDrawMach > 0 and s3 and s3 <= 0 then
EC = 52
EM = string.format(EgtDoorsMsg[401],sNamePar31,EgtToUiUnits(s3), sCompoPath) -- il parametro 's3' deve essere > 0
s3 = T3
elseif bMakeKnuckle and nDrawMach > 0 and d4 and d4 < DgMin then
EC = 53
EM = string.format(EgtDoorsMsg[400],sNamePar32,EgtToUiUnits(d4),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di
d4 = DgMin
elseif bMakeFaceGeom and ( CLH or CLC) and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then
EC = 54
EM = string.format(EgtDoorsMsg[407],sNamePar35,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
local Lg, Dm
local sRequireCompoName
local hint_2
local nSubType = tPivotParam.stype
local dAsDiam = tPivotParam.d2
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
if ptype ~= 3 then -- se non è center hung
if subtype == 1 then -- se sottotipo 1 dei tipi rimanenti
if ptype == 2 and L3 == 0 then -- se intermediate con knuckle nullo lancio il componente usato per center hung
sRequireCompoName = '_Latch'
else
sRequireCompoName = '_PivotL'
end
else
if ptype == 2 then -- se tipo intermediate
if subtype == 4 then
tPivotParam.stype = 1
tPivotParam.d2 = nil
sRequireCompoName = '_PivotL'
else
sRequireCompoName = '_OPivot'
end
tPivotParam.nextSub = subtype
else -- altrimenti tipo offset
sRequireCompoName = '_OPivot'
end
end
else -- altrimenti è center hung, lancio componete tipo concealed hinge
sRequireCompoName = '_Latch'
end
if bMakeFaceGeom then
if mh then
tPivotParam.jn = false
end
tPivotParam.D_X = dPosMortise + D_SK
-- lancio il primo componente base
MHgen = require( sRequireCompoName)
nGeom1, nPkToJoin1, nAS1, nAS2, nPkToJoin3, nAS3, nAS4,
nGeom2b, nPkToJoin2b, nAS1b, nAS2b, nPkToJoin4b, nAS3b, nAS4b = MHgen.Draw( EC, EM, tPivotParam, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor)
tPivotParam.stype = nSubType
tPivotParam.d2 = dAsDiam
-- Clean corner
if nDrawMach >= 0 then -- se abilitata geometria
local CLC1
if sRequireCompoName == '_Latch' then -- se center hung o intermediate chiuso
if ptype == 3 then -- se è center hung
if cl ~= 3 or ( cl == 3 and rf > 0) then -- se c'è almeno un raccordo
if CLC and clc and clc > 0 and clc < H and clc < L then
CLC1 = MakeClcPath(clc, ccr, CLC, Lg, -T, (invG == -1))
if CLC1 then
-- se mantiene backset anche su face
if kbs and kbs > 0 then
local sKeepMode = 'c' -- setto di default per mantenere il centro spessore
EgtSetInfo( CLC1, 'KeepBackSet', sKeepMode)
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( CLC1, 'ProbeSide', '1')
end
if cl == 1 then -- cava arrotondata a sinistra
-- angolo x+y+
local CLC2 = EgtCopyGlob( CLC1, Lg)
EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), -90)
EgtMove( CLC1, Point3d((L/2)-(rf/2),(H/2),0) - ORIG())
-- angolo x+y-
EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), 180)
EgtMove( CLC2, Point3d((L/2)-(rf/2),-(H/2),0) - ORIG())
--[[
if rf <= 0 then
-- angolo x-y-
local CLC3 = EgtCopyGlob( CLC1, Lg)
EgtMove( CLC3, Point3d(-(L/2)+(rf/2),-(H/2),0) - ORIG()) -- mi porto in posizione originaria
EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180)
EgtMove( CLC3, Point3d(-(L/2)-(rf/2),-(H/2),0) - ORIG())
-- angolo x-y+
local CLC4 = EgtCopyGlob( CLC1, Lg)
EgtMove( CLC4, Point3d(-(L/2)+(rf/2),-(H/2),0) - ORIG()) -- mi porto in posizione originaria
EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90)
EgtMove( CLC4, Point3d(-(L/2)-(rf/2),(H/2),0) - ORIG())
end
]]--
elseif cl == 2 then -- cava arrotondata a destra
-- angolo x-y-
local CLC2 = EgtCopyGlob( CLC1, Lg)
EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 90)
EgtMove( CLC1, Point3d(-(L/2)+(rf/2),-(H/2),0) - ORIG())
-- angolo x-y+
EgtMove( CLC2, Point3d(-(L/2)+(rf/2),(H/2),0) - ORIG())
--[[
if rf <= 0 then
-- angolo x+y+
local CLC3 = EgtCopyGlob( CLC1, Lg)
EgtMove( CLC3, Point3d((L/2)-(rf/2),(H/2),0) - ORIG()) -- mi porto in posizione originaria
EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180)
EgtMove( CLC3, Point3d((L/2)+(rf/2),(H/2),0) - ORIG())
-- angolo x+y-
local CLC4 = EgtCopyGlob( CLC1, Lg)
EgtMove( CLC4, Point3d((L/2)-(rf/2),(H/2),0) - ORIG()) -- mi porto in posizione originaria
EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90)
EgtMove( CLC4, Point3d((L/2)+(rf/2),-(H/2),0) - ORIG())
end
]]--
else
-- 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
end
else -- altrimenti è intermediate chiuso
if radius <= 0 then -- se non c'è un raccordo
if CLH and clc and clc > 0 and clc < H and clc < L then
CLC1 = MakeClcPath(clc, ccr, CLH, Lg, -T, (invG == -1))
if CLC1 then
-- se mantiene backset anche su face
if kbs and kbs > 0 then
local sKeepMode = 'w' -- se pivot a L setto 'w' per mantenere il backset su wide side
EgtSetInfo( CLC1, 'KeepBackSet', sKeepMode)
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( CLC1, 'ProbeSide', '1')
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
end
elseif sRequireCompoName == '_PivotL' then -- se offset o intermediate
if ( CLC or CLH) and clc and clc > 0 and clc < H and clc < L then
local sLblGeom
if ptype == 1 then -- se è offset
sLblGeom = CLC
else -- altrimenti è intermediate
sLblGeom = CLH
end
if sLblGeom then
if radius <= 0 then -- se non c'è un raccordo da ddf
CLC1 = MakeClcPath(clc, ccr, sLblGeom, Lg, -T, (invG == -1))
if CLC1 then
-- se mantiene backset anche su face
if kbs and kbs > 0 then
local sKeepMode = 'w' -- se pivot a L setto 'w' per mantenere il backset su wide side
EgtSetInfo( CLC1, 'KeepBackSet', sKeepMode)
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( CLC1, 'ProbeSide', '1')
end
if D_SK > 0 and D_SK2 > 0 then -- se ho knuckle centrato
-- angolo x+y+
local CLC2 = EgtCopyGlob( CLC1, Lg)
EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90)
EgtMove( CLC2, Point3d((L3/2)+D_SK,(H/2),0) - ORIG())
-- angolo x+y-
local CLC3 = EgtCopyGlob( CLC1, Lg)
EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180)
EgtMove( CLC3, Point3d((L3/2)+D_SK,-(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-(L3/2)-D_SK),-(H/2),0) - ORIG())
-- angolo x-y+
EgtMove( CLC1, Point3d(-(L-(L3/2)-D_SK),(H/2),0) - ORIG())
elseif D_SK > 0 then -- se knuckle opposto
-- angolo x+y+
local CLC2 = EgtCopyGlob( CLC1, Lg)
EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90)
EgtMove( CLC2, Point3d((L-(L3/2)),(H/2),0) - ORIG())
-- angolo x+y-
EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 180)
EgtMove( CLC1, Point3d((L-(L3/2)),-(H/2),0) - ORIG())
elseif D_SK == 0 then -- se forma L classica
local CLC4 = EgtCopyGlob( CLC1, Lg)
-- angolo x-y-
EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 90)
EgtMove( CLC1, Point3d(-(L-(L3/2)),-(H/2),0) - ORIG())
-- angolo x-y+
EgtMove( CLC4, Point3d(-(L-(L3/2)),(H/2),0) - ORIG())
end
end
end
if R1 <= 0 and ( D_SK == 0 or D_SK2 == 0) then -- se non c'è raccordo angolo singolo
CLC1 = MakeClcPath(clc, ccr, sLblGeom, Lg, -T, (invG == -1))
if CLC1 then
-- se mantiene backset anche su face
if kbs and kbs > 0 then
local sKeepMode = 'w' -- se pivot a L setto 'w' per mantenere il backset su wide side
EgtSetInfo( CLC1, 'KeepBackSet', sKeepMode)
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( CLC1, 'ProbeSide', '1')
end
if D_SK == 0 then -- se forma L classica
-- angolo x+y-
EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 180)
EgtMove( CLC1, Point3d((L3/2),-(H/2),0) - ORIG())
else -- se L opposta
-- angolo x-y-
EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 90)
EgtMove( CLC1, Point3d(-(L3/2),-(H/2),0) - ORIG())
end
end
end
end
end
end
end
else
-- disattivo il join dei percorsi
jn = false
tPivotParam.jn = false
end
if bMakeMortGeom then
tPivotParam.D_X = dPosMortise
-- lancio il secondo componente base
if ptype == 2 and subtype == 4 then -- se tipo intermediate sottotipo 4
sRequireCompoName = '_PivotL'
tPivotParam.nextSub = 1
else
tLocalTb = tPivotParam
sRequireCompoName = '_Mortise'
end
MHgen = require( sRequireCompoName)
nGeom2, nPkToJoin2, nPkToJoin4 = MHgen.Draw( EC, EM, tPivotParam, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor)
if ptype == 2 and subtype == 4 then -- se tipo intermediate sottotipo 4
nAS5 = nPkToJoin4
nPkToJoin4 = nil
end
elseif mh and LGH then -- se devo fare il foro
-- disattivo il join dei percorsi
jn = false
tPivotParam.jn = false
local dExtraDepth = 0
nGeom2 = EgtCircle( Lg, Point3d(0,0,0), H2/2 , GDB_RT.LOC)
-- se foro deve rimanere orizzontale ed è applicato su fianco bevel, calcolo la profondità aggiuntiva
if HB and mkrev then
if bMakeFaceGeom then -- se esiste face
if not DGC.Bwd or DGC.Bwd <= 1 then -- se backset non parto dalla dimensione wide
dExtraDepth = H/2 * TAN3
end
end
end
EgtModifyCurveThickness( nGeom2, -(T2+dExtraDepth))
EgtSetName( nGeom2, LGH)
-- se mantiene backset anche su mortise
if kbs and kbs > 1 then
local sKeepMode = 'c' -- setto di default per mantenere il centro spessore
if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wide side
sKeepMode = 'w'
end
EgtSetInfo( nGeom2, 'KeepBackSet', sKeepMode)
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( nGeom2, 'ProbeSide', '1')
end
if HB then
EgtSetInfo( nGeom2,'SideDoor','LockLH')
end
end
-- se ci sono i percorsi antischeggia
if EC == 0 and ( nAS1 or nAS2 or nAS3 or nAS4 or nAS5) then
-- se mantiene backset anche su face
if kbs and kbs > 0 then
local sKeepMode = 'c' -- setto di default per mantenere il centro spessore
if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wide side
sKeepMode = 'w'
end
if nAS1 then
EgtSetInfo( nAS1, 'KeepBackSet', sKeepMode)
end
if nAS2 then
EgtSetInfo( nAS2, 'KeepBackSet', sKeepMode)
end
if nAS3 then
EgtSetInfo( nAS3, 'KeepBackSet', sKeepMode)
end
if nAS4 then
EgtSetInfo( nAS4, 'KeepBackSet', sKeepMode)
end
if nAS5 then
EgtSetInfo( nAS5, 'KeepBackSet', sKeepMode)
end
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
if nAS1 then
EgtSetInfo( nAS1, 'ProbeSide', '1')
end
if nAS2 then
EgtSetInfo( nAS2, 'ProbeSide', '1')
end
if nAS3 then
EgtSetInfo( nAS3, 'ProbeSide', '1')
end
if nAS4 then
EgtSetInfo( nAS4, 'ProbeSide', '1')
end
if nAS5 then
EgtSetInfo( nAS5, 'ProbeSide', '1')
end
end
end
-- se ci sono i percorsi della mortasa li sposto nella posizione predefinita
if EC == 0 and ( nGeom2 or nPkToJoin2 or nPkToJoin4) then
if ptype ~= 3 then -- se pivot a L muovo i percorsi della mortasa in X e Y
if not( ptype == 2 and subtype == 4) then
if nGeom2 then
if L3 == 0 then
EgtMove( nGeom2, Point3d(D_X,D,0) - ORIG())
else
EgtMove( nGeom2, Point3d((-(((L or 0)-(L3 or 0))/2)+D_SK+D_X),D,0) - ORIG())
end
end
if nPkToJoin2 then
if L3 == 0 then
EgtMove( nPkToJoin2, Point3d(D_X,D,0) - ORIG())
else
EgtMove( nPkToJoin2, Point3d((-((L-L3)/2)+D_SK+D_X),D,0) - ORIG())
end
end
if nPkToJoin4 then
if L3 == 0 then
EgtMove( nPkToJoin4, Point3d(D_X,D,0) - ORIG())
else
EgtMove( nPkToJoin4, Point3d((-((L-L3)/2)+D_SK+D_X),D,0) - ORIG())
end
end
end
else -- altrimenti se pivot centerhung sposto i percorsi mortasa solo sulla X
if nGeom2 then
EgtMove( nGeom2, Point3d(D_X,0,0) - ORIG())
end
if nPkToJoin2 then
EgtMove( nPkToJoin2, Point3d(D_X,0,0) - ORIG())
end
if nPkToJoin4 then
EgtMove( nPkToJoin4, Point3d(D_X,0,0) - ORIG())
end
end
end
-- se entrambe i percorsi presenti e da lavorare con lo stesso utensile, li concateno
if jn and EC == 0 and nPkToJoin1 and nPkToJoin2 then
-- recupero la nota delle variazioni dalla geometria del face
local sVarNote = EgtGetInfo( nPkToJoin1, 'MVar')
nPkToJoin = EgtCurveCompo( Lg, {nPkToJoin1,nPkToJoin2}, true)
if nPkToJoin then
EgtSetName( nPkToJoin, LM)
EgtSetInfo( nPkToJoin, 'NotCheckDir', '1')
if sVarNote then EgtSetInfo( nPkToJoin, 'MVar', sVarNote) end
-- se mantiene backset anche su face
if kbs and kbs > 0 then
local sKeepMode = 'c' -- setto di default per mantenere il centro spessore
if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside
sKeepMode = 'w'
end
EgtSetInfo( nPkToJoin, 'KeepBackSet', sKeepMode)
EgtSetInfo( nGeom1, 'KeepBackSet', sKeepMode)
EgtSetInfo( nGeom2, 'KeepBackSet', sKeepMode)
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 + 55
EM = string.format( EgtDoorsMsg[426], sCompoPath)
end
elseif not jn and EC == 0 then -- altrimenti se non devo concatenare
-- se mantiene backset su face
if kbs and kbs == 1 and nPkToJoin1 then
local sKeepMode = 'c' -- setto di default per mantenere il centro spessore
if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside
sKeepMode = 'w'
end
EgtSetInfo( nPkToJoin1, 'KeepBackSet', sKeepMode)
EgtSetInfo( nGeom1, 'KeepBackSet', sKeepMode)
-- se mantiene backset su face e mortise
elseif kbs and kbs > 0 then
local sKeepMode = 'c' -- setto di default per mantenere il centro spessore
if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside
sKeepMode = 'w'
end
if nPkToJoin1 then
EgtSetInfo( nPkToJoin1, 'KeepBackSet', sKeepMode)
EgtSetInfo( nGeom1, 'KeepBackSet', sKeepMode)
end
if nPkToJoin2 then
EgtSetInfo( nPkToJoin2, 'KeepBackSet', sKeepMode)
EgtSetInfo( nGeom2, 'KeepBackSet', sKeepMode)
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
-- se entrambe i percorsi inversi presenti e da lavorare con lo stesso utensile, li concateno
if jn and EC == 0 and nPkToJoin3 and nPkToJoin4 then
-- recupero la nota delle variazioni dalla geometria del face
local sVarNote = EgtGetInfo( nPkToJoin3, 'MVar')
nPkToJoin_rev = EgtCurveCompo( Lg, {nPkToJoin3,nPkToJoin4}, true)
if nPkToJoin_rev then
EgtSetName( nPkToJoin_rev, (LM..'_R'))
EgtSetInfo( nPkToJoin_rev, 'NotCheckDir', '1')
if sVarNote then EgtSetInfo( nPkToJoin_rev, 'MVar', sVarNote) end
-- se mantiene backset anche su face
if kbs and kbs > 0 then
local sKeepMode = 'c' -- setto di default per mantenere il centro spessore
if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside
sKeepMode = 'w'
end
EgtSetInfo( nPkToJoin_rev, 'KeepBackSet', sKeepMode)
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( nPkToJoin_rev, 'ProbeSide', '1')
end
else
EC = ErrorBase + 56
EM = string.format( EgtDoorsMsg[425], sCompoPath)
end
elseif not jn and EC == 0 then -- altrimenti se non devo concatenare
-- se mantiene backset su face
if kbs and kbs == 1 and nPkToJoin3 then
local sKeepMode = 'c' -- setto di default per mantenere il centro spessore
if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside
sKeepMode = 'w'
end
EgtSetInfo( nPkToJoin3, 'KeepBackSet', sKeepMode)
-- se mantiene backset su face e mortise
elseif kbs and kbs > 0 then
local sKeepMode = 'c' -- setto di default per mantenere il centro spessore
if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside
sKeepMode = 'w'
end
if nPkToJoin3 then
EgtSetInfo( nPkToJoin3, 'KeepBackSet', sKeepMode)
end
if nPkToJoin4 then
EgtSetInfo( nPkToJoin4, 'KeepBackSet', sKeepMode)
end
end
if pbs and pbs > 0 and nPkToJoin3 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( nPkToJoin3, 'ProbeSide', '1')
elseif pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
if nPkToJoin3 then
EgtSetInfo( nPkToJoin3, 'ProbeSide', '1')
end
if nPkToJoin4 then
EgtSetInfo( nPkToJoin4, 'ProbeSide', '1')
end
end
end
if EC == 0 and ( nPkToJoin2b or nPkToJoin4b) then
-- se mantiene backset anche su face
if kbs and kbs > 0 then
local sKeepMode = 'c' -- setto di default per mantenere il centro spessore
if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside
sKeepMode = 'w'
end
if nPkToJoin2b then
EgtSetInfo( nPkToJoin2b, 'KeepBackSet', sKeepMode)
end
if nPkToJoin4b then
EgtSetInfo( nPkToJoin4b, 'KeepBackSet', sKeepMode)
end
EgtSetInfo( nGeom2b, 'KeepBackSet', sKeepMode)
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
if nPkToJoin2b then
EgtSetInfo( nPkToJoin2b, 'ProbeSide', '1')
end
if nPkToJoin4b then
EgtSetInfo( nPkToJoin4b, 'ProbeSide', '1')
end
EgtSetInfo( nGeom2b, 'ProbeSide', '1')
end
end
-- se ci sono i percorsi antischegia geometria body
if EC == 0 and ( nAS1b or nAS2b or nAS3b or nAS4b) then
-- se mantiene backset anche su face
if kbs and kbs > 0 then
local sKeepMode = 'c' -- setto di default per mantenere il centro spessore
if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside
sKeepMode = 'w'
end
if nAS1b then
EgtSetInfo( nAS1b, 'KeepBackSet', sKeepMode)
end
if nAS2b then
EgtSetInfo( nAS2b, 'KeepBackSet', sKeepMode)
end
if nAS3b then
EgtSetInfo( nAS3b, 'KeepBackSet', sKeepMode)
end
if nAS4b then
EgtSetInfo( nAS4b, 'KeepBackSet', sKeepMode)
end
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
if nAS1b then
EgtSetInfo( nAS1b, 'ProbeSide', '1')
end
if nAS2b then
EgtSetInfo( nAS2b, 'ProbeSide', '1')
end
if nAS3b then
EgtSetInfo( nAS3b, 'ProbeSide', '1')
end
if nAS4b then
EgtSetInfo( nAS4b, 'ProbeSide', '1')
end
end
end
-- aggiungo fori extra
if EC == 0 and nDrawMach >= 0 and subtype == 1 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
if ptype ~= 3 then
if L3 and L3 > 0 then
dPosX10 = -((L-L3)/2) + D_SK - PX10
else
dPosX10 = -PX10
end
else
dPosX10 = -PX10
end
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, HB10, ptype, 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, HB10, ptype, dws, pbs)
end
end
end
end
end
-- aggiungo foro probe
if EC == 0 and nDrawMach > 0 and posh then
local dPosProbe = ((L3-L)/2)+D_SK
if L3 == 0 then
dPosProbe = 0
end
if ptype == 2 and subtype == 3 then -- se tipo intermediate e sottotipo 3
dPosProbe = 0
end
local sPositiveSuffixProbe = ''
local sNegativeSuffixProbe = ''
local dHalfLen = 0
if posp and posp > 0 then
if ptype == 2 and subtype == 3 then -- se tipo intermediate e sottotipo 3
dHalfLen = (L3/2)
else
dHalfLen = (L/2)
end
dPosProbe = dPosProbe + dHalfLen + posp
sPositiveSuffixProbe = '_POS'
sNegativeSuffixProbe = '_NEG'
end
-- foro positivo
local pCentr = Point3d( dPosProbe,posh,0)
local hintPr
-- verifico se devo forzare direzione orizzontale o seguire il profilo
local sSideDoorInfo
if DGC.Fpd then
sSideDoorInfo = 'LockLH'
else
sSideDoorInfo = EgtIf( dl, 'LockLH', 'SideLH')
end
if not B_SK then -- se knuckle non è opposto
if rp == 'c' then
dHalfLen = 0
elseif rp == 'f' then
dHalfLen = (L3/2)+D_SK
else -- se tipo 's'
dHalfLen = (L3/2)
end
if (posiz - (dPosProbe-dHalfLen+1)) > 0 then -- se il foro ci sta
hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC)
else -- se non sta lo metto assieme al negativo
if ptype == 2 and subtype == 3 then -- se tipo intermediate e sottotipo 3
pCentr = Point3d( -dPosProbe,posh,0)
else
pCentr = Point3d( ((L3/2)+D_SK-L-( posp or 0)),posh,0)
end
hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC)
end
else -- altrimenti è opposto e posso metterlo
hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC)
end
if hintPr then
EgtModifyCurveThickness( hintPr, -10)
EgtSetName( hintPr, LH..sPositiveSuffixProbe)
EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo)
end
-- foro negativo
local dCompare = ((L3-L)/2)+D_SK
if L3 == 0 then
dCompare = 0
end
dHalfLen = 0
if ptype == 2 and subtype == 3 then -- se tipo intermediate e sottotipo 3
dCompare = 0 -- D_SK
end
if dPosProbe ~= dCompare then
if ptype == 2 and subtype == 3 then -- se tipo intermediate e sottotipo 3
dHalfLen = (L3/2)
else
dHalfLen = (L/2)
end
pCentr = Point3d((dCompare-dHalfLen-( posp or 0)) ,posh,0)
if B_SK then -- se knuckle è opposto
if rp == 's' then
dHalfLen = 0
end
if ( posiz - (dCompare-dHalfLen-( posp or 0)-1)) < dhei then -- se il foro ci sta
hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC)
else -- altrimenti non ci sta e lo metto assieme al positivo
pCentr = Point3d(((L3/2)+( posp or 0)) ,posh,0)
hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC)
end
else
if rp == 'f' then
dHalfLen = dHalfLen + L3/2 + D_SK
elseif rp == 's' then
dHalfLen = dHalfLen + L3/2
end
if ptype == 2 and subtype == 1 then
if ( posiz - (dCompare-dHalfLen-( posp or 0)-1)) < dhei then -- se il foro ci sta
hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC)
else -- altrimenti non ci sta e lo metto assieme al positivo
pCentr = Point3d(((L3/2)+D_SK+( posp or 0)),posh,0)
hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC)
end
else
hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC)
end
end
if hintPr then
EgtModifyCurveThickness( hintPr, -10)
EgtSetName( hintPr, LH..sNegativeSuffixProbe)
EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo)
end
end
end
if EC == 0 and nDrawMach > 0 and subtype == 1 then -- se abilitata geometria lavorazione
if not dws then -- se viene disposto sul lato narrow o è sulla porta(disposto sul lato stretto)
-- se la sezione strike supera 1/6 dello spessore porta (se è un frame drf vale 0.1 e crea sempre regione)
-- disegno sezione ribasso su faccia superiore/inferiore porta
if fhb > drf then
-- 1: offset type, 2: intermediate type, 3: center hung
if ptype ~= 2 then
-- setto griglia dietro per l'ingombro sicuramente esistente
EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.BACK))
local nIdSideBoxUp
if L3 > 0 then
nIdSideBoxUp = EgtRectangle2P( Lg, Point3d( (L3/2),0,H3-(H/2)), Point3d(-(L3/2),-fhb,H3-(H/2)), GDB_RT.GRID)
end
if nIdSideBoxUp then
EgtModifyCurveThickness(nIdSideBoxUp, -H3)
EgtSetName( nIdSideBoxUp, 'upper')
EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper')
end
EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP))
else
-- setto griglia dietro per l'ingombro sicuramente esistente
EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.BACK))
local nIdSideBoxUp
if L3 > 0 then
nIdSideBoxUp = EgtRectangle2P( Lg, Point3d(-(L3/2)+(H/2),0,0), Point3d((L3/2)+(H/2),fhb,0), GDB_RT.LOC)
end
if nIdSideBoxUp then
EgtModifyCurveThickness(nIdSideBoxUp, -H3)
EgtSetName( nIdSideBoxUp, 'upper')
EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper')
end
EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP))
end
end
else -- altrimenti viene lavorato 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
end
end
if EC == 0 and D_XT and D_XT ~= 0 then
EgtMove( Lg, Point3d(D_XT,0,0) - ORIG())
end
if EC == 0 and D_XE and D_XE ~= 0 then
EgtMove( Lg, Point3d(D_XE,0,0) - ORIG())
end
-- 27/12/2017 New MDC request
if EC == 0 and ptype ~= 3 then -- se tipo a L sposto in Y per avere il backset corretto
local dHeighVal = 0
local dLongVal = 0
if bShiftBackSetPos then
if ptype == 1 then -- se tipo offset
if subtype == 1 then -- se sottotipo 1
if bMakeBody then
if abs(oribackset) <= 0.001 and H then
dHeighVal = H/2
elseif H then
dHeighVal = (H - DGC.Ew)/2
end
end
elseif subtype > 1 and subtype < 4 then -- se sottotipi 2 e 3
dHeighVal = (DGD.dT/2) - backset
else -- se quarto tipo
if bMakeKnuckle then
if H then
dHeighVal = (H/2)
end
else
dHeighVal = (DGD.dT/2) - backset
end
dLongVal = posiz
end
EgtMove( Lg, Point3d(dLongVal,-dHeighVal,0) - ORIG())
else -- se tipo offset intermediate
if subtype == 1 or subtype == 4 then -- se sottotipo 1 o 4
if abs(oribackset) <= 0.001 and H then
dHeighVal = H/2
elseif H then
dHeighVal = (H - DGC.Ew)/2
end
else -- sottotipo 3
dHeighVal = (DGD.dT/2) - backset
end
EgtMove( Lg, Point3d(0,-dHeighVal,0) - ORIG())
end
else -- se backset applicato in centro a body
if ptype == 1 then -- se tipo offset
if subtype > 1 and subtype < 4 then -- se sottotipi 2 e 3
dHeighVal = (DGD.dT/2) - backset
elseif subtype == 4 then -- se sottotipo 4
if bMakeKnuckle then
dHeighVal = 0
else
dHeighVal = (DGD.dT/2) - backset
end
dLongVal = posiz
end
EgtMove( Lg, Point3d(dLongVal,-dHeighVal,0) - ORIG())
else -- se tipo offset intermediate
if subtype == 3 then -- se sottotipo 3
dHeighVal = (DGD.dT/2) - backset
end
EgtMove( Lg, Point3d(dLongVal,-dHeighVal,0) - ORIG())
end
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' ,'Pivot')
EgtSetInfo(Lg,'L' ,L)
EgtSetInfo(Lg,'H' ,H)
EgtSetInfo(Lg,'T' ,T)
EgtSetInfo(Lg,'L3' ,L3)
EgtSetInfo(Lg,'H3' ,H3)
EgtSetInfo(Lg,'T3' ,T3)
EgtSetInfo(Lg,'radius' ,radius)
EgtSetInfo(Lg,'R1' ,R1)
EgtSetInfo(Lg,'D_SK' ,D_SK)
EgtSetInfo(Lg,'D_SK2' ,D_SK2)
EgtSetInfo(Lg,'d' ,d)
EgtSetInfo(Lg,'p' ,p)
EgtSetInfo(Lg,'sf' ,sf)
EgtSetInfo(Lg,'sf3' ,sf3)
EgtSetInfo(Lg,'cl' ,cl)
EgtSetInfo(Lg,'rf' ,rf)
EgtSetInfo(Lg,'clc' ,clc)
EgtSetInfo(Lg,'ccr' ,ccr)
EgtSetInfo(Lg,'d2' ,d2)
EgtSetInfo(Lg,'mh' ,mh)
EgtSetInfo(Lg,'HB' ,HB)
EgtSetInfo(Lg,'mkrev' ,mkrev)
EgtSetInfo(Lg,'stn' ,stn)
EgtSetInfo(Lg,'stnb' ,stnb)
EgtSetInfo(Lg,'tb' ,tb)
EgtSetInfo(Lg,'L2' ,L2)
EgtSetInfo(Lg,'H2' ,H2)
EgtSetInfo(Lg,'T2' ,T2)
EgtSetInfo(Lg,'d3' ,d3)
EgtSetInfo(Lg,'p3' ,p3)
EgtSetInfo(Lg,'s' ,s)
EgtSetInfo(Lg,'invG' ,invG)
EgtSetInfo(Lg,'ech' ,ech)
EgtSetInfo(Lg,'est' ,est)
EgtSetInfo(Lg,'kbs' ,kbs)
EgtSetInfo(Lg,'pbs' ,pbs)
EgtSetInfo(Lg,'ptype' ,ptype)
EgtSetInfo(Lg,'subtype' ,subtype)
EgtSetInfo(Lg,'B_SK' ,B_SK)
EgtSetInfo(Lg,'posh' ,posh)
EgtSetInfo(Lg,'posp' ,posp)
EgtSetInfo(Lg,'rp' ,rp)
EgtSetInfo(Lg,'drf' ,drf)
EgtSetInfo(Lg,'dws' ,dws)
EgtSetInfo(Lg,'dthd' ,dthd)
EgtSetInfo(Lg,'ttp' ,ttp)
EgtSetInfo(Lg,'D_XE' ,D_XE)
EgtSetInfo(Lg,'LG' ,LG)
EgtSetInfo(Lg,'LG3' ,LG3)
EgtSetInfo(Lg,'LM' ,LM)
EgtSetInfo(Lg,'LM3' ,LM3)
EgtSetInfo(Lg,'LA' ,LA)
EgtSetInfo(Lg,'LA3' ,LA3)
EgtSetInfo(Lg,'CLC' ,CLC)
EgtSetInfo(Lg,'CLH' ,CLH)
EgtSetInfo(Lg,'LGM' ,LGM)
EgtSetInfo(Lg,'LMM' ,LMM)
EgtSetInfo(Lg,'LGH' ,LGH)
EgtSetInfo(Lg,'LH' ,LH)
EgtSetInfo(Lg,'CH' ,CH)
EgtSetInfo(Lg,'backset' ,backset)
EgtSetInfo(Lg,'oribackset' ,oribackset)
EgtSetInfo(Lg,'Path' ,sCompoPath)
if ptype ~= 3 then -- se pivot a L
local dValueDelta = 0
if rp == 'f' then -- se riferito a face side
if L3 == 0 and L then
dValueDelta = (L/2)
elseif L3 then
dValueDelta = (L3/2)+D_SK
end
elseif rp == 'c' then -- se riferito a center knuckle
dValueDelta = 0
else -- se riferito a knuckle top side
if B_SK then
if L3 == 0 and L then
dValueDelta = -(L/2)
elseif L3 then
dValueDelta = -(L3/2)
end
else
if L3 == 0 and L then
dValueDelta = (L/2)
elseif L3 then
dValueDelta = (L3/2)
end
end
end
EgtSetInfo( Lg, 'DeltaPos' , dValueDelta)
EgtSetInfo( Lg, 'AppPoint', 'Wide') -- setto una nota per indicare da quale lato far partire il punto di riferimento
EgtSetInfo( Lg, 'InserPoint', 'Edge') -- setto una nota per indicare quale punto di riferimento prendere
else
EgtSetInfo( Lg, 'AppPoint', 'Wide') -- setto una nota per indicare da quale lato far partire il punto di riferimento
EgtSetInfo( Lg, 'InserPoint', 'Center') -- setto una nota per indicare quale punto di riferimento prendere
end
-- 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 Pivot