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

1377 lines
59 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
--
-- Rabbet.lua by EgalWare s.r.l. 2017.01.31
-- Autore: Filippo Monchi
-- Rabbet dati i valori 'L' e 'H' e 'T' e 'd' e 'p' e con nomi attributi
-- 2016.09.21 V1.0a0 FM Add warning messages
-- 2018.04.09 V1.0a2 FM Manage info (KeepBackSet) for adjust probe on Z
-- 2018.10.17 V1.0a3 FM Add parameter to show into message 402
-- 2019.05.14 V1.0a4 FM Add second anti-splint path on head door side
-- 2019.10.17 V1.0a5 FM Manage steel option (disable generation of some geometries)
-- 2019.10.18 V2.000 FM Manage use Materials
-- 2020.04.29 V2.001 FM Update for aluminum material
-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false
-- 2021.02.10 V3.001 FM Manage apply rabbet on opposite face
-- 2021.05.25 V3.002 FM Fix error when some parameters (p3, d3) are at nil
-- 2021.11.24 V3.003 FM Manage side probe option if variable DGC.Pms > 2
-- 2022.07.27 V3.004 FM Modification to use compiled code
-- 2023.09.14 V3.005 FM By MDC requests change the machining path direction from alternate direction to same direction
-- so after one passage it come up (out of door) and come back to start point to start new passage in the same direction
-- 2023.11.22 V3.005 FM by new parameter 'Ver' (from configuration file) manage old way (=0) or new mode as MDC required (>0)
-- 2024.01.22 V3.006 FM Manage to have only draw geometry ( not machined). This must be according to template.ini file
-- Tavola per definizione modulo (serve ma non usata)
local Rabbet = {}
-- 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 dExtraH = 0.5
local sMaxFeed = 'MaxFeed'
local sRapid = 'Rapid'
local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc,
nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar)
local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC)
local nNumLine
if idTable then
table.insert( idTable, nLine)
-- se devo inserire una variazione nell'entità
if sMVar then
nNumLine = #idTable
end
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, nNumLine, 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 di sistemazione parametri
function Rabbet.AdjustParams( tMhPar)
local EgtDoorsMsg = require( 'EgtDoorsMsg')
local dMaxMat1
local dMaxMat2
local dMaxMat3
local dMaxMat4
local dNumMessage
local dNumLog = 0
local sMessToOut = ''
local nTempT1
local nTempT2
local nTempT3
local nTempT4
local sMchngName1
local sMchngName2
local sMchngName3
local sMchngName4
if not tMhPar.Ver then tMhPar.Ver = 0 end
-- do errore se profilo con rabbet è tipo bullnose e/o convesso
if DGD.SIDE == 'hinge' and
( 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
return tMhPar, 2599, string.format(EgtDoorsMsg[546], DGD.tProfs.hingeedge.trimming)
end
if DGD.SIDE == 'lock' and
( DGD.tProfs.lockedge.trimming == '1B' or DGD.tProfs.lockedge.trimming == '2B' or
DGD.tProfs.lockedge.trimming == '3B' or DGD.tProfs.lockedge.trimming == '4B' or
DGD.tProfs.lockedge.trimming == '5B' or DGD.tProfs.lockedge.trimming == '6B' or
DGD.tProfs.lockedge.trimming == '7B' or DGD.tProfs.lockedge.trimming == '8B' or
DGD.tProfs.lockedge.trimming == 'CV') then
return tMhPar, 2598, string.format(EgtDoorsMsg[547], DGD.tProfs.lockedge.trimming)
end
-- Assegno parametri da ddf
if DGD.SIDE == 'hinge' or DGD.SIDE == 'lock' then
if DGD.sFrame then
if DGD.sFrame == 'L' or DGD.sFrame == 'LE' or DGD.sFrame == 'H' or DGD.sFrame == 'HE' then -- se frame laterali
tMhPar.L = DGD.dH
else
tMhPar.L = DGD.dW
end
else
tMhPar.L = DGD.LENGTH
end
tMhPar.lw = 0
elseif DGD.SIDE == 'top' or DGD.SIDE == 'bottom' then
if DGD.sFrame then
tMhPar.L = DGD.dT
else
tMhPar.L = DGD.LENGTH
end
tMhPar.lw = 1
else
return tMhPar, 2597, string.format(EgtDoorsMsg[548], DGD.SIDE)
end
-- assegno il valore dell'angolo in base al tipo di frame e allo swing
if DGD.sFrame and DGD.ANGLE and DGD.ANGLE ~= 0 then
if DGD.sFrame == 'LE' or DGD.sFrame == 'HE' then
if ( DGD.sFrame == 'HE' and DGD.Lock == 'L' and DGD.Push) or
( DGD.sFrame == 'LE' and DGD.Lock == 'R' and DGD.Push) or
( DGD.sFrame == 'HE' and DGD.Lock == 'R' and not DGD.Push) or
( DGD.sFrame == 'LE' and DGD.Lock == 'L' and not DGD.Push) then
tMhPar.ang = - DGD.ANGLE
else
tMhPar.ang = DGD.ANGLE
end
else
tMhPar.ang = 0
end
else
tMhPar.ang = 0
end
tMhPar.L2 = DGD.dWidthRabbet
tMhPar.H2 = DGD.WIDTH
tMhPar.H = DGD.WIDTH - EgtIf( tMhPar.ang ~= 0, ( ( tMhPar.L - tMhPar.L2)*tan(abs(tMhPar.ang))),0)
tMhPar.T = DGD.DEPTH
tMhPar.op = DGD.OPPO
-- 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.T
end
-- se non ho parametro step antisplint o è 0 lo assegno uguale allo spessore cava
if not tMhPar.s2 or abs(tMhPar.s2) < GEO.EPS_SMALL then
tMhPar.s2 = tMhPar.T
end
-- se non ho parametro spessore di riferimento lo assegno uguale allo spessore cava
if not tMhPar.Tl or abs(tMhPar.Tl) < GEO.EPS_SMALL then
tMhPar.Tl = tMhPar.T
end
-- Assegno parametri da dati utensili in macchina
local MB = require( 'MachiningBase')
local sLM = tMhPar.LM
local nLMi = 1
local sLMR = tMhPar.LMR
local nLMRi = 1
local sLA = tMhPar.LA
local nLAi = 1
if tMhPar.Ver == 0 then
tMhPar.LA2 = tMhPar.LA
end
local sLA2 = tMhPar.LA2
local nLA2i = 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.est = true
tMhPar.d2 = nil
tMhPar.d4 = nil
else
tMhPar.est = nil
end
if DGD.MachEn > 0 and tMhPar.d and sLM and #sLM > 0 then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLM, nLMi) end
if DGD.MachEn > 0 and tMhPar.d2 and sLA and #sLA > 0 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLA, nLAi) end
if DGD.MachEn > 0 and tMhPar.d3 and sLMR and #sLMR > 0 then nTempT3, dMaxMat3, sMchngName3 = MB.GetToolDataFromAttrib( sLMR, nLMRi) end
if tMhPar.Ver > 0 and DGD.MachEn > 0 and tMhPar.d4 and sLA2 and #sLA2 > 0 then nTempT4, dMaxMat4, sMchngName4 = MB.GetToolDataFromAttrib( sLA2, nLA2i) end
-- se devo disegnare le geometrie di lavorazione
if DGD.MachEn > 0 then
-- gestisco il risultato della lettura utensili
if DGD.bProoduce and tMhPar.d and nTempT1 and nTempT1 <= 0 then
dNumLog = -2596
sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1)
elseif nTempT1 and nTempT1 >= 0 then
tMhPar.d = nTempT1
end
if DGD.bProoduce and tMhPar.lw and tMhPar.lw == 1 and tMhPar.d2 and nTempT2 and nTempT2 <= 0 then
dNumLog = -2596
sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2)
elseif nTempT2 and nTempT2 >= 0 then
tMhPar.d2 = nTempT2
end
if tMhPar.Ver > 0 then
if DGD.bProoduce and tMhPar.lw and tMhPar.lw == 1 and tMhPar.d4 and nTempT4 and nTempT4 <= 0 then
dNumLog = -2596
sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT4, sLA2, nLA2i, tMhPar.d4, dNumLog, sMchngName4)
elseif nTempT4 and nTempT4 >= 0 then
tMhPar.d4 = nTempT4
end
end
if DGD.bProoduce and tMhPar.Tl and tMhPar.T > tMhPar.Tl and tMhPar.d3 and nTempT3 and nTempT3 <= 0 then
dNumLog = -2596
sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLMR, nLMRi, tMhPar.d3, dNumLog, sMchngName3)
elseif nTempT3 and nTempT3 >= 0 then
tMhPar.d3 = nTempT3
end
-- se la profondità della cava è maggiore della capacità utensile limito la profondità ed emetto un warning
if tMhPar.T and dMaxMat1 and tMhPar.T > dMaxMat1 then
dNumLog = -2595
dNumMessage = 549
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1))
tMhPar.T = dMaxMat1
end
-- se la profondità antischeggia della cava è maggiore della capacità utensile limito la profondità ed emetto un warning
if tMhPar.lw and tMhPar.lw == 1 and tMhPar.T and dMaxMat2 and tMhPar.T > dMaxMat2 then
dNumLog = -2594
dNumMessage = 541
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat2))
tMhPar.T = dMaxMat2
end
-- se la profondità della cava è maggiore della capacità utensile limito la profondità ed emetto un warning
if tMhPar.Tl and tMhPar.T > tMhPar.Tl and tMhPar.T and dMaxMat3 and tMhPar.T > dMaxMat3 then
dNumLog = -2593
dNumMessage = 549
sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat3))
tMhPar.T = dMaxMat3
end
end
if dNumLog ~= 0 then
return tMhPar, dNumLog, sMessToOut
end
return tMhPar, 0, ''
end
-- Funzione di disegno
function Rabbet.Draw( tRabbetParameter, bPreview, bRunByCompo, nDrawMach)
-- Assegno le dimensioni
local L = tRabbetParameter.L
local L2 = tRabbetParameter.L2
local H = tRabbetParameter.H
local H2 = tRabbetParameter.H2
local T = tRabbetParameter.T
local ang = tRabbetParameter.ang
local d = tRabbetParameter.d
local p = tRabbetParameter.p
local Tl = tRabbetParameter.Tl
local s = tRabbetParameter.s
local d2 = tRabbetParameter.d2
local d4 = tRabbetParameter.d4
local s2 = tRabbetParameter.s2
local bas = tRabbetParameter.bas
local d3 = tRabbetParameter.d3
local p3 = tRabbetParameter.p3
local lw = tRabbetParameter.lw
local sov = tRabbetParameter.sov
local est = tRabbetParameter.est
local kbs = tRabbetParameter.kbs -- keep backset/thickness (0: none, 1: only face, 2: all)
local pbs = tRabbetParameter.pbs
local op = tRabbetParameter.op
local Ver = tRabbetParameter.Ver
-- Assegno i nomi geometrie
local LG = tRabbetParameter.LG
local LM = tRabbetParameter.LM
local LMR = tRabbetParameter.LMR
local LA = tRabbetParameter.LA
local LA2 = tRabbetParameter.LA2
local DM = 'DUMMY'
-- variabili per messaggi e settaggi vari
local sCompoName = tRabbetParameter.Nome
local nCompoNpar = tRabbetParameter.Npar
local sCompoPath = tRabbetParameter.Path
-- eventuale messaggio errore rilevato nell'adjust
local nCodAdj = tRabbetParameter.nCod
local sCodAdj = tRabbetParameter.sCod
-- nomi parametri per messaggi
local sNamePar1 = tRabbetParameter.N1 or 'L'
local sNamePar2 = tRabbetParameter.N2 or 'H'
local sNamePar3 = tRabbetParameter.N3 or 'T'
local sNamePar4 = tRabbetParameter.N4 or 'd'
local sNamePar5 = tRabbetParameter.N5 or 'p'
local sNamePar6 = tRabbetParameter.N6 or 'd2'
local sNamePar7 = tRabbetParameter.N7 or 's'
local sNamePar8 = tRabbetParameter.N8 or 'Tl'
local sNamePar9 = tRabbetParameter.N9 or 'd3'
local sNamePar10 = tRabbetParameter.N10 or 's2'
local sNamePar11 = tRabbetParameter.N11 or 'p3'
local sNamePar12 = tRabbetParameter.N12 or 'd4'
-- RunByComponetInterface
local RC = true
-- Messaggi codice errori
local EM = ' '
local EC = 0
local ErrorBase = 2500
if T > Tl and not sov then
sov = 0.5
elseif not sov then
sov = 0
end
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
local EgtDoorsMsg = require( 'EgtDoorsMsg')
-- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata
if 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 nDrawMach > 0 and lw and lw == 1 and d2 and d2 < DgMin then
EC = 2
EM = string.format(EgtDoorsMsg[400],sNamePar6,EgtToUiUnits(d2),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di
d2 = DgMin
elseif Ver > 0 and nDrawMach > 0 and lw and lw == 1 and d4 and d4 < DgMin then
EC = 12
EM = string.format(EgtDoorsMsg[400],sNamePar12,EgtToUiUnits(d4),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di
d4 = DgMin
elseif nDrawMach > 0 and d3 and T > Tl and d3 < DgMin then
EC = 3
EM = string.format(EgtDoorsMsg[400],sNamePar9,EgtToUiUnits(d3),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di
d3 = DgMin
elseif H <= 0 then
EC = 4
EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0
H = d/2
elseif nDrawMach > 0 and L <= d then
if DGD.bProoduce then
EC = 5
EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar4,EgtToUiUnits(d), sCompoPath) -- il parametro 'L' deve essere maggiore al diametro utensile
L = d + 0.002
else
d = L - 0.002
end
elseif nDrawMach > 0 and T > Tl and d3 and L <= d3 then
if DGD.bProoduce then
EC = 6
EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar9,EgtToUiUnits(d3), sCompoPath) -- il parametro 'L' deve essere maggiore al diametro utensile
L = d3 + 0.002
else
d3 = L - 0.002
end
elseif nDrawMach > 0 and p and ( p < PtMin or p > PtMax) then
EC = 7
EM = string.format(EgtDoorsMsg[403],sNamePar5,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra
p = 0.8
elseif nDrawMach > 0 and p3 and ( p3 < PtMin or p3 > PtMax) then
EC = 8
EM = string.format(EgtDoorsMsg[403],sNamePar11,p3,PtMin,PtMax, sCompoPath) -- il parametro 'p3' deve essere compreso tra
p3 = 0.8
elseif T < 0 then
EC = 9
EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0
T = 0
elseif nDrawMach > 0 and s and s <= 0 then
EC = 10
EM = string.format(EgtDoorsMsg[401],sNamePar7,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0
s = d
elseif nDrawMach > 0 and s2 and s2 <= 0 then
EC = 11
EM = string.format(EgtDoorsMsg[401],sNamePar10,EgtToUiUnits(s2), sCompoPath) -- il parametro 's2' deve essere > 0
s2 = d2
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
Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale
EgtSetName( Lg, sCompoName)
EgtSetInfo( Lg, 'DeltaPos', L / 2) -- setto una nota per indicare che deve essere spostata della quantità
if nDrawMach > 0 then -- se abilitata geometria lavorazione
Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentatte il diametro utensile
EgtSetName( Dm, DM)
end
local hint1, hint2
local hint, hintPk, hintAs, hintAs2, hintPkSgr
local pIni, pEnd, pIni2, pEnd2
if nDrawMach ~= 1 then -- se abilitata geometria esterna
local tPocket = {}
-- Costruzione della geometria rabbet ( in senso orario)
pIni = Point3d(L/2,0,0)
if ang >= 0 then
pEnd = Point3d(L/2,-H,0)
else
pEnd = Point3d(L/2,-H2,0)
end
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED())
pIni = pEnd
if ang ~= 0 then
if ang > 0 then
pEnd = Point3d(-(L/2)+L2,-H2,0)
else
pEnd = Point3d((L/2)-L2,-H2,0)
end
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED())
pIni = pEnd
end
if ang >= 0 then
pEnd = Point3d(-(L/2),-H2,0)
else
pEnd = Point3d(-(L/2),-H,0)
end
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED())
pIni = pEnd
pEnd = Point3d(-(L/2),0,0)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED())
pIni = pEnd
hint = EgtCurveCompo( Lg, tPocket, true)
EgtModifyCurveThickness( hint, -T)
EgtSetName( hint, LG)
-- se mantiene centro spessore anche su face
if kbs and kbs > 0 then
EgtSetInfo( hint, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto la profondità cava sul lato narrow
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( hint, 'ProbeSide', '1')
end
end
-- Costruzione della geometria di lavorazione
if nDrawMach > 0 then -- se abilitata geometria lavorazione
if not Lg then
Lg = EgtGroup(Pz,GDB_RT.LOC)
EgtSetName(Lg,sCompoName)
end
local tPocketAs = {}
local tPocketAs2 = {}
local dZedStart
local dZedWork
local nStep
local dStep
local nPass
local bMakeRoughPath
if T > Tl and d3 then
bMakeRoughPath = true
end
-- geometria antischeggia
if lw == 1 and d2 then -- se parametro valido
if s2 >= T then -- se passo unico
hint1 = DrawAddLineDrawCircle( Point3d(-((L/2)+dExtraH),(d2*3/4),0), Point3d(-((L/2)+dExtraH), EgtIf( ang >= 0,-(H+(L*tan(ang))),-H)+(d2/2),0),
Lg, nil, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE())
hint2 = DrawAddLineDrawCircle( Point3d(-((L/2)+dExtraH),EgtIf( ang >= 0,-(H+(L*tan(ang))),-H)+(d2/2),0), Point3d(-((L-(d2/2))/2),EgtIf( ang >= 0,-(H+(L*tan(ang))),-H)+(d2/2),0),
Lg, nil, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE())
hintAs = EgtCurveCompo( Lg, {hint1,hint2}, true)
EgtModifyCurveThickness(hintAs, -T)
-- if old mode and double antisplint
if Ver == 0 and bas then
hint1 = DrawAddLineDrawCircle( Point3d(((L/2)+dExtraH),(d2*3/4),0), Point3d(((L/2)+dExtraH), -H+(d2/2),0),
Lg, nil, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE())
hint2 = DrawAddLineDrawCircle( Point3d(((L/2)+dExtraH),-H+(d2/2),0), Point3d(((L-(d2/2))/2),-H+(d2/2),0),
Lg, nil, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE())
hintAs2 = EgtCurveCompo( Lg, {hint1,hint2}, true)
EgtModifyCurveThickness(hintAs2, -T)
end
else -- altrimenti più passate
nStep = ceil(T/s2) -- numero di passate
dStep = (T/nStep) -- passo ricalcolato
nPass = 1
dZedStart = 0
local tMVar = {}
local tMVar2 = {}
local nConEnt
local sKindVar
while nPass <= nStep do
dZedWork = dZedStart - dStep
if nPass == nStep then
dZedWork = -T
end
-- discesa in Y
pIni = Point3d(-((L/2)+dExtraH),(d2*3/4),dZedWork)
pEnd = Point3d(-((L/2)+dExtraH),EgtIf( ang >= 0,-(H+(L*tan(ang))),-H)+(d2/2),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE())
-- entrata in X
pIni = pEnd
pEnd = Point3d(-((L-(d2/2))/2),EgtIf( ang >= 0,-(H+(L*tan(ang))),-H)+(d2/2),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE())
-- faccio il ritorno alla posizione di partenza
-- stacco in Y di 0.2 o 0.01 (in base alla variabile Ver)
pIni = pEnd
pEnd = Point3d( pIni:getX(), pIni:getY()+EgtIf( Ver == 0, 0.2, 0.01), dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE())
-- ritorno in X ( uscendo completamente con Ver > 0, uscendo 0.2 + dExtraH se Ver = 0)
pIni = pEnd
pEnd = Point3d( -((L/2)+EgtIf( Ver == 0, dExtraH + 0.2, (d2/2)+0.5)), pIni:getY(), dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE())
-- ritorno in Y
pIni = pEnd
pEnd = Point3d( pIni:getX(), (d2*3/4), dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE())
pIni = pEnd
pEnd = Point3d( -((L/2)+dExtraH), (d2*3/4), dZedWork)
-- if old mode and double anti-splin
if Ver == 0 and bas then
-- discesa in Y
pIni2 = Point3d(((L/2)+dExtraH),(d2*3/4),dZedWork)
pEnd2 = Point3d(((L/2)+dExtraH),-H+(d2/2),dZedWork)
DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE())
-- entrata in X
pIni2 = pEnd2
pEnd2 = Point3d(((L-(d2/2))/2),-H+(d2/2),dZedWork)
DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE())
-- faccio il ritorno alla posizione di partenza
-- stacco in Y di 0.2
pIni2 = pEnd2
pEnd2 = Point3d( pIni2:getX(), pIni2:getY()+0.2, dZedWork)
DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE())
-- ritorno in X
pIni2 = pEnd2
pEnd2 = Point3d(((L/2)+dExtraH+0.2), pIni2:getY(), dZedWork)
DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE())
-- ritorno in Y
pIni2 = pEnd2
pEnd2 = Point3d( pIni2:getX(), (d2*3/4), dZedWork)
DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE())
pIni2 = pEnd2
pEnd2 = Point3d(((L/2)+dExtraH), (d2*3/4), dZedWork)
end
nPass = nPass + 1
dZedStart = dZedWork
-- se ho altri passi scendo in z
if nPass <= nStep then
local pIniLoc = pEnd
pEnd = Point3d(pIniLoc:getX(), pIniLoc:getY(), (dZedStart - dStep))
_, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true,
ORANGE(), ORANGE(), sMaxFeed)
table.insert( tMVar, {nConEnt,sKindVar})
-- if old mode and double anti-splin
if Ver == 0 and bas then
pIniLoc = pEnd2
pEnd2 = Point3d(pIniLoc:getX(), pIniLoc:getY(), (dZedStart - dStep))
_, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true,
ORANGE(), ORANGE(), sMaxFeed)
table.insert( tMVar2, {nConEnt,sKindVar})
end
end
end -- end while
-- trasformo in geometria composita
if #tPocketAs > 0 then
hintAs = EgtCurveCompo( Lg, tPocketAs, true)
if hintAs then
EgtModifyCurveThickness( hintAs, 0)
-- assegno nota con la lista delle entità di variazione
local sListEnt = ''
for i = 1, #tMVar do
sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar[i][1], 0) .. ', ' .. 'code=' .. tMVar[i][2] .. '}'
if i < #tMVar then
sListEnt = sListEnt .. ','
end
end -- end for
if string.len( sListEnt) > 0 then EgtSetInfo( hintAs, 'MVar', sListEnt) end
end
end
if Ver == 0 and #tPocketAs2 > 0 then -- se secondo percorso antischeggia
hintAs2 = EgtCurveCompo( Lg, tPocketAs2, true)
if hintAs2 then
EgtModifyCurveThickness( hintAs2, 0)
-- assegno nota con la lista delle entità di variazione
local sListEnt = ''
for i = 1, #tMVar2 do
sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar2[i][1], 0) .. ', ' .. 'code=' .. tMVar2[i][2] .. '}'
if i < #tMVar2 then
sListEnt = sListEnt .. ','
end
end -- end for
if string.len( sListEnt) > 0 then EgtSetInfo( hintAs2, 'MVar', sListEnt) end
end
end
end
if hintAs then -- se esiste geometria
EgtSetName(hintAs,LA)
-- se mantiene centro spessore anche su face
if kbs and kbs > 0 then
EgtSetInfo( hintAs, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto la profondità cava sul lato narrow
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( hintAs, 'ProbeSide', '1')
end
end
if Ver == 0 and hintAs2 then -- se esiste geometria secondo antischeggia
EgtSetName(hintAs2,LA)
-- se mantiene centro spessore anche su face
if kbs and kbs > 0 then
EgtSetInfo( hintAs2, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto la profondità cava sul lato narrow
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( hintAs2, 'ProbeSide', '1')
end
end
end
-- seconda geometria antischeggia
if Ver > 0 and lw == 1 and d4 and bas then -- se parametro valido
if s2 >= T then -- se passo unico
hint1 = DrawAddLineDrawCircle( Point3d(((L/2)+dExtraH),(d4*3/4),0), Point3d(((L/2)+dExtraH), -H+(d4/2),0),
Lg, nil, bPreview, Dm, (d4/2), true, true, ORANGE(), ORANGE())
hint2 = DrawAddLineDrawCircle( Point3d(((L/2)+dExtraH),-H+(d4/2),0), Point3d(((L-(d4/2))/2),-H+(d4/2),0),
Lg, nil, bPreview, Dm, (d4/2), true, true, ORANGE(), ORANGE())
hintAs2 = EgtCurveCompo( Lg, {hint1,hint2}, true)
EgtModifyCurveThickness(hintAs2, -T)
else -- altrimenti più passate
nStep = ceil(T/s2) -- numero di passate
dStep = (T/nStep) -- passo ricalcolato
nPass = 1
dZedStart = 0
local tMVar2 = {}
local nConEnt
local sKindVar
while nPass <= nStep do
dZedWork = dZedStart - dStep
if nPass == nStep then
dZedWork = -T
end
-- discesa in Y
pIni2 = Point3d(((L/2)+dExtraH),(d4*3/4),dZedWork)
pEnd2 = Point3d(((L/2)+dExtraH),-H+(d4/2),dZedWork)
DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d4/2), true, true, ORANGE(), ORANGE())
-- entrata in X
pIni2 = pEnd2
pEnd2 = Point3d(((L-(d4/2))/2),-H+(d4/2),dZedWork)
DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d4/2), false, true, ORANGE(), ORANGE())
-- faccio il ritorno alla posizione di partenza
-- stacco in Y di 0.01
pIni2 = pEnd2
pEnd2 = Point3d( pIni2:getX(), pIni2:getY()+0.01, dZedWork)
DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d4/2), false, true, ORANGE(), ORANGE())
-- ritorno in X uscendo completamente
pIni2 = pEnd2
pEnd2 = Point3d(((L/2)+(d4/2)+0.5), pIni2:getY(), dZedWork)
DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d4/2), false, true, ORANGE(), ORANGE())
-- ritorno in Y
pIni2 = pEnd2
pEnd2 = Point3d( pIni2:getX(), (d4*3/4), dZedWork)
DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d4/2), false, true, ORANGE(), ORANGE())
pIni2 = pEnd2
pEnd2 = Point3d(((L/2)+dExtraH), (d4*3/4), dZedWork)
nPass = nPass + 1
dZedStart = dZedWork
-- se ho altri passi scendo in z
if nPass <= nStep then
local pIniLoc = pEnd2
pEnd2 = Point3d(pIniLoc:getX(), pIniLoc:getY(), (dZedStart - dStep))
_, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d4/2), false, true,
ORANGE(), ORANGE(), sMaxFeed)
table.insert( tMVar2, {nConEnt,sKindVar})
end
end -- end while
if ( #tPocketAs2 > 0) then -- se secondo percorso antischeggia
hintAs2 = EgtCurveCompo( Lg, tPocketAs2, true)
if hintAs2 then
EgtModifyCurveThickness( hintAs2, 0)
-- assegno nota con la lista delle entità di variazione
local sListEnt = ''
for i = 1, #tMVar2 do
sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar2[i][1], 0) .. ', ' .. 'code=' .. tMVar2[i][2] .. '}'
if i < #tMVar2 then
sListEnt = sListEnt .. ','
end
end -- end for
if string.len( sListEnt) > 0 then EgtSetInfo( hintAs2, 'MVar', sListEnt) end
end
end
end
if hintAs2 then -- se esiste geometria secondo antischeggia
EgtSetName(hintAs2,LA2)
-- se mantiene centro spessore anche su face
if kbs and kbs > 0 then
EgtSetInfo( hintAs2, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto la profondità cava sul lato narrow
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( hintAs2, 'ProbeSide', '1')
end
end
end
-- geometria finitura
local tPocket = {}
local tMVar = {}
local nConEnt
local sKindVar
local pStart
-- se ho la sgrossatura setto subito la finitura all'affondamento finale
nStep = EgtIf( bMakeRoughPath, 1, ceil(T/s))
dStep = (T/nStep) -- passo ricalcolato
nPass = 1
dZedStart = 0
while LM and #LM > 0 and nPass <= nStep do
dZedWork = dZedStart - dStep
if nPass == nStep then
dZedWork = -T
end
pIni = Point3d(-((L/2)+dExtraH),(d*3/4),dZedWork)
pStart = pIni -- memorizzo punto per ritorno e reiniziare nuovo step
if H <= (d*p) then -- se cava troppo bassa
-- linea entrante in Y
pEnd = Point3d(-((L/2)+dExtraH),-H+(d/2),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED())
-- linea traversa in X
pIni = pEnd
pEnd = Point3d(((L/2)+dExtraH),-H+(d/2),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
pIni = pEnd
-- collego a eventuale linea inclinate
if ang > 0 then -- scivolo verso sinistra
pEnd = Point3d(((L/2)+dExtraH),-H+(((d/2)/cos(ang))+(dExtraH * tan(ang))),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang)),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH),(d*3/4),dZedWork)
elseif ang < 0 then -- scivolo verso destra
pEnd = Point3d(((L/2)+dExtraH),-H+((L+dExtraH)*tan(ang))+((d/2)/cos(ang))+(dExtraH*tan(ang)),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang)),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH),(d*3/4),dZedWork)
else -- piano
pEnd = Point3d(((L/2)+dExtraH),(d*3/4),dZedWork)
end
-- linea di risalita in Y
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
else
local nDirVers = -1
local nHorStep = floor((H/(d*p))+0.6)
local dHorStep = H/nHorStep
local nDistYcentr = dHorStep
local nPosYcentr = nDistYcentr - (d/2)
local nPassHor = 1
-- ciclo passate svuotatura
while nPassHor <= nHorStep do
-- linea affondamento in Y
pEnd = Point3d((nDirVers * ((L/2)+dExtraH)),-nPosYcentr,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
pIni = pEnd
-- linea passata in X
pEnd = Point3d((-nDirVers * ((L/2)+dExtraH)),-nPosYcentr,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
if Ver > 0 then
pIni = pEnd
-- linea risalita in Y
pEnd = Point3d((-nDirVers * ((L/2)+dExtraH)),(d*3/4),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
pIni = pEnd
end
-- calcolo nuovo passo in Y e indice direzione
nPosYcentr = nPosYcentr + nDistYcentr
nPassHor = nPassHor + 1
-- se ancora dentro l'area
if nPassHor <= nHorStep then
if Ver > 0 then
-- linea ritorno in X
pEnd = Point3d((nDirVers * ((L/2)+dExtraH)),(d*3/4),dZedWork)
_, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED(), sMaxFeed)
table.insert( tMVar, {nConEnt,sKindVar})
else
nDirVers = -nDirVers
end
-- ricalcolo punti per linea successiva
pIni = pEnd
end
end -- end while
pIni = pEnd
-- collego a eventuale linea inclinate
if ang > 0 then -- scivolo verso sinistra
if Ver == 0 and nDirVers < 0 then -- se ultima a destra
-- vado al punto di intersezione
pEnd = Point3d(((L/2)+dExtraH),-H+(((d/2)/cos(ang))+(dExtraH*tan(ang))),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
-- faccio linea inclinata
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang)),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
-- punti risalita
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH),(d*3/4),dZedWork)
else -- se ultima a sinistra
-- vado al punto di intersezione
pEnd = Point3d(-((L/2)+dExtraH),-H-((L+dExtraH)*tan(ang))+((d/2)/cos(ang))-(dExtraH*tan(ang)),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
-- faccio linea inclinata
pIni = pEnd
pEnd = Point3d(((L/2)+dExtraH),-H+(((d/2)/cos(ang))+(dExtraH*tan(ang))),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
-- punti risalita
pIni = pEnd
pEnd = Point3d(((L/2)+dExtraH),(d*3/4),dZedWork)
end
elseif ang < 0 then -- scivolo verso destra
if Ver == 0 and nDirVers < 0 then -- se ultima a destra
-- vado al punto di intersezione
pEnd = Point3d(((L/2)+dExtraH),-H+((L+dExtraH)*tan(ang))+((d/2)/cos(ang))+(dExtraH*tan(ang)),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
-- faccio linea inclinata
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang)),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
-- punti risalita
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH),(d*3/4),dZedWork)
else -- se ultima a sinistra
-- vado al punto di intersezione
pEnd = Point3d(-((L/2)+dExtraH),-H+(((d/2)/cos(ang))-(dExtraH*tan(ang))),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
-- faccio linea inclinata
pIni = pEnd
pEnd = Point3d(((L/2)+dExtraH), pIni:getY()+((L+(2*dExtraH))*tan(ang)),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
-- punti risalita
pIni = pEnd
pEnd = Point3d(((L/2)+dExtraH),(d*3/4),dZedWork)
end
else -- piano
pEnd = Point3d(pIni:getX(), (d*3/4), dZedWork)
end
-- linea di risalita in Y
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW())
end
nPass = nPass + 1
dZedStart = dZedWork
-- se ho altri passi torno al punto di inizio
if nPass <= nStep then
pIni = pEnd
pEnd = Point3d(pStart:getX(), pStart:getY(), (dZedStart - dStep))
_, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true,
YELLOW(), YELLOW(), sMaxFeed)
table.insert( tMVar, {nConEnt,sKindVar})
end
end -- end while
-- trasformo in geometria composita
if ( #tPocket > 0) then
hintPk = EgtCurveCompo( Lg, tPocket, true)
if hintPk then
EgtModifyCurveThickness( hintPk, 0)
-- assegno nota con la lista delle entità di variazione
local sListEnt = ''
for i = 1, #tMVar do
sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar[i][1], 0) .. ', ' .. 'code=' .. tMVar[i][2] .. '}'
if i < #tMVar then
sListEnt = sListEnt .. ','
end
end -- end for
if string.len( sListEnt) > 0 then EgtSetInfo( hintPk, 'MVar', sListEnt) end
EgtSetName( hintPk, LM .. EgtIf( lw == 1, '_H', ''))
-- se mantiene centro spessore anche su face
if kbs and kbs > 0 then
EgtSetInfo( hintPk, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto la profondità cava sul lato narrow
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( hintPk, 'ProbeSide', '1')
end
else
EC = ErrorBase + 12
EM = string.format(EgtDoorsMsg[427], sCompoPath)
end
end
-- creo percorso di sgrossatura
if bMakeRoughPath then
-- geometria sgrossatura
local tPocket2 = {}
local tMVar = {}
local nConEnt
local sKindVar
local pStart
nStep = ceil(T/s)
dStep = (T/nStep) -- passo ricalcolato
nPass = 1
dZedStart = 0
while nPass <= nStep do
dZedWork = dZedStart - dStep
if nPass == nStep then
dZedWork = -T
end
pIni = Point3d(-((L/2)+dExtraH),(d3*3/4),dZedWork)
pStart = pIni -- memorizzo punto per ritorno e reiniziare nuovo step
if H <= (d3*p3) then -- se cava troppo bassa
-- linea entrante in Y
pEnd = Point3d(-((L/2)+dExtraH),-H+(d3/2)+sov,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), true, true, RED(), RED())
-- linea traversa in X
pIni = pEnd
pEnd = Point3d(((L/2)+dExtraH),-H+(d3/2)+sov,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
pIni = pEnd
-- collego a eventuale linea inclinate
if ang > 0 then -- scivolo verso sinistra
pEnd = Point3d(((L/2)+dExtraH),-H+(((d3/2)/cos(ang))+(dExtraH * tan(ang)))+sov,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang))+sov,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH),(d3*3/4),dZedWork)
elseif ang < 0 then -- scivolo verso destra
pEnd = Point3d(((L/2)+dExtraH),-H+((L+dExtraH)*tan(ang))+((d3/2)/cos(ang))+(dExtraH*tan(ang))+sov,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang))+sov,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH),(d3*3/4),dZedWork)
else -- piano
pEnd = Point3d(((L/2)+dExtraH),(d3*3/4),dZedWork)
end
-- linea di risalita in Y
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
else
local nDirVers = -1
local nHorStep = floor((H/(d3*p3))+0.6)
local dHorStep = H/nHorStep
local nDistYcentr = dHorStep
local nPosYcentr = nDistYcentr - (d3/2) - sov
local nPassHor = 1
-- ciclo passate svuotatura
while nPassHor <= nHorStep do
-- linea affondamento in Y
pEnd = Point3d((nDirVers * ((L/2)+dExtraH)),-nPosYcentr,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
pIni = pEnd
-- linea passata in X
pEnd = Point3d((-nDirVers * ((L/2)+dExtraH)),-nPosYcentr,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
if Ver > 0 then
pIni = pEnd
-- linea risalita in Y
pEnd = Point3d((-nDirVers * ((L/2)+dExtraH)),(d3*3/4),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
pIni = pEnd
end
-- calcolo nuovo passo in Y e indice direzione
nPosYcentr = nPosYcentr + nDistYcentr
nPassHor = nPassHor + 1
-- se ancora dentro l'area
if nPassHor <= nHorStep then
if Ver > 0 then
-- linea ritorno in X
pEnd = Point3d((nDirVers * ((L/2)+dExtraH)),(d3*3/4),dZedWork)
_, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED(), sMaxFeed)
table.insert( tMVar, {nConEnt,sKindVar})
else
nDirVers = -nDirVers
end
-- ricalcolo punti per linea successiva
pIni = pEnd
end
end -- end while
pIni = pEnd
-- collego a eventuale linea inclinate
if ang > 0 then -- scivolo verso sinistra
if Ver == 0 and nDirVers < 0 then -- se ultima a destra
-- vado al punto di intersezione
pEnd = Point3d(((L/2)+dExtraH),-H+(((d3/2)/cos(ang))+(dExtraH*tan(ang)))+sov,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
-- faccio linea inclinata
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang)),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
-- punti risalita
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH),(d3*3/4),dZedWork)
else -- se ultima a sinistra
-- vado al punto di intersezione
pEnd = Point3d(-((L/2)+dExtraH),-H-((L+dExtraH)*tan(ang))+((d3/2)/cos(ang))-(dExtraH*tan(ang))+sov,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
-- faccio linea inclinata
pIni = pEnd
pEnd = Point3d(((L/2)+dExtraH),-H+(((d3/2)/cos(ang))+(dExtraH*tan(ang)))+sov,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
-- punti risalita
pIni = pEnd
pEnd = Point3d(((L/2)+dExtraH),(d3*3/4),dZedWork)
end
elseif ang < 0 then -- scivolo verso destra
if Ver == 0 and nDirVers < 0 then -- se ultima a destra
-- vado al punto di intersezione
pEnd = Point3d(((L/2)+dExtraH),-H+((L+dExtraH)*tan(ang))+((d3/2)/cos(ang))+(dExtraH*tan(ang))+sov,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
-- faccio linea inclinata
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang)),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
-- punti risalita
pIni = pEnd
pEnd = Point3d(-((L/2)+dExtraH),(d3*3/4),dZedWork)
else -- se ultima a sinistra
-- vado al punto di intersezione
pEnd = Point3d(-((L/2)+dExtraH),-H+(((d3/2)/cos(ang))-(dExtraH*tan(ang)))+sov,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
-- faccio linea inclinata
pIni = pEnd
pEnd = Point3d(((L/2)+dExtraH), pIni:getY()+((L+(2*dExtraH))*tan(ang)),dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED())
-- punti risalita
pIni = pEnd
pEnd = Point3d(((L/2)+dExtraH),(d3*3/4),dZedWork)
end
else -- piano
pEnd = Point3d(pIni:getX(), (d3*3/4), dZedWork)
end
-- linea di risalita in Y
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, YELLOW(), YELLOW())
end
nPass = nPass + 1
dZedStart = dZedWork
-- se ho altri passi torno al punto di inizio
if nPass <= nStep then
pIni = pEnd
pEnd = Point3d(pStart:getX(), pStart:getY(), (dZedStart - dStep))
_, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true,
YELLOW(), YELLOW(), sMaxFeed)
table.insert( tMVar, {nConEnt,sKindVar})
end
end -- end while
-- trasformo in geometria composita
if ( #tPocket2 > 0) then
hintPkSgr = EgtCurveCompo( Lg, tPocket2, true)
if hintPkSgr then
EgtModifyCurveThickness( hintPkSgr, 0)
-- assegno nota con la lista delle entità di variazione
local sListEnt = ''
for i = 1, #tMVar do
sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar[i][1], 0) .. ', ' .. 'code=' .. tMVar[i][2] .. '}'
if i < #tMVar then
sListEnt = sListEnt .. ','
end
end -- end for
if string.len( sListEnt) > 0 then EgtSetInfo( hintPkSgr, 'MVar', sListEnt) end
EgtSetName(hintPkSgr,LMR.. EgtIf( lw == 1, '_H', ''))
EgtSetInfo( hintPkSgr, 'OL', sov)
-- se mantiene centro spessore anche su face
if kbs and kbs > 0 then
EgtSetInfo( hintPkSgr, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto la profondità cava sul lato narrow
end
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( hintPkSgr, 'ProbeSide', '1')
end
else
EC = ErrorBase + 13
EM = string.format(EgtDoorsMsg[427], sCompoPath)
end
end
end
end
-- se rabbet sul lato opposto, ruoto tutte le geoemtrie
if op and op == 1 and EC == 0 then
EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT))
if hint then
EgtRotate( hint, Point3d(0,0,0), Z_AX(), 180, GDB_RT.GRID) -- ruoto su faccia opposta
end
if hintAs then
EgtRotate( hintAs, Point3d(0,0,0), Z_AX(), 180, GDB_RT.GRID) -- ruoto su faccia opposta
end
if hintAs2 then
EgtRotate( hintAs2, Point3d(0,0,0), Z_AX(), 180, GDB_RT.GRID) -- ruoto su faccia opposta
end
if hintPk then
EgtRotate( hintPk, Point3d(0,0,0), Z_AX(), 180, GDB_RT.GRID) -- ruoto su faccia opposta
end
if hintPkSgr then
EgtRotate( hintPkSgr, Point3d(0,0,0), Z_AX(), 180, GDB_RT.GRID) -- ruoto su faccia opposta
end
EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP))
end
-- cambio colore alla geometria
if bPreview then
if EC == 0 then
if hint then
EgtSetColor(hint,AQUA())
end
if hintAs then
EgtSetColor(hintAs,AQUA())
end
if hintAs2 then
EgtSetColor(hintAs2,AQUA())
end
if hintPk then
EgtSetColor(hintPk,AQUA())
end
if hintPkSgr then
EgtSetColor(hintPkSgr,AQUA())
end
else
if hint then
EgtSetColor(hint,ORANGE())
end
if hintAs then
EgtSetColor(hintAs,ORANGE())
end
if hintAs2 then
EgtSetColor(hintAs2,ORANGE())
end
if hintPk then
EgtSetColor(hintPk,ORANGE())
end
if hintPkSgr then
EgtSetColor(hintPkSgr,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 bRunByCompo then
-- scrivo i parametri nelle info del pezzo
WriteCompoDataToPart(Pz,sCompoName,nCompoNpar)
end
-- scrivo note nel layer della cerniera
EgtSetInfo(Lg,'Type' ,'Rabbet')
EgtSetInfo(Lg,'Nome' ,sCompoName)
EgtSetInfo(Lg,'L' ,L)
EgtSetInfo(Lg,'L2' ,L2)
EgtSetInfo(Lg,'H' ,H)
EgtSetInfo(Lg,'H2' ,H2)
EgtSetInfo(Lg,'T' ,T)
EgtSetInfo(Lg,'ang' ,ang)
EgtSetInfo(Lg,'d' ,d)
EgtSetInfo(Lg,'p' ,p)
EgtSetInfo(Lg,'Tl' ,Tl)
EgtSetInfo(Lg,'s' ,s)
EgtSetInfo(Lg,'d2' ,d2)
EgtSetInfo(Lg,'d4' ,d4)
EgtSetInfo(Lg,'s2' ,s2)
EgtSetInfo(Lg,'bas' ,bas)
EgtSetInfo(Lg,'d3' ,d3)
EgtSetInfo(Lg,'p3' ,p3)
EgtSetInfo(Lg,'lw' ,lw)
EgtSetInfo(Lg,'sov' ,sov)
EgtSetInfo(Lg,'est' ,est)
EgtSetInfo(Lg,'kbs' ,kbs)
EgtSetInfo(Lg,'pbs' ,pbs)
EgtSetInfo(Lg,'op' ,op)
EgtSetInfo(Lg,'Ver' ,Ver)
EgtSetInfo(Lg,'LG' ,LG)
EgtSetInfo(Lg,'LM' ,LM)
EgtSetInfo(Lg,'LMR' ,LMR)
EgtSetInfo(Lg,'LA' ,LA)
EgtSetInfo(Lg,'LA2' ,LA2)
EgtSetInfo(Lg,'Path' ,sCompoPath)
end
if EC == 0 and nCodAdj and nCodAdj < 0 then
EC = nCodAdj
EM = sCodAdj
end
return EC, EM, Lg
end
return Rabbet