cc55202ec5
- primo commit con versione corrente.
909 lines
36 KiB
Lua
909 lines
36 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
|
|
--
|
|
-- _Latch.lua by EgalWare s.r.l. 2016.06.14
|
|
-- Autore: Filippo Monchi
|
|
-- Latch, componente di secondo livello, non può essere chiamato direttamente da un lua dei
|
|
-- componenti di interfaccia
|
|
|
|
-- 2019.10.15 V1.002 FM Manage steel option
|
|
-- 2019.10.18 V2.000 FM Manage use Materials
|
|
-- 2020.01.08 V2.001 FM Manage start point on shortest side with steel material
|
|
-- 2020.05.25 V2.002 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side
|
|
-- 2021.10.15 V2.003 FM Fix error on calculate lead out line when length or width is smaller than leadout line
|
|
-- 2021.11.24 V2.004 FM Manage side probe option if variable DGC.Pms > 2
|
|
-- 2024.07.19 V2.005 FM Set note 'NotCheckDir' to pocketing path
|
|
|
|
-- Tavola per definizione modulo (serve ma non usata)
|
|
local _Latch = {}
|
|
|
|
-- Intestazioni
|
|
require( 'EgtBase')
|
|
EgtEnableDebug( false)
|
|
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 DrawAddCircleDrawCircle( 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
|
|
|
|
-- Funzione di disegno
|
|
function _Latch.Draw( EC, EM, tLatchParam, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor, sRunFrom)
|
|
|
|
-- Assegno le dimensioni
|
|
local L = tLatchParam.L
|
|
local H = tLatchParam.H
|
|
local T = tLatchParam.T
|
|
local sf = tLatchParam.sf
|
|
local rf = tLatchParam.rf
|
|
local d = tLatchParam.d
|
|
local p = tLatchParam.p
|
|
local jn = tLatchParam.jn
|
|
local L2 = tLatchParam.L2
|
|
local H2 = tLatchParam.H2
|
|
local cl = tLatchParam.cl
|
|
local D_X = tLatchParam.D_X
|
|
local D_Y = tLatchParam.D_Y
|
|
local invG = tLatchParam.invG
|
|
local smr = tLatchParam.smr
|
|
local DS = tLatchParam.DS
|
|
local est = tLatchParam.est
|
|
local kbs = tLatchParam.kbs
|
|
local pbs = tLatchParam.pbs
|
|
local ls = tLatchParam.ls
|
|
local DY = tLatchParam.DY
|
|
local bEqualTh = tLatchParam.bETh
|
|
local dws = tLatchParam.Dws
|
|
-- Assegno i nomi dei layer
|
|
local LG = tLatchParam.LG
|
|
local LM = tLatchParam.LM
|
|
local DM = 'DUMMY'
|
|
-- variabili per messaggi e settaggi vari
|
|
local sCompoName = tLatchParam.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
|
|
|
|
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 sf or abs(sf) <= GEO.EPS_SMALL then
|
|
sf = T
|
|
end
|
|
|
|
-- radius face: per compatibilità con tutti i componenti, se non è definito lo setto a 0
|
|
if not rf or abs(rf) <= GEO.EPS_SMALL then
|
|
rf = 0
|
|
end
|
|
|
|
if not D_Y then
|
|
D_Y = 0
|
|
end
|
|
|
|
if not smr then
|
|
smr = 0
|
|
end
|
|
|
|
-- Layer
|
|
local Dm
|
|
|
|
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) or GDB_ID.NULL -- layer disegni cerchi rappresentatte il diametro utensile
|
|
EgtSetName(Dm,DM)
|
|
end
|
|
|
|
local tHint = {}
|
|
local hint1
|
|
local hint, hintPk
|
|
local pIni, pEnd, pCen, pStartStep
|
|
|
|
-- creo lo stesso la geometria esterna perché viene utilizzata anche per creare il percorso di lavorazione
|
|
-- se non è previsto viene eliminato dopo
|
|
if LG and cl == 3 and rf > GEO.EPS_SMALL then -- se cava arrotondata da entrambe i lati e raggio valido
|
|
|
|
-- Costruzione della geometria principale
|
|
pIni = Point3d(((L/2)-rf),(H/2),0)
|
|
pCen = Point3d(((L/2)-rf),((H/2)-rf),0)
|
|
pEnd = Point3d((L/2),((H/2)-rf),0)
|
|
DrawAddCircleDrawCircle( pCen, rf, 90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
if abs(rf - (H/2)) > GEO.EPS_SMALL then -- se due raccordi
|
|
pEnd = Point3d((L/2),-(H/2)+rf,0)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
end
|
|
pCen = Point3d(((L/2)-rf),(-(H/2)+rf),0)
|
|
pEnd = Point3d(((L/2)-rf),-(H/2),0)
|
|
DrawAddCircleDrawCircle( pCen, rf, 0,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
pEnd = Point3d(-((L/2)-rf),-(H/2),0)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
pCen = Point3d(-((L/2)-rf),(-(H/2)+rf),0)
|
|
pEnd = Point3d(-(L/2),(-(H/2)+rf),0)
|
|
DrawAddCircleDrawCircle( pCen, rf, -90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
if abs(rf - (H/2)) > GEO.EPS_SMALL then -- se due raccordi
|
|
pEnd = Point3d(-(L/2),((H/2)-rf),0)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
end
|
|
pCen = Point3d(-((L/2)-rf),((H/2)-rf),0)
|
|
pEnd = Point3d(-((L/2)-rf),(H/2),0)
|
|
DrawAddCircleDrawCircle( pCen, rf, 180,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
pEnd = Point3d(((L/2)-rf),(H/2),0)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
elseif LG and cl == 1 and rf > GEO.EPS_SMALL then -- se cava arrotondata a sinistra e raggio valido
|
|
|
|
-- Costruzione della geometria principale
|
|
if smr ~= 0 then
|
|
pIni = Point3d(((L-rf)/2),(H/2)-0.5,0)
|
|
pEnd = Point3d(((L-rf)/2),-(H/2)+0.5,0)
|
|
else
|
|
pIni = Point3d(((L-rf)/2),(H/2),0)
|
|
pEnd = Point3d(((L-rf)/2),-(H/2),0)
|
|
end
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
if smr ~= 0 then
|
|
pCen = Point3d(((L-rf)/2)-0.5,-(H/2)+0.5,0)
|
|
pEnd = Point3d(((L-rf)/2)-0.5,-(H/2),0)
|
|
DrawAddCircleDrawCircle( pCen, 0.5, 0,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
end
|
|
pEnd = Point3d(-((L-rf)/2),-(H/2),0)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
pCen = Point3d(-((L-rf)/2),(-(H/2)+rf),0)
|
|
pEnd = Point3d(-((L-rf)/2)-rf,(-(H/2)+rf),0)
|
|
DrawAddCircleDrawCircle( pCen, rf, -90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
if abs(rf - (H/2)) > GEO.EPS_SMALL then -- se due raccordi
|
|
pEnd = Point3d(-((L-rf)/2)-rf,((H/2)-rf),0)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
end
|
|
pCen = Point3d(-((L-rf)/2),((H/2)-rf),0)
|
|
pEnd = Point3d(-((L-rf)/2),(H/2),0)
|
|
DrawAddCircleDrawCircle( pCen, rf, 180,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
if smr ~= 0 then
|
|
pEnd = Point3d(((L-rf)/2)-0.5,(H/2),0)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pCen = Point3d(((L-rf)/2)-0.5,(H/2)-0.5,0)
|
|
pEnd = Point3d(((L-rf)/2),(H/2)-0.5,0)
|
|
DrawAddCircleDrawCircle( pCen, 0.5, 90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
else
|
|
pEnd = Point3d(((L-rf)/2),(H/2),0)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
end
|
|
elseif LG and cl == 2 and rf > GEO.EPS_SMALL then -- se cava arrotondata a destra e raggio valido
|
|
|
|
-- Costruzione della geometria principale
|
|
pIni = Point3d(((L-rf)/2),(H/2),0)
|
|
pCen = Point3d(((L-rf)/2),((H/2)-rf),0)
|
|
pEnd = Point3d(((L-rf)/2)+rf,((H/2)-rf),0)
|
|
DrawAddCircleDrawCircle( pCen, rf, 90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
if abs(rf - (H/2)) > GEO.EPS_SMALL then -- se due raccordi
|
|
pEnd = Point3d(((L-rf)/2)+rf,(-(H/2)+rf),0)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
end
|
|
pCen = Point3d(((L-rf)/2),(-(H/2)+rf),0)
|
|
pEnd = Point3d(((L-rf)/2),-(H/2),0)
|
|
DrawAddCircleDrawCircle( pCen, rf, 0,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
if smr ~= 0 then
|
|
pEnd = Point3d(-((L-rf)/2)+0.5,-(H/2),0)
|
|
else
|
|
pEnd = Point3d(-((L-rf)/2),-(H/2),0)
|
|
end
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
if smr ~= 0 then
|
|
pCen = Point3d(-((L-rf)/2)+0.5,-(H/2)+0.5,0)
|
|
pEnd = Point3d(-((L-rf)/2),-(H/2),0)
|
|
DrawAddCircleDrawCircle( pCen, 0.5, -90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
pEnd = Point3d(-((L-rf)/2),(H/2)-0.5,0)
|
|
else
|
|
pEnd = Point3d(-((L-rf)/2),(H/2),0)
|
|
end
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
if smr ~= 0 then
|
|
pCen = Point3d(-((L-rf)/2)+0.5,(H/2)-0.5,0)
|
|
pEnd = Point3d(-((L-rf)/2)+0.5,(H/2),0)
|
|
DrawAddCircleDrawCircle( pCen, 0.5, 180,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
end
|
|
pEnd = Point3d(((L-rf)/2),(H/2),0)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
elseif LG then -- cava non arrotondata
|
|
|
|
-- Costruzione della geometria principale
|
|
if est and bEqualTh then -- se altro materiale e altezza come lo spessore porta
|
|
pIni = Point3d(0,((H/2)+(d/2)+0.5),0)
|
|
else
|
|
pIni = Point3d(0,(H/2),0)
|
|
end
|
|
|
|
if smr < 0 then -- se inserimento a sinistra
|
|
pEnd = Point3d((L/2)-0.5,(H/2),0)
|
|
else
|
|
if est and bEqualTh then -- se altro materiale e altezza come lo spessore porta
|
|
pEnd = Point3d(L/2,((H/2)+(d/2)+0.5),0)
|
|
else
|
|
pEnd = Point3d(L/2,(H/2),0)
|
|
end
|
|
end
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
if smr < 0 then -- se inserimento a sinistra
|
|
pCen = Point3d((L/2)-0.5,(H/2)-0.5,0)
|
|
pEnd = Point3d((L/2),(H/2)-0.5,0)
|
|
DrawAddCircleDrawCircle( pCen, 0.5, 90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
pEnd = Point3d(L/2,-(H/2)+0.5,0)
|
|
else
|
|
if est and bEqualTh then -- se altro materiale e altezza come lo spessore porta
|
|
pEnd = Point3d(L/2,-((H/2)+(d/2)+0.5),0)
|
|
else
|
|
pEnd = Point3d(L/2,-(H/2),0)
|
|
end
|
|
end
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
if smr < 0 then -- se inserimento a sinistra
|
|
pCen = Point3d((L/2)-0.5,-(H/2)+0.5,0)
|
|
pEnd = Point3d((L/2)-0.5,-(H/2),0)
|
|
DrawAddCircleDrawCircle( pCen, 0.5, 0,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
end
|
|
if smr > 0 then -- se inserimento a destra
|
|
pEnd = Point3d(-(L/2)+0.5,-(H/2),0)
|
|
else
|
|
if est and bEqualTh then -- se altro materiale e altezza come lo spessore porta
|
|
pEnd = Point3d(-L/2,-((H/2)+(d/2)+0.5),0)
|
|
else
|
|
pEnd = Point3d(-L/2,-(H/2),0)
|
|
end
|
|
end
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
if smr > 0 then -- se inserimento a destra
|
|
pCen = Point3d(-(L/2)+0.5,-(H/2)+0.5,0)
|
|
pEnd = Point3d(-(L/2),-(H/2)+0.5,0)
|
|
DrawAddCircleDrawCircle( pCen, 0.5, -90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
pEnd = Point3d(-(L/2),(H/2)-0.5,0)
|
|
else
|
|
if est and bEqualTh then -- se altro materiale e altezza come lo spessore porta
|
|
pEnd = Point3d(-L/2,((H/2)+(d/2)+0.5),0)
|
|
else
|
|
pEnd = Point3d(-L/2,(H/2),0)
|
|
end
|
|
end
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
if smr > 0 then -- se inserimento a destra
|
|
pCen = Point3d(-(L/2)+0.5,(H/2)-0.5,0)
|
|
pEnd = Point3d(-(L/2)+0.5,(H/2),0)
|
|
DrawAddCircleDrawCircle( pCen, 0.5, 180,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
pIni = pEnd
|
|
end
|
|
if est and bEqualTh then -- se altro materiale e altezza come lo spessore porta
|
|
pEnd = Point3d(0,((H/2)+(d/2)+0.5),0)
|
|
else
|
|
pEnd = Point3d(0,(H/2),0)
|
|
end
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED())
|
|
end
|
|
|
|
-- trasformo in geometria composita i/il percorsi/o di contorno
|
|
-- primo percorso
|
|
if ( #tHint > 0) then
|
|
hint = EgtCurveCompo( Lg, tHint, true)
|
|
if hint then
|
|
EgtModifyCurveThickness(hint, -T)
|
|
EgtSetName(hint,LG)
|
|
if est and not bEqualTh then -- se altro materiale e altezza diversa da spessore porta
|
|
if L > H then -- se lunghezza maggiore di altezza cambio il punto di inizio del percorso
|
|
EgtChangeClosedCurveStartPoint( hint, Point3d( -(L/2), 0, 0))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
---------------------------------------------
|
|
---------------------------------------------
|
|
-- Costruzione delle geometrie di lavorazione
|
|
---------------------------------------------
|
|
---------------------------------------------
|
|
if nDrawMach > 0 and LM then -- se abilitata geometria lavorazione
|
|
|
|
if not Lg then
|
|
Lg = EgtGroup(Pz,GDB_RT.LOC)
|
|
EgtSetName(Lg,sCompoName)
|
|
end
|
|
|
|
local tPocket = {}
|
|
local nRadius, hint_ofs, hint_ofs2
|
|
local nCase
|
|
local nCaseNext
|
|
local dZedStart
|
|
local dZedWork
|
|
local nStep
|
|
local dStep
|
|
local nDirVers
|
|
local nPass
|
|
|
|
---------------------------------------
|
|
-- geometria svuotatura giro esterno
|
|
---------------------------------------
|
|
|
|
-- individuo in che caso sono
|
|
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
|
|
|
|
nStep = ceil(T/sf) -- numero di passate
|
|
dStep = (T/nStep) -- passo ricalcolato
|
|
dZedStart = 0
|
|
nRadius = (H/2)
|
|
|
|
if nCase == 1 then -- solo 1 passaggio in centro
|
|
|
|
nPass = 1
|
|
nDirVers = 1
|
|
dZedStart = 0
|
|
pEnd = Point3d((-nDirVers*((L-d)/2))*invG,0,dZedStart) -- nuovo punto finale
|
|
|
|
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))*invG,0,dZedWork)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED())
|
|
|
|
nPass = nPass + 1
|
|
end
|
|
|
|
-- ultimo mezzo passo
|
|
nDirVers = - nDirVers
|
|
pIni = pEnd
|
|
dZedWork = -T
|
|
pEnd = Point3d((-nDirVers*((L-d)/2))*invG,0,dZedWork)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
|
|
pIni = pEnd
|
|
|
|
if jn then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria
|
|
|
|
-- calcolo in che caso sono con la prossima geometria
|
|
if abs(H2-d) < 0.03 then -- solo 1 passaggio in centro
|
|
nCaseNext = 1
|
|
else
|
|
nCaseNext = 0
|
|
end
|
|
|
|
pIni = pEnd
|
|
|
|
if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta
|
|
pEnd = Point3d((-(((L2-d)/2)*invG)+D_X),D_Y,dZedWork)
|
|
else
|
|
pEnd = Point3d(((((L2-d)/2)*invG)+D_X),((H2-d)/2)+D_Y,dZedWork)
|
|
end
|
|
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
|
|
else
|
|
|
|
-- Uscita in Z0
|
|
dZedWork = 0
|
|
|
|
if ( nDeltaMovX > (L-d)) then
|
|
nDeltaMovX = (L-d)
|
|
end
|
|
pEnd = Point3d(-nDirVers*(((L-d)/2)-nDeltaMovX)*invG,0,dZedWork)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, GREEN(), GREEN())
|
|
end
|
|
-- 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
|
|
|
|
while nPass <= nStep do
|
|
|
|
dZedWork = dZedStart - dStep
|
|
if nPass == nStep then
|
|
dZedWork = -T
|
|
end
|
|
|
|
if cl > 0 and rf > GEO.EPS_SMALL then -- se cava arrotondata
|
|
|
|
-- calcolo il raggio rimanente
|
|
nRadius = nRadius - (d/2)
|
|
|
|
-- copia del percorso per offset
|
|
hint_ofs = EgtCopyGlob( hint, Lg)
|
|
|
|
-- offset
|
|
local nId1 = EgtOffsetCurveAdv( hint_ofs, (d/2), GDB_OT.FILLET)
|
|
|
|
if nId1 and nId1 > 0 then
|
|
|
|
-- cancello il percorso originale e lo sostituisco con il nuovo id offsettato
|
|
EgtErase( hint_ofs)
|
|
hint_ofs = nId1
|
|
|
|
-- muovo la geometria in Z
|
|
EgtMove( hint_ofs, Point3d(0,0,dZedWork) - ORIG())
|
|
|
|
-- se flag inverso, inverto la geometria, solo qui non nelle altre copie
|
|
if invG < 0 then
|
|
EgtInvertCurve(hint_ofs)
|
|
end
|
|
|
|
if invG > 0 then -- se non è invertito
|
|
-- prima linea entrante
|
|
if cl == 3 then -- se cava arrotondata da entrambe i lati
|
|
pIni = Point3d(((L-H)/4),((H-d)/2),dZedStart)
|
|
elseif cl == 0 then
|
|
pIni = Point3d(((L-d)/4),((H-d)/2),dZedStart)
|
|
else
|
|
pIni = Point3d(((L-(H/2))/4),((H-d)/2),dZedStart)
|
|
end
|
|
|
|
pEnd = EgtSP( hint_ofs)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED())
|
|
else -- giro inverso
|
|
-- arco o linea entrante
|
|
if cl == 3 then -- se cava arrotondata da entrambe i lati
|
|
if rf == (H/2) then
|
|
pIni = Point3d(((L-d)/2),0,dZedStart)
|
|
pCen = Point3d(((L-H)/2),0,dZedStart)
|
|
else
|
|
pIni = Point3d(((L-d)/2),0,dZedStart)
|
|
end
|
|
elseif cl == 1 then -- arrotondata a sinistra
|
|
pIni = Point3d(((L-(H/2)-d)/2),0,dZedStart)
|
|
elseif cl == 2 then -- arrotondata a destra
|
|
pIni = Point3d(((L+(H/2)-d)/2),0,dZedStart)
|
|
pCen = Point3d(((L-(H/2))/2),0,dZedStart)
|
|
end
|
|
|
|
pEnd = EgtSP( hint_ofs)
|
|
if cl == 1 then -- arrotondata a sinistra
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED())
|
|
else
|
|
if rf == (H/2) then
|
|
hint1 = EgtArcCPA( Lg, pCen, pIni, 90, ( dZedWork - dZedStart), GDB_RT.LOC)
|
|
table.insert( tPocket, hint1)
|
|
else
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED())
|
|
end
|
|
end
|
|
end
|
|
|
|
pEnd = EgtEP( hint_ofs)
|
|
pStartStep = Point3d( pIni:getX(), pIni:getY(), pEnd:getZ())
|
|
-- faccio una copia del percorso offsettato per i prossimi offset
|
|
hint_ofs2 = EgtCopyGlob( hint_ofs, Lg)
|
|
table.insert( tPocket, hint_ofs)
|
|
end
|
|
else
|
|
|
|
-- prima linea entrante
|
|
pIni = Point3d(((L-d)/4)*invG,((H-d)/2),dZedStart)
|
|
pEnd = Point3d(((L-d)/2)*invG,((H-d)/2),dZedWork)
|
|
pStartStep = Point3d( pIni:getX(), pIni:getY(), pEnd:getZ())
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED())
|
|
|
|
-- prima linea contorno
|
|
pIni = pEnd
|
|
pEnd = Point3d(((L-d)/2)*invG,-((H-d)/2),dZedWork)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
|
|
|
|
-- seconda linea contorno
|
|
pIni = pEnd
|
|
pEnd = Point3d(-((L-d)/2)*invG,-((H-d)/2),dZedWork)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
|
|
|
|
-- terza linea contorno
|
|
pIni = pEnd
|
|
pEnd = Point3d(-((L-d)/2)*invG,((H-d)/2),dZedWork)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
|
|
|
|
-- quarta linea contorno
|
|
pIni = pEnd
|
|
pEnd = Point3d(((L-d)/2)*invG,((H-d)/2),dZedWork)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED())
|
|
end
|
|
|
|
if nCase == 2 then -- passaggio di contornatura
|
|
-- cancello copia dell'offset
|
|
if hint_ofs2 then EgtErase( hint_ofs2) end
|
|
-- verifico se il tratto di uscita in X e Y è più grande dello spazio interno e nel caso lo riduco
|
|
if L-d < nDeltaMovX then
|
|
nDeltaMovX = (L-d) / 2
|
|
end
|
|
if H-d < nDeltaMovY then
|
|
nDeltaMovY = (H-d) / 2
|
|
end
|
|
if cl > 0 and rf > GEO.EPS_SMALL then -- se cava arrotondata
|
|
pEnd2 = Point3d(( pEnd:getX() - nDeltaMovX),(pEnd:getY()-nDeltaMovY),0)
|
|
else
|
|
pEnd2 = Point3d(( pEnd:getX()-(nDeltaMovX*invG)),(pEnd:getY()-nDeltaMovY),0)
|
|
end
|
|
elseif nCase == 3 then -- passaggio di contornatura + un passaggio centrale
|
|
-- verifico se il tratto di uscita in X è più grande dello spazio interno e nel caso lo riduco
|
|
if L-d < nDeltaMovX then
|
|
nDeltaMovX = (L-d) / 2
|
|
end
|
|
if cl > 0 and rf > GEO.EPS_SMALL then -- se cava arrotondata
|
|
|
|
-- cancello copia dell'offset
|
|
if hint_ofs2 then EgtErase( hint_ofs2) end
|
|
|
|
-- linea posizionamento passata centrale
|
|
pIni = pEnd
|
|
if cl == 3 then -- se cava arrotondata da entrambe i lati
|
|
pEnd = Point3d(((L-H)/2),0,dZedWork)
|
|
elseif cl == 1 then -- se cava arrotondata a sinistra
|
|
pEnd = Point3d((((L-(H/2))/2)-((d*3)/4)),0,dZedWork)
|
|
elseif cl == 2 then -- se cava arrotondata a destra
|
|
pEnd = Point3d(((L-(H/2))/2),0,dZedWork)
|
|
else
|
|
pEnd = Point3d((((L*2)-(d*3))/4),0,dZedWork)
|
|
end
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW())
|
|
|
|
-- linea passata centrale
|
|
pIni = pEnd
|
|
if cl == 3 then -- se cava arrotondata da entrambe i lati
|
|
pEnd = Point3d(-((L-H)/2),0,dZedWork)
|
|
elseif cl == 1 then -- se cava arrotondata a sinistra
|
|
pEnd = Point3d(-((L-(H/2))/2),0,dZedWork)
|
|
elseif cl == 2 then -- se cava arrotondata a destra
|
|
pEnd = Point3d(-(((L-(H/2))/2)-((d*3)/4)),0,dZedWork)
|
|
else
|
|
pEnd = Point3d(-(((L*2)-(d*3))/4),0,dZedWork)
|
|
end
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW())
|
|
pEnd2 = Point3d(( pEnd:getX() + nDeltaMovX),pEnd:getY(),0)
|
|
else
|
|
-- quinta linea posizionamento passata centrale
|
|
pIni = pEnd
|
|
pEnd = Point3d((((L*2)-(d*3))/4)*invG,0,dZedWork)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW())
|
|
|
|
-- sesta linea passata centrale
|
|
pIni = pEnd
|
|
pEnd = Point3d(-(((L*2)-(d*3))/4)*invG,0,dZedWork)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW())
|
|
pEnd2 = Point3d(( pEnd:getX()+(nDeltaMovX*invG)),pEnd:getY(),0)
|
|
end
|
|
|
|
elseif nCase == 4 then -- passaggio di contornatura + passaggi svuotatura
|
|
|
|
local nDistYcentr = (d*p)
|
|
local bContinue
|
|
-- verifico se il tratto di uscita in X è più grande dello spazio interno e nel caso lo riduco
|
|
if L-d < nDeltaMovX then
|
|
nDeltaMovX = (L-d) / 2
|
|
end
|
|
if cl > 0 and rf > GEO.EPS_SMALL then -- se cava arrotondata
|
|
|
|
-- se percorso offset esiste
|
|
if hint_ofs2 then
|
|
|
|
-- faccio l'offset del raggio fresa
|
|
nRadius = nRadius - nDistYcentr
|
|
bContinue = nRadius > 0
|
|
|
|
-- se non posso continuare
|
|
if not bContinue then
|
|
EgtErase( hint_ofs2)
|
|
end
|
|
|
|
-- ciclo passate svuotatura
|
|
while bContinue do
|
|
|
|
hint_ofs = hint_ofs2
|
|
local nId1 = EgtOffsetCurveAdv( hint_ofs, nDistYcentr*invG, GDB_OT.FILLET)
|
|
|
|
if nId1 and nId1 > 0 then
|
|
|
|
-- cancello il percorso originale e lo sostituisco con il nuovo id offsettato
|
|
EgtErase( hint_ofs)
|
|
hint_ofs = nId1
|
|
|
|
-- linea congiunzione tra osset
|
|
pIni = pEnd
|
|
pEnd = EgtSP( hint_ofs)
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW())
|
|
pEnd = EgtEP( hint_ofs)
|
|
-- faccio una copia del percorso offsettato per i prossimi offset
|
|
hint_ofs2 = EgtCopyGlob( hint_ofs, Lg)
|
|
table.insert( tPocket, hint_ofs)
|
|
|
|
-- calcolo nuovo passo in Y e indice direzione
|
|
nRadius = nRadius - nDistYcentr
|
|
bContinue = nRadius > 0
|
|
|
|
if not bContinue then
|
|
EgtErase( hint_ofs2)
|
|
end
|
|
else
|
|
bContinue = false
|
|
EgtErase( hint_ofs)
|
|
end
|
|
end
|
|
|
|
pEnd2 = Point3d(( pEnd:getX()-(nDeltaMovX*invG)),pEnd:getY(),0)
|
|
end
|
|
else
|
|
|
|
local nDirVers = -1
|
|
local nPosYcentr = ((H-d)/2) - nDistYcentr
|
|
bContinue = nPosYcentr > -((H-d)/2)
|
|
|
|
-- linea posizionamento passaggi svuotatura
|
|
pIni = pEnd
|
|
pEnd = Point3d((-nDirVers * (((L*2)-(d*3))/4))*invG,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))*invG,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))*invG,nPosYcentr,dZedWork)
|
|
end
|
|
end
|
|
pEnd2 = Point3d(( pEnd:getX()-(nDeltaMovX*invG*nDirVers)), pEnd:getY(),0)
|
|
end
|
|
end
|
|
|
|
nPass = nPass + 1
|
|
dZedStart = dZedStart - dStep
|
|
nRadius = (H/2)
|
|
|
|
-- se ho altri passi torno al punto di inizio
|
|
if nPass <= nStep then
|
|
pIni = pEnd
|
|
pEnd = pStartStep
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW())
|
|
end
|
|
end -- end while
|
|
|
|
if jn then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria
|
|
|
|
-- calcolo in che caso sono con la prossima geometria
|
|
if abs(H2-d) < 0.03 then -- solo 1 passaggio in centro
|
|
nCaseNext = 1
|
|
else
|
|
nCaseNext = 0
|
|
end
|
|
|
|
pIni = pEnd
|
|
|
|
if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta
|
|
pEnd = Point3d(((-((L2-d)/2)*invG)+D_X),D_Y,dZedWork)
|
|
else
|
|
pEnd = Point3d(((((L2-d)/2)*invG)+D_X),((H2-d)/2)+D_Y,dZedWork)
|
|
end
|
|
|
|
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
|
|
else
|
|
-- Uscita in Z0
|
|
pIni = pEnd
|
|
DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket, bPreview, Dm, (d/2), false, true, GREEN(), GREEN())
|
|
end
|
|
end
|
|
|
|
-- trasformo in geometria composita i/il percorsi/o di svuotatura
|
|
-- primo percorso
|
|
if ( #tPocket > 0) then
|
|
hintPk = EgtCurveCompo( Lg, tPocket, true)
|
|
if hintPk then
|
|
EgtModifyCurveThickness(hintPk, 0)
|
|
EgtSetName(hintPk,LM)
|
|
if sRunFrom and sRunFrom == 'OH' then -- se lanciato da over head completo gli spostamenti e assegnazioni
|
|
-- muovo la geometria verso sinistra del valore di L/2 + DS
|
|
EgtMove( hintPk, Point3d(-((L/2)+DS),DY,0) - ORIG())
|
|
EgtSetInfo( hintPk,'InserPoint' ,'Edge') -- setto una nota per indicare su che lato della porta deve essere spostato
|
|
EgtSetInfo( hintPk,'DeltaPos' ,( L+(2*DS)))
|
|
-- se mantiene lato anche su face
|
|
if kbs and kbs > 0 then
|
|
local sKeepMode = 'c' -- setto per mantenere il centro dello spessore
|
|
EgtSetInfo( hintPk, 'KeepBackSet', sKeepMode)
|
|
end
|
|
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
|
|
EgtSetInfo( hintPk, 'ProbeSide', '1')
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- se abilitata solo geometria di lavorazione elimino il percorso di sola geometria
|
|
if nDrawMach == 1 then
|
|
if hint then
|
|
-- cancello il percorso
|
|
EgtErase( hint)
|
|
end
|
|
else -- altrimenti se lo mantengo, cambio il punto di inizio in base a certe condizioni
|
|
if hint then
|
|
if not est and cl and cl > 0 and rf and rf > GEO.EPS_SMALL then -- se materiale non steel e cava arrotondata da entrambe i lati e raggio valido
|
|
EgtChangeClosedCurveStartPoint( hint, Point3d(0,(H/2),0))
|
|
end
|
|
if sRunFrom and sRunFrom == 'OH' then -- se lanciato da over head completo gli spostamenti e assegnazioni
|
|
-- muovo la geometria verso sinistra del valore di L/2 + DS
|
|
EgtMove( hint, Point3d(-((L/2)+DS),DY,0) - ORIG())
|
|
EgtSetInfo( hint,'InserPoint' ,'Edge') -- setto una nota per indicare su che lato della porta deve essere spostato
|
|
EgtSetInfo( hint,'DeltaPos' ,( L+(2*DS)))
|
|
-- se mantiene lato anche su face
|
|
if kbs and kbs > 0 then
|
|
local sKeepMode = 'c' -- setto per mantenere il centro dello spessore
|
|
EgtSetInfo( hint, 'KeepBackSet', sKeepMode)
|
|
end
|
|
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
|
|
EgtSetInfo( hint, 'ProbeSide', '1')
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
if nDrawMach > 0 and dws then
|
|
|
|
local nIdSideBoxUp
|
|
|
|
if hint then
|
|
nIdSideBoxUp = EgtCopyGlob( hint, Lg)
|
|
EgtSetName( nIdSideBoxUp, 'upper')
|
|
EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper')
|
|
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
|
|
|
|
-- cancello le parti ausiliarie se disegnate
|
|
if Dm then
|
|
EgtErase( Dm)
|
|
end
|
|
-- assegno nota su percorso svuotatura
|
|
if hintPk then
|
|
EgtSetInfo( hintPk, 'NotCheckDir', '1')
|
|
end
|
|
end
|
|
|
|
return hint, hintPk
|
|
end
|
|
|
|
return _Latch
|