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

485 lines
18 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
--
-- _OverHeadPocket.lua by EgalWare s.r.l. 2016.06.30
-- Autore: Filippo Monchi
-- Over Head Arm dati i valori 'L' e 'H' e 'T' e 'd' e 'p' e 'DS' e con nomi attributi
-- 2016.09.21 V1.001 FM Add warning messages
-- 2019.10.18 V2.000 FM Manage use Materials
-- 2020.05.25 V2.001 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side
-- 2021.11.24 V2.002 FM Manage side probe option if variable DGC.Pms > 2
-- 2021.11.24 V2.003 FM Manage side probe option if variable DGC.Pms > 2
-- 2022.07.27 V2.004 FM Modification to use compiled code
-- 2024.07.19 V2.005 FM Set note 'NotCheckDir' to pocketing path
-- Tavola per definizione modulo (serve ma non usata)
local _OverHeadPocket = {}
-- Intestazioni
require( 'EgtBase')
EgtEnableDebug( false)
-- per messaggi
-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua')
-- EgtAddToPackagePath( DGD.BASEDIR .. '?.lua')
local function DrawAddLineDrawCircle( 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
-- Funzione di disegno
function _OverHeadPocket.Draw( EC, EM, tOHPkt, bPreview, bRunByCompo, nDrawMach, Pz, Lg)
-- Assegno le dimensioni
local L = tOHPkt.L2
local H = tOHPkt.H2
local T = tOHPkt.T2
local d = tOHPkt.d3
local p = tOHPkt.p3
local s = tOHPkt.s
local DS = tOHPkt.DS2
local kbs = tOHPkt.kbs -- keep backset/thickness (0: none, 1: only face, 2: all)
local pbs = tOHPkt.pbs
local dws = tOHPkt.Dws
-- Assegno i nomi geometrie
local LG = tOHPkt.LGM
local LM = tOHPkt.LMM
local DM = 'DUMMY'
-- variabili per messaggi e settaggi vari
local sCompoName = tOHPkt.Nome
-- RunByComponetInterface
local RC = true
-- Variabili per risalita distaccata
local nDeltaMovX = 2
local nDeltaMovY = 2
if not bRunByCompo then -- controllo se lanciato da componente
RC = false
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
-- set variabili per compatibilità con vecchi componenti
-- step face: per compatibilità con tutti i componenti, se non è definito lo setto = alla profondità cava
if not s or abs(s) <= GEO.EPS_SMALL then
s = T
end
-- Layer
local Dm, Dor
if not Lg then
Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale
EgtSetName( Lg, sCompoName)
end
if nDrawMach > 0 then -- se abilitata geometria lavorazione
Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentatte il diametro utensile
EgtSetName( Dm, DM)
Dor = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentatte l'origine
EgtSetName( Dor, DM)
end
local hint1, hint2, hint3, hint4, hint5, hint6, hint, hintPk
-- disegno cerchio origine
if Dor then
local nCircleOri = EgtCircle( Dor, Point3d(0,0,0), d/4 , GDB_RT.LOC)
EgtSetColor( nCircleOri, NAVY())
end
if nDrawMach ~= 1 then -- se abilitata geometria esterna
hint1 = DrawAddLineDrawCircle( Point3d(0,H/2,0), Point3d(L/2,H/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED())
hint2 = DrawAddLineDrawCircle( Point3d(L/2,H/2,0), Point3d(L/2,-(H/2),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED())
hint3 = DrawAddLineDrawCircle( Point3d(L/2,-(H/2),0), Point3d(-L/2,-(H/2),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED())
hint4 = DrawAddLineDrawCircle( Point3d(-L/2,-(H/2),0), Point3d(-L/2,H/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED())
hint5 = DrawAddLineDrawCircle( Point3d(-L/2,H/2,0), Point3d(0,H/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED())
hint = EgtCurveCompo( Lg, {hint1,hint2,hint3,hint4,hint5}, true)
if hint then
EgtModifyCurveThickness(hint, -T)
EgtSetName(hint,LG)
-- muovo la geometria vesro sinistra del valore di L/2 + DS
EgtMove( hint, Point3d(-((L/2)+DS),0,0) - ORIG())
EgtSetInfo( hint,'InserPoint' ,'Center') -- setto una nota per indicare su che lato della porta deve essere spostato
EgtSetInfo( hint,'DeltaPos' ,( L+(2*DS)))
-- se mantiene centro spessore anche su face
if kbs and kbs > 0 then
EgtSetInfo( hint, 'KeepBackSet', 'c') -- setto 'c' perchè viene mantenuto il centro spessore
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( hint, 'ProbeSide', '1')
end
end
end
---------------------------------------
---------------------------------------
-- Costruzione delle geometrie di lavorazione
---------------------------------------
---------------------------------------
if nDrawMach > 0 then -- se abilitata geometria lavorazione
if not Lg then
Lg = EgtGroup(Pz,GDB_RT.LOC)
EgtSetName(Lg,sCompoName)
end
---------------------------------------
-- geometria svuotatura giro interno
---------------------------------------
local tPocket = {}
local pIni
local pEnd
local pEnd2
local nStep
local dStep
local dPerim
local nDirVers
local nPass
local dZedStart = 0
local dZedWork = -T
-- individuo in che caso sono
local nCase
if abs(H-d) < 0.03 then -- solo 1 passaggio in centro
nCase = 1
elseif (H-d) <= ( d*0.98) then -- solo passaggio di contornatura
nCase = 2
elseif ((H-d) > ( d*0.98)) and ( (H-d) <= (d*(1+p))) then -- passaggio di contornatura + un passaggio centrale
nCase = 3
elseif (H-d) > (d*(1+p)) then -- passaggio di contornatura + passaggi zig zag
nCase = 4
end
dPerim = 2*( H + L -(2*d))
nStep = ceil(T/s) -- numero di passate
dStep = (T/nStep) -- passo ricalcolato
if nCase == 1 then -- solo 1 passaggio in centro
nPass = 1
nDirVers = 1
dZedStart = 0
pEnd = Point3d((-nDirVers*((L-d)/2)),0,dZedStart) -- nuovo punto finale
hint3 = EgtCircle( Dm, pEnd, (d/2) , GDB_RT.LOC)
EgtSetColor(hint3,PURPLE())
local nDoubleStep = nStep * 2
while nPass <= nDoubleStep do
-- primo mezzo passo
nDirVers = - nDirVers
pIni = pEnd
dZedWork = dZedStart - ((dStep * nPass)/2)
if nPass == nDoubleStep then
dZedWork = -T
end
pEnd = Point3d((-nDirVers*((L-d)/2)),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
nPass = nPass + 1
end
-- ultimo mezzo passo
nDirVers = - nDirVers
pIni = pEnd
dZedWork = -T
pEnd = Point3d((-nDirVers*((L-d)/2)),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
-- Uscita in Z0
pIni = pEnd
dZedWork = 0
if ( nDeltaMovX > (L-d)) then
nDeltaMovX = (L-d)
end
pEnd = Point3d((-nDirVers*((L-d)/2)-nDeltaMovX),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, GREEN(), GREEN())
-- solo contornatura or contornatura + un passaggio centrale or contornatura + passaggi svuotatura
elseif ( nCase == 2) or ( nCase == 3) or ( nCase == 4) then
nPass = 1
nDirVers = 1
dZedStart = 0
pEnd = Point3d(((L-d)/2),((H-d)/2),dZedStart) -- nuovo punto finale
hint3 = EgtCircle( Dm, pEnd, (d/2) , GDB_RT.LOC)
EgtSetColor(hint3,PURPLE())
while nPass <= nStep do
if nCase > 2 then -- se ho la svuotatura centrale scendo direttamente al passo
-- prima linea discendente
pIni = pEnd
dZedWork = dZedStart - dStep
if nPass == nStep then
dZedWork = -T
end
pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- prima linea contorno
pIni = pEnd
if nCase == 2 then
dZedWork = dZedStart - ( dStep*((H-d)/dPerim))
end
pEnd = Point3d(((L-d)/2),-((H-d)/2),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
-- seconda linea contorno
pIni = pEnd
if nCase == 2 then
dZedWork = dZedStart - ( dStep*((H+L-(2*d))/dPerim))
end
pEnd = Point3d(-((L-d)/2),-((H-d)/2),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
-- terza linea contorno
pIni = pEnd
if nCase == 2 then
dZedWork = dZedStart - ( dStep*(((2*H)+L-(3*d))/dPerim))
end
pEnd = Point3d(-((L-d)/2),((H-d)/2),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
-- quarta linea contorno
pIni = pEnd
if nCase == 2 then
dZedWork = dZedStart - dStep
if nPass == nStep then
dZedWork = -T
end
end
pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
-- Se passaggio di contornatura e sono all'ultimo passo, faccio ancora un giro di contorno
if nCase == 2 and nPass == nStep then -- passaggio di contornatura
-- prima linea contorno
pIni = pEnd
pEnd = Point3d(((L-d)/2),-((H-d)/2),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
-- seconda linea contorno
pIni = pEnd
pEnd = Point3d(-((L-d)/2),-((H-d)/2),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
-- terza linea contorno
pIni = pEnd
pEnd = Point3d(-((L-d)/2),((H-d)/2),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
-- quarta linea contorno
pIni = pEnd
pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork)
if ( nDeltaMovX > ((L-d)/2)) then -- se delta più grande di metà cava in X
nDeltaMovX = (L-d)/2
end
if ( nDeltaMovY > ((H-d)/2)) then -- se delta più grande di metà cava in Y
nDeltaMovY = (H-d)/2
end
pEnd2 = Point3d((((L-d)/2)-nDeltaMovX),(((H-d)/2)-nDeltaMovY),0)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
if nCase == 3 then -- passaggio di contornatura + un passaggio centrale
-- quinta linea posizionamento passata centrale
pIni = pEnd
pEnd = Point3d((((L*2)-(d*3))/4),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, LIME(), LIME())
-- sesta linea passata centrale
pIni = pEnd
pEnd = Point3d(-(((L*2)-(d*3))/4),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, LIME(), LIME())
-- settima linea ritorno a posizione iniziale
pIni = pEnd
pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork)
if ( nDeltaMovX > ((L-d)/2)) then -- se delta più grande di metà cava in X
nDeltaMovX = (L-d)/2
end
if ( nDeltaMovY > ((H-d)/2)) then -- se delta più grande di metà cava in Y
nDeltaMovY = (H-d)/2
end
pEnd2 = Point3d((((L-d)/2)-nDeltaMovX),(((H-d)/2)-nDeltaMovY),0)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
elseif nCase == 4 then -- passaggio di contornatura + passaggi svuotatura
nDirVers = -1
local nDistYcentr = (d*p)
local nPosYcentr = ((H-d)/2) - nDistYcentr
local bContinue = nPosYcentr > -((H-d)/2)
-- linea posizionamento passaggi svuotatura
pIni = pEnd
pEnd = Point3d((-nDirVers * (((L*2)-(d*3))/4)),nPosYcentr,dZedWork)
-- ciclo passate svuotatura
while bContinue do
-- linea affondamento in Y
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW())
-- linea passata in X
pIni = pEnd
pEnd = Point3d((nDirVers * (((L*2)-(d*3))/4)),nPosYcentr,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW())
-- calcolo nuovo passo in Y e indice direzione
nPosYcentr = nPosYcentr - nDistYcentr
bContinue = nPosYcentr > -((H-d)/2)
-- calcolo prossimo punto solo se sono ancora dentro l'area
if bContinue then
nDirVers = -nDirVers
-- ricalcolo punti per linea successiva
pIni = pEnd
pEnd = Point3d((-nDirVers * (((L*2)-(d*3))/4)),nPosYcentr,dZedWork)
end
end
-- ultima linea ritorno a posizione iniziale
pIni = pEnd
pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork)
if ( nDeltaMovX > ((L-d)/2)) then -- se delta più grande di metà cava in X
nDeltaMovX = (L-d)/2
end
if ( nDeltaMovY > ((H-d)/2)) then -- se delta più grande di metà cava in Y
nDeltaMovY = (H-d)/2
end
pEnd2 = Point3d((((L-d)/2)-nDeltaMovX),(((H-d)/2)-nDeltaMovY),0)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
nPass = nPass + 1
dZedStart = dZedStart - dStep
end
-- Uscita in Z0
pIni = pEnd
DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket, bPreview, Dm, (d/2), false, true, GREEN(), GREEN())
end
-- trasformo in geometria composita il percorso di svuotatura
if ( #tPocket > 0) then
hintPk = EgtCurveCompo( Lg, tPocket, true)
if hintPk then
EgtModifyCurveThickness(hintPk, 0)
EgtSetName(hintPk,LM)
-- muovo la geometria vesro sinistra del valore di L/2 + DS
EgtMove( hintPk, Point3d(-((L/2)+DS),0,0) - ORIG())
-- muovo la geometria vesro sinistra del valore di L/2 + DS
EgtMove( Dm, Point3d(-((L/2)+DS),0,0) - ORIG())
EgtSetInfo( hintPk,'InserPoint' ,'Center') -- setto una nota per indicare su che lato della porta deve essere spostato
EgtSetInfo( Dm,'InserPoint' ,'Center') -- setto una nota per indicare su che lato della porta deve essere spostato
EgtSetInfo( hintPk,'DeltaPos' ,( L+(2*DS)))
EgtSetInfo( Dm,'DeltaPos' ,( L+(2*DS)))
-- se mantiene centro spessore anche su mortise
if kbs and kbs > 0 then
EgtSetInfo( hintPk, 'KeepBackSet', 'c') -- setto 'c' perchè viene mantenuto il centro spessore
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( hintPk, 'ProbeSide', '1')
end
end
end
if dws then -- se frame viene disposto sul lato wide
local nIdSideBoxUp
if hint then
nIdSideBoxUp = EgtCopyGlob( hint, Lg)
EgtSetName( nIdSideBoxUp, 'upper')
EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper')
end
end
end
-- cambio colore alla geometria
if bPreview then
if EC == 0 then
if hint then
EgtSetColor(hint,AQUA())
end
if hintPk then
EgtSetColor(hintPk,AQUA())
end
else
if hint then
EgtSetColor(hint,ORANGE())
end
if hintPk then
EgtSetColor(hintPk,ORANGE())
end
end
else -- altrimenti non Preview
-- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti)
-- cancello le parti ausiliarie se disegnate
if Dm then
EgtErase(Dm)
end
if Dor then
EgtErase(Dor)
end
-- assegno nota su percorso svuotatura
if hintPk then
EgtSetInfo( hintPk, 'NotCheckDir', '1')
end
end
return hint, hintPk
end
return _OverHeadPocket