-- -- 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 -- -- MortiseHinge.lua by EgalWare s.r.l. 2016.06.14 -- Autore: Filippo Monchi -- Mortise Hinge dati i valori 'L' e 'H' e 'T' e 'd' e 'p' e con nomi attributi -- 2016.09.21 V1.011 FM Add warning messages -- 2016.09.21 V1.012 FM Disabled to use reverse geometries _R on tool diameter caculation -- 2017.09.05 V1.013 FM Manage lead-in on opposite side and anti-splint path V lead-in -- 2017.12.08 V1.014 FM Manage offset position on probe geometry and duplicate it for manage probe when door is placed on left or right position -- 2018.01.11 V1.015 FM Manage new extra bore parameters (4 couples of bores) -- 2018.02.21 V1.016 FM Make new extra bore as construction geometry (before was machining geometry) -- 2018.04.05 V1.017 FM Manage info (KeepBackSet) for adjust probe on Z -- 2018.10.17 V1.018 FM Add parameter to show into message 402 -- 2018.11.09 V1.019 FM Manage flag to enable/disable rotation on profile on extra bores -- 2018.12.06 V1.01a FM Manage geometry for calculate box without MortiseHinge Volume -- 2019.01.06 V1.01b FM Fix error in case both parameters ( thickness lua parameter (.T) and ddf thickness parameter) are missing -- 2019.10.02 V1.01c FM Manage steel option (disable to generate pocket path, make closed and extend path) -- 2019.10.18 V2.000 FM Manage use Materials -- 2019.10.21 V2.001 FM Modify the closed path start point for steel material -- 2019.10.21 V2.001 FM Add Button hole geometry and its machining path (only for steel material) -- 2019.10.24 V2.002 FM Add clean corner geometries -- 2019.12.18 V2.003 FM Use new parameter DGC.Eah that allow insert template also on bullnose ans convex profiles -- 2020.04.28 V2.004 FM Add manage aluminum material -- 2020.05.04 V2.005 FM Manage Coninuos hinge mode on extra bores -- 2020.05.25 V2.006 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side -- 2020.07.01 V2.007 FM Disable Warning message on frames if parameter DGD.Spd is <= 0 -- 2020.09.29 V2.008 FM Manage 15 extra bores numbers into Continuos hinge type, and it's possible specify the bores number for any extra bores. -- 2020.09.29 V2.008 FM Fix error on check null Interaxes value on Continuous hinge -- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false -- 2021.03.12 V3.001 FM Manage rotation parameters on extra bores/buttonhole -- 2021.11.24 V3.002 FM Manage side probe option if variable DGC.Pms > 2 -- 2022.07.27 V3.003 FM Modification to use compiled code -- 2022.12.06 V3.004 FM Manage (by new nNewType variable) the extra bores rotation around 2 interax (along door heigh (local X) and alog door thickness (local Y)) -- 2023.03.20 V3.005 FM Manage double hole/button hole into Continuous hinge by parameter ITx (Interaxis along T of door) -- 2024.07.19 V3.006 FM Set note 'NotCheckDir' to pocketing, antisplint and buttonhole pocketing paths -- 2024.10.29 V3.007 FM Manage new DGC.Fpd CurrDoorCustomData variable to force shuttle probe geometry to stay horizontal -- Tavola per definizione modulo (serve ma non usata) local MortiseHinge = {} -- 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 nNewType = 1 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 local function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) local EgtDoorsMsg = require( 'EgtDoorsMsg') local sMessage = '' if dOriDiamTool then if nErrorId == -1 then -- lavorazione non presente in tabella sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -5 then -- diametro utensile non trovato sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -6 then -- nome geometria non presente in tabella sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -7 then -- altezza massima utensile non trovata sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) elseif nErrorId == -8 then -- tabella non presente nelle note sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) end elseif nErrorId == -1 then -- lavorazione non presente in tabella sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) elseif nErrorId == -2 then -- errore nel settare la lavorazione sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -5 then -- diametro utensile non trovato sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -6 then -- nome geometria non presente in tabella sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) elseif nErrorId == -7 then -- altezza massima utensile non trovata sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) elseif nErrorId == -8 then -- tabella non presente nelle note sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) end return sMessage end -- Funzione creazione foro o asola o rampa per asola local function MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, PX10, Int10, dIntT10, D10, dParH, PY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, nBI, pbs, RCIT10) local pIni, pEnd, pCen local hint3, hint5 local tPath = {} local tPathPok = {} if IY10 > 0 and EBH10 ~= '' then -- se parametri asola presenti pIni = Point3d((PX10+Int10+(D10/2)),(dParH+dIntT10+PY10),0) pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+dIntT10+PY10-(IY10/2)),0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+dIntT10+PY10-(IY10/2)),0) pCen = Point3d((PX10+Int10),(dParH+dIntT10+PY10-(IY10/2)),0) DrawAddCircleDrawCircle( pCen, (D10/2), 0,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+dIntT10+PY10+(IY10/2)),0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+dIntT10+PY10+(IY10/2)),0) pCen = Point3d((PX10+Int10),(dParH+dIntT10+PY10+(IY10/2)),0) DrawAddCircleDrawCircle( pCen, (D10/2), 180,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+dIntT10+PY10),0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd hint3 = EgtCurveCompo( Lg, tPath, true) EgtModifyCurveThickness( hint3, -T10) -- se rotazione attiva if AR10 ~= 0 then -- rotazione in centro a entrambe gli interassi if RCI10 and RCIT10 then EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto -- rotazione in centro all'interasse lungo l'altezza porta (X locale) elseif RCI10 then -- nuova rotazione, solo attornoo all'interasse X locale (ma non sulla Y locale) if nNewType and nNewType > 0 then EgtRotate( hint3, Point3d((PX10),(dParH+dIntT10+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto -- vecchia rotazione in centro all'interasse X e Y locale else EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto end -- rotazione in centro all'interasse lungo lo sspessore porta (Y locale) elseif RCIT10 then EgtRotate( hint3, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto -- rotazione in centro all'asola else EgtRotate( hint3, Point3d((PX10+Int10),(dParH+dIntT10+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto end end if nDrawMach > 0 and RP10 and RP10 > 0 and (RP10/2) < T10 then --se parametro step è valido, creo il percorso a zig-zag centrale EgtSetName( hint3,'_'..EBH10) -- aggiungo _ per disabilitare lavorazione local nStep = ceil(T10/RP10) -- numero di passate local dStep = (T10/nStep) -- passo ricalcolato local nPass = 1 local dZedStart = 0 local dZedWork local nInv = 1 pIni = Point3d((PX10+Int10),(dParH+dIntT10+PY10+((IY10/2)*nInv)),dZedStart) while nPass <= nStep do dZedWork = dZedStart - (dStep/2) nInv = -nInv pEnd = Point3d((PX10+Int10),(dParH+dIntT10+PY10+((IY10/2)*nInv)),dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd dZedWork = dZedStart - dStep nInv = -nInv pEnd = Point3d((PX10+Int10),(dParH+dIntT10+PY10+((IY10/2)*nInv)),dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd -- se ho altri passi scendo in z if nPass < nStep then dZedStart = dZedWork end nPass = nPass + 1 end -- faccio passata di ritorno nInv = -nInv pEnd = Point3d((PX10+Int10),(dParH+dIntT10+PY10+((IY10/2)*nInv)),-T10) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) hint5 = EgtCurveCompo( Lg, tPathPok, true) EgtModifyCurveThickness( hint5, 0) EgtSetName( hint5, EBH10) EgtSetInfo( hint5, 'NotCheckDir', '1') -- se rotazione attiva if AR10 ~= 0 then -- rotazione in centro a entrambe gli interassi if RCI10 and RCIT10 then EgtRotate( hint5, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto -- rotazione in centro all'interasse lungo l'altezza porta (X locale) elseif RCI10 then -- nuova rotazione, solo attornoo all'interasse X locale (ma non sulla Y locale) if nNewType and nNewType > 0 then EgtRotate( hint5, Point3d((PX10),(dParH+dIntT10+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto -- vecchia rotazione in centro all'interasse X e Y locale else EgtRotate( hint5, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto end -- rotazione in centro all'interasse lungo lo sspessore porta (Y locale) elseif RCIT10 then EgtRotate( hint5, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto -- rotazione in centro all'asola else EgtRotate( hint5, Point3d((PX10+Int10),(dParH+dIntT10+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto end end else EgtSetName( hint3, EBH10) end elseif EB10 ~= '' then hint3 = EgtCircle( Lg, Point3d((PX10+Int10),(dParH+dIntT10+PY10),0), D10/2 , GDB_RT.LOC) EgtModifyCurveThickness( hint3, -T10) EgtSetName( hint3, EB10) -- se rotazione in centro all'interasse (solo questo caso perchè non ha senso ruotare un foro in centro a se stesso) if AR10 ~= 0 then -- rotazione in centro a entrambe gli interassi if RCI10 and RCIT10 then EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto -- rotazione in centro all'interasse lungo l'altezza porta (X locale) elseif RCI10 then -- nuova rotazione, solo attornoo all'interasse X locale (ma non sulla Y locale) if nNewType and nNewType > 0 then EgtRotate( hint3, Point3d((PX10),(dParH+dIntT10+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto -- vecchia rotazione in centro all'interasse X e Y locale else EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto end -- rotazione in centro all'interasse lungo lo sspessore porta (Y locale) elseif RCIT10 then EgtRotate( hint3, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto end end end -- se mantiene backset if kbs and kbs > 0 then local sKeepMode = 'n' -- setto di default per mantenere il lato narrow if bEqualTh then -- se spessore passante sKeepMode = 'c' -- setto per mantenere il centro dello spessore end EgtSetInfo( hint3, 'KeepBackSet', sKeepMode) if hint5 then EgtSetInfo( hint5, 'KeepBackSet', sKeepMode) end end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( hint3, 'ProbeSide', '1') if hint5 then EgtSetInfo( hint5, 'ProbeSide', '1') end end if HB10 then EgtSetInfo( hint3, 'SideDoor', 'LockLH') if hint5 then EgtSetInfo( hint5, 'SideDoor', 'LockLH') end else EgtSetInfo (hint3, 'SideDoor', 'SideLH') if hint5 then EgtSetInfo( hint5, 'SideDoor', 'SideLH') end end if dws then local nIdSideBoxUp = EgtCopyGlob( hint3, Lg) EgtSetName( nIdSideBoxUp, 'upper') EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') if hint5 then nIdSideBoxUp = EgtCopyGlob( hint5, Lg) EgtSetName( nIdSideBoxUp, 'upper') EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') end end return nBI + 1 end -- Funzione di sistemazione parametri function MortiseHinge.AdjustParams( tMhPar) local EgtDoorsMsg = require( 'EgtDoorsMsg') local dMaxMat0 local dMaxMat1 local dMaxMat2 local dNumMessage local dNumLog = 0 local sMessToOut = '' local nTempT0 local nTempT1 local nTempT2 local sMchngName0 local sMchngName1 local sMchngName2 tMhPar.fht = 0 -- setto il face h top a 0 tMhPar.fhb = 0 -- setto il face h bottom a 0 -- parametro disposizione frame su lato wide (se = nil è sulla porta, se true dispsizione frame sul lato wide, se false dispsozione su lato narrow) tMhPar.Dws = DGD.Dws if tMhPar.Dws then -- se disposto sul lato wide, calcolo lo spessore relativo if DGD.nTypePz == 3 or DGD.nTypePz == 4 then tMhPar.dThD = DGD.dW elseif DGD.nTypePz == 5 or DGD.nTypePz == 6 then tMhPar.dThD = DGD.dH end end -- do errore se profilo hinge è tipo bullnose e convesso e non è ammesso if not DGC.Eah and ( DGD.tProfs.hingeedge.trimming == 'CV' or DGD.tProfs.hingeedge.trimming == '1B' or DGD.tProfs.hingeedge.trimming == '2B' or DGD.tProfs.hingeedge.trimming == '3B' or DGD.tProfs.hingeedge.trimming == '4B' or DGD.tProfs.hingeedge.trimming == '5B' or DGD.tProfs.hingeedge.trimming == '6B' or DGD.tProfs.hingeedge.trimming == '7B' or DGD.tProfs.hingeedge.trimming == '8B') then return tMhPar, 1649, string.format(EgtDoorsMsg[428], tMhPar.Nome, DGD.tProfs.hingeedge.trimming) end -- Assegno parametri da ddf tMhPar.H = DGD.dT - DGD.BACK_SET if DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BU' or DGD.tProfs.hingeedge.trimming == 'BDEB' or DGD.tProfs.hingeedge.trimming == 'BUEB' then tMhPar.H = tMhPar.H / cos( 3) tMhPar.bev = true end if DGD.THICKNESS then -- se spessore cerniera da ddf tMhPar.T = DGD.THICKNESS end -- calcolo la posizione del centro foro sullo spessore porta -- se non ruota su profilo bevel o non è bevel if DGC.Fpd or not tMhPar.bev then tMhPar.posh = DGD.dT/2 else tMhPar.posh = (DGD.dT/2) / cos( 3) end -- se non ho il suo parametro setto il chiseling disabilitato if not tMhPar.ech then tMhPar.ech = false end -- se parametro backset è 0 disabilito il chisel e il radius face e il clean corner tMhPar.bETh = false if DGD.BACK_SET == 0 then tMhPar.ech = false -- disattivo il chisel tMhPar.rf = 0 -- disattivo il radius face tMhPar.bETh = true tMhPar.clc = nil tMhPar.CLH = nil end -- se non c'è la variabile suffisso la definisco if not tMhPar.CH then tMhPar.CH = '_Chisel' end -- se è presente un foro extra con opzione continuos hinge risetto la lunghezza hinge pari all'altezza porta if tMhPar.CH4 or tMhPar.CH5 or tMhPar.CH6 or tMhPar.CH7 or tMhPar.CH8 or tMhPar.CH9 or tMhPar.CH10 or tMhPar.CH11 or tMhPar.CH12 or tMhPar.CH13 or tMhPar.CH14 or tMhPar.CH15 or tMhPar.CH16 or tMhPar.CH17 or tMhPar.CH18 then tMhPar.sopp = ( DGD.Lock == 'L' and DGD.Push) or ( DGD.Lock == 'R' and not DGD.Push) if DGD.sFrame then -- se è un assemblato tMhPar.sopp = not tMhPar.sopp -- leggo la nota con il tipo di pezzo local nTypePiece = EgtGetInfo( DGD.PZ, 'Piece Type', 'i') if nTypePiece == 4 or nTypePiece == 3 then tMhPar.L = DGD.dOH or DGD.dH else tMhPar.L = DGD.dH end else tMhPar.L = DGD.dH end end -- setto parametro riferimento profondità hinge tMhPar.drf = DGD.dT/6 if DGD.sFrame then -- se è un assemblato tMhPar.drf = 0 -- in questo modo crea semre la regione da togliere relativa al materiale asportato end -- Assegno parametri da dati utensili in macchina local MB = require( 'MachiningBase') local sLM local nLMi = 1 local sLA local nLAi = 1 local sLG local nLGi = 1 -- se profilo cerniere bevel up if DGD.tProfs.hingeedge.trimming == 'BU' or DGD.tProfs.hingeedge.trimming == 'BUEB' then nLMi = 2 nLAi = 2 -- l'antischeggia avrà le tre lavorazioni identiche perché l'utensile è su aggregato orizzontale nLGi = 2 elseif DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BDEB' then -- se profilo cerniere bevel down nLMi = 3 nLAi = 3 -- l'antischeggia avrà le tre lavorazioni identiche perché l'utensile è su aggregato orizzontale nLGi = 3 end -- se porta steel o aluminum disabilito l'antischeggia, la svuotatura, il chisel e modifico il nome geometria if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then tMhPar.LM = nil tMhPar.LA = nil tMhPar.ech = false tMhPar.CH = nil tMhPar.est = true tMhPar.d2 = nil else tMhPar.est = nil tMhPar.IY4 = nil tMhPar.EBH4 = nil tMhPar.IY5 = nil tMhPar.EBH5 = nil tMhPar.IY6 = nil tMhPar.EBH6 = nil end if tMhPar.est and tMhPar.LG then sLG = tMhPar.LG if DGD.MachEn > 0 and tMhPar.d then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end end if tMhPar.LM then sLM = tMhPar.LM if DGD.MachEn > 0 and tMhPar.d then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLM, nLMi) end end if tMhPar.LA then sLA = tMhPar.LA if DGD.MachEn > 0 and tMhPar.d2 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLA, nLAi) end end -- se devo disegnare le geometrie di lavorazione if DGD.MachEn > 0 then -- gestisco il risultato della lettura utensili if DGD.bProoduce and tMhPar.est and tMhPar.d and nTempT0 and nTempT0 <= 0 then dNumLog = -1646 sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT0, sLG, nLGi, tMhPar.d, dNumLog, sMchngName0) elseif tMhPar.est and nTempT0 then tMhPar.d = nTempT0 end -------------------------------------------------------------------------------- -- se c'è materiale steel faccio in modo che non assegni il diametro utensile -------------------------------------------------------------------------------- -- svuotatura face if DGD.bProoduce and not tMhPar.est and tMhPar.d and nTempT1 and nTempT1 <= 0 then dNumLog = -1646 sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) elseif not tMhPar.est and nTempT1 then tMhPar.d = nTempT1 end -- antischeggia if DGD.bProoduce and not tMhPar.est and tMhPar.d2 and nTempT2 and nTempT2 <= 0 then dNumLog = -1646 sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2) elseif not tMhPar.est and nTempT2 then tMhPar.d2 = nTempT2 end end -- Regola applicazione chiseling: -- se ho impostato un raccordo, anche se poi viene annullato perché inferiore del raggio fresa -- disabilito il chiseling perché se c'è un valore di raccordo non devo fare il chiseling -- se ho il raggio valido disabilito il chiseling e il clean corner if tMhPar.rf and tMhPar.rf > 0 then tMhPar.ech = false tMhPar.clc = nil tMhPar.CLH = nil else -- se non è definito o già nullo lo azzero tMhPar.rf = 0 end -- se devo disegnare le geometrie di lavorazione if DGD.MachEn > 0 then -- Raggio: se altro materiale e raggio presente e se raggio minore del diametro utensile + delta, lo annullo if tMhPar.est and tMhPar.rf and tMhPar.rf > 0 and tMhPar.d and tMhPar.rf < ((tMhPar.d/2)+0.02) then tMhPar.rf = 0 end -- se la profondità della face per steel è maggiore della capacità utensile limito la profondità ed emetto un warning if tMhPar.est and tMhPar.T and dMaxMat0 and tMhPar.T > dMaxMat0 then dNumLog = -1645 dNumMessage = 460 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat0)) tMhPar.T = dMaxMat0 end -- se la profondità della face è maggiore della capacità utensile limito la profondità ed emetto un warning if tMhPar.T and dMaxMat1 and tMhPar.T > dMaxMat1 then dNumLog = -1648 dNumMessage = 460 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) tMhPar.T = dMaxMat1 end -- se la profondità antischeggia della face è maggiore della capacità utensile limito la profondità ed emetto un warning if tMhPar.T and dMaxMat2 and tMhPar.T > dMaxMat2 then dNumLog = -1647 dNumMessage = 462 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat2)) tMhPar.T = dMaxMat2 end -- setto un valore di poco inferiore allo spessore per non fresare le ventose local sPieceName if tMhPar.Dws then tMhPar.TTP = tMhPar.dThD - DGD.Spd if DGD.nTypePz == 3 then sPieceName = 'left Jamb' elseif DGD.nTypePz == 4 then sPieceName = 'right Jamb' elseif DGD.nTypePz == 5 then sPieceName = 'Frame header' else sPieceName = 'Threshold' end end -- controllo se le profondità delle geometrie non superano lo spessore frame if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T and abs(tMhPar.T) > tMhPar.TTP then dNumLog = -1644 dNumMessage = 681 sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T', EgtToUiUnits(tMhPar.T), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) tMhPar.T = tMhPar.TTP end if tMhPar.T and tMhPar.T > 0 then if tMhPar.bev then tMhPar.fht = tMhPar.T / cos(3) -- se passante calcolo l'ingombro sulla parte opposta considerando l'angolo if tMhPar.bETh then tMhPar.fhb = tMhPar.fht + ( DGD.dT * TAN3) else tMhPar.fhb = tMhPar.fht end else tMhPar.fht = tMhPar.T tMhPar.fhb = tMhPar.fht end end if tMhPar.CLH and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.H or tMhPar.clc >= tMhPar.L) then tMhPar.clc = nil elseif not tMhPar.CLH then tMhPar.clc = nil end end -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava if tMhPar.T and ( not tMhPar.sf or abs(tMhPar.sf) < GEO.EPS_SMALL) then tMhPar.sf = tMhPar.T end if dNumLog ~= 0 then return tMhPar, dNumLog, sMessToOut end return tMhPar, 0, '' end -- Funzione di disegno function MortiseHinge.Draw( tMortPar, bPreview, bRunByCompo, nDrawMach) -- Assegno le dimensioni local L = tMortPar.L local H = tMortPar.H local T = tMortPar.T local R = tMortPar.rf local clc = tMortPar.clc local ccr = tMortPar.ccr local d = tMortPar.d local p = tMortPar.p local s = tMortPar.sf local d2 = tMortPar.d2 local posh = tMortPar.posh -- posizione in Y del foro di tastatura local posp = tMortPar.posp -- posizione in X del foro di tastatura local ech = tMortPar.ech local est = tMortPar.est local bEqualTh = tMortPar.bETh local kbs = tMortPar.kbs -- keep backset/thicknesss (0: none, 1: only face, 2: all) local pbs = tMortPar.pbs local fht = tMortPar.fht local fhb = tMortPar.fhb local sopp = tMortPar.sopp local drf = tMortPar.drf local dws = tMortPar.Dws local dthd = tMortPar.dThD local ttp = tMortPar.TTP -- tabella per i fori opzionali local tExtraBore = {} table.insert( tExtraBore, { tMortPar.D3, tMortPar.T3, tMortPar.I3, tMortPar.PX3, tMortPar.PY3, tMortPar.EB3, tMortPar.HB3, tMortPar.IT3}) table.insert( tExtraBore, { tMortPar.D4, tMortPar.IY4, tMortPar.T4, tMortPar.I4, tMortPar.PX4, tMortPar.PY4, tMortPar.RP4, tMortPar.EB4, tMortPar.EBH4, tMortPar.HB4, tMortPar.CH4, tMortPar.BN4, tMortPar.AR4, tMortPar.RCI4, tMortPar.IT4, tMortPar.RCIT4}) table.insert( tExtraBore, { tMortPar.D5, tMortPar.IY5, tMortPar.T5, tMortPar.I5, tMortPar.PX5, tMortPar.PY5, tMortPar.RP5, tMortPar.EB5, tMortPar.EBH5, tMortPar.HB5, tMortPar.CH5, tMortPar.BN5, tMortPar.AR5, tMortPar.RCI5, tMortPar.IT5, tMortPar.RCIT5}) table.insert( tExtraBore, { tMortPar.D6, tMortPar.IY6, tMortPar.T6, tMortPar.I6, tMortPar.PX6, tMortPar.PY6, tMortPar.RP6, tMortPar.EB6, tMortPar.EBH6, tMortPar.HB6, tMortPar.CH6, tMortPar.BN6, tMortPar.AR6, tMortPar.RCI6, tMortPar.IT6, tMortPar.RCIT6}) table.insert( tExtraBore, { tMortPar.D7, tMortPar.IY7, tMortPar.T7, tMortPar.I7, tMortPar.PX7, tMortPar.PY7, tMortPar.RP7, tMortPar.EB7, tMortPar.EBH7, tMortPar.HB7, tMortPar.CH7, tMortPar.BN7, tMortPar.AR7, tMortPar.RCI7, tMortPar.IT7, tMortPar.RCIT7}) table.insert( tExtraBore, { tMortPar.D8, tMortPar.IY8, tMortPar.T8, tMortPar.I8, tMortPar.PX8, tMortPar.PY8, tMortPar.RP8, tMortPar.EB8, tMortPar.EBH8, tMortPar.HB8, tMortPar.CH8, tMortPar.BN8, tMortPar.AR8, tMortPar.RCI8, tMortPar.IT8, tMortPar.RCIT8}) table.insert( tExtraBore, { tMortPar.D9, tMortPar.IY9, tMortPar.T9, tMortPar.I9, tMortPar.PX9, tMortPar.PY9, tMortPar.RP9, tMortPar.EB9, tMortPar.EBH9, tMortPar.HB9, tMortPar.CH9, tMortPar.BN9, tMortPar.AR9, tMortPar.RCI9, tMortPar.IT9, tMortPar.RCIT9}) table.insert( tExtraBore, { tMortPar.D10, tMortPar.IY10, tMortPar.T10, tMortPar.I10, tMortPar.PX10, tMortPar.PY10, tMortPar.RP10, tMortPar.EB10, tMortPar.EBH10, tMortPar.HB10, tMortPar.CH10, tMortPar.BN10, tMortPar.AR10, tMortPar.RCI10, tMortPar.IT10, tMortPar.RCIT10}) table.insert( tExtraBore, { tMortPar.D11, tMortPar.IY11, tMortPar.T11, tMortPar.I11, tMortPar.PX11, tMortPar.PY11, tMortPar.RP11, tMortPar.EB11, tMortPar.EBH11, tMortPar.HB11, tMortPar.CH11, tMortPar.BN11, tMortPar.AR11, tMortPar.RCI11, tMortPar.IT11, tMortPar.RCIT11}) table.insert( tExtraBore, { tMortPar.D12, tMortPar.IY12, tMortPar.T12, tMortPar.I12, tMortPar.PX12, tMortPar.PY12, tMortPar.RP12, tMortPar.EB12, tMortPar.EBH12, tMortPar.HB12, tMortPar.CH12, tMortPar.BN12, tMortPar.AR12, tMortPar.RCI12, tMortPar.IT12, tMortPar.RCIT12}) table.insert( tExtraBore, { tMortPar.D13, tMortPar.IY13, tMortPar.T13, tMortPar.I13, tMortPar.PX13, tMortPar.PY13, tMortPar.RP13, tMortPar.EB13, tMortPar.EBH13, tMortPar.HB13, tMortPar.CH13, tMortPar.BN13, tMortPar.AR13, tMortPar.RCI13, tMortPar.IT13, tMortPar.RCIT13}) table.insert( tExtraBore, { tMortPar.D14, tMortPar.IY14, tMortPar.T14, tMortPar.I14, tMortPar.PX14, tMortPar.PY14, tMortPar.RP14, tMortPar.EB14, tMortPar.EBH14, tMortPar.HB14, tMortPar.CH14, tMortPar.BN14, tMortPar.AR14, tMortPar.RCI14, tMortPar.IT14, tMortPar.RCIT14}) table.insert( tExtraBore, { tMortPar.D15, tMortPar.IY15, tMortPar.T15, tMortPar.I15, tMortPar.PX15, tMortPar.PY15, tMortPar.RP15, tMortPar.EB15, tMortPar.EBH15, tMortPar.HB15, tMortPar.CH15, tMortPar.BN15, tMortPar.AR15, tMortPar.RCI15, tMortPar.IT15, tMortPar.RCIT15}) table.insert( tExtraBore, { tMortPar.D16, tMortPar.IY16, tMortPar.T16, tMortPar.I16, tMortPar.PX16, tMortPar.PY16, tMortPar.RP16, tMortPar.EB16, tMortPar.EBH16, tMortPar.HB16, tMortPar.CH16, tMortPar.BN16, tMortPar.AR16, tMortPar.RCI16, tMortPar.IT16, tMortPar.RCIT16}) table.insert( tExtraBore, { tMortPar.D17, tMortPar.IY17, tMortPar.T17, tMortPar.I17, tMortPar.PX17, tMortPar.PY17, tMortPar.RP17, tMortPar.EB17, tMortPar.EBH17, tMortPar.HB17, tMortPar.CH17, tMortPar.BN17, tMortPar.AR17, tMortPar.RCI17, tMortPar.IT17, tMortPar.RCIT17}) table.insert( tExtraBore, { tMortPar.D18, tMortPar.IY18, tMortPar.T18, tMortPar.I18, tMortPar.PX18, tMortPar.PY18, tMortPar.RP18, tMortPar.EB18, tMortPar.EBH18, tMortPar.HB18, tMortPar.CH18, tMortPar.BN18, tMortPar.AR18, tMortPar.RCI18, tMortPar.IT18, tMortPar.RCIT18}) -- Assegno i nomi geometrie local LG = tMortPar.LG local LM = tMortPar.LM local LA = tMortPar.LA local CH = tMortPar.CH local CLH = tMortPar.CLH local LH = 'Hinge_Probe' local DM = 'DUMMY' -- variabili per messaggi e settaggi vari local sCompoName = tMortPar.Nome local nCompoNpar = tMortPar.Npar local sCompoPath = tMortPar.Path -- eventuale messaggio errore rilevato nell'adjust local nCodAdj = tMortPar.nCod local sCodAdj = tMortPar.sCod -- nomi parametri per messaggi local sNamePar1 = tMortPar.N1 or 'L' local sNamePar2 = tMortPar.N2 or 'H' local sNamePar3 = tMortPar.N3 or 'T' local sNamePar4 = tMortPar.N4 or 'd' local sNamePar5 = tMortPar.N5 or 'p' local sNamePar6 = tMortPar.N6 or 'd2' local sNamePar7 = tMortPar.N7 or 's' local sNamePar8 = tMortPar.N8 or 'R' local sNamePar9 = tMortPar.N9 or 'clc' local sNamePar10 = tMortPar.N10 or 'ccr' -- settaggio opzione per partenza ad angolo o meno local bStartAng = true local bStartOppo = true -- RunByComponetInterface local RC = true -- Messaggi codice errori local EM = ' ' local EC = 0 local ErrorBase = 1600 if not bRunByCompo then -- controllo se lanciato da componente RC = false end -- 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 -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione nDrawMach = 0 end local nForceMakeFace = nDrawMach -- se ho abilitato il chiseling modifico il nome geometria if ech then LG = LG .. CH -- se ho abilitato solo le geometrie di lavorazione, abilito la generazione di entrambe per il contorno chisel if nDrawMach == 1 then nForceMakeFace = 2 end end local EgtDoorsMsg = require( 'EgtDoorsMsg') -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata if nDrawMach > 0 and d 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 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 H <= 0 then EC = 3 EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0 H = d/2 elseif nDrawMach > 0 and L and d and L <= d then if DGD.bProoduce then EC = 4 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 d2 and L and L <= d2 then if DGD.bProoduce then EC = 5 EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar6,EgtToUiUnits(d2), sCompoPath) -- il parametro 'L' deve essere maggiore al diametro utensile L = d2 + 0.002 else d2 = L - 0.002 end elseif nDrawMach > 0 and p and ( p < PtMin or p > PtMax) then EC = 6 EM = string.format(EgtDoorsMsg[403],sNamePar5,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra p = 0.8 elseif T and T < 0 then EC = 7 EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 T = 0 elseif L and L <= 0 then EC = 8 EM = string.format(EgtDoorsMsg[401],sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L' deve essere > 0 L = d elseif nDrawMach > 0 and s and s < 0 then EC = 9 EM = string.format(EgtDoorsMsg[401],sNamePar7,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 s = d elseif R and L and 2*R >= L then EC = 10 EM = string.format(EgtDoorsMsg[406],sNamePar8,EgtToUiUnits(R),sNamePar1..'/2',EgtToUiUnits(L/2), sCompoPath) -- il parametro 'R' deve essere < del parametro L/2 R = d/2 elseif R and H and R >= H then EC = 11 EM = string.format(EgtDoorsMsg[406],sNamePar8,EgtToUiUnits(R),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'R' deve essere < del parametro H R = d/2 elseif CLH and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then EC = 12 EM = string.format(EgtDoorsMsg[407],sNamePar9,EgtToUiUnits(clc),'',EgtToUiUnits(2*(ccr*sin(45))), sCompoPath) -- il parametro 'clc' deve essere > 'crc' clc = (2*(ccr*sin(45)))+0.2 end if not bPreview and EC ~= 0 then return (ErrorBase+EC), EM end -- Se Preview cancello tutto if bPreview then EgtNewFile() EgtSetDefaultMaterial( BLACK()) end -- Pezzo e Layer local Pz if bPreview then Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo else if not RC then Pz = EgtGetCurrPart() -- pezzo corrente end if not Pz then Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo end end local Lg, Dm 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, hint3, hint4, hint5 local hint, hintPk, hintAs1, hintAs2, hintPr, hintPkR, hintAsR1, hintAsR2 local nIdSideBoxUp local pIni, pEnd, pCen local pIni2, pEnd2 if nForceMakeFace ~= 1 and T and T > 0 then -- se abilitata geometria esterna -- Costruzione della geometria if bEqualTh then -- se cava alta come lo spessore porta o porta steel, disegno un contorno chiuso if est then hint1 = DrawAddLineDrawCircle( Point3d(-((L/2)-(d/2)-dExtraH),((d/2)+dExtraH),0), Point3d((L/2),((d/2)+dExtraH),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) hint2 = DrawAddLineDrawCircle( Point3d((L/2),((d/2)+dExtraH),0), Point3d((L/2),-H,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) hint3 = DrawAddLineDrawCircle( Point3d((L/2),-H,0), Point3d(-(L/2),-H,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) hint4 = DrawAddLineDrawCircle( Point3d(-(L/2),-H,0), Point3d(-(L/2),((d/2)+dExtraH),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) hint5 = DrawAddLineDrawCircle( Point3d(-(L/2),((d/2)+dExtraH),0), Point3d(-((L/2)-(d/2)-dExtraH),((d/2)+dExtraH),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) hint = EgtCurveCompo( Lg, {hint1,hint2,hint3,hint4,hint5}, true) else hint1 = DrawAddLineDrawCircle( Point3d(0,0,0), Point3d((L/2),0,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) hint2 = DrawAddLineDrawCircle( Point3d((L/2),0,0), Point3d((L/2),-H,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) hint3 = DrawAddLineDrawCircle( Point3d((L/2),-H,0), Point3d(-(L/2),-H,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) hint4 = DrawAddLineDrawCircle( Point3d(-(L/2),-H,0), Point3d(-(L/2),0,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) hint5 = DrawAddLineDrawCircle( Point3d(-(L/2),0,0), Point3d(0,0,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) hint = EgtCurveCompo( Lg, {hint1,hint2,hint3,hint4,hint5}, true) end else -- altrimenti contorno aperto -- Costruzione della geometria cerniera ( in senso orario) local tPocket = {} if est then pIni = Point3d(-((L/2)-(d/2)-dExtraH),((d/2)+dExtraH),0) pEnd = Point3d(L/2,((d/2)+dExtraH),0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd else pIni = Point3d(L/2,0,0) end if R > 0 then pEnd = Point3d(L/2,(-H+R),0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd pEnd = Point3d(((L/2)-R),-H,0) pCen = Point3d(((L/2)-R),(-H+R),0) DrawAddCircleDrawCircle( pCen, R, 0,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd else pEnd = Point3d(L/2,-H,0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd end if R > 0 then pEnd = Point3d((-(L/2)+R),-H,0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd pEnd = Point3d(-(L/2),(-H+R),0) pCen = Point3d((-(L/2)+R),(-H+R),0) DrawAddCircleDrawCircle( pCen, R, -90,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd else pEnd = Point3d(-(L/2),-H,0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd end if est then pEnd = Point3d(-(L/2),((d/2)+dExtraH),0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd pEnd = Point3d(-((L/2)-(d/2)-dExtraH),((d/2)+dExtraH),0) else pEnd = Point3d(-(L/2),0,0) end DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) pIni = pEnd hint = EgtCurveCompo( Lg, tPocket, true) end EgtModifyCurveThickness( hint, -T) EgtSetName( hint, LG) if est then EgtSetInfo( hint, 'StartFromExt', 1) end -- se mantiene backset if kbs and kbs > 0 then local sKeepMode = 'n' -- setto di default per mantenere il lato narrow if bEqualTh then -- se spessore passante sKeepMode = 'c' -- setto per mantenere il centro dello spessore end EgtSetInfo( hint, 'KeepBackSet', sKeepMode) end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( hint, 'ProbeSide', '1') end end if nDrawMach >= 0 then -- se abilitata geometria lavorazione -- fori ( viti o passaggio filo elettrico) for k = 1, 16 do local D10 local IY10 local T10 local I10 local IT10 local PX10 local PY10 local RP10 local EB10 local EBH10 local HB10 local CH10 local BN10 local AR10 local RCI10 local RCIT10 if k == 1 then D10 = tExtraBore[k][1] T10 = tExtraBore[k][2] I10 = tExtraBore[k][3] PX10 = tExtraBore[k][4] PY10 = tExtraBore[k][5] EB10 = tExtraBore[k][6] HB10 = tExtraBore[k][7] IT10 = tExtraBore[k][8] else D10 = tExtraBore[k][1] IY10 = tExtraBore[k][2] T10 = tExtraBore[k][3] I10 = tExtraBore[k][4] PX10 = tExtraBore[k][5] PY10 = tExtraBore[k][6] RP10 = tExtraBore[k][7] EB10 = tExtraBore[k][8] EBH10 = tExtraBore[k][9] HB10 = tExtraBore[k][10] CH10 = tExtraBore[k][11] BN10 = tExtraBore[k][12] AR10 = tExtraBore[k][13] RCI10 = tExtraBore[k][14] IT10 = tExtraBore[k][15] RCIT10 = tExtraBore[k][16] end if dws and T10 and abs(T10) > ttp then T10 = ttp end if D10 and T10 and ( EB10 or EBH10) then if D10 > 0 and T10 ~= 0 and ( EB10 ~= '' or EBH10 ~= '') then if not IY10 then IY10 = 0 end if not I10 then I10 = 0 end if not PX10 then PX10 = 0 end if not PY10 then PY10 = 0 end if not AR10 then AR10 = 0 end if not IT10 then IT10 = 0 end local dInt10 = (I10/2) local dIntT10 = (IT10/2) local dPosX10 = PX10 local bInvDir = sopp local nBI = 0 if not BN10 or BN10 < 0 then BN10 = 2000 end if abs(AR10) >= 360 then while abs(AR10) >= 360 do AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) end end if CH10 then -- se è presente il continuos hinge setto la posizione di partenza dove PX10 è la distanza iniziale dal bordo (L/2) if I10 < 0 then bInvDir = not sopp end dInt10 = 0 -- se la posizione è negativa tengo la distribuzione centrata if PX10 < 0 then local nStep = floor( ( L - D10) / EgtIf( abs(I10) > 0, abs(I10), ( L - D10))) dPosX10 = (( nStep * abs(I10)) / 2) * EgtIf( bInvDir, 1, -1) -- se ho posizione 0 annullo la creazione dei fori if abs(dPosX10) < GEO.EPS_SMALL then PX10 = 2*L end else dPosX10 = ( (L/2) - EgtIf( dPosX10 > (D10/2), dPosX10, (D10/2))) * EgtIf( bInvDir, 1, -1) end if abs(PX10) < ( L - D10) and nBI < BN10 then -- creo foro o asola con eventuale svuotatura a rampa nBI = MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, dInt10, dIntT10, D10, -H, PY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, nBI, pbs, RCIT10) -- se l'interasse lungo lo spessore è valido if abs(IT10) > GEO.EPS_SMALL then -- creo foro o asola con eventuale svuotatura a rampa nBI = MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, dInt10, -dIntT10, D10, -H, PY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, nBI, pbs, RCIT10) end end elseif nBI < BN10 then -- creo foro o asola con eventuale svuotatura a rampa nBI = MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, dInt10, dIntT10, D10, -H, PY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, nBI, pbs, RCIT10) end if CH10 and abs(I10) > D10/2 then dInt10 = 0 -- primo passo local dPosStep = dPosX10 + EgtIf( bInvDir, -abs(I10), abs(I10)) while abs(dPosStep) <= ( ( L - D10) / 2) and nBI < BN10 do -- creo foro o asola con eventuale svuotatura a rampa nBI = MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosStep, -dInt10, dIntT10, D10, -H, PY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, nBI, pbs, RCIT10) -- se l'interasse lungo lo spessore è valido if abs(IT10) > GEO.EPS_SMALL then -- creo foro o asola con eventuale svuotatura a rampa nBI = MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosStep, -dInt10, -dIntT10, D10, -H, PY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, nBI, pbs, RCIT10) end dPosStep = dPosStep + EgtIf( bInvDir, -abs(I10), abs(I10)) end else -- se l'interasse lungo lo spessore è valido if abs(IT10) > GEO.EPS_SMALL and nBI < BN10 then -- creo foro o asola con eventuale svuotatura a rampa nBI = MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, dInt10, -dIntT10, D10, -H, PY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, nBI, pbs, RCIT10) end -- se l'interasse lungo l'altezza porta è valido if abs(I10) > GEO.EPS_SMALL and nBI < BN10 then -- creo foro o asola con eventuale svuotatura a rampa nBI = MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, -dInt10, dIntT10, D10, -H, PY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, nBI, pbs, RCIT10) -- se l'interasse lungo lo spessore è valido if abs(IT10) > GEO.EPS_SMALL then -- creo foro o asola con eventuale svuotatura a rampa nBI = MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, -dInt10, -dIntT10, D10, -H, PY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, nBI, pbs, RCIT10) end end end end end end -- Clean corner if CLH and clc and clc > 0 and clc < H and clc < L then local CLC1 = MakeClcPath( clc, ccr, CLH, Lg, -T) if CLC1 then -- se mantiene backset if kbs and kbs > 0 then local sKeepMode = 'n' -- setto di default per mantenere il lato narrow if bEqualTh then -- se spessore passante sKeepMode = 'c' -- setto per mantenere il centro dello spessore end EgtSetInfo( CLC1, 'KeepBackSet', sKeepMode) end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( CLC1, 'ProbeSide', '1') end -- angolo x+y- local CLC2 = EgtCopyGlob( CLC1, Lg) EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), 180) EgtMove( CLC2, Point3d((L/2),-H,0) - ORIG()) -- angolo x-y- EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 90) EgtMove( CLC1, Point3d(-(L/2),-H,0) - ORIG()) 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 local dZedStart local dZedWork local nStep local dStep local nPass -- geometria antischeggia if d2 then -- se parametro valido local tPocketAs = {} local tPocketAs2 = {} if s >= T and T > 0 then -- se passo unico local dPosY, dEndPosY, dIniPosY, dDeltaPosX local dPosY2, dEndPosY2, dIniPosY2 if bStartAng then -- se lead-in con angolo if H >= (d2*3/4) then if (H-R) > (d2/4) then dEndPosY = -(d2/4) dEndPosY2 = (-H+(d2/4)) else dEndPosY = -(H-R) dEndPosY2 = -R end else if (H-R) > 0 then dEndPosY = -(H-R) dEndPosY2 = -R else dEndPosY = -H+(d2/2) dEndPosY2 = -(d2/2) end end dPosY = dEndPosY + (d2/8) dPosY2 = dEndPosY2 - (d2/8) dIniPosY = dPosY + (d2*7/8) dIniPosY2 = dPosY2 - (d2*7/8) dDeltaPosX = ( (d2*7/8) / tan(30)) -- linea entrante inclinata pIni = Point3d(-((L-d2)/2) + 0.2 + dDeltaPosX, dIniPosY,0) pEnd = Point3d(-((L-d2)/2) + 0.2, dPosY,0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) -- linea entrante in Y pIni = pEnd pEnd = Point3d(-((L-d2)/2) + 0.2, dEndPosY,0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) -- linee tangente al percorso pIni = pEnd pEnd = Point3d(-((L-d2)/2), dEndPosY,0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) -- linea di uscita pIni = pEnd pEnd = Point3d(-((L-d2)/2),(d2*3/4),0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) if bEqualTh then -- linea entrante inclinata pIni = Point3d((((L-d2)/2) - 0.2 - dDeltaPosX), dIniPosY2,0) pEnd = Point3d((((L-d2)/2) - 0.2), dPosY2,0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs2, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) -- linea entrante in Y pIni = pEnd pEnd = Point3d((((L-d2)/2) - 0.2), dEndPosY2,0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) -- linee tangente al percorso pIni = pEnd pEnd = Point3d(((L-d2)/2), dEndPosY2,0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) -- linea di uscita pIni = pEnd pEnd = Point3d(((L-d2)/2),(-H-(d2*3/4)),0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) end else -- lead-in diritto if H >= (d2*3/4) then if (H-R) > (d2/4) then dEndPosY = -(d2/4) dEndPosY2 = -H+(d2/4) else dEndPosY = -(H-R) dEndPosY2 = -R end else if (H-R) > 0 then dEndPosY = -(H-R) dEndPosY2 = -R else dEndPosY = -H+(d2/2) dEndPosY2 = -(d2/2) end end dIniPosY = (d2*3/4) dIniPosY2 = -H-(d2*3/4) pIni = Point3d(-((L-d2)/2), dIniPosY,0) pEnd = Point3d(-((L-d2)/2), dEndPosY,0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) if bEqualTh then pIni = Point3d(((L-d2)/2), dIniPosY2,0) pEnd = Point3d(((L-d2)/2), dEndPosY2,0) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs2, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) end end -- trasformo in geometria composita if ( #tPocketAs > 0) then hintAs1 = EgtCurveCompo( Lg, tPocketAs, true) if hintAs1 then EgtModifyCurveThickness( hintAs1, -T) end end if ( #tPocketAs2 > 0) then hintAs2 = EgtCurveCompo( Lg, tPocketAs2, true) if hintAs2 then EgtModifyCurveThickness( hintAs2, -T) end end else -- altrimenti più passate nStep = ceil(T/s) -- numero di passate dStep = (T/nStep) -- passo ricalcolato nPass = 1 dZedStart = 0 local tMVar = {} local tMVar2 = {} local nConEnt local sKindVar local dPosY, dEndPosY, dIniPosY, dDeltaPosX local dPosY2, dEndPosY2, dIniPosY2 while nPass <= nStep do dZedWork = dZedStart - dStep if nPass == nStep then dZedWork = -T end if bStartAng then -- se lead-in con angolo if H >= (d2*3/4) then if (H-R) > (d2/4) then dEndPosY = -(d2/4) dEndPosY2 = -H+(d2/4) else dEndPosY = -(H-R) dEndPosY2 = -R end else if (H-R) > 0 then dEndPosY = -(H-R) dEndPosY2 = -R else dEndPosY = -H+(d2/2) dEndPosY2 = -(d2/2) end end dPosY = dEndPosY + (d2/8) dPosY2 = dEndPosY2 - (d2/8) dIniPosY = dPosY + (d2*7/8) dIniPosY2 = dPosY2 - (d2*7/8) dDeltaPosX = ( (d2*7/8) / tan(30)) -- linea entrante inclinata pIni = Point3d(-((L-d2)/2) + 0.2 + dDeltaPosX, dIniPosY, dZedWork) pEnd = Point3d(-((L-d2)/2) + 0.2, dPosY, dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) -- linea entrante in Y pIni = pEnd pEnd = Point3d(-((L-d2)/2) + 0.2, dEndPosY, dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) -- linee tangente al percorso pIni = pEnd pEnd = Point3d(-((L-d2)/2), dEndPosY, dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) -- linea di uscita pIni = pEnd pEnd = Point3d(-((L-d2)/2),(d2*3/4), dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) pIni = pEnd pEnd = Point3d(-((L-d2)/2) + 0.2 + dDeltaPosX, pIni:getY(), dZedWork) if bEqualTh then -- linea entrante inclinata pIni2 = Point3d(((L-d2)/2) - 0.2 - dDeltaPosX, dIniPosY2,dZedWork) pEnd2 = Point3d(((L-d2)/2) - 0.2, dPosY2,dZedWork) DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) -- linea entrante in Y pIni2 = pEnd2 pEnd2 = Point3d(((L-d2)/2) - 0.2, dEndPosY2,dZedWork) DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) -- linee tangente al percorso pIni2 = pEnd2 pEnd2 = Point3d(((L-d2)/2), dEndPosY2,dZedWork) DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) -- linea di uscita pIni2 = pEnd2 pEnd2 = Point3d(((L-d2)/2),(-H-(d2*3/4)),dZedWork) DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) pIni2 = pEnd2 pEnd2 = Point3d(((L-d2)/2) - 0.2 - dDeltaPosX, pIni2:getY(), dZedWork) end else -- lead-in diritto if H >= (d2*3/4) then if (H-R) > (d2/4) then dEndPosY = -(d2/4) dEndPosY2 = -H+(d2/4) else dEndPosY = -(H-R) dEndPosY2 = -R end else if (H-R) > 0 then dEndPosY = -(H-R) dEndPosY2 = -R else dEndPosY = -H+(d2/2) dEndPosY2 = -(d2/2) end end dIniPosY = (d2*3/4) dIniPosY2 = -H-(d2*3/4) pIni = Point3d(-((L-d2)/2) + 0.2, dIniPosY, dZedWork) pEnd = Point3d(-((L-d2)/2) + 0.2, dEndPosY, dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) -- faccio il ritorno alla posizione di partenza pIni = pEnd pEnd = Point3d( pIni:getX() - 0.2, dEndPosY, dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) pIni = pEnd pEnd = Point3d( pIni:getX(), dIniPosY, dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) pIni = pEnd pEnd = Point3d(-((L-d2)/2) + 0.2, pIni:getY(), dZedWork) if bEqualTh then pIni2 = Point3d(((L-d2)/2) - 0.2, dIniPosY2, dZedWork) pEnd2 = Point3d(((L-d2)/2) - 0.2, dEndPosY2, dZedWork) DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) -- faccio il ritorno alla posizione di partenza pIni2 = pEnd2 pEnd2 = Point3d(((L-d2)/2), dEndPosY2, dZedWork) DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) pIni2 = pEnd2 pEnd2 = Point3d( pIni2:getX(), dIniPosY2, dZedWork) DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) pIni2 = pEnd2 pEnd2 = Point3d(((L-d2)/2) + 0.2, pIni2:getY(), dZedWork) end 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 bEqualTh then local pIniLoc2 = pEnd2 pEnd2 = Point3d(pIniLoc2:getX(), pIniLoc2: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 hintAs1 = EgtCurveCompo( Lg, tPocketAs, true) if hintAs1 then EgtModifyCurveThickness( hintAs1, 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( hintAs1, 'MVar', sListEnt) end end end if ( #tPocketAs2 > 0) then 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 hintAs1 then EgtSetName( hintAs1, LA) EgtSetInfo( hintAs1, 'NotCheckDir', '1') -- se mantiene backset if kbs and kbs > 0 then local sKeepMode = 'n' -- setto di default per mantenere il lato narrow if bEqualTh then -- se spessore passante sKeepMode = 'c' -- setto per mantenere il centro dello spessore end EgtSetInfo( hintAs1, 'KeepBackSet', sKeepMode) end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( hintAs1, 'ProbeSide', '1') end end if hintAs2 then EgtSetName( hintAs2, LA) EgtSetInfo( hintAs2, 'NotCheckDir', '1') -- se mantiene backset if kbs and kbs > 0 then local sKeepMode = 'n' -- setto di default per mantenere il lato narrow if bEqualTh then -- se spessore passante sKeepMode = 'c' -- setto per mantenere il centro dello spessore end EgtSetInfo( hintAs2, 'KeepBackSet', sKeepMode) end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( hintAs2, 'ProbeSide', '1') end end end -- cerchiolino/i per tastatura if posh and T > 0 then local dPosProbe = 0 local sPositiveSuffixProbe = '' local sNegativeSuffixProbe = '' if posp and posp > 0 then dPosProbe = (L/2) + posp sPositiveSuffixProbe = '_POS' sNegativeSuffixProbe = '_NEG' end pCen = Point3d( dPosProbe, -posh, 0) hintPr = DrawAddCircleDrawCircle( pCen, 1, 0,-360, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) -- verifico se devo forzare direzione orizzontale o seguire il profilo local sSideDoorInfo if DGC.Fpd then sSideDoorInfo = 'LockLH' else sSideDoorInfo = EgtIf( dl, 'LockLH', 'SideLH') end if hintPr then EgtModifyCurveThickness( hintPr, -10) EgtSetName( hintPr, LH..sPositiveSuffixProbe) EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) end if dPosProbe > 0 then pCen = Point3d( -dPosProbe, -posh,0) hintPr = DrawAddCircleDrawCircle( pCen, 1, 0,-360, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) if hintPr then EgtModifyCurveThickness( hintPr, -10) EgtSetName( hintPr, LH..sNegativeSuffixProbe) EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) end end end --------------------------------------- -- geometria svuotatura giro esterno --------------------------------------- if not est then -- se non c'è lavorazione steel local tPocket = {} local tMVar = {} local nConEnt local sKindVar local pStart nStep = ceil(T/s) -- numero di passate dStep = (T/nStep) -- passo ricalcolato nPass = 1 dZedStart = 0 while nPass <= nStep do dZedWork = dZedStart - dStep if nPass == nStep then dZedWork = -T end if bStartOppo then pIni = Point3d(-((L-d)/2) + 0.2,(d*3/4),dZedWork) pStart = pIni -- memorizzo punto per ritorno e re-iniziare nuovo step -- linea in Y con centro utensile fuori pEnd = Point3d(-((L-d)/2) + 0.2,dExtraH,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) -- linea traversa in X per andare sul vecchio punto iniziale (in X) pIni = pEnd pEnd = Point3d(((L-d)/2),dExtraH,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) pIni = pEnd else pIni = Point3d(((L-d)/2),(d*3/4),dZedWork) pStart = pIni -- memorizzo punto per ritorno e reiniziare nuovo step end local bDrawCircle = EgtIf( bStartOppo, false, true) if H <= (d/2) then -- se cava troppo bassa -- linea entrante in Y if bEqualTh then pEnd = Point3d(((L-d)/2),-H-dExtraH,dZedWork) else pEnd = Point3d(((L-d)/2),-H+(d/2),dZedWork) end DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), bDrawCircle, true, RED(), RED()) -- linea traversa in X pIni = pEnd if bEqualTh then pEnd = Point3d(-((L-d)/2),-H-dExtraH,dZedWork) else pEnd = Point3d(-((L-d)/2),-H+(d/2),dZedWork) end DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) -- linea di risalita in Y pIni = pEnd pEnd = Point3d(-((L-d)/2),(d*3/4),dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) pIni = pEnd else if R > (d/2) then -- linea entrante in Y pEnd = Point3d(((L-d)/2),(-H+R),dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), bDrawCircle, true, RED(), RED()) -- raccordo 1 pIni = pEnd pEnd = Point3d(((L/2)-R),-H+(d/2),dZedWork) pCen = Point3d(((L/2)-R),(-H+R),dZedWork) DrawAddCircleDrawCircle( pCen, (R-(d/2)), 0,-90, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) -- linea traversa in X pIni = pEnd pEnd = Point3d((-(L/2)+R),-H+(d/2),dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) -- raccordo 2 pIni = pEnd pEnd = Point3d(-((L-d)/2),(-H+R),dZedWork) pCen = Point3d((-(L/2)+R),(-H+R),dZedWork) DrawAddCircleDrawCircle( pCen, (R-(d/2)), -90,-90, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) pIni = pEnd else -- linea entrante in Y if bEqualTh then pEnd = Point3d(((L-d)/2),-H-dExtraH,dZedWork) else pEnd = Point3d(((L-d)/2),-H+(d/2),dZedWork) end DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), bDrawCircle, true, RED(), RED()) -- linea traversa in X pIni = pEnd if bEqualTh then pEnd = Point3d(-((L-d)/2),-H-dExtraH,dZedWork) else pEnd = Point3d(-((L-d)/2),-H+(d/2),dZedWork) end DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) pIni = pEnd end -- linea di risalita in Y pEnd = Point3d(-((L-d)/2),dExtraH,dZedWork) DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) pIni = pEnd -- linea di riposizionamento in X if bStartOppo then pEnd = Point3d(-(((L*2)-(d*3))/4),dExtraH,dZedWork) else pEnd = Point3d((((L*2)-(d*3))/4),dExtraH,dZedWork) end DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) pIni = pEnd local nDirVers = EgtIf( bStartOppo, 1, -1) local nDistYcentr = (d*p) local nPosYcentr = dExtraH - nDistYcentr local nDeltaXPk = 0 local bContinue if bEqualTh then bContinue = nPosYcentr > -H else bContinue = nPosYcentr > (-H+(d/2)) end -- se c'è il raggio e la coordinata Y è entrata nell'influenza del raccordo ne calcolo il delta in x if bContinue and R > (d/2) and nPosYcentr < (-H+R) then local nDeltaY = nPosYcentr - (-H+R) nDeltaXPk = (R-(d/2)) - sqrt( ((R-(d/2))*(R-(d/2))) - (nDeltaY*nDeltaY)) end pEnd = Point3d((-nDirVers * ((((L*2)-(d*3))/4)-nDeltaXPk)),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()) pIni = pEnd -- linea passata in X pEnd = Point3d((nDirVers * ((((L*2)-(d*3))/4)-nDeltaXPk)),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 if bEqualTh then bContinue = nPosYcentr > -H else bContinue = nPosYcentr > ( -H +(d/2)) end -- calcolo il delta x relativo alla presenza del raccordo if bContinue and R > (d/2) and nPosYcentr < (-H+R) then local nDeltaY = nPosYcentr - (-H+R) nDeltaXPk = (R-(d/2)) - sqrt( ((R-(d/2))*(R-(d/2))) - (nDeltaY*nDeltaY)) end -- se ancora dentro l'area if bContinue then nDirVers = -nDirVers -- ricalcolo punti per linea successiva pIni = pEnd pEnd = Point3d((-nDirVers * ((((L*2)-(d*3))/4)-nDeltaXPk)),nPosYcentr,dZedWork) end end -- end while -- linea di risalita in Y pIni = pEnd pEnd = Point3d(pIni:getX(), (d*3/4), dZedWork) 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) EgtSetInfo( hintPk, 'NotCheckDir', '1') -- se mantiene backset if kbs and kbs > 0 then local sKeepMode = 'n' -- setto di default per mantenere il lato narrow if bEqualTh then -- se spessore passante sKeepMode = 'c' -- setto per mantenere il centro dello spessore end EgtSetInfo( hintPk, 'KeepBackSet', sKeepMode) end if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then EgtSetInfo( hintPk, 'ProbeSide', '1') end else EC = ErrorBase + 13 EM = string.format(EgtDoorsMsg[427], sCompoPath) end end end if EC == 0 then if not dws then -- se frame viene disposto sul lato narrow o è sulla porta(disposto sul lato stretto) -- se la sezione supera 1/6 dello spessore porta (se è un frame drf vale 0 e crea sempre regione) -- disegno sezione ribasso su faccia superiore/inferiore porta if fhb > drf then -- setto griglia dietro per l'ingombro sicuramente esistente EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.BACK)) nIdSideBoxUp = EgtRectangle2P( Lg, Point3d((L/2),0,0), Point3d(-(L/2),fhb,0), GDB_RT.LOC) if nIdSideBoxUp then if bEqualTh then EgtModifyCurveThickness(nIdSideBoxUp, -DGD.dT) else EgtModifyCurveThickness(nIdSideBoxUp, -H) end EgtSetName( nIdSideBoxUp, 'upper') EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') end EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) end else -- altrimenti viene lavorato disposto sul lato wide if hint then nIdSideBoxUp = EgtCopyGlob( hint, Lg) EgtSetName( nIdSideBoxUp, 'upper') EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') end end end end -- cambio colore alla geometria if bPreview then if EC == 0 then if hint then EgtSetColor(hint,AQUA()) end if hintAs1 then EgtSetColor(hintAs1,AQUA()) end if hintAs2 then EgtSetColor(hintAs2,AQUA()) end if hintPk then EgtSetColor(hintPk,AQUA()) end if nIdSideBoxUp then EgtSetColor(nIdSideBoxUp,AQUA()) end else if hint then EgtSetColor(hint,ORANGE()) end if hintAs1 then EgtSetColor(hintAs1,ORANGE()) end if hintAs2 then EgtSetColor(hintAs2,ORANGE()) end if hintPk then EgtSetColor(hintPk,ORANGE()) end if nIdSideBoxUp then EgtSetColor(nIdSideBoxUp,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 nDrawMach > 0 then -- se abilitata geometria lavorazione -- faccio la copia e il mirror delle lavorazioni per gestire il caso che la geometria finisca sottosquadra if hintAs1 then hintAsR1 = EgtCopyGlob ( hintAs1, Lg) if hintAsR1 then EgtMirror( hintAsR1, ORIG(), X_AX()) -- faccio il mirror su asse Y EgtSetName(hintAsR1,LA..'_R') end end if hintAs2 then hintAsR2 = EgtCopyGlob ( hintAs2, Lg) if hintAsR2 then EgtMirror( hintAsR2, ORIG(), X_AX()) -- faccio il mirror su asse Y EgtSetName(hintAsR2,LA..'_R') end end if hintPk then hintPkR = EgtCopyGlob ( hintPk, Lg) if hintPkR then EgtMirror( hintPkR, ORIG(), X_AX()) -- faccio il mirror su asse Y EgtSetName(hintPkR,LM..'_R') end end 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' ,'MortiseHinge') EgtSetInfo( Lg, 'Nome' ,sCompoName) EgtSetInfo( Lg, 'L' ,L) EgtSetInfo( Lg, 'H' ,H) EgtSetInfo( Lg, 'T' ,T) EgtSetInfo( Lg, 'R' ,R) EgtSetInfo( Lg, 'clc' ,clc) EgtSetInfo( Lg, 'ccr' ,ccr) EgtSetInfo( Lg, 'd' ,d) EgtSetInfo( Lg, 'p' ,p) EgtSetInfo( Lg, 's' ,s) EgtSetInfo( Lg, 'd2' ,d2) EgtSetInfo( Lg, 'posh' ,posh) EgtSetInfo( Lg, 'posp' ,posp) EgtSetInfo( Lg, 'ech' ,ech) EgtSetInfo( Lg, 'est' ,est) EgtSetInfo( Lg, 'bEqualTh' ,bEqualTh) EgtSetInfo( Lg, 'kbs' ,kbs) EgtSetInfo( Lg, 'pbs' ,pbs) EgtSetInfo( Lg, 'fht' ,fht) EgtSetInfo( Lg, 'fhb' ,fhb) EgtSetInfo( Lg, 'sopp' ,sopp) EgtSetInfo( Lg, 'drf' ,drf) EgtSetInfo( Lg, 'dws' ,dws) EgtSetInfo( Lg, 'dthd' ,dthd) EgtSetInfo( Lg, 'ttp' ,ttp) EgtSetInfo( Lg, 'LG' ,LG) EgtSetInfo( Lg, 'LM' ,LM) EgtSetInfo( Lg, 'LA' ,LA) EgtSetInfo( Lg, 'CLH' ,CLH) EgtSetInfo( Lg, 'LH' ,LH) EgtSetInfo( Lg, 'CH' ,CH) 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 MortiseHinge